/* AI Call Center console. Colors are tokens; dark mode redefines them. */
:root {
  color-scheme: light;
  --page: #f5f5f3; --surface: #ffffff; --surface-2: #f9f9f7; --sunken: #efeee9;
  --ink: #16171a; --ink-2: #52514e; --muted: #7d7b75; --line: #e4e3dd; --line-strong: #c9c8c0;
  --accent: #2a63d6; --accent-ink: #ffffff; --accent-soft: #e8effc;
  --good: #0a7a2f; --good-soft: #e3f4e7; --warn: #8a5a00; --warn-soft: #fdf1d8;
  --serious: #a8431a; --serious-soft: #fce9e0; --critical: #c02f2f; --critical-soft: #fbe6e6;
  --live: #0ca30c;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --grid: #e1e0d9; --axis: #c3c2b7;
  --sidebar: #16181d; --sidebar-ink: #c9ccd3; --sidebar-muted: #7e838f; --sidebar-active: #262a33;
  --shadow: 0 1px 2px rgba(16, 17, 20, .06), 0 1px 1px rgba(16, 17, 20, .04);
  --shadow-lg: 0 12px 40px rgba(16, 17, 20, .18);
  --radius: 10px; --radius-sm: 6px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0f1012; --surface: #1a1a19; --surface-2: #202020; --sunken: #151516;
    --ink: #f2f2f0; --ink-2: #c3c2b7; --muted: #8f8d86; --line: #2c2c2a; --line-strong: #45443f;
    --accent: #5b8cff; --accent-ink: #0b0d12; --accent-soft: #1c2740;
    --good: #3cc463; --good-soft: #13291a; --warn: #f0b545; --warn-soft: #2e2410;
    --serious: #f08a5d; --serious-soft: #321a10; --critical: #f07070; --critical-soft: #331616;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --grid: #2c2c2a; --axis: #383835;
    --sidebar: #111214; --sidebar-active: #22252c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 12px 40px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0f1012; --surface: #1a1a19; --surface-2: #202020; --sunken: #151516;
  --ink: #f2f2f0; --ink-2: #c3c2b7; --muted: #8f8d86; --line: #2c2c2a; --line-strong: #45443f;
  --accent: #5b8cff; --accent-ink: #0b0d12; --accent-soft: #1c2740;
  --good: #3cc463; --good-soft: #13291a; --warn: #f0b545; --warn-soft: #2e2410;
  --serious: #f08a5d; --serious-soft: #321a10; --critical: #f07070; --critical-soft: #331616;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --grid: #2c2c2a; --axis: #383835;
  --sidebar: #111214; --sidebar-active: #22252c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 12px 40px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--page); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 15px; }
code, pre { font-family: var(--mono); font-size: 12px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- shell ---- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-ink); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 14px 10px; gap: 6px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent); color: #fff; flex: none; }
.brand-mark .icon { stroke: #fff; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text b { color: #fff; line-height: 1.25; overflow-wrap: anywhere; }
.brand-text small { color: var(--sidebar-muted); font-size: 11px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px;
  color: var(--sidebar-ink); font-weight: 500; }
.nav-link:hover { background: var(--sidebar-active); text-decoration: none; color: #fff; }
.nav-link.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.icon { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sys-status { border-top: 1px solid #2a2d35; padding: 10px 8px 2px; display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; color: var(--sidebar-muted); }
.sys-item { display: flex; align-items: center; gap: 8px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 10px 24px;
  background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 18px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn.menu-btn { display: none; }
.view { padding: 20px 24px 48px; display: flex; flex-direction: column; gap: 16px; max-width: 1400px; width: 100%; outline: none; }
.scrim { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 30; transform: translateX(-100%);
    transition: transform .2s ease; }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 20; }
  .icon-btn.menu-btn { display: grid; }
  .topbar { padding: 10px 16px; }
  .view { padding: 16px 16px 40px; }
  .user-name, .topbar-right select[name=theme] { display: none; }
}

/* ---- controls ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 40%, var(--line)); }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; filter: none; }
.icon-btn { display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--ink-2); cursor: pointer; font: inherit; }
.icon-btn:hover { background: var(--sunken); }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-align: left; }
.link-btn:hover { text-decoration: underline; }
.input { height: 34px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: inherit; min-width: 0; width: 100%; }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.45; }
select.input { padding-right: 28px; }
.input.compact { height: 30px; width: auto; font-size: 13px; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.search { width: 280px; max-width: 100%; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .input:not(.search) { width: auto; }
.toolbar.tight { gap: 8px; }
.segmented { display: inline-flex; background: var(--sunken); border-radius: 8px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented button { border: 0; background: transparent; color: var(--ink-2); padding: 5px 12px; border-radius: 6px;
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---- cards and layout ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-2.wide-left { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 1100px) { .grid-2, .grid-2.wide-left, .detail-grid { grid-template-columns: 1fr; } }
.back { color: var(--muted); font-size: 13px; align-self: flex-start; }
.error-card { border-color: var(--critical); }

/* ---- KPIs ---- */
.kpis { display: grid; grid-template-columns: 1.4fr repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpis.small { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpis .hero { grid-column: 1 / -1; } }
@media (max-width: 520px) { .kpis.small { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tile-label { color: var(--ink-2); font-size: 13px; }
.tile-value { font-size: 26px; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; }
.hero-value { font-size: 48px; font-weight: 650; letter-spacing: -.03em; line-height: 1.05; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 500; }
.delta.good { color: var(--good); } .delta.bad { color: var(--critical); }
.delta .icon { stroke-width: 2.5; }
.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-bottom: 8px; }
.mini .badge { max-width: 100%; white-space: normal; text-align: left; line-height: 1.25; }
.mini { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 10px 12px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--line); color: inherit; }
.mini:hover { border-color: var(--line-strong); text-decoration: none; }
.mini-value { font-size: 20px; font-weight: 600; }
.live-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--good);
  background: var(--good-soft); padding: 3px 10px; border-radius: 999px; }

/* ---- badges and dots ---- */
.badge { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500;
  white-space: nowrap; background: var(--sunken); color: var(--ink-2); line-height: 1.6; }
.tone-good { background: var(--good-soft); color: var(--good); }
.tone-warn { background: var(--warn-soft); color: var(--warn); }
.tone-serious { background: var(--serious-soft); color: var(--serious); }
.tone-critical { background: var(--critical-soft); color: var(--critical); }
.tone-accent { background: var(--accent-soft); color: var(--accent); }
.tone-live { background: var(--good-soft); color: var(--good); }
.tone-muted { background: var(--sunken); color: var(--muted); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--live); } .dot.warn { background: #fab219; } .dot.bad { background: #d03b3b; }
.dot.live { background: var(--live); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 6px 10px;
  border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table td.wrap { white-space: normal; min-width: 180px; max-width: 420px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table th.num { text-align: right; }
.table td.actions { text-align: right; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table.compact td, .table.compact th { padding: 5px 8px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 12px; }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty p { max-width: 460px; margin: 0; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 40px; justify-content: center; }
.spin { width: 16px; height: 16px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- facts, feed, notes ---- */
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.facts div { display: contents; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.feed li { display: grid; grid-template-columns: 10px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); margin-top: 7px; }
.feed-dot.ai { background: var(--accent); }
.profile-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.profile-head h2 { font-size: 20px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.notes { margin-top: 8px; padding: 8px 12px; background: var(--warn-soft); border-radius: 8px; white-space: pre-wrap; }
.description { white-space: pre-wrap; }
.notes-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.notes-list li { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.notes-list p { margin: 4px 0 0; white-space: pre-wrap; }
.note-form { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.total-row { text-align: right; padding-top: 10px; font-size: 15px; }
.prose p { color: var(--ink-2); }
.try-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft);
  color: var(--accent); font-weight: 600; font-size: 13px; flex: none; }
.avatar.big { width: 52px; height: 52px; font-size: 22px; }

/* ---- user menu ---- */
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 3px 6px;
  border-radius: 8px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--sunken); }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); min-width: 220px; padding: 6px; z-index: 40; }
.menu-head { padding: 6px 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; color: var(--ink-2); font-size: 13px; }
.menu-item { display: block; width: 100%; text-align: left; padding: 7px 10px; border: 0; background: none; color: var(--ink);
  border-radius: 6px; font: inherit; cursor: pointer; }
.menu-item:hover { background: var(--sunken); }

/* ---- transcript and console ---- */
.transcript, .chat-log { display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 80%; padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.agent { align-self: flex-start; background: var(--sunken); border-bottom-left-radius: 4px; }
.bubble.caller { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.bubble-meta { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.bubble.caller .bubble-meta { color: color-mix(in srgb, var(--accent-ink) 75%, transparent); }
.sys-event { align-self: center; font-size: 12px; color: var(--muted); padding: 3px 12px; border: 1px dashed var(--line-strong);
  border-radius: 999px; text-align: center; }
.sys-event.bad { color: var(--critical); border-color: var(--critical); }
.tool-card { align-self: flex-start; max-width: 92%; border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; font-size: 12px; }
.tool-card summary { display: flex; align-items: center; gap: 8px; padding: 6px 10px; cursor: pointer; flex-wrap: wrap; }
.tool-card summary code { color: var(--muted); overflow-wrap: anywhere; }
.tool-card.failed { border-color: color-mix(in srgb, var(--critical) 45%, var(--line)); }
.tool-card pre { margin: 0; padding: 8px 10px; border-top: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 280px; overflow: auto; }
.console-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(260px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .console-grid { grid-template-columns: 1fr; } }
.card.chat { display: flex; flex-direction: column; height: calc(100vh - 140px); min-height: 460px; padding-bottom: 12px; }
.chat-log { flex: 1; overflow-y: auto; padding: 4px 2px 12px; }
.chat-input { display: flex; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.typing { align-self: flex-start; display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: pulse 1s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }
.typing em { margin-left: 6px; font-style: normal; }
.audio { width: 100%; }

/* ---- charts ---- */
.chart { position: relative; }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.chart-plot svg { display: block; overflow: visible; }
.chart-plot .grid { stroke: var(--grid); stroke-width: 1; }
.chart-plot .axis { stroke: var(--axis); stroke-width: 1; }
.chart-plot .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-plot .hit { fill: transparent; }
.chart-plot .hit:hover { fill: color-mix(in srgb, var(--ink) 4%, transparent); }
.chart-tip { position: absolute; top: 30px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow-lg); padding: 8px 10px; font-size: 12px; pointer-events: none; min-width: 160px; z-index: 3; }
.tip-title { font-weight: 600; margin-bottom: 4px; }
.tip-row { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; color: var(--ink-2); }
.tip-row b { color: var(--ink); font-variant-numeric: tabular-nums; }
.chart-table { max-height: 260px; overflow: auto; }
.hbars { display: flex; flex-direction: column; gap: 8px; }
.hbar { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 12px; align-items: center; font-size: 13px; }
.hbar-label { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hbar-fill { height: 10px; border-radius: 0 4px 4px 0; flex: none; }
.hbar-value { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 500; }

/* ---- forms and modals ---- */
.form-grid { display: grid; gap: 12px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 600px) { .form-grid.two { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field-hint { font-size: 12px; color: var(--muted); }
.static { padding: 6px 0; font-weight: 500; }
.form-error { color: var(--critical); font-size: 13px; min-height: 0; }
.form-error:empty { display: none; }
.item-head, .item-row { display: grid; grid-template-columns: 1fr 80px 110px 32px; gap: 8px; align-items: center; }
.item-head { margin: 4px 0; }
.items { display: flex; flex-direction: column; gap: 6px; }
.items-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.backdrop { position: fixed; inset: 0; background: rgba(10, 11, 14, .45); display: grid; place-items: center; z-index: 50;
  padding: 16px; animation: fade .12s ease; }
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); width: min(480px, 100%);
  max-height: calc(100vh - 32px); display: flex; flex-direction: column; border: 1px solid var(--line); }
.modal.wide { width: min(680px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 16px; }
.modal-body { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
@keyframes fade { from { opacity: 0; } }

/* ---- login ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 20% -10%, var(--accent-soft), transparent), var(--page); }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { font-size: 20px; }
.brand.big { padding: 0; font-weight: 600; font-size: 15px; }
.login-card select { align-self: flex-start; }

/* ---- toasts ---- */
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: var(--page); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-lg);
  font-size: 13px; transition: opacity .4s, transform .4s; max-width: 360px; }
.toast.bad { background: var(--critical); color: #fff; }
.toast.warn { background: #8a5a00; color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---- settings ---- */
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.reg-status { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }
.secret { user-select: all; }
.model-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.model-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.progress { display: flex; flex-direction: column; gap: 6px; }
.progress .bar { height: 6px; background: var(--sunken); border-radius: 999px; overflow: hidden; }
.progress .bar span { display: block; height: 100%; background: var(--accent); transition: width .5s; }
input[readonly].input { background: var(--sunken); color: var(--ink-2); }

/* ---- platform: navigation sections, agents, knowledge base, leads, campaigns ---- */
.nav { overflow-y: auto; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--sidebar-muted);
  padding: 12px 10px 4px; }
.kpis.business { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1100px) { .kpis.business { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile-link { color: inherit; text-decoration: none; }
.tile-link:hover { border-color: var(--line-strong); text-decoration: none; }
.tile-btn { text-align: left; font: inherit; color: inherit; cursor: pointer; }
.tile-btn.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.small-value { font-size: 18px; }
.sub-head { font-size: 13px; margin: 14px 0 6px; color: var(--ink-2); }
.dot-label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.health { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.dir { display: inline-block; width: 16px; color: var(--muted); }
.notice { border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--line)); background: var(--warn-soft); color: var(--ink);
  border-radius: var(--radius); padding: 10px 14px; }
.notice p { margin: 2px 0; }
.sys-event.handoff { border-style: solid; border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); color: var(--ink-2); }
.checklist { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 4px; }
.checklist li { color: var(--ink-2); }
.checklist li.done { color: var(--good); }
.progress.inline { flex-direction: row; align-items: center; gap: 8px; min-width: 140px; }
.progress.inline .bar { flex: 1; }
.flow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.flow-group { display: flex; flex-wrap: wrap; gap: 6px; }
.flow-node { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font-size: 13px; text-decoration: none; }
.flow-node.entry { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 500; }
a.flow-node:hover { text-decoration: none; border-color: var(--line-strong); }
.flow-arrow { color: var(--muted); }
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.agent-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); color: inherit; text-decoration: none; }
.agent-card:hover { border-color: var(--line-strong); text-decoration: none; }
.agent-card.off { opacity: .6; }
.agent-head { display: flex; align-items: center; gap: 12px; }
.agent-desc { color: var(--ink-2); font-size: 13px; margin: 0; display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden; }
.agent-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; border-top: 1px solid var(--line); padding-top: 10px; }
.agent-stats div { display: flex; flex-direction: column; }
.agent-stats b { font-size: 16px; }
.agent-stats span { font-size: 11px; color: var(--muted); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 16px; }
.check-grid .check { align-items: flex-start; }
.check-grid .check input { margin-top: 3px; }
textarea.mono { font-family: var(--mono); font-size: 12.5px; line-height: 1.5; }
.kb-list { display: flex; flex-direction: column; }
.kb-item { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 10px 4px; border: 0;
  border-bottom: 1px solid var(--line); background: none; color: var(--ink); font: inherit; cursor: pointer; }
.kb-item:last-child { border-bottom: 0; }
.kb-item:hover b { color: var(--accent); }
.score { position: relative; display: inline-flex; align-items: center; width: 80px; height: 18px; background: var(--sunken);
  border-radius: 999px; overflow: hidden; }
.score span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent-soft); }
.score em { position: relative; font-style: normal; font-size: 11px; padding-left: 8px; font-variant-numeric: tabular-nums; }
.preview { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px dashed var(--line-strong); }
.preview ul { margin: 6px 0 0; padding-left: 18px; }
.rec { color: var(--critical); font-size: 12px; }
.hours { display: flex; flex-direction: column; gap: 6px; }
.hours-row { display: grid; grid-template-columns: 110px 1fr 1fr; gap: 8px; align-items: center; }

/* Settings: sticky links to every section */
.section-nav { position: sticky; top: 57px; z-index: 4; display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0 10px;
  margin: -8px 0 4px; background: var(--page); }
.section-nav a { flex: none; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.section-nav a:hover { color: var(--ink); border-color: var(--line-strong); text-decoration: none; }
.card { scroll-margin-top: 160px; }
.card.flash { box-shadow: 0 0 0 2px var(--accent); transition: box-shadow .3s; }
@media (max-width: 760px) {
  .section-nav { top: 53px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .section-nav::-webkit-scrollbar { display: none; }
}

/* Dashboard: callers to call back */
.cb-list { display: grid; }
.cb-row { display: grid; grid-template-columns: minmax(170px, 220px) 1fr auto; gap: 8px 16px; align-items: center;
  padding: 10px 0; border-top: 1px solid var(--line); }
.cb-phone { font-weight: 600; white-space: nowrap; }
.cb-reason { min-width: 0; }
.cb-actions { display: flex; gap: 6px; justify-content: flex-end; }
@media (max-width: 760px) {
  .cb-row { grid-template-columns: 1fr auto; }
  .cb-reason { grid-column: 1 / -1; grid-row: 2; }
}

/* Global search in the top bar */
.gsearch-wrap { flex: 0 1 380px; min-width: 0; }
.gsearch { position: relative; }
.gsearch .input { padding-left: 32px; height: 34px; }
.gsearch-icon { position: absolute; left: 10px; top: 9px; color: var(--ink-3, var(--ink-2)); pointer-events: none; }
.gsearch-open { display: none; }
.gsearch-results { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20; max-height: 70vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg, 0 12px 32px rgba(0,0,0,.15));
  padding: 6px; }
.gsearch-kind { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); padding: 8px 8px 4px; }
.gsearch-item { display: flex; flex-direction: column; gap: 2px; padding: 7px 8px; border-radius: 6px; color: var(--ink); }
.gsearch-item:hover, .gsearch-item.active { background: var(--surface-2); text-decoration: none; }
.gsearch-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gsearch-empty { padding: 10px 8px; }
@media (max-width: 760px) {
  .gsearch-wrap { flex: none; }
  .gsearch-open { display: inline-flex; }
  .gsearch { display: none; }
  .gsearch.expanded { display: block; position: absolute; left: 12px; right: 12px; top: 8px; z-index: 30; }
  .gsearch.expanded .input { height: 38px; background: var(--surface); }
}

/* SaaS: sign-up, company banner, first steps, companies */
.login-card.wide { width: min(480px, 100%); }
.signup-cta { text-align: center; margin: 4px 0 0; }
.company-banner { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 24px; font-size: 14px;
  background: var(--accent-soft); color: var(--ink); border-bottom: 1px solid var(--line); }
.company-banner.warn { background: #fff4d6; }
.company-banner.bad { background: #fde8e8; }
:root[data-theme="dark"] .company-banner.warn { background: #3a2f12; }
:root[data-theme="dark"] .company-banner.bad { background: #3a1818; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .company-banner.warn { background: #3a2f12; }
  :root:not([data-theme="light"]) .company-banner.bad { background: #3a1818; } }
.company-banner .spacer { flex: 1; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.steps li { display: grid; grid-template-columns: 22px 1fr; gap: 2px 10px; align-items: start; }
.steps li .muted { grid-column: 2; }
.step-mark { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-strong); display: inline-grid;
  place-items: center; font-size: 12px; font-weight: 700; }
.steps li.done .step-mark { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.steps li.done a, .steps li.done span:not(.step-mark) { color: var(--ink-2); text-decoration: line-through; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; }
.chip-x { border: 0; background: transparent; cursor: pointer; color: var(--ink-2); font-size: 15px; line-height: 1; padding: 0 4px; }
.text-bad { color: var(--bad, #c0392b); }

/* Speech lab */
.lab-list { display: grid; }
.lab-row { display: grid; grid-template-columns: 260px 1fr auto; gap: 8px 14px; align-items: center; padding: 10px 0;
  border-top: 1px solid var(--line); }
.lab-row audio { width: 100%; height: 36px; }
.lab-text { display: grid; gap: 4px; min-width: 0; }
.lab-text .heard { font-style: italic; }
.toolbar.wrap { flex-wrap: wrap; }
@media (max-width: 760px) { .lab-row { grid-template-columns: 1fr; } }
