/* ═══════════════════════════════════════════════════════════════════════════
   Comms console — visual system
   ───────────────────────────────────────────────────────────────────────────
   Dark-first, because that is the house style: the retail POS prototype Chris
   approved runs a deep-navy/electric-blue system, and PLAN.md's rule is
   ui-pattern-preservation — reuse the approved language, do not invent a
   second one. The tokens below are that palette, not a new theme.

   The brief was "premium, not AI-like". Concretely that meant removing:
     · oversized cards with 40px padding and one number floating in the middle
     · centred prose where a table belongs
     · gradient headers, decorative emoji, pill-shaped everything
   and replacing them with what an operations console actually is: DENSE,
   scannable, monospaced where identifiers live, tabular where numbers line up,
   and quiet until something needs attention.

   Rule of thumb used throughout: colour is reserved for STATE. Chrome is
   greyscale. If everything is highlighted, nothing is.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── tokens ───────────────────────────────────────────────────────────── */
:root {
  /* Surfaces, darkest → lightest. Four steps is enough; more reads as noise. */
  --bg:            #08090b;
  --bg-grid:       rgba(255,255,255,.022);
  --rail:          #0b0d11;
  --panel:         #11161d;
  --panel-2:       #161c24;
  --panel-3:       #1d242d;
  --input:         #0d1117;

  --line:          rgba(255,255,255,.075);
  --line-2:        rgba(255,255,255,.045);
  --line-strong:   rgba(255,255,255,.145);

  --text:          #f2f6fa;
  --soft:          #c6d1dc;
  --muted:         #8c9bab;
  --faint:         #64717f;

  --accent:        #2563eb;
  --accent-hi:     #3b82f6;
  --accent-press:  #1d4ed8;
  --accent-ink:    #ffffff;
  --accent-soft:   rgba(37,99,235,.15);
  --accent-line:   rgba(37,99,235,.42);

  --ok:            #16a34a;
  --ok-soft:       rgba(22,163,74,.14);
  --ok-line:       rgba(22,163,74,.40);
  --warn:          #d97706;
  --warn-soft:     rgba(217,119,6,.14);
  --warn-line:     rgba(217,119,6,.40);
  --bad:           #dc2626;
  --bad-soft:      rgba(220,38,38,.14);
  --bad-line:      rgba(220,38,38,.40);
  --info:          #7c3aed;
  --info-soft:     rgba(124,58,237,.14);
  --info-line:     rgba(124,58,237,.40);

  --r-xs: 5px;  --r-sm: 7px;  --r-md: 10px;  --r-lg: 13px;  --r-xl: 18px;
  --sh-sm: 0 1px 2px rgba(0,0,0,.45);
  --sh:    0 1px 2px rgba(0,0,0,.35), 0 8px 22px rgba(0,0,0,.26);
  --sh-lg: 0 12px 44px rgba(0,0,0,.5);

  --rail-w: 232px;
  --ease: cubic-bezier(.4,0,.2,1);
  --fast: 130ms var(--ease);

  --ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, 'Cascadia Mono', monospace;
}

/* Light theme. Same structure, inverted ramp — not a different design. */
:root[data-theme="light"] {
  --bg:            #f4f6f9;
  --bg-grid:       rgba(15,23,42,.026);
  --rail:          #ffffff;
  --panel:         #ffffff;
  --panel-2:       #f8fafc;
  --panel-3:       #eef2f7;
  --input:         #ffffff;

  --line:          rgba(15,23,42,.10);
  --line-2:        rgba(15,23,42,.06);
  --line-strong:   rgba(15,23,42,.18);

  --text:          #0d1520;
  --soft:          #33465c;
  --muted:         #5b6c80;
  --faint:         #8494a6;

  --accent-soft:   rgba(37,99,235,.09);
  --ok-soft:       rgba(22,163,74,.10);
  --warn-soft:     rgba(217,119,6,.11);
  --bad-soft:      rgba(220,38,38,.09);
  --info-soft:     rgba(124,58,237,.09);

  --sh-sm: 0 1px 2px rgba(15,23,42,.06);
  --sh:    0 1px 2px rgba(15,23,42,.05), 0 8px 22px rgba(15,23,42,.07);
  --sh-lg: 0 12px 44px rgba(15,23,42,.14);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* an author display beats the UA's hidden rule; this restores hidden */
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* A barely-there grid. Reads as "instrument", and is invisible unless looked for. */
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 56px 56px;
}

/* Numbers must line up. This is the single highest-value line in the file for
   a console whose whole job is columns of durations, counts and money. */
table, .num, .kpi-value, .mono, time, .dur { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .92em; letter-spacing: -.01em; }

::selection { background: var(--accent); color: #fff; }

:where(a) { color: var(--accent-hi); text-decoration: none; }
:where(a):hover { text-decoration: underline; text-underline-offset: 2px; }

:where(button, [tabindex]):focus-visible,
:where(a, input, select, textarea):focus-visible {
  outline: 2px solid var(--accent-hi);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* ── shell ────────────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: var(--rail-w) 1fr; min-height: 100dvh; }

.sidebar {
  background: var(--rail);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100dvh;
  z-index: 40;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 15px 14px 13px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--accent-hi), var(--accent-press));
  color: #fff; font-weight: 700; font-size: 12px; letter-spacing: .02em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.22), var(--sh-sm);
}
.brand-name { font-weight: 640; font-size: 13.5px; letter-spacing: -.01em; line-height: 1.15; }
.brand-sub  { font-size: 10.5px; color: var(--faint); line-height: 1.3; }

.nav { padding: 4px 8px 8px; overflow-y: auto; flex: 1; }
.nav-group {
  font-size: 10px; font-weight: 620; letter-spacing: .10em; text-transform: uppercase;
  color: var(--faint); padding: 14px 8px 5px;
}
.nav button {
  width: 100%; display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; margin-bottom: 1px;
  background: none; border: 0; border-radius: var(--r-sm);
  color: var(--muted); font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; text-align: left;
  transition: background var(--fast), color var(--fast);
}
.nav button svg { flex: none; opacity: .85; }
.nav button:hover { background: var(--panel-2); color: var(--soft); }
.nav button[aria-current="page"] {
  background: var(--accent-soft); color: var(--text); font-weight: 560;
  box-shadow: inset 0 0 0 1px var(--accent-line);
}
.nav button[aria-current="page"] svg { opacity: 1; color: var(--accent-hi); }
.nav .count {
  margin-left: auto; font-size: 10.5px; font-weight: 620;
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--panel-3); color: var(--muted);
}
.nav .count.alert { background: var(--bad); color: #fff; }

.sidebar-foot { padding: 9px; border-top: 1px solid var(--line-2); display: grid; gap: 6px; }

/* ── topbar ───────────────────────────────────────────────────────────── */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px; height: 52px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
}
.topbar h1 { font-size: 14.5px; font-weight: 620; margin: 0; letter-spacing: -.012em; }
.topbar-spacer { flex: 1; }
.crumb { color: var(--faint); font-size: 12.5px; }

/* Global search. Present because every real console has one, and its absence
   is one of the things that makes a UI feel like a mockup. */
.omni {
  display: flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 9px; min-width: 210px;
  background: var(--input); border: 1px solid var(--line);
  border-radius: var(--r-sm); color: var(--faint);
  font-size: 12.5px; cursor: text; transition: border-color var(--fast);
}
.omni:hover { border-color: var(--line-strong); }
.omni kbd {
  margin-left: auto; font-family: var(--ui); font-size: 10px; font-weight: 600;
  padding: 2px 5px; border-radius: 4px;
  background: var(--panel-3); border: 1px solid var(--line); color: var(--muted);
}

.view { padding: 16px; max-width: 1500px; width: 100%; }

/* ── buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 31px; padding: 0 11px;
  background: var(--panel-2); color: var(--soft);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font: inherit; font-size: 12.5px; font-weight: 530; cursor: pointer;
  white-space: nowrap;
  transition: background var(--fast), border-color var(--fast), color var(--fast), transform var(--fast);
}
.btn:hover { background: var(--panel-3); border-color: var(--line-strong); color: var(--text); }
.btn:active { transform: translateY(.5px); }
.btn.sm { height: 27px; padding: 0 8px; font-size: 12px; }
.btn.icon { width: 31px; padding: 0; }
.btn.icon.sm { width: 27px; }
.btn.primary {
  background: var(--accent); border-color: transparent; color: var(--accent-ink); font-weight: 570;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.16), var(--sh-sm);
}
.btn.primary:hover { background: var(--accent-hi); color: #fff; }
.btn.danger { color: #f8b4b4; }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad-line); color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.menu-btn { display: none; }   /* .btn.menu-btn — specificity must beat .btn */

.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px; gap: 2px; }
.seg button {
  height: 25px; padding: 0 10px; border: 0; border-radius: var(--r-xs);
  background: none; color: var(--muted); font: inherit; font-size: 12px; font-weight: 530; cursor: pointer;
  transition: background var(--fast), color var(--fast);
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--panel-3); color: var(--text); box-shadow: var(--sh-sm); }

/* ── cards ────────────────────────────────────────────────────────────── */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: var(--sh-sm);
}
.card-head {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 14px; border-bottom: 1px solid var(--line-2);
  background: linear-gradient(180deg, rgba(255,255,255,.018), transparent);
}
.card-head h2 { font-size: 12.5px; font-weight: 620; margin: 0; letter-spacing: -.005em; }
.card-head .sub { font-size: 11.5px; color: var(--faint); }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-body { padding: 14px; }
.card-body.flush { padding: 0; }
.grid { display: grid; gap: 12px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0,1fr)); }

/* ── KPIs — compact by design ─────────────────────────────────────────── */
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 11px 13px; position: relative; overflow: hidden;
}
.kpi-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: .085em; text-transform: uppercase;
  color: var(--faint); margin-bottom: 5px;
}
.kpi-value { font-size: 25px; font-weight: 640; letter-spacing: -.03em; line-height: 1.08; }
.kpi-note { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.kpi .spark { position: absolute; right: 10px; bottom: 9px; opacity: .5; }

/* ── pills ────────────────────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 560; white-space: nowrap;
  background: var(--panel-3); color: var(--muted);
  border: 1px solid var(--line);
}
.pill .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: none; }
.pill.ok   { background: var(--ok-soft);   color: #6ee7a0; border-color: var(--ok-line); }
.pill.warn { background: var(--warn-soft); color: #fbbf5a; border-color: var(--warn-line); }
.pill.bad  { background: var(--bad-soft);  color: #fca5a5; border-color: var(--bad-line); }
.pill.info { background: var(--info-soft); color: #c4b5fd; border-color: var(--info-line); }
.pill.accent { background: var(--accent-soft); color: #93b4fd; border-color: var(--accent-line); }
:root[data-theme="light"] .pill.ok   { color: #15803d; }
:root[data-theme="light"] .pill.warn { color: #b45309; }
:root[data-theme="light"] .pill.bad  { color: #b91c1c; }
:root[data-theme="light"] .pill.info { color: #6d28d9; }
:root[data-theme="light"] .pill.accent { color: #1d4ed8; }

/* A live indicator that actually pulses — used only for in-progress calls. */
.live { position: relative; }
.live::before {
  content: ''; position: absolute; inset: -3px; border-radius: 50%;
  background: currentColor; opacity: .35; animation: pulse 1.8s var(--ease) infinite;
}
@keyframes pulse { 0% { transform: scale(.7); opacity: .5; } 70%,100% { transform: scale(1.7); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .live::before { animation: none; } }

/* ── tables — the workhorse ───────────────────────────────────────────── */
.scroll-x { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
thead th {
  text-align: left; font-size: 10px; font-weight: 620;
  letter-spacing: .085em; text-transform: uppercase; color: var(--faint);
  padding: 8px 14px; border-bottom: 1px solid var(--line);
  background: var(--panel-2); position: sticky; top: 0; z-index: 1;
  white-space: nowrap;
}
tbody td { padding: 9px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--fast); }
tbody tr:hover { background: var(--panel-2); }
td .t1 { font-weight: 545; color: var(--text); }
td .t2 { font-size: 11.5px; color: var(--faint); }
td.right, th.right { text-align: right; }
.dur { font-family: var(--mono); font-size: 12px; color: var(--soft); }

/* Direction glyph on a call row — inbound/outbound/missed at a glance. */
.dir { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 6px; flex: none; }
.dir.in   { background: var(--ok-soft);  color: #6ee7a0; }
.dir.out  { background: var(--accent-soft); color: #93b4fd; }
.dir.miss { background: var(--bad-soft); color: #fca5a5; }

.avatar {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--panel-3); color: var(--soft);
  font-size: 10.5px; font-weight: 640; letter-spacing: .01em;
  border: 1px solid var(--line);
}
.who { display: flex; align-items: center; gap: 9px; min-width: 0; }
.who > div { min-width: 0; }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── notes ────────────────────────────────────────────────────────────── */
.note {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 10px 12px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--panel-2);
  font-size: 12.5px; color: var(--soft); margin-bottom: 10px;
}
.note svg { flex: none; margin-top: 1px; color: var(--muted); }
.note.warn { background: var(--warn-soft); border-color: var(--warn-line); }
.note.warn svg { color: #fbbf5a; }
.note.bad  { background: var(--bad-soft);  border-color: var(--bad-line); }
.note.bad svg { color: #fca5a5; }
.note.ok   { background: var(--ok-soft);   border-color: var(--ok-line); }
.note.ok svg { color: #6ee7a0; }
.note strong { color: var(--text); font-weight: 620; }
.note code { font-family: var(--mono); font-size: 11.5px; background: rgba(255,255,255,.06); padding: 1px 4px; border-radius: 4px; }

/* ── empty states ─────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 40px 24px; color: var(--muted); }
.empty svg { color: var(--line-strong); margin-bottom: 10px; }
.empty h3 { font-size: 13px; font-weight: 600; margin: 0 0 4px; color: var(--soft); }
.empty p { font-size: 12.5px; margin: 0 auto; max-width: 46ch; line-height: 1.6; color: var(--faint); }

/* ── definition rows ──────────────────────────────────────────────────── */
.rows { display: grid; }
.row {
  display: grid; grid-template-columns: 190px 1fr; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--line-2); align-items: baseline;
}
.row:last-child { border-bottom: 0; }
.row dt { font-size: 12px; color: var(--muted); }
.row dd { margin: 0; font-size: 12.5px; color: var(--text); min-width: 0; }
.row dd .hint { display: block; font-size: 11.5px; color: var(--faint); margin-top: 2px; }

/* ── two-pane inbox ───────────────────────────────────────────────────── */
.split {
  display: grid; grid-template-columns: 300px 1fr;
  height: calc(100dvh - 52px - 32px);
  min-height: 440px;
  border: 1px solid var(--line); border-radius: var(--r-lg);
  overflow: hidden; background: var(--panel);
}
/* ⚠️ `min-height: 0` on both panes is load-bearing. A grid item defaults to `min-height: auto`,
   which means "as tall as my content" — so a thread of forty bubbles grew the pane to 1252px
   inside a 733px box, the bubble list never scrolled, and the composer was clipped off the
   bottom. Measured, not guessed. The fixed height on `.split` is only honoured once its children
   are allowed to be shorter than what they hold. */
.split-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); }
.split-tools { display: flex; gap: 6px; padding: 9px; border-bottom: 1px solid var(--line-2); align-items: center; }
.split-scroll { overflow-y: auto; flex: 1; min-height: 0; }
.split-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel-2); }

.conv {
  display: flex; gap: 9px; padding: 10px 11px; cursor: pointer;
  border-bottom: 1px solid var(--line-2); transition: background var(--fast);
}
.conv:hover { background: var(--panel-2); }
.conv[aria-selected="true"] { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.conv-top { display: flex; align-items: baseline; gap: 6px; }
.conv-name { font-weight: 570; font-size: 12.5px; }
.conv-time { margin-left: auto; font-size: 10.5px; color: var(--faint); white-space: nowrap; }
.conv-snip { font-size: 11.5px; color: var(--faint); }

.input-row { display: flex; gap: 7px; padding: 10px; border-top: 1px solid var(--line); background: var(--panel); align-items: flex-end; }
.field {
  width: 100%; background: var(--input); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 7px 10px; font: inherit; font-size: 12.5px; resize: none;
  transition: border-color var(--fast), box-shadow var(--fast);
}
.field:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field::placeholder { color: var(--faint); }

.bubbles { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 62%; padding: 8px 11px; border-radius: 13px; font-size: 12.5px; line-height: 1.5; }
.bubble.in  { align-self: flex-start; background: var(--panel-3); border-bottom-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bubble-meta { font-size: 10px; color: var(--faint); margin-top: 3px; }
.bubble.out .bubble-meta { color: rgba(255,255,255,.72); }
/* A refused attempt stays in the thread — a refusal is a fact, not an absence — but it is an
   OPERATOR outcome, not something the customer ever saw, so it must not be drawn like a message.
   It used to be a full-width red bubble with the body struck through and two paragraphs of
   reason; two of those made the thread unreadable and read as "we sent something and it was
   blocked". Now one quiet line at its place in time, with the reason a click away. */
.refused { align-self: flex-end; max-width: 62%; font-size: 11px; color: var(--muted); }
.refused summary {
  cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px; border-radius: 999px; border: 1px dashed var(--line-strong); color: var(--muted);
}
.refused summary::-webkit-details-marker { display: none; }
.refused summary:hover { color: var(--text); border-color: var(--bad-line); }
.refused summary .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--bad); flex: none; }
.refused[open] summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.refused-body {
  margin-top: -1px; padding: 8px 10px; border: 1px dashed var(--line-strong); border-radius: 10px; border-top-left-radius: 0;
  background: var(--panel); color: var(--soft); font-size: 11.5px; line-height: 1.5;
}
.refused-body .draft { color: var(--faint); text-decoration: line-through; margin-bottom: 4px; }

/* ── dialer ───────────────────────────────────────────────────────────── */
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; max-width: 232px; }
.key {
  aspect-ratio: 1.45; border-radius: var(--r-md);
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); font: inherit; font-size: 17px; font-weight: 560;
  cursor: pointer; display: grid; place-items: center; line-height: 1;
  transition: background var(--fast), transform var(--fast), border-color var(--fast);
}
.key:hover { background: var(--panel-3); border-color: var(--line-strong); }
.key:active { transform: scale(.96); }
.key small { display: block; font-size: 8.5px; letter-spacing: .14em; color: var(--faint); font-weight: 600; margin-top: 2px; }
.dial-display {
  font-family: var(--mono); font-size: 20px; letter-spacing: .01em;
  padding: 10px 12px; min-height: 44px; margin-bottom: 10px;
  background: var(--input); border: 1px solid var(--line); border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.dial-display .ph { color: var(--faint); font-family: var(--ui); font-size: 13px; }

/* ── waveform (recordings) ────────────────────────────────────────────── */
.wave { display: flex; align-items: center; gap: 1.5px; height: 22px; }
.wave i { width: 2px; border-radius: 1px; background: var(--line-strong); display: block; }
.wave i.on { background: var(--accent-hi); }

/* ── misc ─────────────────────────────────────────────────────────────── */
.gate {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 550;
  background: var(--warn-soft); color: #fbbf5a; border: 1px solid var(--warn-line);
}
:root[data-theme="light"] .gate { color: #b45309; }

.bar { height: 5px; border-radius: 3px; background: var(--panel-3); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

.stack { display: flex; flex-direction: column; gap: 3px; }
.inline { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.tiny { font-size: 11.5px; }
hr.sep { border: 0; border-top: 1px solid var(--line-2); margin: 12px 0; }

/* ── responsive ───────────────────────────────────────────────────────── */
@media (max-width: 1080px) { .grid.c4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 262px;
    transform: translateX(-100%); transition: transform 220ms var(--ease);
    box-shadow: var(--sh-lg);
  }
  .sidebar.open { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr; gap: 2px; }
  .omni { display: none; }
  .split { grid-template-columns: 1fr; height: auto; }
  .split-list { border-right: 0; border-bottom: 1px solid var(--line); max-height: 300px; }
  .bubble { max-width: 82%; }
  .view { padding: 12px; }
}

.scrim {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  opacity: 0; pointer-events: none; transition: opacity 200ms var(--ease); z-index: 35;
  backdrop-filter: blur(2px);
}
.scrim.on { opacity: 1; pointer-events: auto; }

/* Scrollbars — thin, so they do not shout inside dense panes. */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

@media print { .sidebar, .topbar { display: none; } .card { break-inside: avoid; } }

/* ═══════════════════════════════════════════════════════════════════════════
   Live data — the four states a fetched panel can be in.
   ───────────────────────────────────────────────────────────────────────────
   Added when the console stopped rendering fixtures. Same palette, same
   density, same rule: colour is reserved for STATE.

   The organising idea is that this product's claim is "nothing is silently
   dropped", so the UI answers questions rather than displaying metrics. Hence
   .state-strip: a question, a short answer, and the evidence under it — never
   a big number floating in a card, which says how many without saying whether
   anything works.
   ═══════════════════════════════════════════════════════════════════════════ */

.state-strip {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px;
}
.state {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 13px 15px 14px; min-width: 0;
}
.state-q {
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--faint); display: flex; align-items: center; gap: 7px;
}
.state-q::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; flex: none;
  background: var(--muted); box-shadow: 0 0 0 3px rgba(255,255,255,.04);
}
.state-a {
  font-size: 21px; font-weight: 640; letter-spacing: -.02em; margin: 7px 0 5px;
  font-variant-numeric: tabular-nums;
}
.state-why { margin: 0; font-size: 11.5px; line-height: 1.55; color: var(--muted); }
.state-why code { font-size: 10.5px; }

.state.good .state-q::before { background: var(--ok);   box-shadow: 0 0 0 3px var(--ok-soft); }
.state.bad  .state-q::before { background: var(--bad);  box-shadow: 0 0 0 3px var(--bad-soft); }
.state.watch .state-q::before{ background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.state.idle .state-q::before { background: var(--faint); }
.state.unknown .state-q::before { background: var(--info); box-shadow: 0 0 0 3px var(--info-soft); }
.state.bad  { border-color: var(--bad-line); background: linear-gradient(0deg, var(--bad-soft), var(--bad-soft)), var(--panel); }
.state.bad .state-a { color: #fca5a5; }
.state.good .state-a { color: var(--text); }
.state.unknown .state-a { color: var(--muted); }

/* Loading. Shapes rather than a spinner, so the panel does not jump when data lands. */
.skel { padding: 14px; display: grid; gap: 10px; }
.skel-row { display: grid; grid-template-columns: 34% 22% 1fr; gap: 10px; animation: skel 1.15s var(--ease) infinite; }
.skel-row span { height: 11px; border-radius: 4px; background: var(--panel-3); display: block; }
.skel-row span:nth-child(2) { opacity: .72; }
.skel-row span:nth-child(3) { opacity: .5; }
@keyframes skel { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .skel-row { animation: none; opacity: .8; } }

/* A failure, said out loud. Never a blank panel, never "something went wrong". */
.problem {
  display: flex; gap: 11px; align-items: flex-start; margin: 12px 14px;
  padding: 13px 14px; border-radius: 9px;
  border: 1px solid var(--bad-line);
  background: linear-gradient(0deg, var(--bad-soft), var(--bad-soft)), var(--panel);
}
.problem svg { color: #fca5a5; flex: none; margin-top: 1px; }
.problem .t1 { color: #fecaca; }
.card-body > .problem:only-child { margin: 0; }

/* Nav marker for a section still on fixtures. Small, permanent, unmissable once you know it. */
.tag-fx {
  margin-left: auto; font-size: 9.5px; font-weight: 650; letter-spacing: .06em;
  text-transform: uppercase; color: var(--warn);
  background: var(--warn-soft); border: 1px solid var(--warn-line);
  padding: 1px 5px; border-radius: 5px; line-height: 1.5;
}

@media (max-width: 900px) { .state-strip { grid-template-columns: 1fr; } }

/* ── signed out: the auth screen (spec §7) ─────────────────────────────────── */
.auth {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 26px 26px 22px; box-shadow: var(--sh);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.auth h1 { font-size: 17px; font-weight: 640; letter-spacing: -.012em; margin: 0 0 4px; }
.auth p.lead { color: var(--muted); font-size: 12.5px; margin: 0 0 16px; }
.auth label { display: block; font-size: 11.5px; font-weight: 560; color: var(--soft); margin: 12px 0 5px; }
.auth .field { height: 36px; padding: 0 11px; }
.auth .btn.primary { width: 100%; height: 36px; margin-top: 16px; }
.auth .aux { display: flex; justify-content: space-between; margin-top: 12px; font-size: 12px; }
.auth .aux a { color: var(--accent-hi); cursor: pointer; }
.auth .say { min-height: 18px; margin-top: 10px; font-size: 12px; }
.auth .say.bad { color: var(--bad); }
.auth .say.ok { color: var(--ok); }

/* ── the signed-in person, in the sidebar foot ───────────────────────────── */
.who-btn {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 8px;
  background: none; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  color: var(--text); font: inherit; text-align: left; cursor: pointer;
  transition: background var(--fast);
}
.who-btn:hover { background: var(--panel-2); }
.who-btn .t1 { font-size: 12.5px; font-weight: 560; }
.who-btn .t2 { font-size: 10.5px; color: var(--faint); }

/* ── tab mode: the console minus its side menu (D21, embed §1) ───────────── */
.tab-mode .app { grid-template-columns: 1fr; }
.tab-mode .sidebar, .tab-mode .menu-btn, .tab-mode .omni, .tab-mode .gate { display: none; }
.tab-mode .tab-settings { display: inline-flex; }
.tab-mode .topbar { height: 44px; }
.tab-settings { margin-left: 8px; }

/* ── People: the permission matrix ───────────────────────────────────────── */
.matrix { display: grid; gap: 6px; }
.matrix-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 7px 10px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--panel-2); }
.matrix-row .t2 { font-size: 11px; color: var(--faint); }
.tri { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.tri button { background: none; border: 0; padding: 4px 9px; font: inherit; font-size: 11px; color: var(--muted); cursor: pointer; }
.tri button[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); font-weight: 560; }
.tri button.deny[aria-pressed="true"] { background: var(--bad-soft); color: var(--bad); }
.tri button:disabled { opacity: .45; cursor: not-allowed; }
.person { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: start; padding: 12px 14px; border-bottom: 1px solid var(--line-2); }
.person:last-child { border-bottom: 0; }
.person .badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.person details { margin-top: 8px; }
.person summary { cursor: pointer; font-size: 12px; color: var(--accent-hi); list-style: none; }
.person summary::-webkit-details-marker { display: none; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.form-grid label { display: block; font-size: 11.5px; font-weight: 560; color: var(--soft); margin-bottom: 4px; }
select.field { appearance: auto; height: 34px; }
