/* ═══════════════════════════════════════════════════════════════════════════════
   Ghost Browser — Console Design System
   Zinc neutrals + Emerald accent. Dark sidebar always-on.
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ── DESIGN TOKENS ──────────────────────────────────────────────────────────── */
:root {
  /* Emerald brand */
  --brand-50:  #ecfdf5;
  --brand-100: #d1fae5;
  --brand-400: #34d399;
  --brand-500: #10b981;
  --brand-600: #059669;
  --brand-700: #047857;

  /* Light-mode surfaces (main content area) */
  --bg:        #fafafa;
  --panel:     #ffffff;
  --panel-2:   #f4f4f5;
  --line:      #e4e4e7;
  --line-soft: #f4f4f5;

  /* Type */
  --tx:    #09090b;
  --text:  #09090b;
  --muted: #71717a;
  --faint: #a1a1aa;

  /* Accent */
  --accent:      var(--brand-600);
  --accent-fg:   #ffffff;
  --accent-soft: var(--brand-50);

  /* Status */
  --ok:        #059669;
  --good:      #059669;
  --live:      #10b981;
  --warn:      #d97706;
  --warn-soft: rgba(217,119,6,.10);
  --bad:       #e11d48;
  --bad-soft:  rgba(225,29,72,.10);

  /* Focus ring */
  --ring: rgba(5,150,105,.35);

  /* Shadows */
  --shadow:    0 1px 2px rgba(9,9,11,.04), 0 1px 3px rgba(9,9,11,.06);
  --shadow-lg: 0 4px 6px -1px rgba(9,9,11,.07), 0 10px 15px -3px rgba(9,9,11,.07);

  /* Radii */
  --radius:    14px;
  --radius-sm: 10px;
  --r:          8px;
  --rr:        10px;
  --rs:        14px;

  /* Sidebar (always dark, never toggles with theme) */
  --side-bg:     #09090b;
  --side-line:   #27272a;
  --side-tx:     #e4e4e7;
  --side-muted:  #71717a;
  --side-hover:  #18181b;
  --side-active: #27272a;

  /* App console stage */
  --stage: #0b1120;
}

/* Dark-mode overrides for the content area only */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #09090b;
    --panel:     #18181b;
    --panel-2:   #27272a;
    --line:      #27272a;
    --line-soft: #1c1c1f;
    --tx:    #fafafa;
    --text:  #fafafa;
    --muted: #a1a1aa;
    --faint: #71717a;
    --accent-soft: rgba(5,150,105,.18);
    --shadow:    0 1px 2px rgba(0,0,0,.3), 0 1px 3px rgba(0,0,0,.2);
    --shadow-lg: 0 4px 6px -1px rgba(0,0,0,.35), 0 10px 15px -3px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  --bg:        #09090b;
  --panel:     #18181b;
  --panel-2:   #27272a;
  --line:      #27272a;
  --line-soft: #1c1c1f;
  --tx:    #fafafa;
  --text:  #fafafa;
  --muted: #a1a1aa;
  --faint: #71717a;
  --accent-soft: rgba(5,150,105,.18);
  --shadow:    0 1px 2px rgba(0,0,0,.3), 0 1px 3px rgba(0,0,0,.2);
  --shadow-lg: 0 4px 6px -1px rgba(0,0,0,.35), 0 10px 15px -3px rgba(0,0,0,.3);
}

/* ── RESET ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: 'Plus Jakarta Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--tx);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}
button:disabled { opacity: .4; cursor: not-allowed; }

input, textarea, select {
  font-family: inherit;
  font-size: 14px;
  color: var(--tx);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 9px 12px;
  width: 100%;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}

h1, h2, h3 { line-height: 1.25; font-weight: 700; color: var(--tx); }

.hide { display: none !important; }

/* ── SHARED BUTTONS ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--rr); border: 1px solid var(--line);
  background: var(--panel); color: var(--tx); font: 600 13.5px/1 inherit;
  cursor: pointer; transition: background .1s, border-color .1s;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { background: var(--brand-700); border-color: var(--brand-700); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.full { width: 100%; }
.btn.sm { padding: 6px 12px; font-size: 12.5px; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: transparent; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

/* ── SHARED MSG BOX ─────────────────────────────────────────────────────────── */
.msg {
  font-size: 13px; padding: 8px 12px; border-radius: var(--r);
  margin-top: 8px; min-height: 32px; color: var(--muted);
}
.msg.ok  { background: var(--accent-soft); color: var(--accent); }
.msg.err { background: var(--bad-soft);    color: var(--bad); }

/* ── UTILITIES ──────────────────────────────────────────────────────────────── */
.cap { font-size: 12px; color: var(--muted); }


/* ═══════════════════════════════════════════════════════════════════════════════
   GATE — split sign-in layout
   Left: dark brand story. Right: clean form, no outer card.
   ═══════════════════════════════════════════════════════════════════════════════ */
#gate {
  position: fixed; inset: 0;
  display: flex; align-items: stretch;
  background: var(--side-bg);
}

.gate-split {
  display: flex; width: 100%; height: 100%;
}

/* Left column */
.gate-brand {
  flex: 0 0 420px;
  background: var(--side-bg);
  display: flex; align-items: center; justify-content: center;
  padding: 48px 52px;
  position: relative; overflow: hidden;
}
.gate-brand::before {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,.06) 1px, transparent 1px);
  background-size: 24px 24px; pointer-events: none;
}
.gate-brand::after {
  content: ''; position: absolute;
  width: 320px; height: 320px; border-radius: 50%;
  background: radial-gradient(circle, rgba(5,150,105,.12) 0%, transparent 70%);
  top: -80px; left: -80px; pointer-events: none;
}
.gate-brand-inner { position: relative; z-index: 1; }

.gate-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 36px; }
.gate-logo-mark {
  width: 40px; height: 40px; background: var(--accent); color: #fff;
  font-size: 18px; font-weight: 900; border-radius: 10px;
  display: grid; place-items: center; flex: none;
}
.gate-logo-name { font-size: 18px; font-weight: 400; color: var(--side-muted); letter-spacing: -.01em; }
.gate-logo-name b { color: var(--side-tx); font-weight: 700; }

.gate-tagline {
  font-size: 22px; font-weight: 600; color: var(--side-tx);
  line-height: 1.35; letter-spacing: -.02em;
  margin-bottom: 28px; max-width: 320px;
}

.gate-features { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.gate-features li {
  font-size: 13.5px; color: var(--side-muted);
  padding-left: 20px; position: relative; line-height: 1.4;
}
.gate-features li::before {
  content: ''; position: absolute; left: 0; top: 7px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); opacity: .7;
}

/* Right column — always light regardless of OS theme */
.gate-form-wrap {
  flex: 1; background: #f8fafc;
  display: flex; align-items: center; justify-content: center;
  padding: 48px 40px;
}
.gate-form-inner { width: 100%; max-width: 380px; }

.gate-form-header { margin-bottom: 32px; }
.gate-form-header h1 {
  font-size: 26px; font-weight: 800; color: #09090b;
  letter-spacing: -.02em; margin-bottom: 6px;
}
.gate-form-header p { font-size: 14px; color: #71717a; }

#gateForm { display: flex; flex-direction: column; gap: 14px; margin-bottom: 16px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 600; color: #09090b; }

/* Gate inputs always use light styles */
#gate input {
  background: #fff; color: #09090b; border-color: #e4e4e7;
}
#gate input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

#gateGo { margin-top: 4px; padding: 11px 20px; font-size: 14.5px; }

.gate-recovery { margin-top: 20px; }
.gate-recovery-link { font-size: 13px; color: #71717a; }
.gate-recovery-link:hover { color: #09090b; }
.gate-recovery-info {
  font-size: 13px; color: var(--muted); line-height: 1.45; margin: 12px 0 10px;
}
.gate-recovery-info code {
  font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--panel-2); padding: 1px 5px; border-radius: 4px;
}
.gate-recovery-row { display: flex; gap: 8px; }
.gate-recovery-input { flex: 1; font-size: 13px; }

@media (max-width: 700px) {
  .gate-split { flex-direction: column; }
  .gate-brand { flex: 0 0 auto; padding: 36px 28px; }
  .gate-brand::after { display: none; }
  .gate-tagline { font-size: 18px; }
  .gate-features { display: none; }
  .gate-form-wrap { padding: 36px 24px; }
}


/* ═══════════════════════════════════════════════════════════════════════════════
   DASHBOARD — dark sidebar + light main
   ═══════════════════════════════════════════════════════════════════════════════ */
#dash { position: fixed; inset: 0; display: flex; }
#dash.hide { display: none !important; }

.dash-layout { display: flex; width: 100%; height: 100%; overflow: hidden; }

/* ── Sidebar ─── */
.dash-sidebar {
  width: 220px; flex: none;
  background: var(--side-bg);
  border-right: 1px solid var(--side-line);
  display: flex; flex-direction: column;
  height: 100vh; overflow-y: auto;
  scrollbar-width: none; position: relative; z-index: 10;
}
.dash-sidebar::-webkit-scrollbar { display: none; }

.dash-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--side-line);
}
.dash-brand-mark {
  width: 28px; height: 28px; background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 900; border-radius: 7px;
  display: grid; place-items: center; flex: none;
}
.dash-brand-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.dash-brand-name { font-size: 13.5px; font-weight: 700; color: var(--side-tx); letter-spacing: -.01em; white-space: nowrap; }
.dash-brand-sub  { font-size: 10.5px; color: var(--side-muted); letter-spacing: .04em; text-transform: uppercase; }

.dash-nav { flex: 1; padding: 10px; display: flex; flex-direction: column; gap: 2px; }

.dash-nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px; border-radius: var(--r);
  font-size: 13.5px; font-weight: 500; color: var(--side-muted);
  background: none; border: none; cursor: pointer; text-align: left;
  transition: background .1s, color .1s;
}
.dash-nav-item:hover { background: var(--side-hover); color: var(--side-tx); }
.dash-nav-item.on   { background: var(--side-active); color: var(--side-tx); }
.dash-nav-item.on .nav-icon { opacity: 1; color: var(--accent); }

.nav-icon { width: 16px; height: 16px; flex: none; opacity: .55; transition: opacity .1s; }
.dash-nav-item:hover .nav-icon { opacity: .8; }

.dash-nav-sep { height: 1px; background: var(--side-line); margin: 6px 0; }

.dash-badge {
  margin-left: auto; background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 5px;
}

.dash-nav-item--super.hide { display: none !important; }

.dash-sidebar-foot { border-top: 1px solid var(--side-line); padding: 14px 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.dash-user { display: flex; align-items: center; gap: 9px; }
.dash-user-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); flex: none; }
.dash-user-label { display: flex; flex-direction: column; gap: 1px; }
.dash-user-status { font-size: 12.5px; font-weight: 600; color: var(--side-tx); }
.dash-user-device { font-size: 11px; color: var(--side-muted); }
.dash-signout {
  font-size: 12px; font-weight: 500; color: var(--side-muted);
  padding: 4px 8px; border-radius: 5px; text-align: left;
  transition: background .1s, color .1s;
}
.dash-signout:hover { background: var(--side-hover); color: var(--side-tx); }

/* ── Mobile drawer ─── */
.dwrap { contents: initial; }
#dashScrim {
  display: none; position: fixed; inset: 0; z-index: 9;
  background: rgba(0,0,0,.55);
}

/* ── Main area ─── */
.dash-main {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; background: var(--bg); min-width: 0;
}

.dash-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px; height: 58px;
  border-bottom: 1px solid var(--line); background: var(--panel); flex: none;
}
.dash-ham {
  display: none; width: 32px; height: 32px; border-radius: var(--r);
  align-items: center; justify-content: center; color: var(--muted);
  transition: background .1s;
}
.dash-ham:hover { background: var(--panel-2); }
.dash-ham svg { width: 18px; height: 18px; }

.dash-topbar-title { flex: 1; min-width: 0; }
.dash-header-title {
  font-size: 15px; font-weight: 700; color: var(--tx);
  display: flex; align-items: baseline; gap: 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dash-header-title small { font-size: 12px; font-weight: 400; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

.dash-topbar-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }

.dash-kpis {
  display: flex; align-items: center; gap: 1px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--rr); overflow: hidden;
}
.dash-kpi { display: flex; flex-direction: column; align-items: center; padding: 6px 14px; gap: 1px; }
.dash-kpi b { font-size: 16px; font-weight: 800; line-height: 1; color: var(--tx); }
.dash-kpi span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.dash-stat--live b { color: var(--live); }
.dash-stat--connected b { color: var(--good); }

.dash-theme {
  width: 32px; height: 32px; border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); transition: background .1s, color .1s;
}
.dash-theme:hover { background: var(--panel-2); color: var(--tx); }
.dash-theme svg { width: 17px; height: 17px; }

.dash-body { flex: 1; overflow-y: auto; }

/* Views */
.dash-view { padding: 28px 28px 48px; }
.dash-view.hide { display: none !important; }

/* ── Accounts view ─── */
.dash-banner {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; border-radius: var(--rs);
  background: color-mix(in srgb, var(--warn) 8%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--warn) 25%, var(--line));
  margin-bottom: 28px;
}
.dash-banner.hide { display: none !important; }
.dash-banner-icon svg { width: 18px; height: 18px; color: var(--warn); }
.dash-banner-body { flex: 1; min-width: 0; }
.dash-banner-title { font-size: 13.5px; font-weight: 600; color: var(--tx); }
.dash-banner-sub   { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.dash-section { margin-bottom: 36px; }
.dash-section-hd { display: flex; flex-direction: column; gap: 3px; margin-bottom: 16px; }
.dash-section-hd h2 { font-size: 15px; font-weight: 700; color: var(--tx); }
.dash-section-hd p  { font-size: 13px; color: var(--muted); }

.dash-platforms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.dash-live-rail { display: flex; flex-direction: column; gap: 8px; }
.dash-note { font-size: 12.5px; color: var(--faint); margin-top: 8px; }

/* ── Platform cards ─── */
.logo {
  width: 36px; height: 36px; border-radius: 9px; flex: none;
  background: var(--brand, var(--accent)); color: #fff;
  font: 700 14px/1 inherit; display: grid; place-items: center;
}
.logo.mono-lo { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.dash-platform-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--rs); padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  cursor: pointer; transition: border-color .12s, box-shadow .12s;
  position: relative;
}
.dash-platform-card:hover {
  border-color: color-mix(in srgb, var(--brand, var(--accent)) 35%, var(--line));
  box-shadow: var(--shadow);
}
.dash-platform-card--off { opacity: .9; }
.dash-platform-card--add {
  border-style: dashed; background: transparent;
  align-items: center; justify-content: center; text-align: center;
  min-height: 120px; gap: 6px;
}
.dash-platform-card--add:hover { border-color: var(--accent); background: var(--accent-soft); }

.dash-platform-logo-container { display: flex; }
.dash-platform-info { display: flex; flex-direction: column; gap: 2px; }
.dash-platform-name { font-size: 14px; font-weight: 700; color: var(--tx); }
.dash-platform-url { font: 11.5px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--faint); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.dash-platform-status { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.dash-platform-status .now  { color: var(--live); font-weight: 600; }
.dash-platform-status .dim  { color: var(--faint); font-size: 11.5px; }
.dash-platform-status b     { color: var(--good); }
/* Status pill classes set by JS on statusHtml content */
.p-good { color: var(--good); }
.p-live { color: var(--live); font-weight: 600; }
.p-off  { color: var(--muted); }

.dash-platform-roles {
  display: flex; flex-wrap: wrap; gap: 5px; margin-top: 2px;
}
.dash-platform-role {
  font: 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 3px 7px; border-radius: 999px;
  background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--line); white-space: nowrap;
}
.dash-platform-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding-top: 6px; border-top: 1px solid var(--line);
  margin-top: auto;
}
.dash-platform-button {
  padding: 6px 12px; border-radius: var(--r); border: 1px solid var(--line);
  background: var(--panel); color: var(--tx); font: 600 12.5px/1 inherit;
  cursor: pointer; transition: background .1s; white-space: nowrap;
}
.dash-platform-button:hover { background: var(--panel-2); }
.dash-platform-button.primary {
  background: var(--brand, var(--accent)); border-color: transparent; color: #fff;
}
.dash-platform-button.primary:hover { filter: brightness(1.08); }
.dash-platform-button.ghost { background: transparent; }
.dash-platform-button.ghost:hover { background: var(--panel-2); }

.dash-platform-add-icon { font-size: 22px; color: var(--muted); line-height: 1; }
.dash-platform-add-title { font-size: 13.5px; font-weight: 700; color: var(--tx); }
.dash-platform-add-subtitle { font-size: 12px; color: var(--muted); line-height: 1.4; max-width: 180px; }

/* ── Live rail ─── */
.dash-live-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--rs); padding: 12px 14px;
}
.dash-live-logo .logo { width: 30px; height: 30px; font-size: 12px; }
.dash-live-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.dash-live-title { font-size: 13.5px; font-weight: 700; color: var(--tx); }
.dash-live-role { }
.dash-live-activity { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Settings view ─── */
.dash-view--settings { display: flex; flex-direction: column; gap: 20px; }

.scard {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--rs); padding: 24px;
}
.scard h3 {
  font-size: 15px; font-weight: 700; color: var(--tx);
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.si { font-size: 17px; line-height: 1; }
.scard .desc {
  font-size: 13px; color: var(--muted); line-height: 1.45;
  margin-bottom: 18px; max-width: 620px;
}
.srow { display: flex; gap: 9px; flex-wrap: wrap; align-items: flex-start; margin-top: 10px; }
.sgrow { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 0; }
.slabel { font-size: 12.5px; font-weight: 600; color: var(--tx); }
.sstate { font-weight: 400; color: var(--muted); }
.sin {
  padding: 9px 12px; border-radius: var(--r); border: 1px solid var(--line);
  background: var(--bg); color: var(--tx); font: inherit; font-size: 13.5px;
}
.sin:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); outline: none; }
.sbtn {
  padding: 9px 16px; border-radius: var(--r); border: 1px solid var(--line);
  background: var(--panel); color: var(--tx); font: 600 13px/1 inherit;
  white-space: nowrap; transition: background .1s;
}
.sbtn:hover { background: var(--panel-2); }
.sbtn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.sbtn.primary:hover { background: var(--brand-700); border-color: var(--brand-700); }
.sbtn.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, var(--line)); }
.sbtn.bad:hover { background: var(--bad-soft); }
.stog { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; margin-top: 12px; }
.stog input[type=checkbox] { width: 16px; height: 16px; flex: none; margin-top: 2px; accent-color: var(--accent); }
.stog .tt { font-size: 13.5px; font-weight: 600; color: var(--tx); display: block; }
.stog .ts { font-size: 12.5px; color: var(--muted); line-height: 1.4; display: block; margin-top: 3px; }
.smsg { font-size: 13px; color: var(--muted); min-height: 20px; margin-top: 6px; }
.smsg.ok  { color: var(--good); }
.smsg.err { color: var(--bad); }
.shr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.skey {
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--r); padding: 10px 12px; word-break: break-all;
  color: var(--tx); margin-top: 8px;
}
.sempty { color: var(--muted); font-size: 13px; padding: 8px 0; }

/* ── Admin view ─── */
.admin-tabs { display: flex; gap: 6px; align-items: center; padding: 0 0 20px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.admin-tab {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); font: 600 13px/1 inherit; color: var(--muted); cursor: pointer; transition: .1s;
}
.admin-tab:hover { color: var(--tx); }
.admin-tab.on { background: var(--tx); color: var(--bg); border-color: var(--tx); }
.admin-refresh { margin-left: auto; font-size: 13px; color: var(--muted); padding: 5px 10px; border-radius: var(--r); transition: background .1s; }
.admin-refresh:hover { background: var(--panel-2); color: var(--tx); }
.admin-empty { color: var(--muted); font-size: 13.5px; padding: 20px 0; }

/* ── API view ─── */
.dash-view--api { display: flex; flex-direction: column; gap: 20px; }

.apilead { font-size: 14px; color: var(--tx); line-height: 1.6; margin-bottom: 12px; }
.apilead b { color: var(--tx); }
.apilead code {
  font: 13px ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--panel-2); padding: 1px 5px; border-radius: 4px; color: var(--tx);
}
.apiquick { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 16px; }
.apichip {
  display: inline-flex; padding: 5px 12px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 500; color: var(--muted);
  transition: color .1s, border-color .1s;
}
.apichip:hover { color: var(--tx); border-color: var(--muted); text-decoration: none; }
.apihd { font-size: 16px; font-weight: 700; color: var(--tx); display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.apistep { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 4px; }
.apistep .num {
  width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 800; display: grid; place-items: center; flex: none; margin-top: 2px;
}
.apistep .tx { font-size: 13.5px; color: var(--tx); padding-top: 1px; line-height: 1.4; }

.endpoint { border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin: 14px 0; background: var(--bg); }
.ep-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.method {
  font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 3px 7px; border-radius: 4px; text-transform: uppercase; letter-spacing: .04em; flex: none;
}
.method.get    { background: color-mix(in srgb, var(--good) 12%, transparent); color: var(--good); }
.method.post   { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.method.delete { background: var(--bad-soft); color: var(--bad); }
.epath { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--tx); font-weight: 600; }
.ep-auth { margin-left: auto; font-size: 11px; padding: 2px 8px; border-radius: 4px; background: var(--panel-2); color: var(--muted); letter-spacing: .03em; font-weight: 500; }
.ep-auth.open { background: var(--accent-soft); color: var(--accent); }
.ep-desc { font-size: 13px; color: var(--muted); margin-bottom: 10px; line-height: 1.45; }
.ptable { width: 100%; border-collapse: collapse; font-size: 13px; margin: 10px 0; }
.ptable th, .ptable td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.ptable th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; background: var(--panel-2); }
.ptable td.nm { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--accent); font-weight: 500; }
.ptable td.ty { color: var(--muted); font-size: 12px; }
.ptable td.req { color: var(--bad); font-size: 12px; }
.ptable td.opt { color: var(--faint); font-size: 12px; }
.codewrap { border-radius: var(--r); overflow: hidden; margin: 10px 0; border: 1px solid var(--line); }
.codebar { display: flex; align-items: center; justify-content: space-between; padding: 7px 12px; background: var(--panel-2); border-bottom: 1px solid var(--line); }
.codelabel { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.copybtn { font-size: 11px; color: var(--muted); padding: 2px 8px; border-radius: 4px; border: 1px solid var(--line); background: var(--panel); transition: color .1s; }
.copybtn:hover { color: var(--tx); }
.code {
  font: 12.5px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--panel); color: var(--tx); padding: 14px 16px; overflow-x: auto; white-space: pre;
}

/* ── Dashboard modal ─── */
.dmodal {
  position: fixed; inset: 0; z-index: 50;
  display: none; align-items: center; justify-content: center;
  padding: 24px; background: rgba(0,0,0,.5);
}
.dmodal.on { display: flex; }
.dmodal .mcard {
  width: 100%; max-width: 520px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--rs); box-shadow: var(--shadow-lg); overflow: hidden;
}
.dmodal .mhd { display: flex; align-items: center; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.dmodal .mhd .logo { width: 38px; height: 38px; flex: none; }
.dmodal .mhd .t { font-size: 15px; font-weight: 700; color: var(--tx); }
.dmodal .mhd .s { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.dmodal .mhd .x {
  margin-left: auto; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; background: var(--panel-2);
  color: var(--muted); font-size: 13px; transition: background .1s, color .1s;
}
.dmodal .mhd .x:hover { background: var(--line); color: var(--tx); }
.dmodal .mbody { padding: 18px 20px; max-height: 60vh; overflow-y: auto; }
.dmodal .mfoot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px 18px; border-top: 1px solid var(--line); }

/* ── Mobile sidebar drawer ─── */
@media (max-width: 820px) {
  .dash-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%); transition: transform .2s ease;
    z-index: 20; box-shadow: var(--shadow-lg);
  }
  .dwrap.draw .dash-sidebar { transform: translateX(0); }
  .dwrap.draw #dashScrim { display: block; }
  .dash-ham { display: flex; }
  .dash-topbar { padding: 0 16px; }
  .dash-view { padding: 20px 16px 40px; }
}


/* ═══════════════════════════════════════════════════════════════════════════════
   APP — browser console
   ═══════════════════════════════════════════════════════════════════════════════ */
#app { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
#app.hide { display: none !important; }

#app header {
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px; height: 48px;
  background: var(--panel); border-bottom: 1px solid var(--line); flex: none;
}

#dashBack {
  display: flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 600; color: var(--muted);
  padding: 5px 8px; border-radius: var(--r); transition: background .1s, color .1s;
}
#dashBack:hover { background: var(--panel-2); color: var(--tx); }
#dashBack svg { width: 14px; height: 14px; }

.brand { font-size: 14px; font-weight: 700; color: var(--tx); letter-spacing: -.01em; margin-right: 4px; }
.brand span { color: var(--accent); }

#app select { height: 30px; font-size: 13px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); color: var(--tx); width: auto; }

.browserlabel { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.dotb { width: 6px; height: 6px; border-radius: 50%; background: var(--live); flex: none; }

#open.go, button.go {
  padding: 6px 14px; border-radius: var(--r);
  background: var(--accent); color: #fff; border: none;
  font: 600 13px/1 inherit; transition: background .1s;
}
#open.go:hover, button.go:hover { background: var(--brand-700); }
#open.go:disabled { opacity: .4; }

#app header button:not(.go):not(#dashBack) {
  padding: 5px 10px; font-size: 13px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--panel);
  color: var(--muted); transition: background .1s, color .1s;
}
#app header button:not(.go):not(#dashBack):hover { background: var(--panel-2); color: var(--tx); }

.overflow { position: relative; }
.iconbtn { font-size: 17px !important; padding: 4px 8px !important; }
#hdrMenu {
  position: absolute; top: calc(100% + 5px); right: 0;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--rs); box-shadow: var(--shadow-lg);
  padding: 6px; min-width: 160px; z-index: 40;
  display: none; flex-direction: column; gap: 2px;
}
#hdrMenu.on { display: flex; }
#hdrMenu button { display: block; width: 100%; text-align: left; padding: 7px 12px; font-size: 13px; border: none !important; border-radius: var(--r) !important; }
#hdrMenu button:hover { background: var(--panel-2) !important; color: var(--tx) !important; }

#app .bar {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 12px; background: var(--panel);
  border-bottom: 1px solid var(--line); flex: none;
}
.url { flex: 1; height: 32px; font-size: 13px; border: 1px solid var(--line); border-radius: var(--r); padding: 0 10px; background: var(--bg); }
#app .bar button { height: 32px; padding: 0 12px; font-size: 13px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); color: var(--muted); cursor: pointer; white-space: nowrap; }
#app .bar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); display: inline-block; flex: none; }
#app .bar .dot.on { background: var(--live); }
.kbdbtn { font-size: 16px !important; }

#app main { flex: 1; display: flex; overflow: hidden; }

.stage { flex: 1; position: relative; overflow: hidden; background: var(--stage); }

.empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 32px; text-align: center; font-size: 14px; color: rgba(255,255,255,.35); line-height: 1.6;
}
.empty b { color: rgba(255,255,255,.6); }

#view { display: block; width: 100%; height: 100%; object-fit: contain; }

#kbd { position: absolute; left: -9999px; top: 0; width: 1px; height: 1px; opacity: 0; font-size: 16px; }

.hintbar {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.75); color: #fff; font-size: 12px;
  padding: 5px 12px; border-radius: 999px; pointer-events: none;
}

#panel {
  width: 320px; flex: none; display: flex; flex-direction: column;
  background: var(--panel); border-left: 1px solid var(--line); overflow: hidden;
}

.grip {
  display: none; align-items: center; gap: 8px;
  padding: 8px 14px; background: var(--panel-2);
  border-bottom: 1px solid var(--line); cursor: ns-resize;
}
.grip .who { font-size: 12.5px; font-weight: 700; color: var(--tx); }
.grip .st  { font-size: 12px; color: var(--muted); }

.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.tab {
  flex: 1; padding: 9px; font-size: 12.5px; font-weight: 600;
  color: var(--muted); border: none; background: none;
  border-bottom: 2px solid transparent; transition: color .1s, border-color .1s; position: relative;
}
.tab:hover { color: var(--tx); }
.tab.on { color: var(--tx); border-bottom-color: var(--accent); }
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--bad); color: #fff; border-radius: 8px;
  font-size: 10px; font-weight: 700; margin-left: 4px; vertical-align: middle;
}

#panel section { flex: 1; overflow-y: auto; display: flex; flex-direction: column; padding: 0; }
#panel h2 { font-size: 12.5px; color: var(--muted); padding: 12px 14px 6px; font-weight: 600; }

.chathead {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex: none;
}
.chathead select { height: 28px; font-size: 12.5px; padding: 0 7px; width: auto; }
.chathead-actions { display: flex; gap: 4px; margin-left: auto; }
.chatact {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 9px; border-radius: var(--r); font-size: 12px; font-weight: 600;
  color: var(--muted); border: 1px solid var(--line); background: var(--panel);
  transition: background .1s, color .1s;
}
.chatact:hover { background: var(--panel-2); color: var(--tx); }
.chatact svg { width: 14px; height: 14px; }
.chatact.danger { color: var(--bad); }
.chatact.danger:hover { background: var(--bad-soft); }
.chatact:disabled { opacity: .35; }

.roleline { font-size: 12px; color: var(--muted); padding: 7px 12px; border-bottom: 1px solid var(--line); flex: none; line-height: 1.4; }

.feed {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth;
}
.ev {
  border-radius: var(--r); padding: 10px 12px; font-size: 13px; line-height: 1.45;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--tx);
}
.ev.user { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.ev.agent { background: var(--panel); }
.ev.step  { background: var(--panel-2); font-size: 12.5px; color: var(--muted); }
.ev.ask   { background: color-mix(in srgb, var(--warn) 10%, var(--panel)); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.ev.lead  { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.ev.err   { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 25%, transparent); color: var(--bad); }
.ev.hidden { display: none; }
.ev-time { font-size: 10.5px; color: var(--faint); margin-top: 4px; }

.leadbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--line); font-size: 12px; background: var(--panel-2); flex: none; }
#csv { color: var(--accent); font-weight: 600; font-size: 12px; }

#composer { padding: 10px 12px 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 5px; flex: none; }
.composer-box { display: flex; gap: 6px; align-items: flex-end; }
#sayText { flex: 1; min-height: 38px; max-height: 120px; resize: none; border-radius: var(--r); font-size: 13.5px; line-height: 1.45; overflow-y: auto; padding: 8px 10px; }
#sayBtn { height: 38px; padding: 0 14px; flex: none; font-size: 13.5px; border-radius: var(--r); }

#els { list-style: none; padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; }
#els li { font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--tx); padding: 5px 8px; border-radius: var(--r); background: var(--panel-2); }

.log { flex: 1; overflow-y: auto; font: 11.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 8px 10px; color: var(--muted); white-space: pre-wrap; }
.kv { font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; }

/* ── App exit panel ─── */
#exitPanel { padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }

/* ── App modals ─── */
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(0,0,0,.5);
}
.modal.hide { display: none !important; }
.modal > div {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--rs); box-shadow: var(--shadow-lg);
  padding: 22px 24px; max-width: 540px; width: 100%;
  max-height: 90vh; overflow-y: auto;
}
.modal h3 { font-size: 17px; margin-bottom: 6px; }
.modal label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 5px; }
.modal input, .modal select, .modal textarea { width: 100%; margin-bottom: 2px; }
.modal textarea { resize: vertical; min-height: 72px; }
.modal .foot { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; flex-wrap: wrap; }
.modal .row { display: flex; gap: 8px; flex-wrap: wrap; }
.pb { display: flex; flex-direction: column; gap: 5px; }
.pb-item { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; }

@media (max-width: 700px) {
  #panel { position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: 45vh; border-left: none; border-top: 1px solid var(--line); z-index: 30; }
  .grip { display: flex; }
  #app main { flex-direction: column; }
  .stage { flex: 1; }
}
