/* Voice Vault — staff console. Dense, calm operations UI. */
:root {
  color-scheme: light;
  --bg: #f6f6f3;
  --surface: #fff;
  --surface-2: #f0efea;
  --border: #e2e0d8;
  --text: #1b1b18;
  --muted: #6d6b63;
  --accent: #2f5bea;
  --accent-ink: #fff;
  --ok: #2f8f5b;
  --warn: #b7791f;
  --danger: #e5484d;
  --danger-ink: #c62f35;
  --ok-bg: #e5f3ea;
  --warn-bg: #fbf0dc;
  --danger-bg: #fde8e8;
  --accent-bg: #e8edfd;
  --staff: #3a2f6b;          /* staff-console identity band */
  --staff-ink: #fff;
  /* chart series (dataviz reference palette, validated: slots 1–2) */
  --series-1: #257de0;
  --series-2: #f47230;
  --grid: #ebe9e2;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.06);
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1b1b19;
    --surface-2: #24231f;
    --border: #33322d;
    --text: #ecebe6;
    --muted: #9a988f;
    --accent: #7a9bff;
    --accent-ink: #0e1430;
    --ok: #4cc38a;
    --warn: #f0b252;
    --danger: #ff6369;
    --danger-ink: #ff8a8e;
    --ok-bg: #16291f;
    --warn-bg: #2e2412;
    --danger-bg: #331a1b;
    --accent-bg: #1d2440;
    --staff: #4b3d8f;
    --staff-ink: #fff;
    --series-1: #338ced;
    --series-2: #e76624;
    --grid: #2a2925;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); font: 13px/1.45 var(--font);
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 13px; }
code, .mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 6px 10px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ── top bar ── */
.topbar {
  position: sticky; top: 0; z-index: 20; height: 48px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; background: var(--staff); color: var(--staff-ink);
  background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.04) 0 10px, transparent 10px 20px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; background: rgba(255,255,255,.16); font-weight: 700; font-size: 11px; }
.brand-name { font-weight: 600; }
.staff-tag {
  font-size: 11px; font-weight: 700; letter-spacing: .12em; padding: 3px 8px; border-radius: 4px;
  background: #ffd84d; color: #2a2100;
}
.demo-badge { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; border: 1px dashed rgba(255,255,255,.7); }
.who { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.who-email { opacity: .92; }
.role-pill { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.18); text-transform: uppercase; letter-spacing: .05em; }
.topbar .btn-ghost { color: var(--staff-ink); border-color: rgba(255,255,255,.35); }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.12); }

/* ── layout ── */
.app { display: grid; grid-template-columns: 200px minmax(0, 1fr); min-height: calc(100vh - 48px); }
.sidenav { border-right: 1px solid var(--border); background: var(--surface); padding: 12px 8px; position: sticky; top: 48px; height: calc(100vh - 48px); overflow: auto; display: flex; flex-direction: column; }
.sidenav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sidenav a {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 6px; color: var(--text); text-decoration: none; font-weight: 500;
}
.sidenav a:hover { background: var(--surface-2); }
.sidenav a[aria-current="page"] { background: var(--accent-bg); color: var(--accent); }
.sidenav .nav-sep { margin: 8px 10px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.nav-foot { margin-top: auto; padding: 10px; line-height: 1.4; }
.main { padding: 18px 22px 60px; min-width: 0; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head p { margin: 2px 0 0; }
.crumbs { font-size: 12px; margin-bottom: 4px; }
.crumbs a { text-decoration: none; }
.boot { position: fixed; inset: 48px 0 0 0; display: grid; place-items: center; color: var(--muted); }

/* ── cards, grids ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; min-width: 0; }
.card > h3, .card-head { margin-bottom: 10px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.kpi .k-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi .k-value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .k-sub { font-size: 12px; color: var(--muted); }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .app { grid-template-columns: 160px minmax(0,1fr); } }

/* ── controls ── */
.btn {
  appearance: none; font: inherit; font-weight: 500; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 6px 12px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; line-height: 1.3;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.07); background: var(--accent); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.07); background: var(--danger); }
.btn-warn { background: var(--warn-bg); border-color: var(--warn); color: var(--text); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 3px 9px; font-size: 12px; }
.btn-link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 6px 9px; min-width: 0;
}
textarea { width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.field { display: grid; gap: 4px; margin-bottom: 10px; }
.field > span, .field > label { font-size: 12px; font-weight: 500; }
.field .hint { font-size: 11px; color: var(--muted); }
.code-input { font-family: var(--mono); font-size: 20px; letter-spacing: .35em; text-align: center; width: 100%; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button { font: inherit; border: 0; background: var(--surface); color: var(--text); padding: 5px 11px; cursor: pointer; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent-bg); color: var(--accent); font-weight: 600; }

/* ── tabs ── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 6px 0 12px; overflow-x: auto; }
.tabs [role=tab] { font: inherit; font-weight: 500; border: 0; background: none; color: var(--muted); padding: 8px 12px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs [role=tab][aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs [role=tab]:hover { color: var(--text); }

/* ── tables ── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data th, .data td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.data th { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; }
.data tbody tr:last-child td { border-bottom: 0; }
.data tbody tr.clickable { cursor: pointer; }
.data tbody tr.clickable:hover, .data tbody tr.clickable:focus-within { background: var(--surface-2); }
.data th.num, .data td.num { text-align: right; }
.data th button.sort { all: unset; cursor: pointer; }
.data th button.sort:focus-visible { outline: 2px solid var(--accent); }
.data tr.glass td { background: var(--danger-bg); }
.data tr.glass td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.data tr.retired td { color: var(--muted); }
.data a.rowlink { color: var(--text); font-weight: 600; text-decoration: none; }
.data a.rowlink:hover { text-decoration: underline; }
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 8px; }

/* ── pills ── */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-bg); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.danger { color: var(--danger-ink); background: var(--danger-bg); }
.pill.neutral { color: var(--muted); background: var(--surface-2); }
.pill.accent { color: var(--accent); background: var(--accent-bg); }
.pill.plain::before { display: none; }

/* ── banners ── */
.banner { border: 1px solid var(--border); border-left-width: 4px; border-radius: 6px; padding: 9px 12px; margin-bottom: 12px; background: var(--surface); }
.banner.info { border-left-color: var(--accent); background: var(--accent-bg); }
.banner.warn { border-left-color: var(--warn); background: var(--warn-bg); }
.banner.danger { border-left-color: var(--danger); background: var(--danger-bg); }
.banner.ok { border-left-color: var(--ok); background: var(--ok-bg); }
.banner strong { font-weight: 600; }

/* ── states ── */
.state { padding: 28px 12px; text-align: center; color: var(--muted); }
.state.error { color: var(--danger-ink); }
.state .btn { margin-top: 8px; }
.skeleton { height: 12px; border-radius: 4px; background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; margin: 8px 0; }
@keyframes shimmer { to { background-position: -200% 0; } }
.loading-dim { opacity: .55; transition: opacity .15s; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* ── auth ── */
.auth { min-height: calc(100vh - 48px); display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--staff); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.auth-kicker { margin: 0 0 4px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.auth-card h1 { margin-bottom: 6px; }
.auth-card form { margin-top: 16px; }
.auth-card .btn-primary { width: 100%; justify-content: center; padding: 8px; }
.auth-alt { margin-top: 12px; text-align: center; }
.qr { display: block; width: 180px; height: 180px; margin: 10px auto; background: #fff; padding: 8px; border-radius: 6px; border: 1px solid var(--border); }
.secret { display: flex; gap: 6px; align-items: center; margin-bottom: 12px; }
.secret code { flex: 1; padding: 6px 8px; background: var(--surface-2); border-radius: 6px; word-break: break-all; }
.steps { display: flex; gap: 6px; margin: 12px 0 0; font-size: 11px; color: var(--muted); }
.steps span[aria-current="step"] { color: var(--text); font-weight: 600; }

/* ── dialog ── */
.dialog { border: 1px solid var(--border); border-radius: 10px; padding: 0; background: var(--surface); color: var(--text); width: min(560px, calc(100vw - 32px)); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(10,10,8,.45); }
.dialog form { padding: 18px 20px; }
.dialog h2 { margin-bottom: 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.dialog-error { color: var(--danger-ink); margin: 8px 0 0; }
.dialog.glass { border-color: var(--danger); border-top: 4px solid var(--danger); }
.consequence { background: var(--surface-2); border-radius: 6px; padding: 10px 12px; margin: 0 0 12px; }
.consequence ul { margin: 4px 0 0; padding-left: 18px; }
.dialog textarea.json { font-family: var(--mono); font-size: 12px; min-height: 160px; }

/* ── toasts ── */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 6px; padding: 9px 12px; box-shadow: var(--shadow); display: flex; gap: 10px; align-items: flex-start; }
.toast.error { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
.toast button { margin-left: auto; }

/* ── charts ── */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis-text { fill: var(--muted); font-size: 10.5px; font-family: var(--font); }
.chart .label-text { fill: var(--text); font-size: 11px; font-family: var(--font); font-weight: 600; }
.chart .baseline { stroke: var(--border); stroke-width: 1; }
.chart .s1 { fill: var(--series-1); }
.chart .s2 { fill: var(--series-2); }
.chart .ln1 { stroke: var(--series-1); fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .ln2 { stroke: var(--series-2); fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area1 { fill: var(--series-1); opacity: .12; }
.chart .bar { transition: opacity .1s; }
.chart .bar.dim { opacity: .45; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit:focus { outline: none; }
.chart:focus-within .crosshair { stroke: var(--accent); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text); margin-bottom: 6px; }
.legend .key { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 6px; border-radius: 1px; }
.legend .key.rect { height: 10px; width: 10px; border-radius: 2px; }
.key.k1 { background: var(--series-1); }
.key.k2 { background: var(--series-2); }
.hbars { display: grid; gap: 6px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; gap: 8px; align-items: center; font-size: 12px; }
.hbar .track { height: 10px; background: transparent; }
.hbar .fill { height: 10px; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-table summary { cursor: pointer; font-size: 12px; color: var(--muted); margin-top: 6px; }
.chart-table .table-wrap { max-height: 240px; overflow: auto; margin-top: 6px; }
.tooltip {
  position: fixed; z-index: 70; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 9px; box-shadow: var(--shadow); font-size: 12px; min-width: 120px;
}
.tooltip .tt-title { color: var(--muted); font-size: 11px; margin-bottom: 3px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 6px; }
.tooltip .tt-row strong { font-variant-numeric: tabular-nums; }
.tooltip .tt-key { width: 10px; height: 2px; border-radius: 1px; }
.tooltip .tt-name { color: var(--muted); }

/* ── misc ── */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; font-size: 12.5px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.server-card.stale { border-color: var(--warn); box-shadow: inset 3px 0 0 var(--warn); }
.transcript { white-space: pre-wrap; font-size: 12.5px; background: var(--surface-2); border-radius: 6px; padding: 10px 12px; margin: 6px 0 0; max-height: 320px; overflow: auto; }
details.rec { border-bottom: 1px solid var(--border); padding: 8px 2px; }
details.rec summary { cursor: pointer; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
details.rec summary::-webkit-details-marker { display: none; }
details.rec summary::before { content: "▸"; color: var(--muted); }
details.rec[open] summary::before { content: "▾"; }
.ann { border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 6px; padding: 10px 12px; background: var(--surface); display: flex; gap: 12px; align-items: flex-start; }
.ann.warning { border-left-color: var(--warn); }
.ann.critical { border-left-color: var(--danger); }
.ann.ended { opacity: .65; }
.ann p { margin: 0 0 4px; }
.actions-cell { display: flex; gap: 4px; flex-wrap: wrap; }
.menu-btn { position: relative; }
.json-view { font-family: var(--mono); font-size: 11.5px; white-space: pre-wrap; word-break: break-word; margin: 0; color: var(--muted); }
.section-title { margin: 18px 0 8px; }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
