:root {
  --bg: var(--tg-theme-bg-color, #07111f);
  --text: var(--tg-theme-text-color, #f4fbff);
  --hint: var(--tg-theme-hint-color, #79a7c2);
  --link: var(--tg-theme-link-color, #22d3ee);
  --button: var(--tg-theme-button-color, #2f8cff);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #0b1b2e);
  --section-bg: var(--tg-theme-section-bg-color, #0f2438);
  --header-bg: var(--tg-theme-header-bg-color, #091827);
  --destructive: var(--tg-theme-destructive-text-color, #ff5c7a);
  --accent: var(--tg-theme-accent-text-color, var(--link));
  --line: rgba(148,213,255,0.16);
  --panel: #0f2438;
  --panel-2: #132d46;
  --ok: #22d3ee;
  --warn: #fbbf24;
  --ink: var(--text);
  --ink-2: #b9d8ea;
  --ink-3: var(--hint);
  --bg-soft: var(--secondary-bg);
  --border: #1e4766;
  --accent-soft: rgba(47,140,255,0.16);
  --danger: var(--destructive);
  --danger-soft: rgba(255,92,122,0.14);
  --warn-soft: rgba(251,191,36,0.16);
  --switch-off: #24435d;
  --radius: 8px;
  --pad: 12px;
  --tap: 48px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #07111f;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

#root {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--header-bg);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

#topbar h1 {
  flex: 1;
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.iconbtn {
  min-width: var(--tap);
  min-height: var(--tap);
  background: transparent;
  border: 0;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 8px;
}
.iconbtn:active { background: rgba(255,255,255,0.08); }
.iconbtn[hidden] { display: none; }

.banner {
  padding: 10px 14px;
  background: #b54b00;
  color: #fff;
  font-size: 13px;
  text-align: center;
}

#app {
  flex: 1;
  padding: var(--pad);
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding-bottom: 86px;
}

h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 18px 4px 8px;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card {
  background: var(--section-bg);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: var(--tap);
}

.row + .row { border-top: 1px solid rgba(255,255,255,0.06); }

.row-main { flex: 1; min-width: 0; }
.row-title {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-sub {
  font-size: 12px;
  color: var(--hint);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tap {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--section-bg);
  color: var(--text);
  border: 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font: inherit;
  min-height: var(--tap);
  cursor: pointer;
  transition: background 150ms;
}
.tap:active { background: rgba(255,255,255,0.08); }

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: var(--tap);
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 0;
  background: var(--button);
  color: var(--button-text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 150ms;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:active:not(:disabled) { opacity: 0.85; }

.btn-block { display: flex; width: 100%; margin-top: 8px; }
.btn-danger { background: var(--destructive); }
.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(255,255,255,0.12);
}

.btn-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.btn-grid .btn { width: 100%; }

input, select, textarea {
  width: 100%;
  background: var(--secondary-bg);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 11px 12px;
  border-radius: var(--radius);
  font: inherit;
  min-height: var(--tap);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--button);
}

label {
  display: block;
  margin: 10px 0 4px;
  font-size: 13px;
  color: var(--hint);
}

.search {
  position: sticky;
  top: 56px;
  z-index: 5;
  background: var(--bg);
  padding: 6px 0 10px;
}

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(255,255,255,0.08);
  color: var(--hint);
  margin-left: 6px;
}
.pill-ok { background: rgba(76,175,80,0.18); color: #76d28a; }
.pill-off { background: rgba(255,255,255,0.06); color: var(--hint); }
.pill-warn { background: rgba(255,180,0,0.18); color: #ffc14d; }
.pill-bad { background: rgba(236,57,66,0.18); color: #ff7782; }

.kv {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 6px 10px;
  font-size: 13px;
}
.kv dt { color: var(--hint); }
.kv dd { margin: 0; word-break: break-all; }

.mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
}

.empty {
  text-align: center;
  color: var(--hint);
  padding: 32px 12px;
  font-size: 13px;
}

.loading {
  display: flex;
  justify-content: center;
  padding: 40px;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: var(--button);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
#modal-root {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
}
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  pointer-events: auto;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  animation: fade 150ms ease-out;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.modal {
  width: 100%;
  max-width: 480px;
  background: var(--secondary-bg);
  border-radius: 14px;
  padding: 18px;
  animation: slide 180ms ease-out;
}
@keyframes slide { from { transform: translateY(20px) } to { transform: translateY(0) } }
.modal h3 { margin: 0 0 8px; font-size: 16px; }
.modal p { margin: 6px 0; font-size: 13px; color: var(--hint); }
.modal .ttl {
  font-size: 12px;
  color: var(--hint);
  margin-top: 4px;
}
.modal .typed-required {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(255,255,255,0.06);
  padding: 6px 10px;
  border-radius: 6px;
  margin: 8px 0;
  font-size: 13px;
  word-break: break-all;
}
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.modal-actions .btn { flex: 1; }

/* Toasts */
#toast-root {
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.toast {
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  max-width: 90%;
  pointer-events: auto;
  animation: fade 120ms ease-out;
}
.toast-err { background: var(--destructive); }
.toast-ok { background: #2e7d32; }

/* Operator dashboard */
.operator-dashboard {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hero-status,
.dashboard-section,
.client-preview-row,
.quick-action {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
}

.hero-status {
  padding: 14px;
  background: #20221f;
}

.hero-topline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: #2fb36d;
  color: #07140f;
  font-weight: 800;
  letter-spacing: 0;
}

.hero-title {
  flex: 1;
  min-width: 0;
}

.hero-title strong,
.client-preview-main strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-title strong {
  font-size: 17px;
}

.hero-title span,
.hero-subtitle,
.client-preview-main span {
  display: block;
  color: var(--hint);
  font-size: 12px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-refresh {
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.hero-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.status-pill,
.service-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1;
  background: rgba(255,255,255,0.07);
  color: var(--hint);
}

.status-pill.ok,
.service-chip.ok {
  background: rgba(47,179,109,0.16);
  color: #b8f3ce;
}

.status-pill.bad,
.service-chip.off {
  background: rgba(236,57,66,0.16);
  color: #ff9ea5;
}

.service-chip.mode {
  background: rgba(215,155,41,0.16);
  color: #ffd990;
  text-transform: uppercase;
}

.hero-number {
  margin-top: 7px;
  font-size: 28px;
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: 0;
}

.hero-mini-action,
.section-link,
.client-preview-action {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: var(--radius);
}

.hero-mini-action {
  width: 44px;
  min-height: 44px;
  font: inherit;
}

.service-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.quick-action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.quick-action {
  display: flex;
  min-height: 76px;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px;
  color: var(--text);
  font: inherit;
  text-align: left;
}

.quick-action.primary {
  background: #2fb36d;
  color: #07140f;
}

.quick-action strong {
  font-size: 13px;
  line-height: 1.18;
}

.quick-action span {
  color: var(--hint);
  font-size: 11px;
}

.quick-action.primary span {
  color: rgba(7,20,15,0.72);
}

.dashboard-section {
  padding: 12px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.section-heading h2 {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  text-transform: none;
  letter-spacing: 0;
}

.section-link {
  min-height: 34px;
  padding: 0 10px;
  color: var(--hint);
  font: inherit;
  font-size: 12px;
}

.client-preview-list {
  display: grid;
  gap: 8px;
}

.client-preview-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 10px;
  color: var(--text);
  font: inherit;
  text-align: left;
}

.client-state-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--hint);
}

.client-state-dot.ok {
  background: var(--ok);
}

.client-state-dot.off {
  background: #74746d;
}

.client-preview-main {
  flex: 1;
  min-width: 0;
}

.client-preview-action {
  display: grid;
  place-items: center;
  flex: none;
  min-width: 42px;
  min-height: 34px;
  padding: 0 9px;
  color: var(--hint);
  font-size: 11px;
}

.audit-mini-list {
  display: grid;
  gap: 6px;
}

.audit-mini-row {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 4px 8px;
  font-size: 12px;
  color: var(--hint);
}

.audit-mini-row strong {
  color: var(--text);
  font-weight: 600;
}

.audit-mini-row em {
  grid-column: 2;
  color: var(--hint);
  font-style: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.operator-list-view .client-list {
  display: grid;
  gap: 8px;
}

.bottom-nav {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 10px;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  max-width: 696px;
  margin: 0 auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(25,26,23,0.94);
  backdrop-filter: blur(12px);
}

.bottom-nav-item {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--hint);
  font: inherit;
  font-size: 12px;
}

.bottom-nav-item.active {
  background: var(--panel-2);
  color: var(--text);
}

/* Fallback page */
.fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 60px 24px;
  gap: 14px;
}
.fallback .lg { font-size: 18px; font-weight: 600; }
.fallback .sm { font-size: 13px; color: var(--hint); }

/* small util */
.spacer { height: 16px; }
.right { text-align: right; }
.row-actions { display: flex; gap: 6px; }
.muted { color: var(--hint); }
.break { word-break: break-all; }
.qr { white-space: pre; font-family: ui-monospace, monospace; font-size: 7px; line-height: 7px; overflow-x: auto; padding: 10px; background: #fff; color: #000; border-radius: 8px; }

/* =================================================================
   THEME OVERLAY — L5 Pastel Mint + D2 Midnight Slate
   `data-theme="system"` (default) → keep --tg-theme-* fallback from :root above
   `data-theme="light"`  → L5 Pastel Mint  (per phase-a/webapp/design/theme-tokens.jsx)
   `data-theme="dark"`   → D2 Midnight Slate
   ================================================================= */

[data-theme="light"] {
  --bg:             #eef7ff;
  --text:           #0b2035;
  --hint:           #577891;
  --link:           #006ee6;
  --button:         #0b84ff;
  --button-text:    #ffffff;
  --secondary-bg:   #dff0ff;
  --section-bg:     #ffffff;
  --header-bg:      #f7fbff;
  --destructive:    #c92f4b;
  --accent:         #0b84ff;
  --line:           #c9e4fb;
  --panel:          #ffffff;
  --panel-2:        #f3f9ff;
  --ok:             #00b8d9;
  --warn:           #b96b00;
  --ink:            var(--text);
  --ink-2:          #244b68;
  --ink-3:          var(--hint);
  --bg-soft:        var(--secondary-bg);
  --border:         #c9e4fb;
  --accent-soft:    #dff1ff;
  --danger:         var(--destructive);
  --danger-soft:    rgba(201,47,75,0.12);
  --warn-soft:      rgba(185,107,0,0.14);
  --switch-off:     #bdd7ea;
}
[data-theme="light"] html,
[data-theme="light"] body { background: #eef7ff; color: #0b2035; }

[data-theme="dark"] {
  --bg:             #07111f;
  --text:           #f4fbff;
  --hint:           #79a7c2;
  --link:           #22d3ee;
  --button:         #2f8cff;
  --button-text:    #ffffff;
  --secondary-bg:   #0b1b2e;
  --section-bg:     #0f2438;
  --header-bg:      #091827;
  --destructive:    #ff5c7a;
  --accent:         #22d3ee;
  --line:           #1e4766;
  --panel:          #0f2438;
  --panel-2:        #132d46;
  --ok:             #22d3ee;
  --warn:           #fbbf24;
  --ink:            var(--text);
  --ink-2:          #b9d8ea;
  --ink-3:          var(--hint);
  --bg-soft:        var(--secondary-bg);
  --border:         #1e4766;
  --accent-soft:    rgba(47,140,255,0.16);
  --danger:         var(--destructive);
  --danger-soft:    rgba(255,92,122,0.14);
  --warn-soft:      rgba(251,191,36,0.16);
  --switch-off:     #24435d;
}
[data-theme="dark"] html,
[data-theme="dark"] body { background: #07111f; color: #f4fbff; }

/* Theme button — sits between back and refresh in header */
.themebtn { font-size: 16px; }

/* ─────────── VISUAL-BUG FIXES (6 from screenshots) ───────────── */

/* Bug #1 — modal-overlay scrim was too light, modal bled into body.
   Stronger backdrop + explicit solid panel bg + box-shadow halo. */
.modal-overlay {
  background: rgba(0,0,0,0.78) !important;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal-box {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 -12px 40px rgba(0,0,0,0.45);
}
[data-theme="light"] .modal-box {
  box-shadow: 0 -12px 40px rgba(11,132,255,0.20);
}

/* Bug #2 — buttons inside a .row (Копировать / QR / Ротировать) were
   flex children with content-based width, so QR was narrower. Make
   them equal-flex so the row reads symmetric. */
.row > .btn { flex: 1; min-width: 0; }

/* Bug #3 — VLESS-ссылка and Subscription URL used <textarea> with a
   scrollbar. Now they render in <div class="link-block"> which wraps
   the full string with word-break; no scroll, smaller font, tap to
   select-all & copy. */
.link-block {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.45;
  word-break: break-all;
  white-space: normal;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 10px 12px;
  border-radius: var(--radius);
  margin: 6px 0 8px;
  user-select: all;
  -webkit-user-select: all;
  cursor: copy;
  transition: background 140ms cubic-bezier(0.4,0,0.2,1);
}
.link-block:active { background: var(--panel); }

/* Bug #4 — "Disable"/"Enable" English labels under RU UI: fixed in
   app.js (translated to "Отключить"/"Включить"). No CSS change. */

/* Bug #5 — theme switcher: handled by [data-theme] overrides above
   + .themebtn icon-button in header. */

/* Bug #6 — QR distorted because UTF-8 block characters are not square
   in mono fonts. Daemon now also returns qr_svg (qrencode -t SVG); we
   render the SVG inline at any scale without distortion. */
.qr-svg {
  display: block;
  width: min(78vw, 320px);
  max-width: 100%;
  margin: 6px auto;
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.20);
}
.qr-svg svg {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  shape-rendering: crispEdges;
}
.qr-text {
  display: block;
  font-family: ui-monospace, monospace;
  font-size: 6px;
  line-height: 6px;
  white-space: pre;
  background: #fff;
  color: #000;
  padding: 12px;
  border-radius: 10px;
  letter-spacing: 0;
  text-align: center;
  margin: 6px auto;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
}

/* Reduced-motion guard */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}


/* Hardcoded dark colors in base style.css need explicit overrides
   for the [data-theme=light] palette. */
[data-theme="light"] .hero-status {
  background: var(--panel) !important;
}
[data-theme="light"] .hero-refresh {
  background: var(--panel-2);
  color: var(--text);
}
[data-theme="light"] .status-pill,
[data-theme="light"] .service-chip {
  background: rgba(0,0,0,0.06);
  color: var(--hint);
}
[data-theme="light"] .status-pill.ok,
[data-theme="light"] .service-chip.ok {
  background: rgba(0,184,217,0.16);
  color: #006f8f;
}
[data-theme="light"] .status-pill.bad,
[data-theme="light"] .service-chip.off {
  background: rgba(179,50,47,0.16);
  color: #6b1e1a;
}
[data-theme="light"] .service-chip.mode {
  background: rgba(185,107,0,0.14);
  color: #744300;
}
[data-theme="light"] .hero-number,
[data-theme="light"] .hero-title strong,
[data-theme="light"] .client-preview-main strong {
  color: var(--text);
}
[data-theme="light"] .brand-mark {
  background: var(--button);
  color: var(--button-text);
}
[data-theme="light"] .bottom-nav {
  background: var(--header-bg);
  border-top: 1px solid var(--line);
}
[data-theme="light"] .modal-overlay {
  background: rgba(8,38,72,0.48) !important;
}

/* Dark theme cosmetic adjustments to match D2 Midnight Slate accent */
[data-theme="dark"] .hero-status {
  background: linear-gradient(160deg, #0f2438, #07111f) !important;
}
[data-theme="dark"] .brand-mark {
  background: var(--button);
  color: var(--button-text);
}
[data-theme="dark"] .status-pill.ok,
[data-theme="dark"] .service-chip.ok {
  background: rgba(34,211,238,0.14);
  color: #67e8f9;
}

/* ─── Codex vanilla app.js compat: classes from origin/dev ─── */

.card.hero {
  padding: 18px;
  border-radius: 18px;
}

[data-theme="dark"] .card.hero {
  background: linear-gradient(160deg, #0f2438, #07111f);
}

.pill.warn { background: var(--warn-soft); color: var(--warn); }

.pill.warn::before { background: var(--warn); }

.pill.bad, .pill.danger { background: var(--danger-soft); color: var(--danger); }

.pill.bad::before, .pill.danger::before { background: var(--danger); }

.badge {
  display: inline-block;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-2);
}

.badge.off { background: var(--bg-soft); color: var(--ink-3); }

.badge.warn { background: var(--warn-soft); color: var(--warn); }

.badge.bad, .badge.danger { background: var(--danger-soft); color: var(--danger); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 600;
}

.row.split { justify-content: space-between; }

.list {
  display: flex; flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

[data-theme="dark"] .list { box-shadow: none; }

.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--switch-off);
  flex-shrink: 0;
}

.dot.on { background: var(--accent); box-shadow: 0 0 6px var(--accent); }

.btn.block, .btn-block { width: 100%; }

.btn.ghost, .btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn.warn { background: var(--warn); color: #fff; }

.btn.danger, .btn-danger { background: var(--danger); color: #fff; }

.btn-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
}

.btn-grid .btn, .btn-grid-3 .btn { width: 100%; }

.qa .tile {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 6px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  cursor: pointer;
  font: inherit;
  font-size: 12.5px; font-weight: 600;
  color: var(--ink);
  text-align: center;
  transition: transform var(--m-fast) var(--m-tight),
              background var(--m-base) var(--m-soft);
}

.qa .tile:active { transform: scale(0.97); }

.qa .tile svg { width: 22px; height: 22px; color: var(--accent); }

.qa .tile.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

.qa .tile.primary svg { color: var(--accent-ink); }

.view {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.audit-preview {
  padding-bottom: 4px;
}

.nav-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.nav-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 72px;
  padding: 14px 8px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform var(--m-fast) var(--m-tight);
}

[data-theme="dark"] .nav-tile { box-shadow: none; }

.nav-tile:active { transform: scale(0.97); }

.modal-input {
  width: 100%;
  background: var(--card-2);
  color: var(--ink);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 8px;
  font: inherit;
  font-family: var(--mono);
  font-size: 13px;
  min-height: 44px;
}

.modal-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.toast.err  { background: var(--danger); color: #fff; }

.toast.warn { background: var(--warn);   color: #fff; }

.toast-out  { opacity: 0; transform: translateY(-8px); transition: all 200ms; }

.audit-list {
  list-style: none;
  padding: 0; margin: 8px 0 0;
}

.audit-list li {
  display: flex; gap: 10px;
  padding: 6px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--hair);
}

.audit-list li:last-child { border-bottom: 0; }

.audit-ts { color: var(--ink-3); font-family: var(--mono); width: 60px; flex-shrink: 0; }

.audit-action { color: var(--accent-2); font-weight: 500; flex: 1; }

.audit-target { color: var(--ink-3); text-align: right; flex-shrink: 0; max-width: 50%; overflow: hidden; text-overflow: ellipsis; }

.fab {
  position: sticky;
  bottom: calc(12px + env(safe-area-inset-bottom));
  align-self: flex-end;
  margin: 0 0 0 auto;
  width: auto;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

[data-theme="dark"] .fab {
  box-shadow: 0 8px 24px rgba(110,224,166,0.20);
}

.copy-row { display: flex; gap: 8px; margin: 8px 0 0; }

.copy-row .btn { flex: 1; }

.sec {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 4px 4px 0;
  margin-top: 4px;
}

.sec h2 { margin: 0; }

.sec a { color: var(--accent-2); font-size: 13px; font-weight: 600; }

/* =================================================================
   Codex full redesign: Electric Console, 20260707-181342
   Visual-only layer. Existing class names and app behavior are kept.
   ================================================================= */

:root {
  --radius: 12px;
  --pad: 14px;
  --tap: 50px;
  --console-bg: radial-gradient(circle at 18% -8%, rgba(47,140,255,0.34), transparent 34%),
                radial-gradient(circle at 86% 6%, rgba(34,211,238,0.24), transparent 32%),
                linear-gradient(180deg, #06111f 0%, #081726 42%, #050b14 100%);
  --glass: rgba(9,24,39,0.76);
  --glass-2: rgba(15,42,65,0.72);
  --glass-line: rgba(142,214,255,0.22);
  --glow-blue: 0 14px 44px rgba(47,140,255,0.22);
  --glow-cyan: 0 0 26px rgba(34,211,238,0.18);
  --accent-2: #22d3ee;
  --accent-ink: #ffffff;
  --card: var(--panel);
  --card-2: var(--panel-2);
  --shadow: 0 18px 50px rgba(0,0,0,0.30);
}

[data-theme="light"] {
  --console-bg: radial-gradient(circle at 18% -8%, rgba(11,132,255,0.20), transparent 32%),
                radial-gradient(circle at 84% 0%, rgba(0,184,217,0.16), transparent 28%),
                linear-gradient(180deg, #f6fbff 0%, #e8f5ff 46%, #f8fcff 100%);
  --glass: rgba(255,255,255,0.82);
  --glass-2: rgba(243,249,255,0.84);
  --glass-line: rgba(0,110,230,0.20);
  --glow-blue: 0 14px 42px rgba(11,132,255,0.14);
  --glow-cyan: 0 0 24px rgba(0,184,217,0.12);
  --card: var(--panel);
  --card-2: var(--panel-2);
  --shadow: 0 18px 48px rgba(20,89,145,0.12);
}

html,
body {
  min-height: 100%;
  background: var(--console-bg) fixed !important;
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent 78%);
}

[data-theme="light"] body::before {
  background:
    linear-gradient(rgba(0,110,230,0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,110,230,0.035) 1px, transparent 1px);
  background-size: 22px 22px;
}

#app {
  max-width: 760px;
  padding: 16px 14px 104px;
}

#topbar {
  background: color-mix(in srgb, var(--header-bg) 82%, transparent);
  border-bottom: 1px solid var(--glass-line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.18);
}

#topbar h1 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--hint);
}

.operator-dashboard,
.operator-list-view,
.view {
  gap: 14px;
}

.card,
.tap,
.hero-status,
.dashboard-section,
.client-preview-row,
.quick-action,
.list,
.nav-tile,
.qa .tile {
  border: 1px solid var(--glass-line) !important;
  background: linear-gradient(180deg, var(--glass), var(--glass-2)) !important;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.06);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.card,
.dashboard-section,
.list {
  border-radius: 18px;
}

.tap,
.client-preview-row,
.quick-action,
.nav-tile,
.qa .tile {
  border-radius: 14px;
}

.hero-status,
.card.hero {
  position: relative;
  overflow: hidden;
  padding: 18px !important;
  border-radius: 22px !important;
  background:
    linear-gradient(135deg, rgba(47,140,255,0.28), rgba(34,211,238,0.08) 48%, rgba(9,24,39,0.74)),
    var(--glass) !important;
  box-shadow: var(--shadow), var(--glow-blue), inset 0 1px 0 rgba(255,255,255,0.10);
}

[data-theme="light"] .hero-status,
[data-theme="light"] .card.hero {
  background:
    linear-gradient(135deg, rgba(11,132,255,0.18), rgba(0,184,217,0.08) 48%, rgba(255,255,255,0.86)),
    var(--glass) !important;
}

.hero-status::after,
.card.hero::after {
  content: "";
  position: absolute;
  right: -44px;
  top: -54px;
  width: 168px;
  height: 168px;
  border-radius: 50%;
  border: 1px solid rgba(34,211,238,0.26);
  box-shadow: inset 0 0 40px rgba(34,211,238,0.08);
  pointer-events: none;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: linear-gradient(135deg, #2f8cff, #22d3ee) !important;
  color: #ffffff !important;
  box-shadow: 0 12px 30px rgba(47,140,255,0.34), inset 0 1px 0 rgba(255,255,255,0.26);
}

.hero-title strong,
.client-preview-main strong,
.section-heading h2 {
  letter-spacing: 0;
}

.hero-title span,
.hero-subtitle,
.client-preview-main span,
.row-sub,
.muted {
  color: var(--hint);
}

.hero-number {
  font-size: 34px;
  letter-spacing: 0;
  text-shadow: 0 0 28px rgba(34,211,238,0.18);
}

.service-strip {
  gap: 8px;
}

.status-pill,
.service-chip,
.pill,
.badge,
.chip {
  border: 1px solid var(--glass-line);
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  color: var(--hint);
}

[data-theme="light"] .status-pill,
[data-theme="light"] .service-chip,
[data-theme="light"] .pill,
[data-theme="light"] .badge,
[data-theme="light"] .chip {
  background: rgba(255,255,255,0.66);
}

.status-pill.ok,
.service-chip.ok,
.pill-ok,
.badge.ok {
  background: rgba(34,211,238,0.14) !important;
  border-color: rgba(34,211,238,0.30);
  color: #7defff !important;
}

[data-theme="light"] .status-pill.ok,
[data-theme="light"] .service-chip.ok,
[data-theme="light"] .pill-ok,
[data-theme="light"] .badge.ok {
  color: #006f8f !important;
}

.quick-action-grid,
.nav-grid {
  gap: 10px;
}

.quick-action {
  min-height: 92px;
  padding: 14px;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.quick-action:active,
.tap:active,
.client-preview-row:active,
.nav-tile:active,
.qa .tile:active {
  transform: translateY(1px) scale(0.99);
}

.quick-action.primary,
.qa .tile.primary,
.btn,
.btn.primary {
  background: linear-gradient(135deg, #147dff, #22d3ee) !important;
  color: #ffffff !important;
  border-color: transparent !important;
  box-shadow: 0 12px 28px rgba(47,140,255,0.28);
}

.quick-action.primary span {
  color: rgba(255,255,255,0.76) !important;
}

.btn {
  min-height: 48px;
  border-radius: 13px;
  font-weight: 650;
}

.btn-ghost,
.btn.ghost,
.hero-refresh,
.hero-mini-action,
.section-link,
.client-preview-action {
  background: rgba(255,255,255,0.06) !important;
  border: 1px solid var(--glass-line) !important;
  color: var(--text) !important;
  box-shadow: none;
}

[data-theme="light"] .btn-ghost,
[data-theme="light"] .btn.ghost,
[data-theme="light"] .hero-refresh,
[data-theme="light"] .hero-mini-action,
[data-theme="light"] .section-link,
[data-theme="light"] .client-preview-action {
  background: rgba(255,255,255,0.76) !important;
}

.btn-danger,
.btn.danger,
.btn-danger.primary {
  background: linear-gradient(135deg, #ef335f, #ff7a98) !important;
}

input,
select,
textarea,
.modal-input,
.link-block {
  border: 1px solid var(--glass-line) !important;
  background: rgba(255,255,255,0.06) !important;
  border-radius: 14px !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea,
[data-theme="light"] .modal-input,
[data-theme="light"] .link-block {
  background: rgba(255,255,255,0.80) !important;
}

input:focus,
select:focus,
textarea:focus,
.modal-input:focus {
  border-color: rgba(34,211,238,0.72) !important;
  box-shadow: 0 0 0 3px rgba(47,140,255,0.16) !important;
}

.client-preview-row {
  min-height: 68px;
}

.client-state-dot,
.dot {
  width: 10px;
  height: 10px;
  box-shadow: 0 0 0 4px rgba(255,255,255,0.04);
}

.client-state-dot.ok,
.dot.on {
  background: #22d3ee;
  box-shadow: 0 0 0 4px rgba(34,211,238,0.10), 0 0 18px rgba(34,211,238,0.44);
}

.bottom-nav {
  left: 14px;
  right: 14px;
  bottom: 12px;
  max-width: 732px;
  padding: 8px;
  gap: 7px;
  border-radius: 22px;
  border: 1px solid var(--glass-line);
  background: rgba(5,14,24,0.78) !important;
  box-shadow: 0 18px 54px rgba(0,0,0,0.34), inset 0 1px 0 rgba(255,255,255,0.08);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

[data-theme="light"] .bottom-nav {
  background: rgba(255,255,255,0.78) !important;
}

.bottom-nav-item {
  min-height: 46px;
  border-radius: 16px;
  font-size: 11.5px;
  font-weight: 650;
  color: var(--hint);
}

.bottom-nav-item.active {
  background: linear-gradient(135deg, rgba(47,140,255,0.24), rgba(34,211,238,0.14)) !important;
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(34,211,238,0.18);
}

.modal-overlay {
  align-items: center;
  padding: 20px;
  background: rgba(2,8,16,0.74) !important;
}

.modal,
.modal-box {
  max-width: 500px;
  border-radius: 24px !important;
  border: 1px solid var(--glass-line) !important;
  background: linear-gradient(180deg, var(--glass), var(--glass-2)) !important;
  box-shadow: 0 24px 80px rgba(0,0,0,0.44), var(--glow-blue) !important;
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.toast {
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(6,17,31,0.88);
  box-shadow: 0 10px 28px rgba(0,0,0,0.28);
  backdrop-filter: blur(16px);
}

.qr-svg,
.qr-text,
.qr {
  border: 1px solid var(--glass-line);
  box-shadow: var(--glow-blue);
}

@media (min-width: 680px) {
  #app {
    padding-top: 20px;
  }
  .operator-dashboard {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
    align-items: start;
  }
  .hero-status {
    grid-column: 1 / -1;
  }
  .quick-action-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
