/* =============================================================================
   AI Patient Online, staff app: the shared stylesheet.
   Synthetic data only. Every page loads this file and Inter from Google Fonts.

   PAGE HEAD (every page):
     <meta name="viewport" content="width=device-width, initial-scale=1" />
     <meta name="theme-color" content="#0f6b5f" />
     <link rel="icon" href="/favicon.svg" type="image/svg+xml" />
     <link rel="alternate icon" href="/favicon.ico" />
     <link rel="preconnect" href="https://fonts.googleapis.com" />
     <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
     <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" />
     <link rel="stylesheet" href="app.css" />

   PAGE LAYOUT (signed-in pages):
     <header class="bar"></header>        common.js renderNav() fills it (logo, nav tabs, user area).
     <main>
       <div class="page-head"><div><h1>Title</h1><p class="page-sub">One line.</p></div></div>
       ... cards ...
     </main>

   REUSABLE CLASSES (the login and admin pages use these):
     .card                 White rounded box: 1px border, radius 12px, 20px padding.
     .card-header          Row at the top of a card: title (h2) on the left, actions on the right.
     .kpi-row              Responsive grid of KPI tiles.
     .kpi                  KPI tile (a card). Children:
       .kpi-label          Small muted label.
       .kpi-value          Big number (30px, 600). Add .good (green), .bad (red) or .warn (amber).
       .kpi-caption        Small muted caption under the number.
     .btn                  Base button (white, gray border, radius 8px).
     .btn-primary          Solid teal, white text.
     .btn-secondary        White, 1px teal border, teal text.
     .btn-danger           Solid red, white text.
     .btn-link             Text-only button (teal text, no box).
     .btn-sm               Smaller button.  :disabled buttons turn gray.
     .badge                Small rounded pill. Colors:
       .badge-red .badge-amber .badge-blue .badge-green .badge-gray .badge-solid-red
     .field                Label + input stack:  <div class="field"><label>..</label><input>..<span class="hint">..</span></div>
     .form-error           Red tinted message box (empty = hidden).
     .form-ok              Green tinted message box (empty = hidden).
     .alert                Tinted banner. Add .alert-red, .alert-amber or .alert-green.
     .muted                Muted gray text.
     .small                13px text.
     .mono                 Monospace text (due times, ids, numbers).
     .auth-shell           Full-height centered layout for a narrow sign-in card (max-width 420px).
                           <div class="auth-shell"><div class="auth-brand">..</div><div class="card">..</div></div>
     .table                Styled table: uppercase small muted headers, roomy rows, 1px row lines.
     .table-wrap           Wrap a wide table: it scrolls inside its card, never the page.
     .toolbar              Flex row with a gap that wraps. Add .toolbar-end to push items right.
     .empty                Muted empty-state text.
   ============================================================================= */

:root {
  color-scheme: light;
  /* surfaces and text */
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f2f4f7;
  --text: #1f2933;
  --text-2: #52606d;
  --text-3: #7b8794;
  --border: #e5e7eb;
  --border-strong: #d0d5dd;
  /* accent */
  --accent: #0f6b5f;
  --accent-hover: #0b574d;
  --accent-tint: #e6f2ef;
  --accent-text: #0f6b5f;
  --on-accent: #ffffff;
  --focus-ring: rgba(15, 107, 95, 0.28);
  /* status tints */
  --red-bg: #fde8e8;   --red: #b42318;   --red-solid: #b42318;
  --amber-bg: #fef3c7; --amber: #92400e;
  --blue-bg: #e8f0fe;  --blue: #1d4ed8;
  --green-bg: #e7f6ec; --green: #166534; --green-strong: #15803d;
  --gray-bg: #f2f4f7;  --gray: #475467;
  /* type and shape */
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);

  /* Older names, kept so page-local rules still resolve. */
  --paper: var(--bg);
  --panel: var(--surface);
  --ink: var(--text);
  --steel: var(--text-2);
  --line: var(--border);
  --care: var(--accent);
  --care-tint: var(--accent-tint);
  --urgent: var(--red);
  --urgent-tint: var(--red-bg);
  --wait: var(--amber);
  --wait-tint: var(--amber-bg);
  --sign: var(--font);
  --read: var(--font);
}

/* Dark palette: the OS setting, unless the page forces light with data-theme="light". */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #0f1418; --surface: #171d23; --surface-2: #1c232a; --surface-3: #222a32;
    --text: #e4e7eb; --text-2: #a3adb8; --text-3: #7f8a96;
    --border: #2a333c; --border-strong: #3a4550;
    --accent: #14806f; --accent-hover: #189a86; --accent-tint: #133b35; --accent-text: #5fd0bd; --on-accent: #ffffff;
    --focus-ring: rgba(95, 208, 189, 0.35);
    --red-bg: #3d1717; --red: #fca5a5; --red-solid: #c2362b;
    --amber-bg: #3a2b0b; --amber: #fcd34d;
    --blue-bg: #172449; --blue: #9dbdff;
    --green-bg: #11301e; --green: #86efac; --green-strong: #4ade80;
    --gray-bg: #242c35; --gray: #c3cad3;
    --shadow: none;
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0f1418; --surface: #171d23; --surface-2: #1c232a; --surface-3: #222a32;
  --text: #e4e7eb; --text-2: #a3adb8; --text-3: #7f8a96;
  --border: #2a333c; --border-strong: #3a4550;
  --accent: #14806f; --accent-hover: #189a86; --accent-tint: #133b35; --accent-text: #5fd0bd; --on-accent: #ffffff;
  --focus-ring: rgba(95, 208, 189, 0.35);
  --red-bg: #3d1717; --red: #fca5a5; --red-solid: #c2362b;
  --amber-bg: #3a2b0b; --amber: #fcd34d;
  --blue-bg: #172449; --blue: #9dbdff;
  --green-bg: #11301e; --green: #86efac; --green-strong: #4ade80;
  --gray-bg: #242c35; --gray: #c3cad3;
  --shadow: none;
}

/* ---- base ----------------------------------------------------------------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--font);
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-text); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

h1 { font-size: 26px; line-height: 1.2; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
h2 { font-size: 16px; line-height: 1.3; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 12px; }
h3 { font-size: 14px; line-height: 1.3; font-weight: 600; margin: 0 0 8px; color: var(--text); }
p { margin: 0 0 12px; }

.muted { color: var(--text-2); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 0.92em; font-variant-numeric: tabular-nums; }
.hint { font-size: 13px; color: var(--text-2); }
.empty { padding: 24px 4px; color: var(--text-2); text-align: center; }

main { padding: 28px 32px 48px; max-width: 1360px; margin: 0 auto; }

/* ---- header bar (built by common.js renderNav) ---------------------------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  min-height: 64px; padding: 0 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex: none; }
.brand:hover { color: var(--text); }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; background: var(--accent);
  display: grid; place-items: center; color: #fff; flex: none;
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; white-space: nowrap; }
.brand-sub { font-size: 12px; color: var(--text-3); font-weight: 500; padding-left: 8px; border-left: 1px solid var(--border); }

.bar nav { display: flex; gap: 2px; min-width: 0; }
.bar nav a {
  color: var(--text-2); text-decoration: none; font-size: 14px; font-weight: 500;
  padding: 7px 12px; border-radius: 999px; white-space: nowrap;
}
.bar nav a:hover { color: var(--text); background: var(--surface-3); }
.bar nav a[aria-current] { background: var(--accent-tint); color: var(--accent-text); font-weight: 600; }

.user { margin-left: auto; display: flex; align-items: center; gap: 14px; flex: none; }
.user-id { display: flex; flex-direction: column; line-height: 1.25; text-align: right; min-width: 0; }
.user-id b { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 22ch; }
.user-id span { font-size: 12px; color: var(--text-2); text-transform: capitalize; }

/* ---- page heading ------------------------------------------------------------ */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head > div { min-width: 0; }
.eyebrow { font-size: 13px; color: var(--text-2); margin: 0 0 4px; font-weight: 500; }
.page-sub { margin: 6px 0 0; color: var(--text-2); font-size: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.page-sub .sep { color: var(--border-strong); }

/* ---- card ------------------------------------------------------------------ */
.card, .panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 24px; min-width: 0; box-shadow: var(--shadow);
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-header h2 { margin: 0; }
.card-sub { color: var(--text-2); font-size: 13px; margin: 0 0 16px; }
.card-header:has(+ .card-sub) { margin-bottom: 4px; }
.card > h2:first-child, .panel > h2:first-child { margin-bottom: 4px; }
.stack { display: grid; gap: 20px; }

/* ---- KPI tiles ---------------------------------------------------------------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; min-width: 0; box-shadow: var(--shadow); }
.kpi-label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.kpi-value { font-size: 30px; line-height: 1.15; font-weight: 600; letter-spacing: -0.02em; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.kpi-value.good { color: var(--green-strong); }
.kpi-value.bad { color: var(--red); }
.kpi-value.warn { color: var(--amber); }
.kpi-caption { font-size: 12.5px; color: var(--text-2); }
a.kpi { text-decoration: none; color: inherit; display: block; }
a.kpi:hover { border-color: var(--border-strong); }

/* ---- buttons -------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  border-radius: var(--radius-sm); padding: 8px 14px; font-size: 14px; font-weight: 600; line-height: 1.3;
  white-space: nowrap; text-decoration: none; transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); color: var(--text); }
.btn-primary, .btn.care { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover, .btn.care:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-secondary { background: var(--surface); border-color: var(--accent); color: var(--accent-text); }
.btn-secondary:hover { background: var(--accent-tint); border-color: var(--accent); color: var(--accent-text); }
.btn-danger, .btn.stop { background: var(--red-solid); border-color: var(--red-solid); color: #fff; }
.btn-danger:hover, .btn.stop:hover { background: #912018; border-color: #912018; color: #fff; }
.btn-link { background: none; border: 0; padding: 4px 2px; color: var(--accent-text); font-weight: 600; font-size: 14px; }
.btn-link:hover { color: var(--accent-hover); text-decoration: underline; background: none; }
.btn-sm, .btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled, .btn[aria-disabled='true'], .btn-link:disabled {
  background: var(--surface-3); border-color: var(--border); color: var(--text-3); cursor: not-allowed;
}
.mic[aria-pressed='true'] { background: var(--red-solid); color: #fff; border-color: var(--red-solid); }

/* ---- badges ------------------------------------------------------------------------- */
.badge, .prio, .state, .pill, .status, .sev {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600; line-height: 1; letter-spacing: 0.03em;
  padding: 5px 9px; border-radius: 999px; white-space: nowrap; text-transform: uppercase;
  background: var(--gray-bg); color: var(--gray);
}
.badge { text-transform: none; letter-spacing: 0; font-size: 12.5px; padding: 4px 10px; }
.page-sub .badge { white-space: normal; line-height: 1.3; }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-solid-red { background: var(--red-solid); color: #fff; }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-gray { background: var(--gray-bg); color: var(--gray); }
.badge-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* task priority (Dr. Emil's Part 8): class is the first word of the priority */
.prio.EMERGENT, .prio.HOSPITAL { background: var(--red-solid); color: #fff; }
.prio.URGENT { background: var(--red-bg); color: var(--red); }
.prio.SAME { background: var(--amber-bg); color: var(--amber); }
.prio.ROUTINE { background: var(--blue-bg); color: var(--blue); }

/* call / presence state */
.state.connected, .state.available { background: var(--green-bg); color: var(--green); }
.state.holding, .state.ringing, .state.waiting, .state.callback_offer, .state.hold_or_callback, .state.checking, .state.busy, .state.break { background: var(--amber-bg); color: var(--amber); }
.state.agent, .state.on-call { background: var(--blue-bg); color: var(--blue); }
.state.urgent, .state.emergency { background: var(--red-bg); color: var(--red); }
.state.ended, .state.offline { background: var(--gray-bg); color: var(--text-2); }
.state:empty { display: none; }

/* urgency pill (call logs) */
.pill.urgent { background: var(--red-bg); color: var(--red); }
.pill.emergent { background: var(--red-solid); color: #fff; }

/* queue status and check severity */
.status.held, .status.pending { background: var(--blue-bg); color: var(--blue); }
.status.confirmed, .status.approved, .status.bridged { background: var(--green-bg); color: var(--green); }
.status.to_doctor { background: var(--amber-bg); color: var(--amber); }
.status.expired, .status.denied, .status.released { background: var(--red-bg); color: var(--red); }
.sev { margin-right: 8px; }
.sev.contraindicated, .sev.allergy { background: var(--red-solid); color: #fff; }
.sev.caution, .sev.duplicate { background: var(--amber-bg); color: var(--amber); }

/* Claude grade */
.gr {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px;
  font-size: 12.5px; font-weight: 700; border-radius: 7px; text-decoration: none;
  background: var(--green-bg); color: var(--green);
}
.gr.C, .gr.D { background: var(--amber-bg); color: var(--amber); }
.gr.F { background: var(--red-solid); color: #fff; }

/* ---- forms ------------------------------------------------------------------------- */
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=search], input[type=number], input:not([type]), select, textarea {
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 9px 12px;
  background: var(--surface); color: var(--text); font-size: 14px; line-height: 1.4; max-width: 100%;
  transition: border-color 0.12s, box-shadow 0.12s;
}
select { padding-right: 32px; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-3); color: var(--text-3); cursor: not-allowed; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
label { font-size: 14px; font-weight: 500; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; min-width: 0; }
.field > label { font-size: 13.5px; font-weight: 600; color: var(--text); }
.field > input, .field > select, .field > textarea { width: 100%; }
.field .hint { margin: 0; }
.form-error, .form-ok { border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13.5px; margin: 0 0 14px; }
.form-error { background: var(--red-bg); color: var(--red); }
.form-ok { background: var(--green-bg); color: var(--green); }
.form-error:empty, .form-ok:empty { display: none; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.toolbar-end { margin-left: auto; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* ---- alerts ------------------------------------------------------------------------- */
.alert {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px; font-size: 14px;
  background: var(--red-bg); color: var(--red); border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
}
.alert b { font-weight: 700; letter-spacing: 0.02em; }
.alert .btn { margin-left: auto; }
.alert-red { background: var(--red-bg); color: var(--red); }
.alert-amber { background: var(--amber-bg); color: var(--amber); }
.alert-green { background: var(--green-bg); color: var(--green); }
.alert-blue { background: var(--blue-bg); color: var(--blue); }
.flag { display: block; background: var(--red-bg); color: var(--red); border-radius: var(--radius-sm); padding: 10px 14px; margin: 0 0 8px; font-weight: 600; font-size: 14px; }
.tflag { display: block; font-size: 12.5px; color: var(--amber); margin-top: 2px; }

/* ---- tables ----------------------------------------------------------------------- */
.table, .card table, .panel table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .card th, .panel th {
  text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-3); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td, .card td, .panel td { padding: 14px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td, .card tbody tr:last-child td, .panel tbody tr:last-child td { border-bottom: 0; }
.table th:first-child, .table td:first-child, .card th:first-child, .card td:first-child { padding-left: 0; }
.table th:last-child, .table td:last-child, .card th:last-child, .card td:last-child { padding-right: 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -24px; padding: 0 24px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.open-row, tr.callrow { cursor: pointer; }
tr.open-row:hover td, tr.callrow:hover td { background: var(--surface-2); }
tr.open-row[data-open] td { background: var(--accent-tint); }
tr.detail-row > td { background: var(--surface-2); padding: 16px 16px !important; }
.cell-title { font-weight: 600; }
.cell-sub { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.due { font-family: var(--mono); font-size: 12px; color: var(--text-2); margin-top: 6px; white-space: nowrap; }
.due.late { color: var(--red); font-weight: 600; }

/* ---- timelines and transcripts --------------------------------------------------- */
.timeline, .tl { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13.5px; }
.timeline li, .tl li { display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 3px 0; }
.timeline .t, .tl time { font-family: var(--mono); font-size: 12px; color: var(--text-3); text-align: right; padding-top: 1px; }
.tl .safety { color: var(--red); font-weight: 600; }

.convo { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; padding: 4px; }
.line { max-width: 86%; padding: 9px 13px; border-radius: 12px; background: var(--surface-3); font-size: 14px; overflow-wrap: anywhere; }
.line .who { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 2px; }
.line.agent { background: var(--blue-bg); border-bottom-left-radius: 4px; }
.line.caller { align-self: flex-end; background: var(--accent-tint); border-bottom-right-radius: 4px; }
.line.staff { background: var(--amber-bg); }
.line.system { align-self: center; background: none; color: var(--text-2); font-size: 13px; padding: 2px 8px; }
.say { display: flex; gap: 8px; margin-top: 12px; }
.say input { flex: 1; min-width: 0; }

/* ---- call board ------------------------------------------------------------------------ */
.board { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }
.board-top { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; margin-bottom: 20px; align-items: stretch; }
.staffrow { display: flex; gap: 10px; flex-wrap: wrap; }
.staffrow .who {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; display: flex; gap: 10px; align-items: center; min-width: 0;
}
.staffrow .who b { font-size: 14px; font-weight: 600; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent-tint); color: var(--accent-text); font-size: 11.5px; font-weight: 700;
}
#oncallPhone { width: 12em; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.say-line { font-size: 13.5px; margin: 0 0 6px; }

/* ---- staff app ------------------------------------------------------------------------- */
.me { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.me .name { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 8px 14px; font-weight: 600; font-size: 13.5px; color: var(--text-2); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button:hover { background: var(--surface-2); color: var(--text); }
.seg button[aria-pressed='true'] { background: var(--accent); color: var(--on-accent); }

/* The one bold moment: an incoming transfer. */
.incoming { border: 2px solid var(--accent); border-radius: 16px; background: var(--surface); padding: 28px 32px; margin-bottom: 24px; }
.incoming.urgent { border-color: var(--red-solid); }
.incoming .kicker { font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent-text); }
.incoming.urgent .kicker { color: var(--red); }
.incoming .brief { font-size: 24px; line-height: 1.4; margin: 12px 0 20px; max-width: 60ch; letter-spacing: -0.01em; }
.incoming .timer { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; margin-bottom: 20px; }
.incoming .timer > i { display: block; height: 100%; background: var(--accent); transform-origin: left; }
.incoming.urgent .timer > i { background: var(--red-solid); }
.incoming .actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.incoming .actions .btn { font-size: 17px; padding: 12px 26px; }

.oncall { display: grid; grid-template-columns: minmax(300px, 2fr) 3fr; gap: 20px; align-items: start; }
.card dl { margin: 0; display: grid; grid-template-columns: 120px 1fr; gap: 8px 14px; font-size: 14px; }
.card dt { color: var(--text-2); font-size: 13px; }
.card dd { margin: 0; overflow-wrap: anywhere; }
.card .src { display: block; color: var(--text-3); font-size: 12px; }
.card .verified { color: var(--green); font-weight: 600; }
.card .unverified { color: var(--amber); font-weight: 600; }
.card section + section { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.qs { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 14px; }
.qs li { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.qs li.done { background: var(--green-bg); border-color: transparent; }
.qs li.done::before { content: '✓ '; color: var(--green); font-weight: 700; }
.qs li .ev { display: block; font-size: 12.5px; color: var(--text-2); }
.talk .convo { height: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.talk .tools { display: flex; gap: 8px; justify-content: space-between; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.mood { font-size: 13px; color: var(--text-2); }
.draft label { display: block; font-weight: 600; font-size: 13.5px; margin: 14px 0 6px; }
.draft textarea { width: 100%; min-height: 80px; }
.idle { text-align: center; padding: 56px 24px; }
.idle p { font-size: 18px; font-weight: 600; margin: 0 0 6px; }
.idle-icon { width: 48px; height: 48px; border-radius: 14px; margin: 0 auto 14px; display: grid; place-items: center; background: var(--accent-tint); color: var(--accent-text); }

/* ---- caller phone ------------------------------------------------------------------------ */
.phone { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.phone .convo { height: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.phone-status { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.phone-status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.phone.live .phone-status::before { background: var(--green-strong); box-shadow: 0 0 0 4px var(--green-bg); }
.phone .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.phone select { flex: 1; min-width: 0; }
.phone .convo.sms { height: auto; min-height: 64px; max-height: 240px; border: 0; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 999px;
  padding: 5px 11px; font-size: 13px; color: var(--text); text-align: left;
}
.chips button:hover { border-color: var(--accent); color: var(--accent-text); background: var(--accent-tint); }

/* ---- call logs ------------------------------------------------------------------------- */
.logs { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); max-height: calc(100vh - 200px); overflow: auto; position: sticky; top: 84px; }
.list .tools { position: sticky; top: 0; z-index: 1; background: var(--surface); padding: 12px; border-bottom: 1px solid var(--border); display: flex; gap: 8px; }
.list .tools input { flex: 1; min-width: 0; }
.item { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--border); background: none; padding: 12px 16px; }
.item:last-child { border-bottom: 0; }
.item:hover { background: var(--surface-2); }
.item[aria-current="true"] { background: var(--accent-tint); box-shadow: inset 3px 0 0 var(--accent); }
.item .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.item .top > span:last-child { display: inline-flex; gap: 6px; align-items: center; font-weight: 500; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.item .sub { display: block; color: var(--text-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-detail h2 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
.call-detail h3 { margin: 24px 0 10px; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.call-detail .convo { overflow: visible; padding: 0; }
.call-detail > .line { margin-bottom: 8px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 16px 0; font-size: 14px; }
.meta dt { color: var(--text-2); }
.meta dd { margin: 0; overflow-wrap: anywhere; }
.task { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px; font-size: 14px; }
.issue { border-left: 3px solid var(--border-strong); padding: 6px 12px; margin: 8px 0; background: var(--surface); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 14px; }
.issue.critical { border-color: var(--red-solid); }
.issue.major { border-color: #d97706; }
.review { border: 1px solid var(--border); border-radius: var(--radius); margin: 16px 0 4px; background: var(--surface-2); }
.review > summary { display: flex; gap: 12px; align-items: center; padding: 12px 14px; cursor: pointer; list-style: none; }
.review > summary::-webkit-details-marker { display: none; }
.review > summary::after { content: '▸'; margin-left: auto; color: var(--text-3); transition: transform 0.15s; }
.review[open] > summary::after { transform: rotate(90deg); }
.review > summary .gr { font-size: 16px; min-width: 36px; height: 36px; border-radius: 10px; }
.review .rv-head { line-height: 1.4; }
.review .rv-body { padding: 4px 14px 14px; border-top: 1px solid var(--border); }
.review .rv-body .dims { margin: 12px 0; }
.review.empty { padding: 12px 14px; display: flex; gap: 12px; align-items: center; justify-content: flex-start; text-align: left; }
.dims { display: flex; gap: 8px 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }

/* ---- queues ------------------------------------------------------------------------------ */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 20px; padding: 4px; background: var(--surface-3); border-radius: 10px; width: fit-content; max-width: 100%; }
.tabs button { border: 0; background: none; padding: 7px 14px; font-size: 14px; font-weight: 600; color: var(--text-2); border-radius: 7px; display: inline-flex; align-items: center; gap: 6px; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08); }
.tabs .n { display: inline-block; min-width: 20px; padding: 2px 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 11.5px; text-align: center; }
.tabs .n:empty { display: none; }
.qitem { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; background: var(--surface); }
.qitem h3 { font-size: 15px; margin: 0 0 6px; }
.qitem .row { margin-top: 12px; }
.qitem input[type=text] { flex: 1 1 200px; min-width: 0; }
.qmeta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 13px; color: var(--text-2); }
.checks { list-style: none; padding: 0; margin: 12px 0 0; font-size: 13.5px; display: grid; gap: 6px; }
.reasons { margin: 10px 0 0; padding-left: 18px; font-size: 13px; color: var(--text-2); }
.err { color: var(--red); font-size: 13px; }
.qitem .err { width: 100%; }
.err:empty { display: none; }
.rec { font-weight: 600; color: var(--text); }

/* ---- synthetic tests ---------------------------------------------------------------------- */
.prog { height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; flex: 1; min-width: 120px; }
.prog > i { display: block; height: 100%; background: var(--accent); transition: width 0.4s; }
.dist { display: grid; grid-template-columns: 2em 1fr 3em; gap: 8px 12px; align-items: center; max-width: 560px; }
.dist .b { height: 12px; border-radius: 6px; background: var(--accent); min-width: 2px; }
.dist .b.C, .dist .b.D { background: #d97706; }
.dist .b.F { background: var(--red-solid); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.tline { margin: 0 0 6px; font-size: 13px; }

/* ---- web call ------------------------------------------------------------------------------ */
.wc { max-width: 560px; margin: 0 auto; display: grid; gap: 16px; }
.wc select { width: 100%; }
.wc-status { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.wc-status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.wc-status.live { color: var(--accent-text); }
.wc-status.live::before { background: var(--green-strong); box-shadow: 0 0 0 4px var(--green-bg); }
.wc-status.err { color: var(--red); }
.wc-status.err::before { background: var(--red-solid); }

/* ---- sign-in shell (login.html) ------------------------------------------------------------ */
.auth-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 32px 16px; }
.auth-shell > .card { width: 100%; max-width: 420px; padding: 32px; }
.auth-shell h1 { font-size: 22px; margin-bottom: 6px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.auth-shell .btn-primary { width: 100%; padding: 11px 14px; }
.auth-foot { font-size: 12.5px; color: var(--text-3); text-align: center; max-width: 420px; }

/* ---- responsive ------------------------------------------------------------------------------ */
@media (max-width: 1180px) {
  .bar { gap: 16px; }
  .brand-sub { display: none; }
  .user .badge { display: none; }
}
@media (max-width: 1024px) {
  .board, .board-top, .oncall, .logs { grid-template-columns: minmax(0, 1fr); }
  .list { position: static; max-height: 420px; }
}
@media (max-width: 900px) {
  .bar { flex-wrap: wrap; gap: 0 12px; padding: 10px 16px 0; min-height: 0; }
  .bar .brand { order: 1; }
  .bar .user { order: 2; }
  .bar nav {
    order: 3; flex-basis: 100%; overflow-x: auto; scrollbar-width: none;
    margin: 8px -16px 0; padding: 0 16px 10px;
  }
  .bar nav::-webkit-scrollbar { display: none; }
  main { padding: 20px 16px 40px; }
  .card, .panel { padding: 18px 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .detail-grid, .two { grid-template-columns: 1fr; }
  .incoming { padding: 22px 20px; }
  .incoming .brief { font-size: 20px; }
}
@media (max-width: 560px) {
  h1 { font-size: 22px; }
  .page-head { margin-bottom: 18px; }
  .kpi-row { grid-template-columns: 1fr 1fr; gap: 12px; }
  .kpi { padding: 14px 16px; }
  .kpi-value { font-size: 26px; }
  .user { gap: 10px; }
  .user-id b { max-width: 14ch; }
  .user-id span { display: none; }
  .card dl { grid-template-columns: 1fr; gap: 2px; }
  .card dl dd { margin-bottom: 8px; }
  .meta { grid-template-columns: 1fr; gap: 2px; }
  .meta dd { margin-bottom: 8px; }
  .alert .btn { margin-left: 0; }
  .page-sub .sep { display: none; }
  /* task table: priority and action on one line, the task under them */
  .tasks-table thead { display: none; }
  .tasks-table tr { display: grid; grid-template-columns: 1fr auto; border-bottom: 1px solid var(--border); padding: 12px 0; }
  .tasks-table tbody tr:last-child { border-bottom: 0; }
  .tasks-table td { border: 0 !important; padding: 0 !important; }
  .tasks-table td:nth-child(2) { grid-column: 1 / -1; order: 3; margin-top: 8px; }
  .tasks-table td .due { display: inline; margin-left: 8px; }
  .tasks-table td.empty { grid-column: 1 / -1; padding: 24px 0 !important; }
  .me .name { font-size: 20px; }
  .auth-shell > .card { padding: 24px 20px; }
}

/* ---- Admin console and account page ---- */
.invite-grid { display: grid; grid-template-columns: 2fr 1.5fr 1fr auto; gap: 12px; align-items: end; }
.invite-grid .field { margin: 0; }
.invite-go { align-self: end; }
.table td.actions { white-space: nowrap; text-align: right; }
.table td.actions .btn-link + .btn-link { margin-left: 12px; }
.btn-link.danger { color: var(--red); }
a.user-id { color: inherit; text-decoration: none; }
a.user-id:hover b { text-decoration: underline; }
.account-card { max-width: 520px; }
.auth-title { font-size: 22px; margin: 0 0 4px; }
.auth-alt { margin-top: 16px; text-align: center; }
.btn-block { width: 100%; justify-content: center; }
@media (max-width: 720px) { .invite-grid { grid-template-columns: 1fr; } }
.auth-brand { color: var(--text); text-decoration: none; }
