/* ============================================================================
   components.css — every part a page is built out of.
   Brief 7.

   Panels, key numbers, buttons, tables, chips, badges, forms, switches,
   skeletons, empty states, tabs, charts, the call panel's chat bubbles.

   ONE gold action per page: .btn-primary. If a page has two, one of them is
   wrong and should be .btn-quiet.
   ========================================================================= */

/* =========================================================== PANEL ====== */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-panel);
  overflow: hidden;
}
.panel + .panel { margin-top: var(--s4); }

.panel-head {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.panel-head-text { flex: 1; min-width: 180px; }
.panel-title { font-size: var(--t-h2); font-family: var(--font-serif); line-height: 1.2; }
.panel-sub { font-size: var(--t-small); color: var(--text-2); margin-top: 2px; }
.panel-tools { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.panel-body { padding: var(--s5); }
.panel-body.tight { padding: var(--s4); }

.grid { display: grid; gap: var(--s4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
@media (max-width: 1240px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1020px) {
  .grid-2, .grid-3, .grid-2-1 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 620px) { .grid-4 { grid-template-columns: minmax(0, 1fr); } }

/* ====================================================== KEY NUMBERS ===== */
/* Layout rule 4: at most four, and rule 9: every one clickable through to
   what it is made of. The one that matters most gets .lead — which is the only
   place on the page the gold number appears. */

.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4); }
@media (max-width: 1240px) { .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px)  { .figures { grid-template-columns: minmax(0, 1fr); } }

.figure {
  display: block; width: 100%; text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s4) var(--s4) var(--s4);
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.figure[data-href]:hover, button.figure:hover {
  border-color: var(--line-strong);
  background: var(--panel-2);
}
.figure-label {
  font-size: var(--t-label);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-2);
  display: flex; align-items: center; gap: var(--s2);
}
.figure-value {
  font-family: var(--font-serif);
  font-size: var(--t-display);
  line-height: 1.05;
  letter-spacing: -0.015em;
  margin-top: var(--s3);
  font-variant-numeric: tabular-nums;
}
.figure.lead .figure-value { color: var(--gold); }
.figure-note { font-size: var(--t-small); color: var(--text-3); margin-top: var(--s2); }
.figure-note.up   { color: var(--emerald); }
.figure-note.down { color: var(--rose); }

/* ========================================================= BUTTONS ====== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  padding: 8px var(--s4);
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--panel-3);
  color: var(--text);
  font-size: var(--t-small);
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease),
              color var(--fast) var(--ease), opacity var(--fast) var(--ease);
}
.btn:hover { background: var(--panel-2); border-color: var(--text-3); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:disabled:hover { background: var(--panel-3); border-color: var(--line-strong); }
.btn svg { width: 14px; height: 14px; }

/* THE action. One per page. */
.btn-primary {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--text-on-gold);
}
.btn-primary:hover { background: var(--gold-bright); border-color: var(--gold-bright); }

.btn-quiet {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--text-2);
}
.btn-quiet:hover { background: var(--panel-2); color: var(--text); }

.btn-bare {
  background: none; border-color: transparent;
  color: var(--text-2);
  padding: 6px var(--s2);
}
.btn-bare:hover { background: var(--panel-2); color: var(--text); border-color: transparent; }

.btn-danger { border-color: var(--rose-dim); color: var(--rose); background: transparent; }
.btn-danger:hover { background: var(--rose-dim); border-color: var(--rose); color: var(--rose); }

.btn-sm { padding: 5px var(--s3); font-size: var(--t-small); }
.btn-sm svg { width: 13px; height: 13px; }
.btn-icon { padding: 7px; border-radius: var(--r-sm); }
.btn-icon svg { width: 15px; height: 15px; }
.btn-block { width: 100%; }

/* A button that is working. The dot pulses; nothing bounces. */
.btn.busy { pointer-events: none; opacity: 0.7; }
.btn.busy::after {
  content: ""; width: 12px; height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 620ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================= COLLAPSIBLE SETTINGS ==== */
/*
 * The seven jobs on the Settings page. Brief 11, Part C.
 *
 * Built on <details>/<summary> rather than on a button and a class, and that
 * is the whole reason this is only CSS: the browser handles the open state,
 * the keyboard (Enter and Space), the focus ring, and screen-reader
 * announcement of "expanded"/"collapsed". A div with an onclick gets none of
 * those right without work, and gets them silently wrong.
 *
 * Both themes come out of the tokens, so there is nothing per-theme here.
 */
.setting-group {
  max-width: 760px;
  margin-bottom: var(--s3);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.setting-group[open] { border-color: var(--line-strong); }
/* One section holds a TABLE rather than a column of fields — what a call
   can have ended as, with five switches a row. 760px is the right width
   for reading a label and one box; it cuts a table off at the fourth
   column. Wider here, and the table scrolls sideways on a phone the way
   every other table in the dashboard does. */
.setting-group.wide { max-width: 1100px; }

.setting-group-head {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s4);
  cursor: pointer;
  list-style: none;                 /* no triangle; the chevron below is ours */
  user-select: none;
}
.setting-group-head::-webkit-details-marker { display: none; }
.setting-group-head:hover { background: var(--panel-2); }
.setting-group-head:focus-visible {
  outline: 2px solid var(--gold); outline-offset: -2px;
}

.setting-group-title {
  display: block;
  font-size: var(--t-body);
  font-weight: 500;
  color: var(--text);
}
.setting-group-job {
  display: block;
  margin-top: 2px;
  font-size: var(--t-small);
  color: var(--text-2);
}
.setting-group-count {
  flex-shrink: 0;
  font-size: var(--t-micro);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.setting-group-head > svg {
  width: 14px; height: 14px; flex-shrink: 0;
  color: var(--text-3);
  transition: transform 140ms ease;
}
.setting-group[open] > .setting-group-head > svg { transform: rotate(180deg); }

.setting-group-body {
  padding: 0 var(--s4) var(--s4);
  border-top: 1px solid var(--line);
  padding-top: var(--s4);
}

/* The steps within one job. A label, not a panel: a second box inside a box
   is a border nobody needs. */
.setting-section-label {
  margin: var(--s5) 0 var(--s3);
  font-size: var(--t-micro);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}
.setting-section-label:first-child { margin-top: 0; }

/* ===================================================== TOP BAR PARTS ==== */

.tb-select {
  display: inline-flex; align-items: center; gap: var(--s2);
  padding: 6px var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--panel);
  color: var(--text-2);
  font-size: var(--t-small);
  max-width: 220px;
}
.tb-select:hover { color: var(--text); border-color: var(--line-strong); }
.tb-select svg { width: 13px; height: 13px; flex-shrink: 0; opacity: 0.7; }
.tb-select .truncate { max-width: 150px; }

/* Which timezone every date on this dashboard is in. Brief 11, Part G2.
   Deliberately NOT a .tb-select: it is a statement, not a control, and
   looking like a dropdown would invite a click that does nothing. No border,
   no hover, muted — the same weight as the version number in the sidebar
   foot. Both themes get it from the tokens, so there is nothing per-theme
   here. */
.tb-zone {
  display: inline-flex; align-items: center; gap: var(--s2);
  padding: 6px var(--s2);
  color: var(--text-3, var(--text-2));
  font-size: var(--t-small);
  white-space: nowrap;
  cursor: default;
}
.tb-zone svg { width: 13px; height: 13px; flex-shrink: 0; opacity: 0.6; }

.tb-kbd {
  display: inline-flex; align-items: center; gap: var(--s2);
  padding: 6px var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--panel);
  color: var(--text-3);
  font-size: var(--t-small);
}
.tb-kbd:hover { color: var(--text); border-color: var(--line-strong); }
.tb-kbd svg { width: 13px; height: 13px; }

kbd {
  font-family: var(--font-sans);
  font-size: var(--t-micro);
  padding: 1px 5px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--panel-3);
  color: var(--text-2);
}

.avatar {
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--panel-3);
  color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--t-small); font-weight: 500;
}

/* A dropdown hung off a top-bar control. */
.menu-wrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 232px; max-width: 320px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  box-shadow: var(--shadow-pop);
  padding: var(--s2);
  z-index: 70;
  display: none;
  max-height: 60vh; overflow-y: auto;
}
.menu.open { display: block; animation: modal-in var(--fast) var(--ease); }
.menu-label {
  font-size: var(--t-micro); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-3); padding: var(--s2) var(--s3) var(--s1);
}
.menu-item {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; padding: 7px var(--s3);
  border-radius: var(--r-sm);
  font-size: var(--t-small);
  color: var(--text-2); text-align: left;
}
.menu-item:hover { background: var(--panel-2); color: var(--text); }
.menu-item.on { color: var(--text); }
.menu-item.on::after { content: "✓"; margin-left: auto; color: var(--gold); }
.menu-sep { height: 1px; background: var(--line); margin: var(--s2) var(--s3); }
.menu-head { padding: var(--s3); border-bottom: 1px solid var(--line); margin-bottom: var(--s2); }

/* =========================================================== TABLE ====== */
/* Layout rule 4: ONE table per page, with search, filter chips, pagination. */

.table-tools {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s5);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.search {
  display: flex; align-items: center; gap: var(--s2);
  padding: 6px var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--panel-3);
  min-width: 220px; flex: 1; max-width: 340px;
}
.search svg { width: 14px; height: 14px; color: var(--text-3); flex-shrink: 0; }
.search input {
  flex: 1; min-width: 0;
  border: none; background: none; outline: none;
  font-size: var(--t-small); color: var(--text);
}
.search input::placeholder { color: var(--text-3); }

.chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text-2);
  font-size: var(--t-small);
  transition: all var(--fast) var(--ease);
}
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip.on { background: var(--panel-3); border-color: var(--text-3); color: var(--text); }
.chip-count { font-size: var(--t-micro); color: var(--text-3); font-variant-numeric: tabular-nums; }
.chip.on .chip-count { color: var(--text-2); }

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg-sunken);
  font-size: var(--t-label);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  text-align: left;
  padding: var(--s3) var(--s4);
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--text-2); }
thead th .arrow { opacity: 0.5; margin-left: 3px; }
thead th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }

tbody td {
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line);
  font-size: var(--t-small);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }

/* Layout rule 5: the row is the way in. */
tbody tr.clickable { cursor: pointer; transition: background var(--fast) var(--ease); }
tbody tr.clickable:hover { background: var(--panel-2); }
tbody tr.on { background: var(--panel-2); }

.cell-main { font-weight: 500; }
.cell-sub { font-size: var(--t-micro); color: var(--text-3); margin-top: 1px; }
.cell-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* Rule 9: a number you can click through to what it is made of. */
.drill {
  color: inherit;
  border-bottom: 1px dotted var(--line-strong);
  cursor: pointer;
}
.drill:hover { color: var(--gold); border-bottom-color: var(--gold-line); }

.pager {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s3) var(--s5);
  border-top: 1px solid var(--line);
  font-size: var(--t-small);
  color: var(--text-3);
  flex-wrap: wrap;
}
.pager-btns { display: flex; gap: var(--s2); }

/* ========================================================== BADGES ====== */
/* Muted, and never more than one per row. */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px var(--s2);
  border-radius: var(--r-pill);
  font-size: var(--t-micro);
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge-emerald { background: var(--emerald-dim); color: var(--emerald); border-color: var(--emerald-dim); }
.badge-amber   { background: var(--amber-dim);   color: var(--amber);   border-color: var(--amber-dim); }
.badge-rose    { background: var(--rose-dim);    color: var(--rose);    border-color: var(--rose-dim); }
.badge-slate   { background: var(--slate-dim);   color: var(--slate);   border-color: var(--slate-dim); }
.badge-violet  { background: var(--violet-dim);  color: var(--violet);  border-color: var(--violet-dim); }
.badge-gold    { background: var(--gold-dim);    color: var(--gold);    border-color: var(--gold-line); }
.badge-outline { background: transparent; color: var(--text-2); border-color: var(--line-strong); }

.dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; background: var(--slate); }
.dot-emerald { background: var(--emerald); }
.dot-amber   { background: var(--amber); }
.dot-rose    { background: var(--rose); }
.dot-gold    { background: var(--gold); }

/* A call happening right now. The only thing on the platform that pulses, so
   it means exactly one thing. */
.dot-live { background: var(--emerald); animation: live 2s var(--ease) infinite; }
@keyframes live {
  0%, 100% { box-shadow: 0 0 0 0 var(--emerald-dim); }
  50%      { box-shadow: 0 0 0 5px transparent; }
}

/* ====================================================== STATUS LINES ==== */
/* Used by the health strip and the capacity page. */

.stat-line {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--line);
}
.stat-line:last-child { border-bottom: none; }
.stat-line-label { font-size: var(--t-small); color: var(--text-2); flex: 1; min-width: 0; }
.stat-line-value { font-size: var(--t-small); font-weight: 500; font-variant-numeric: tabular-nums; }

.meter { height: 4px; border-radius: var(--r-pill); background: var(--panel-3); overflow: hidden; }
.meter-fill { height: 100%; border-radius: var(--r-pill); background: var(--slate); transition: width var(--slow) var(--ease); }
.meter-fill.ok    { background: var(--emerald); }
.meter-fill.warn  { background: var(--amber); }
.meter-fill.bad   { background: var(--rose); }

/* ======================================================== NOTICES ======= */

.notice {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: var(--s3) var(--s4);
  border: 1px solid var(--line);
  border-left: 2px solid var(--slate);
  border-radius: var(--r-sm);
  background: var(--panel-2);
  font-size: var(--t-small);
  color: var(--text-2);
  line-height: 1.55;
}
.notice svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 2px; }
.notice-title { color: var(--text); font-weight: 500; margin-bottom: 2px; }
.notice.warn { border-left-color: var(--amber); background: var(--amber-dim); }
.notice.warn svg { color: var(--amber); }
.notice.bad  { border-left-color: var(--rose); background: var(--rose-dim); }
.notice.bad svg { color: var(--rose); }
.notice.ok   { border-left-color: var(--emerald); background: var(--emerald-dim); }
.notice.ok svg { color: var(--emerald); }
.notice + .notice { margin-top: var(--s2); }

/* An AI draft nobody has checked. Dashed on purpose: it must never read as
   part of the page's own content. Brief 6, Part G15. */
.draft-panel {
  border: 1px dashed var(--amber);
  border-radius: var(--r);
  background: var(--amber-dim);
  padding: var(--s4);
}
.draft-stamp {
  font-size: var(--t-micro);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber);
  font-weight: 600;
  margin-bottom: var(--s3);
}

/* ==================================================== EMPTY STATES ====== */
/* Layout rule 7: an empty state teaches. */

.empty {
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding: var(--s7) var(--s5);
  gap: var(--s2);
}
.empty svg { width: 22px; height: 22px; color: var(--text-3); margin-bottom: var(--s2); }
.empty-title { font-family: var(--font-serif); font-size: 18px; }
.empty-text { font-size: var(--t-small); color: var(--text-2); max-width: 46ch; line-height: 1.6; }
.empty .btn { margin-top: var(--s3); }

/* ====================================================== SKELETONS ======= */
/* Layout rule 8: skeletons, not spinners. Nothing shows nothing. */

.sk {
  background: linear-gradient(90deg, var(--panel-2) 25%, var(--panel-3) 37%, var(--panel-2) 63%);
  background-size: 400% 100%;
  animation: sk 1.4s ease-in-out infinite;
  border-radius: 5px;
  height: 11px;
}
@keyframes sk {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
.sk-line { height: 11px; margin: 6px 0; }
.sk-w-30 { width: 30%; } .sk-w-50 { width: 50%; }
.sk-w-70 { width: 70%; } .sk-w-90 { width: 90%; }
.sk-figure { height: 38px; width: 60%; margin-top: var(--s3); }
.sk-row td { padding: var(--s3) var(--s4); }

/* =========================================================== FORMS ====== */

.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-top: var(--s4); }
.field-label { font-size: var(--t-small); font-weight: 500; color: var(--text-2); }
.field-hint { font-size: var(--t-micro); color: var(--text-3); line-height: 1.55; }
.field-err { font-size: var(--t-micro); color: var(--rose); }

.input, .select, .textarea {
  width: 100%;
  padding: 9px var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--panel-3);
  color: var(--text);
  font-size: var(--t-small);
  outline: none;
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--line-focus); background: var(--panel-2); }
.input:disabled, .select:disabled, .textarea:disabled { opacity: 0.55; cursor: default; }
.textarea { min-height: 88px; resize: vertical; line-height: 1.55; font-family: inherit; }
.textarea.code { font-family: var(--font-mono); font-size: var(--t-small); min-height: 180px; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa0a8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  padding-right: var(--s6);
}

.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
/* Two fields SIDE BY SIDE are not one field under another, and `.field + .field`
   was pushing the right-hand one down by a row gap — so every two-column row on
   every page had its second label and its second box sitting lower than the
   first. The grid already provides the gap between them. */
.field-row > .field + .field, .field-row-3 > .field + .field { margin-top: 0; }
.field-row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
@media (max-width: 620px) { .field-row, .field-row-3 { grid-template-columns: minmax(0, 1fr); } }

.input-wrap { position: relative; }
.input-wrap .input { padding-right: 38px; }
.input-eye {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); padding: 4px;
}
.input-eye:hover { color: var(--text); }
.input-eye svg { width: 15px; height: 15px; }

/* A switch. Used for every on/off in the platform — announce-AI, line on/off. */
.switch { display: flex; align-items: flex-start; gap: var(--s3); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 34px; height: 20px; flex-shrink: 0;
  border-radius: var(--r-pill);
  background: var(--panel-3);
  border: 1px solid var(--line-strong);
  position: relative;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease);
  margin-top: 1px;
}
.switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--text-3);
  transition: transform var(--fast) var(--ease), background var(--fast) var(--ease);
}
.switch input:checked + .switch-track { background: var(--gold-dim); border-color: var(--gold-line); }
.switch input:checked + .switch-track::after { transform: translateX(14px); background: var(--gold); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--gold); outline-offset: 2px; }
.switch-text { font-size: var(--t-small); }
.switch-sub { font-size: var(--t-micro); color: var(--text-3); margin-top: 2px; line-height: 1.5; }

.check { display: flex; align-items: flex-start; gap: var(--s3); cursor: pointer; font-size: var(--t-small); }
.check input { margin-top: 3px; accent-color: var(--gold); width: 15px; height: 15px; flex-shrink: 0; }

/* ============================================================ TABS ====== */

.tabs {
  display: flex; gap: var(--s1);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tab {
  padding: var(--s3) var(--s4);
  font-size: var(--t-small);
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--gold); }

/* =============================================== DEFINITION ROWS ======== */
/* The call panel, the country card, a lead's details: label on the left,
   value on the right, hairline between. */

.dl { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; }
.dl > dt {
  font-size: var(--t-small); color: var(--text-2);
  padding: var(--s3) var(--s3) var(--s3) 0;
  border-bottom: 1px solid var(--line);
}
.dl > dd {
  font-size: var(--t-small);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--line);
  word-break: break-word;
}
.dl > dt:last-of-type, .dl > dd:last-of-type { border-bottom: none; }
@media (max-width: 620px) {
  .dl { grid-template-columns: minmax(0, 1fr); }
  .dl > dt { padding-bottom: 0; border-bottom: none; }
  .dl > dd { padding-top: 2px; }
}

/* ================================================= THE CALL PANEL ======= */

.player {
  display: flex; flex-direction: column; gap: var(--s2);
  padding: var(--s4);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.player audio { width: 100%; height: 34px; }

/* The transcript, as a conversation. */
.chat { display: flex; flex-direction: column; gap: var(--s3); }
.bubble-row { display: flex; gap: var(--s3); align-items: flex-end; }
.bubble-row.agent { flex-direction: row-reverse; }
.bubble {
  max-width: 78%;
  padding: var(--s3) var(--s4);
  border-radius: var(--r-lg);
  font-size: var(--t-small);
  line-height: 1.55;
  background: var(--panel-2);
  border: 1px solid var(--line);
}
/* The agent is ours, so it carries the faintest gold wash — a tint, not the
   accent, so it does not compete with the page's one gold thing. */
.bubble-row.agent .bubble {
  background: var(--gold-dim);
  border-color: var(--gold-line);
  border-bottom-right-radius: 4px;
}
.bubble-row.caller .bubble { border-bottom-left-radius: 4px; }
.bubble-time {
  font-size: var(--t-micro);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  padding-bottom: 3px;
}
.bubble-who {
  font-size: var(--t-micro);
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 4px;
}

/* ========================================================== CHARTS ====== */
/* Drawn with divs and inline SVG — there is no charting library and no build
   step, and a bar chart does not need one. */

.bars { display: flex; flex-direction: column; gap: var(--s2); }
.bar-row { display: flex; align-items: center; gap: var(--s3); font-size: var(--t-small); }
.bar-label { width: 96px; flex-shrink: 0; text-align: right; color: var(--text-2); font-size: var(--t-micro); }
.bar-track { flex: 1; height: 18px; background: var(--panel-3); border-radius: 4px; overflow: hidden; }
.bar-fill {
  /* `display: block` is load-bearing. These are spans, and the track is a plain
     block, not a flex container — so without this the fill stays `display:
     inline`, where width and height simply do not apply. It rendered as a
     zero-width nothing and every bar chart on the platform was an empty track:
     Analytics' five, the Overview's, and Billing's three. */
  display: block;
  height: 100%; border-radius: 4px;
  background: var(--slate);
  transition: width var(--slow) var(--ease);
}
.bar-fill.gold { background: var(--gold); }
.bar-fill.ok   { background: var(--emerald); }
.bar-fill.warn { background: var(--amber); }
.bar-fill.bad  { background: var(--rose); }

/* A bar that is also a way through to what it counts (rule 9). */
.bar-button {
  width: 100%; background: none; border: none; text-align: left;
  padding: 2px 0;
  border-radius: var(--r-sm);
}
.bar-button:hover .bar-label { color: var(--text); }
.bar-button:hover .bar-track { background: var(--panel-2); }
.bar-value { width: 56px; flex-shrink: 0; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }

.spark { display: block; width: 100%; height: 56px; }

/* A time series big enough to read, for Billing's money charts.
   `preserveAspectRatio="none"` stretches the viewBox to whatever width the
   panel is, which would normally stretch the stroke with it — hence
   non-scaling-stroke on every line, so a hairline stays a hairline.
   No gridlines, no axis furniture, no legend: the labels under it and the
   figures above it already say what it is. */
.spark-lg { display: block; width: 100%; height: 132px; }
.spark-area { fill: var(--slate-dim); stroke: none; }
.spark-line {
  fill: none; stroke: var(--slate); stroke-width: 1.5;
  stroke-linejoin: round; stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.spark-base { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }

/* There is no marker on the last point on purpose: `preserveAspectRatio="none"`
   turns a circle into an ellipse, and the latest value is printed in words
   above the chart anyway, which is easier to read than a dot. */
.spark-head { display: flex; align-items: baseline; gap: var(--s3); margin-bottom: var(--s3); }
.spark-head-value { font-family: var(--font-serif); font-size: 26px; line-height: 1; }
.spark-head-note { font-size: var(--t-small); color: var(--text-2); }
.spark-delta.up   { color: var(--emerald); }
.spark-delta.down { color: var(--rose); }

/* The dates under a series. They are the only axis it gets. */
.spark-axis {
  display: flex; justify-content: space-between;
  margin-top: var(--s2);
  font-size: var(--t-micro); color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* ============================================================ WIZARD ==== */
/* New Campaign, four steps. */

.steps { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.step {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  font-size: var(--t-small);
  color: var(--text-3);
  background: transparent;
}
.step.on   { color: var(--text); border-color: var(--text-3); background: var(--panel-2); }
.step.done { color: var(--text-2); border-color: var(--line-strong); }
.step-n {
  width: 19px; height: 19px; flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid currentColor;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--t-micro);
  font-variant-numeric: tabular-nums;
}
.step.done .step-n { background: var(--emerald-dim); border-color: var(--emerald); color: var(--emerald); }
.step-arrow { color: var(--text-3); }

/* ── Eleven steps on a 390px screen ──────────────────────────────────────
   Four steps wrap onto two rows and read fine. Eleven wrapped onto SIX,
   with an arrow stranded at the start of a row pointing at nothing, and
   pushed the form itself below the fold on every step.

   The arrows go first: they are decoration between chips that are already
   in order, and on one line they help while on six they mislead. Then the
   chips tighten. Nothing is hidden and nothing stops being tappable —
   jumping back to step 3 from step 9 is the reason the strip is buttons
   rather than a progress bar, and a phone needs that more than a desktop
   does, not less. */
@media (max-width: 620px) {
  .steps { gap: 6px; }
  .step-arrow { display: none; }
  .step { padding: 6px var(--s2); font-size: var(--t-micro); gap: 6px; }
  .step-n { width: 17px; height: 17px; }
}

/* A {{variable}} the script can use. */
.var-chip {
  display: inline-flex; align-items: center;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  background: var(--panel-3);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  color: var(--text-2);
}
.var-chip:hover { border-color: var(--gold-line); color: var(--gold); }

/* ============================================ A TABLE ON A PHONE ======== */
/*
 * Eight columns do not fit in 390px, and a table that scrolls sideways inside
 * a panel is the thing that makes a dashboard feel like a desktop app somebody
 * shrank. So below 720px a row stops being a row and becomes a small stacked
 * card: the column headings move onto each value as a label, and the whole
 * thing reads down the page.
 *
 * Every `td` carries data-label — put there by core/table.js — so this needs
 * no JavaScript and no second set of markup to keep in step.
 */

@media (max-width: 720px) {
  .table-wrap { overflow-x: visible; }

  table, tbody, tr, td { display: block; width: 100%; }

  /* The headings are on each value now. */
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

  tbody tr {
    padding: var(--s3) var(--s4);
    border-bottom: 1px solid var(--line);
  }
  tbody tr:last-child { border-bottom: none; }

  /* A grid, not a flex row, because a cell often holds TWO things — a badge
     and a sentence under it. In a flex row those become two siblings fighting
     for the same line and overlapping. Here the label takes column one and
     everything in the cell stacks down column two. */
  tbody td {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 2px var(--s4);
    align-items: baseline;
    padding: 3px 0;
    border-bottom: none;
  }

  tbody td[data-label]::before {
    content: attr(data-label);
    grid-column: 1;
    font-size: var(--t-micro);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
    white-space: nowrap;
  }
  tbody td[data-label] > *,
  tbody td[data-label] { text-align: right; }
  tbody td[data-label] > * { grid-column: 2; min-width: 0; }

  /* The first cell is the row's name — it gets the whole width and no label. */
  tbody td:first-child { display: block; margin-bottom: var(--s2); text-align: left; }
  tbody td:first-child::before { content: none; }
  tbody td:first-child > * { text-align: left; }

  /* An empty state or an error still spans the "table". */
  tbody td:only-child { display: block; padding: 0; }
  tbody td:only-child::before { content: none; }

  .cell-actions { justify-content: flex-start; margin-top: var(--s2); }

  .table-tools { padding: var(--s3) var(--s4); }
  .search { max-width: none; }
  .pager { padding: var(--s3) var(--s4); }
  .panel-head { padding: var(--s4); }
  .panel-body { padding: var(--s4); }
}

/* Two key numbers across on a phone rather than four tall cards that push the
   rest of the page below the fold. */
@media (max-width: 620px) {
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
  .figure { padding: var(--s3); }
  .figure-value { font-size: 28px; margin-top: var(--s2); }
  .figure-note { font-size: var(--t-micro); }
}
@media (max-width: 360px) {
  .figures { grid-template-columns: minmax(0, 1fr); }
}

/* ========================================= A BALANCED TWO-COLUMN PAGE === */
/*
 * Two columns of stacked panels that END ON THE SAME LINE.
 *
 * A plain grid does not do this: each column stops wherever its content
 * happens to end, and the shorter one leaves a block of dead space at the
 * bottom of the page. Here each column is a flex column, and the panel marked
 * `.grow-panel` — the last one, the list — takes whatever height is left. Both
 * columns then reach the same line whatever is in them.
 */

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: var(--s4);
  align-items: stretch;
}
.split-col {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  min-width: 0;
}
.split-col > .panel { margin-top: 0; }
.grow-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.grow-panel > .panel-head { flex-shrink: 0; }
.grow-panel > *:last-child { flex: 1; overflow-y: auto; }

@media (max-width: 1020px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  /* Stacked on a phone there is no second column to balance against, so a
     panel that grows would just be a panel with a hole in it. */
  .grow-panel { flex: initial; }
  .grow-panel > *:last-child { overflow-y: visible; }
}

.micro { font-size: var(--t-micro); }

/* ╔════════════════════════════════════════════════════════════════════════╗
   ║  SETTING UP AN AUTHENTICATOR APP                                       ║
   ╚════════════════════════════════════════════════════════════════════════╝

   These three were in auth.css, which only the login page loads — and the
   dashboard's own two-factor modal (core/security.js) uses all three. So the
   setup key and the ten recovery codes have been drawing UNSTYLED inside the
   dashboard since Brief 10: no box, no spacing, no tracking, on the one
   screen where a character has to be read off a screen and typed into a
   phone. Found while adding the QR code. They live here now, where both the
   login page and the dashboard can see them. */

.auth-link {
  background: none; border: none; padding: 0;
  font-size: var(--t-small);
  color: var(--gold);
}
.auth-link:hover { color: var(--gold-bright); text-decoration: underline; }

/* Brief 10, Part C: the authenticator key, and the ten recovery codes.
   One box for both. It has to be READ OFF THE SCREEN and typed somewhere
   else, or written down, so: a wide tracking so 0 and O are not the same
   shape, a size big enough to read at arm's length, and `user-select: all`
   so one click selects the whole thing instead of half of it. */
.secret-box {
  margin: var(--s3) 0;
  padding: var(--s3) var(--s4);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-size: 15px;
  line-height: 1.9;
  letter-spacing: 0.08em;
  color: var(--text);
  word-break: break-all;
  user-select: all;
  text-align: center;
}

/* ── Brief 11, Part B4: the QR code ────────────────────────────────────────

   WHITE, IN BOTH THEMES, AND THAT IS NOT AN OVERSIGHT. A QR code is read by
   a camera, and a camera needs dark modules on a light background — the
   inverted version is not reliably readable, and a code somebody cannot scan
   at 11pm in dark mode is worse than no code at all. So the white is painted
   on rather than inherited, and neither colour is a theme token.

   The padding is the quiet zone's margin of safety: the SVG carries four
   modules of white of its own, and this keeps the panel's own border off it.

   The size is capped so it does not fill a desktop screen, and `width:100%`
   under that cap so it shrinks to fit a phone. 220px is comfortably above
   the ~2cm a phone camera needs for a version 9 code. */
.qr-box {
  margin: var(--s3) 0;
  padding: var(--s3);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--r);
  display: flex;
  justify-content: center;
}
.qr-box .qr {
  display: block;
  width: 100%;
  max-width: 240px;
  height: auto;
  image-rendering: pixelated;
}

@media (max-width: 480px) {
  /* On a phone the code is being scanned by ANOTHER phone, or the app is on
     the same phone and the key below is the easier route. Either way there
     is no point in a 240px square on a 360px screen. */
  .qr-box .qr { max-width: 200px; }
}

/* ── Brief 12, Part E: a client's own logo and colour ───────────────────
   The preview box on their settings page, and the swatch beside the hex
   code. `contain` on the image so a wide logo and a square one both sit in
   the same box without being stretched — a stretched logo is worse than no
   logo at all. */
.brand-preview {
  width: 120px; height: 120px; flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel-3);
  padding: var(--s3);
  display: flex; align-items: center; justify-content: center;
}
.brand-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }

.brand-swatch {
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
}

/* ============================================ CHOOSING ONE OF MANY ====== */
/*
 * A grid of things to pick from — a starting point for a new agent, a voice.
 * A dropdown would be smaller and would be wrong for both: picking a voice
 * means reading three lines about each one and pressing play, and picking a
 * starting point means reading a sentence about each.
 *
 * It is a button, not a radio, because each card carries its own controls
 * (the Listen button) and a label wrapping a radio would swallow their
 * clicks.
 */
.pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--s3);
}
.pick {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: var(--s4);
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel-2);
  cursor: pointer;
}
.pick:hover { border-color: var(--line-strong); }
.pick.on { border-color: var(--gold-line); background: var(--gold-dim); }
.pick-title { font-size: var(--t-small); font-weight: 500; color: var(--text); }
.pick-sub { font-size: var(--t-micro); color: var(--text-2); line-height: 1.5; }
.pick-tag {
  margin-top: 2px;
  font-size: var(--t-micro);
  color: var(--text-3);
}
.pick .btn { margin-top: var(--s2); }

@media (max-width: 620px) {
  .pick-grid { grid-template-columns: minmax(0, 1fr); }
}
