/* Call test. A calm operator's console around one loud thing: the call. Readex Pro (drawn for
   Arabic and Latin together, so Darija transcripts read as well as the interface). Green means a
   call can start or runs, red ends it, violet is the agent's voice. Light only. */
:root {
  --mist: #f1f3f6;
  --surface: #ffffff;
  --sunk: #e9edf2;
  --hover: #f5f7fa;
  --ink: #0f1b2d;
  --ink-2: #3a4a60;
  --muted: #5b6778;
  --faint: #8a95a5;
  --line: #dce2ea;
  --line-soft: #e8ecf1;
  --call: #0e9f6e;
  --call-hover: #0b8a5f;
  --call-ink: #07734f;
  --call-soft: #e3f6ee;
  --end: #e0464e;
  --end-hover: #c93a42;
  --end-ink: #b3262e;
  --end-soft: #fdecec;
  --agent: #6d5ef5;
  --agent-ink: #4b3fd0;
  --agent-soft: #f0eeff;
  --warn: #b7791f;
  --warn-ink: #8a5a12;
  --warn-soft: #fff5e0;
  --focus: #6d5ef5;
  --wave-person: #3a4a60;
  --wave-agent: #6d5ef5;
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-pill: 999px;
  --pop: 0 16px 40px rgba(15, 27, 45, 0.16), 0 2px 8px rgba(15, 27, 45, 0.06);
  --font: "Readex Pro", system-ui, -apple-system, "Segoe UI", "Noto Sans Arabic", sans-serif;
  --top: 60px;
  --tabs: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--mist); color: var(--ink); font: 400 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; }
a { color: var(--agent-ink); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.ic { flex: none; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.row-gap { display: inline-flex; gap: 2px; align-items: center; }
.stack { display: grid; gap: 10px; }
.stack-sm { display: grid; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.empty-note { color: var(--muted); font-size: 14px; padding: 6px 0; }

/* ── Controls ─────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 500; font-size: 14.5px; cursor: pointer; white-space: nowrap; transition: background-color 0.12s, border-color 0.12s, color 0.12s, transform 0.08s; }
.btn:hover { background: var(--hover); border-color: #c9d1dc; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: #24344a; border-color: #24344a; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--sunk); border-color: transparent; color: var(--ink); }
.btn-danger { background: var(--end); border-color: var(--end); color: #fff; }
.btn-danger:hover { background: var(--end-hover); border-color: var(--end-hover); }
.btn-call { background: var(--call); border-color: var(--call); color: #fff; }
.btn-call:hover { background: var(--call-hover); border-color: var(--call-hover); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13.5px; gap: 6px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15.5px; border-radius: var(--r-md); }
.btn-icon { width: 40px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }

.input { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); transition: border-color 0.12s, box-shadow 0.12s; }
.input::placeholder { color: var(--faint); }
.input:hover { border-color: #c9d1dc; }
.input:focus { outline: none; border-color: var(--agent); box-shadow: 0 0 0 3px var(--agent-soft); }
.input:disabled { background: var(--hover); color: var(--muted); }
textarea.input { height: auto; padding: 10px 12px; line-height: 1.55; resize: vertical; }
textarea.prompt { min-height: 190px; font-size: 14px; }
select.input { appearance: none; padding-inline-end: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b6778' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-size: 16px; background-position: right 11px center; }
input[type="range"] { width: 100%; accent-color: var(--agent); height: 42px; }

.field { display: grid; gap: 6px; }
.field + .field, .grid2 + .field, .field + .grid2, .seg + .field, .field + .switch, .facts + .field { margin-top: 14px; }
.grid2 > .field + .field, .grid2 > .field { margin-top: 0; }
.field-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-height: 20px; }
.field-label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field-aside { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.field-aside output { color: var(--ink); }
.field-hint { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.field-error { font-size: 12.5px; color: var(--end-ink); }
.field.has-error .input { border-color: var(--end); box-shadow: 0 0 0 3px var(--end-soft); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; padding: 3px; border-radius: var(--r-sm); background: var(--sunk); }
.seg button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 4px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-weight: 500; font-size: 13.5px; cursor: pointer; }
.seg button:hover:not(:disabled) { color: var(--ink); }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(15, 27, 45, 0.1), 0 0 0 1px var(--line); }
.seg button:disabled { opacity: 0.4; cursor: not-allowed; }
.seg-tall button { flex-direction: column; align-items: flex-start; text-align: start; gap: 1px; padding: 9px 12px; }
.seg-tall .seg-label { font-size: 14px; }
.seg-hint { font-size: 12px; font-weight: 400; color: var(--muted); line-height: 1.35; }

.switch { display: flex; align-items: flex-start; gap: 12px; padding: 4px 0; cursor: pointer; }
.switch input { appearance: none; flex: none; width: 36px; height: 22px; margin: 1px 0 0; border-radius: var(--r-pill); background: #cdd4de; position: relative; cursor: pointer; transition: background-color 0.15s; }
.switch input::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(15, 27, 45, 0.25); transition: transform 0.15s; }
.switch input:checked { background: var(--agent); }
.switch input:checked::after { transform: translateX(14px); }
[dir="rtl"] .switch input:checked::after { transform: translateX(-14px); }
.switch-text { display: grid; gap: 1px; }
.switch-label { font-weight: 500; font-size: 14px; }
.switch-hint { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.switch.is-disabled { cursor: not-allowed; }
.switch.is-disabled input { opacity: 0.45; cursor: not-allowed; }
.switch.is-disabled .switch-label { color: var(--muted); }

.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--r-pill); background: var(--sunk); color: var(--ink-2); font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge-warn { background: var(--warn-soft); color: var(--warn-ink); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot-wait { background: var(--warn); }
.pill { display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 11px; border-radius: var(--r-pill); background: var(--sunk); color: var(--ink-2); font-size: 13px; font-weight: 500; white-space: nowrap; }
.pill-ok { background: var(--call-soft); color: var(--call-ink); }
.pill-ok .dot { background: var(--call); }
.pill-live { background: var(--call-soft); color: var(--call-ink); }
.pill-live .dot { background: var(--call); box-shadow: 0 0 0 3px rgba(14, 159, 110, 0.18); }
.pill-wait { background: var(--warn-soft); color: var(--warn-ink); }
.pill-wait .dot { background: var(--warn); animation: blink 1.2s ease-in-out infinite; }
.pill-bad { background: var(--end-soft); color: var(--end-ink); }
.pill-bad .dot { background: var(--end); }
@keyframes blink { 50% { opacity: 0.3; } }

/* ── Combobox ─────────────────────────────────────────────── */
.combo { position: relative; }
.combo-btn { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 6px 10px 6px 13px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); text-align: start; cursor: pointer; transition: border-color 0.12s; }
.combo-btn:hover { border-color: #c9d1dc; }
.combo.is-open .combo-btn { border-color: var(--agent); box-shadow: 0 0 0 3px var(--agent-soft); }
.combo-main { display: grid; flex: 1; min-width: 0; }
.combo-title { font-weight: 500; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-hint { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-btn.is-empty .combo-title { color: var(--faint); font-weight: 400; }
.combo-chev { color: var(--muted); transition: transform 0.15s; }
.combo.is-open .combo-chev { transform: rotate(180deg); }
.combo-pop { position: absolute; z-index: 40; inset-inline: 0; top: calc(100% + 6px); display: flex; flex-direction: column; max-height: min(400px, 62vh); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--pop); overflow: hidden; }
.combo-search { display: flex; align-items: center; gap: 8px; padding: 0 13px; border-bottom: 1px solid var(--line-soft); color: var(--muted); }
.combo-search input { flex: 1; min-width: 0; height: 44px; border: 0; outline: 0; background: transparent; }
.combo-list { overflow-y: auto; padding: 5px; }
.combo-group { padding: 10px 9px 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.combo-opt { display: flex; align-items: center; gap: 10px; padding: 8px 9px; border-radius: var(--r-xs); cursor: pointer; }
.combo-opt.is-active { background: var(--hover); }
.combo-opt.is-selected .combo-title { color: var(--agent-ink); }
.combo-tick { color: var(--agent); }
.combo-empty { padding: 18px 10px; text-align: center; color: var(--muted); font-size: 14px; }
.combo-play { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; }
.combo-play:hover { border-color: var(--agent); color: var(--agent); }
.combo-play.is-playing { background: var(--agent); border-color: var(--agent); color: #fff; }

/* ── Top bar and layout ───────────────────────────────────── */
.top { position: sticky; top: 0; z-index: 30; height: var(--top); display: flex; align-items: center; gap: 14px; padding: 0 14px 0 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 600; font-size: 16px; letter-spacing: -0.01em; white-space: nowrap; }
.top-fill { flex: 1; }
.line-status { max-width: 46vw; }
.line-name { overflow: hidden; text-overflow: ellipsis; }
.line-text { font-weight: 400; opacity: 0.85; }
.line-text::before { content: ""; display: inline-block; width: 3px; height: 3px; margin: 0 7px 3px 1px; border-radius: 50%; background: currentColor; opacity: 0.6; }
.top-nav { display: flex; gap: 2px; }
.top-link { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px; border-radius: var(--r-sm); color: var(--ink-2); font-weight: 500; font-size: 14px; }
.top-link:hover { background: var(--hover); color: var(--ink); }
.top-link[aria-current="page"] { background: var(--sunk); color: var(--ink); }
.top-user { display: inline-flex; align-items: center; gap: 8px; margin: 0; padding-inline-start: 12px; border-inline-start: 1px solid var(--line); }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--agent-soft); color: var(--agent-ink); font-weight: 600; font-size: 13px; }
.top-name { font-size: 14px; color: var(--ink-2); }

.layout { display: grid; grid-template-columns: 380px minmax(0, 1fr) 340px; height: calc(100dvh - var(--top)); }
.col { min-width: 0; overflow-y: auto; }
.col-setup { background: var(--surface); border-inline-end: 1px solid var(--line); }
.col-stage { padding: 28px 32px 40px; }
.col-recent { background: var(--surface); border-inline-start: 1px solid var(--line); }
.tabs { display: none; }

/* ── Setup ────────────────────────────────────────────────── */
.setup { padding-bottom: 32px; }
.scenario { position: sticky; top: 0; z-index: 5; padding: 16px 18px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.scenario-row { display: flex; align-items: center; gap: 4px; }
.scenario-pick { flex: 1; min-width: 0; }
.scenario-note { display: flex; align-items: center; gap: 7px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.scenario-name { display: flex; gap: 6px; margin-top: 10px; }
.scenario-name .input { height: 36px; }

.sec { border-bottom: 1px solid var(--line-soft); }
.sec-head { display: flex; align-items: center; padding-inline-end: 12px; }
.sec-toggle { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 15px 10px 15px 18px; border: 0; background: none; cursor: pointer; text-align: start; }
.sec-toggle:hover .sec-title { color: var(--agent-ink); }
.sec-icon { color: var(--faint); }
.sec.is-open .sec-icon { color: var(--agent); }
.sec-title { font-weight: 600; font-size: 14.5px; }
.sec-summary { flex: 1; min-width: 0; margin-inline-start: 4px; font-size: 13px; color: var(--muted); text-align: end; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sec-chev { margin-inline-start: auto; color: var(--faint); transition: transform 0.15s; }
.sec-summary + .sec-chev { margin-inline-start: 6px; }
.sec.is-open .sec-chev { transform: rotate(180deg); }
.sec-actions { display: inline-flex; gap: 2px; }
.sec-body { display: grid; gap: 0; padding: 2px 18px 20px; }
.sec-body > .seg + .field, .sec-body > .seg + .peek { margin-top: 14px; }
.section-lead { font-size: 13px; color: var(--muted); margin-bottom: 12px; line-height: 1.5; }

.facts { display: grid; gap: 7px; margin: 12px 0 0; padding: 12px 13px; border-radius: var(--r-sm); background: var(--hover); font-size: 13.5px; }
.facts > div { display: grid; grid-template-columns: 110px 1fr; gap: 10px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.facts-wide { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px 18px; padding: 14px 16px; margin: 0; }
.facts-wide > div { display: grid; grid-template-columns: none; gap: 2px; }
.facts-wide dd { font-weight: 500; }

.peek { margin-top: 12px; }
.peek summary { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; color: var(--agent-ink); font-weight: 500; font-size: 13.5px; list-style: none; }
.peek summary::-webkit-details-marker { display: none; }
.peek pre { margin: 10px 0 0; max-height: 300px; overflow: auto; padding: 12px 14px; border-radius: var(--r-sm); background: var(--hover); font: 13px/1.6 var(--font); white-space: pre-wrap; word-break: break-word; }

.products { display: grid; gap: 6px; }
.products-head, .products-row { display: grid; grid-template-columns: minmax(0, 1fr) 50px 88px 64px; gap: 6px; align-items: center; }
.product { display: grid; gap: 6px; }
.product + .product { padding-top: 6px; border-top: 1px dashed var(--line-soft); }
.product-actions { display: inline-flex; gap: 0; }
.product-actions .is-set { color: var(--agent); }
.input.product-link { height: 36px; font-size: 13.5px; }
.input.is-wrong { border-color: var(--end); box-shadow: 0 0 0 3px var(--end-soft); }
.group-title { display: flex; align-items: center; gap: 7px; margin: 20px 0 10px; font-size: 13px; font-weight: 600; color: var(--ink); }
.group-title .ic { color: var(--agent); }
.group-title + .grid2 { margin-top: 0; }
.grid2 + .grid2 { margin-top: 12px; }
.paste { display: grid; gap: 8px; justify-items: start; padding: 12px; border-radius: var(--r-sm); border: 1px dashed var(--line); }
.paste .field { width: 100%; }
.mono-ish { font-size: 13px; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.link-btn { border: 0; background: none; padding: 0; color: var(--agent-ink); font-weight: 500; font-size: 12.5px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.from-context { color: var(--agent-ink); font-weight: 500; }
.section-lead code { font-family: var(--font); font-weight: 600; color: var(--ink-2); }
.products-head { font-size: 12px; color: var(--muted); padding: 0 2px; }
.products-row .input { height: 38px; padding: 0 10px; font-size: 14px; }
.products-add { justify-self: start; margin-top: 2px; }
.context-status { margin-top: 14px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--agent-soft); color: var(--agent-ink); font-size: 13px; line-height: 1.45; }
.context-status.is-bad { background: var(--end-soft); color: var(--end-ink); }
.var-name { font-family: var(--font); font-weight: 600; color: var(--ink); }
.need { color: var(--warn-ink); font-weight: 500; }

/* ── The stage: dialling ──────────────────────────────────── */
.dial { max-width: 560px; margin: 4vh auto 0; text-align: center; }
.dial-kicker { font-size: 22px; font-weight: 600; letter-spacing: -0.015em; }
.dial-sub { margin-top: 4px; color: var(--muted); }
.dial-form { margin-top: 34px; display: grid; justify-items: center; }
.dial-number { display: block; width: 100%; }
.dial-number input { width: 100%; height: 76px; padding: 0 20px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); text-align: center; font-size: clamp(28px, 4vw, 40px); font-weight: 500; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; transition: border-color 0.12s, box-shadow 0.12s; }
.dial-number input::placeholder { color: #c3cad5; font-weight: 400; }
.dial-number input:focus { outline: none; border-color: var(--call); box-shadow: 0 0 0 4px var(--call-soft); }
.dial-as { margin-top: 10px; font-size: 13.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.call-btn { margin-top: 26px; display: inline-flex; align-items: center; justify-content: center; gap: 12px; height: 64px; min-width: 240px; padding: 0 34px; border: 0; border-radius: var(--r-pill); background: var(--call); color: #fff; font-size: 19px; font-weight: 600; cursor: pointer; box-shadow: 0 10px 24px rgba(14, 159, 110, 0.28); transition: background-color 0.12s, transform 0.08s, box-shadow 0.12s; }
.call-btn:hover:not(:disabled) { background: var(--call-hover); }
.call-btn:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
.call-btn:disabled { background: #a9b3c0; box-shadow: none; cursor: not-allowed; }
.checks { list-style: none; margin: 28px auto 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.checks li { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: var(--r-pill); font-size: 13px; }
.checks .is-ok { background: var(--surface); color: var(--ink-2); box-shadow: 0 0 0 1px var(--line); }
.checks .is-ok .ic { color: var(--call); }
.checks .is-bad { background: var(--warn-soft); color: var(--warn-ink); }
.dial-limits { margin-top: 18px; font-size: 12.5px; color: var(--faint); }

/* ── The stage: on the call ───────────────────────────────── */
.oncall, .ended { max-width: 820px; margin: 0 auto; display: grid; gap: 18px; }
.oncall-head { display: flex; align-items: center; gap: 16px; }
.ringer { position: relative; display: grid; place-items: center; flex: none; width: 56px; height: 56px; border-radius: 50%; background: var(--surface); color: var(--ink-2); box-shadow: 0 0 0 1px var(--line); }
.ringer::before, .ringer::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--call); opacity: 0; animation: ring 1.8s ease-out infinite; }
.ringer::after { animation-delay: 0.9s; }
.ringer.is-live { background: var(--call); color: #fff; box-shadow: none; }
.ringer.is-live::before, .ringer.is-live::after { animation: none; }
@keyframes ring { 0% { transform: scale(1); opacity: 0.6; } 100% { transform: scale(1.7); opacity: 0; } }
.oncall-who { flex: 1; min-width: 0; }
.oncall-number { font-size: 24px; font-weight: 600; letter-spacing: 0.01em; font-variant-numeric: tabular-nums; }
.oncall-state { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 2px; color: var(--muted); }
.oncall-clock { font-size: 40px; font-weight: 300; letter-spacing: -0.01em; color: var(--ink); }
.oncall-note { margin-top: -8px; font-size: 13.5px; color: var(--muted); text-align: center; }

.wave { position: relative; height: 170px; border-radius: var(--r-lg); background: var(--surface); box-shadow: 0 0 0 1px var(--line); overflow: hidden; }
.wave-canvas { display: block; width: 100%; height: 100%; -webkit-mask-image: linear-gradient(to right, transparent 0, #000 120px); mask-image: linear-gradient(to right, transparent 0, #000 120px); }
.wave-tag { position: absolute; inset-inline-start: 14px; font-size: 12px; font-weight: 500; }
.wave-tag-person { top: 10px; color: var(--wave-person); }
.wave-tag-agent { bottom: 10px; color: var(--agent-ink); }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 0; border-radius: var(--r-md); background: var(--surface); box-shadow: 0 0 0 1px var(--line); }
.metrics > div { padding: 12px 16px; }
.metrics > div + div { border-inline-start: 1px solid var(--line-soft); }
.metrics dt { font-size: 12px; color: var(--muted); }
.metrics dd { margin: 2px 0 0; font-size: 20px; font-weight: 500; font-variant-numeric: tabular-nums; }
.metrics dd.is-good { color: var(--call-ink); }
.metrics dd.is-slow { color: var(--warn-ink); }

.oncall-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.oncall-controls .hang { margin-inline-start: auto; min-width: 150px; }
.keypad { display: grid; grid-template-columns: repeat(3, 72px); gap: 8px; justify-content: center; }
.keypad button { height: 52px; border: 0; border-radius: var(--r-md); background: var(--surface); box-shadow: 0 0 0 1px var(--line); font-size: 20px; font-weight: 500; cursor: pointer; }
.keypad button:hover { background: var(--hover); }
.keypad button:active { background: var(--sunk); }
.cards { display: grid; gap: 8px; }
.card { padding: 11px 14px; border-radius: var(--r-sm); background: var(--agent-soft); color: var(--agent-ink); }
.card b { display: block; color: var(--ink); }

/* The conversation */
.talk { display: grid; gap: 12px; align-content: start; }
.talk-empty { padding: 30px 0 10px; text-align: center; color: var(--muted); font-size: 14px; }
.say { display: grid; gap: 4px; max-width: min(80%, 620px); }
.say-user { justify-self: end; justify-items: end; }
.say-who { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.say-text { padding: 10px 14px; border-radius: 16px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
.say-assistant .say-text { background: var(--surface); box-shadow: 0 0 0 1px var(--line); border-start-start-radius: 5px; }
.say-user .say-text { background: var(--ink); color: #fff; border-start-end-radius: 5px; }
.say.is-pending .say-text { opacity: 0.7; }
.react { display: inline-block; margin: 0 3px; padding: 0 7px; border-radius: var(--r-pill); background: var(--agent-soft); color: var(--agent-ink); font-size: 12px; font-weight: 500; line-height: 1.7; vertical-align: 1px; }
.say-user .react { background: rgba(255, 255, 255, 0.16); color: #fff; }

/* ── The stage: after the call ────────────────────────────── */
.ended-head { display: grid; justify-items: center; gap: 6px; padding: 26px 20px 22px; text-align: center; border-radius: var(--r-lg); background: var(--surface); box-shadow: 0 0 0 1px var(--line); }
.outcome { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: var(--r-pill); font-size: 13px; font-weight: 600; }
.outcome-ok { background: var(--call-soft); color: var(--call-ink); }
.outcome-bad { background: var(--end-soft); color: var(--end-ink); }
.outcome-idle { background: var(--sunk); color: var(--ink-2); }
.ended-number { margin-top: 6px; font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ended-meta { color: var(--muted); max-width: 520px; }
.ended-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 14px; }

.insight { display: grid; gap: 12px; padding: 18px 20px; border-radius: var(--r-lg); background: var(--surface); box-shadow: 0 0 0 1px var(--line); }
.insight-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.insight-head h3 { font-size: 16px; }
.insight-text { line-height: 1.65; }
.insight-wait { color: var(--muted); font-size: 14px; text-align: center; padding: 4px 0; }
.insight-line { font-size: 14px; color: var(--ink-2); }
.insight .facts-wide { background: var(--hover); }
.kv { width: 100%; border-collapse: collapse; font-size: 14px; }
.kv caption { text-align: start; font-weight: 600; font-size: 13px; color: var(--ink-2); padding-bottom: 6px; }
.kv th, .kv td { padding: 8px 0; border-top: 1px solid var(--line-soft); text-align: start; vertical-align: top; }
.kv th { width: 36%; font-weight: 500; color: var(--muted); padding-inline-end: 12px; }
.kv-why { display: block; font-size: 12.5px; }

.events { max-width: 820px; margin: 34px auto 0; }
.events summary { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; font-weight: 500; color: var(--ink-2); list-style: none; }
.events summary::-webkit-details-marker { display: none; }
.events summary .muted { font-weight: 400; font-size: 12.5px; }
.log { margin: 10px 0 0; max-height: 300px; overflow: auto; padding: 12px 14px; border-radius: var(--r-md); background: #121c2b; color: #c7d0dc; font: 12px/1.6 ui-monospace, "SF Mono", Menlo, monospace; white-space: pre-wrap; word-break: break-word; }
.log-sip { color: #f0c987; } .log-err { color: #ff9b95; } .log-me { color: #a8dcd1; } .log-ev { color: #b9e3a8; } .log-dc { color: #bcc6f5; }

/* ── Recent calls ─────────────────────────────────────────── */
.recent { padding: 16px 0 32px; }
.recent-head { display: flex; align-items: center; justify-content: space-between; padding: 0 16px 0 18px; }
.recent-head h2 { font-size: 16px; }
.recent-tools { display: grid; gap: 8px; padding: 12px 16px 10px 18px; }
.search { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 11px; border-radius: var(--r-sm); background: var(--hover); color: var(--muted); }
.search:focus-within { box-shadow: 0 0 0 2px var(--agent-soft); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 14px; }
.recent-empty { display: grid; justify-items: center; gap: 10px; margin: 30px 22px; text-align: center; color: var(--muted); font-size: 14px; }
.recent .empty-note { padding: 8px 18px; }
.calls { list-style: none; margin: 0; padding: 4px 8px; display: grid; gap: 1px; }
.calls-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 10px; border: 0; border-radius: var(--r-sm); background: none; text-align: start; cursor: pointer; }
.calls-row:hover { background: var(--hover); }
.calls-row.is-current { background: var(--agent-soft); }
.calls-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.calls-dot.is-ok { background: var(--call); }
.calls-dot.is-bad { background: #c3cad5; }
.calls-main { display: grid; flex: 1; min-width: 0; }
.calls-number { font-weight: 500; font-size: 14.5px; }
.calls-what { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.calls-side { display: grid; justify-items: end; flex: none; }
.calls-when { font-size: 12px; color: var(--muted); }
.calls-len { font-size: 13px; color: var(--ink-2); }

/* ── Sheet, toasts ────────────────────────────────────────── */
.sheet-layer { position: fixed; inset: 0; z-index: 60; display: flex; justify-content: flex-end; }
.sheet-scrim { position: absolute; inset: 0; border: 0; background: rgba(15, 27, 45, 0.32); cursor: default; }
.sheet { position: relative; display: flex; flex-direction: column; width: min(520px, 100%); height: 100%; background: var(--mist); box-shadow: var(--pop); animation: slide 0.2s ease-out; outline: none; }
@keyframes slide { from { transform: translateX(24px); opacity: 0.4; } }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 14px 22px; background: var(--surface); border-bottom: 1px solid var(--line); }
.sheet-title { flex: 1; display: grid; font-size: 18px; font-weight: 600; }
.sheet-sub { font-size: 13px; font-weight: 400; color: var(--muted); }
.sheet-body { flex: 1; overflow-y: auto; padding: 20px 22px 28px; display: grid; gap: 16px; align-content: start; }
.sheet-foot { padding: 14px 22px; background: var(--surface); border-top: 1px solid var(--line); }
.sheet-foot .btn { width: 100%; }
.sheet-h { font-size: 15px; margin-top: 4px; }
.ref { font-size: 12.5px; color: var(--faint); }

.toasts { position: fixed; z-index: 80; inset-inline: 0; bottom: 20px; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { display: flex; align-items: flex-start; gap: 10px; width: min(520px, 100%); padding: 12px 12px 12px 14px; border-radius: var(--r-md); background: var(--ink); color: #fff; box-shadow: var(--pop); pointer-events: auto; animation: rise 0.2s ease-out; font-size: 14px; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.toast-error .ic { color: #ff9b95; }
.toast-ok .ic { color: #7fe0b8; }
.toast-info .ic { color: #b8b1ff; }
.toast .ic { margin-top: 2px; }
.toast-text { flex: 1; line-height: 1.5; }
.toast-x { border: 0; background: none; color: #fff; opacity: 0.6; cursor: pointer; padding: 2px; }
.toast-x:hover { opacity: 1; }

/* ── Settings ─────────────────────────────────────────────── */
.settings { max-width: 860px; margin: 0 auto; padding: 32px 20px 80px; }
.settings h1 { font-size: 26px; }
.settings-lead { margin-top: 6px; color: var(--muted); }
.panel { margin-top: 24px; padding: 22px 24px 24px; border-radius: var(--r-lg); background: var(--surface); box-shadow: 0 0 0 1px var(--line); }
.panel h2 { display: flex; align-items: center; gap: 9px; font-size: 17px; }
.panel h2 .ic { color: var(--agent); }
.panel-lead { margin: 4px 0 16px; font-size: 14px; color: var(--muted); }
.panel-sub { margin: 22px 0 10px; font-size: 15px; }
.panel-actions { display: flex; gap: 10px; margin-top: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid .field + .field { margin-top: 0; }
.key-row { display: grid; grid-template-columns: 130px 1fr 150px; gap: 12px; align-items: center; padding: 8px 0; }
.key-name { font-weight: 500; }
.people { list-style: none; margin: 0; padding: 0; }
.people-row { display: grid; grid-template-columns: minmax(0, 1fr) 80px 150px 300px; gap: 12px; align-items: center; min-height: 52px; padding: 8px 0; border-top: 1px solid var(--line-soft); }
.people-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.people-actions { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; align-items: center; }
.inline-form { display: inline-flex; gap: 6px; }
.inline-form .input { height: 34px; width: 190px; }

/* ── Sign-in ──────────────────────────────────────────────── */
.login-body { background: var(--surface); }
.login { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100dvh; }
.login-intro { display: grid; align-content: center; gap: 22px; padding: 56px; background: var(--agent-soft); }
.login-wave { display: flex; align-items: center; gap: 6px; height: 120px; }
.login-wave span { width: 7px; height: 100%; border-radius: 4px; background: var(--agent); transform-origin: center; animation: talk 1.6s ease-in-out infinite; }
.login-wave span:nth-child(3n) { animation-delay: -0.4s; }
.login-wave span:nth-child(3n + 1) { animation-delay: -0.9s; }
.login-wave span:nth-child(4n) { animation-delay: -1.2s; background: var(--ink-2); }
.login-wave span:nth-child(5n) { animation-delay: -0.2s; }
@keyframes talk { 0%, 100% { transform: scaleY(0.12); } 50% { transform: scaleY(0.85); } }
.login-quote { font-size: 26px; line-height: 1.6; color: var(--ink); max-width: 30ch; }
.login-quote-en { color: var(--agent-ink); font-size: 15px; max-width: 46ch; }
.login-box { align-self: center; justify-self: center; width: min(400px, 100% - 32px); display: grid; gap: 0; padding: 40px 0; }
.login-box .brand { margin-bottom: 30px; }
.login-box h1 { font-size: 26px; }
.login-lead { margin: 6px 0 20px; color: var(--muted); }
.login-box .field + .field { margin-top: 14px; }
.login-go { width: 100%; margin-top: 24px; }
.login-message { margin: 0 0 14px; padding: 11px 13px; border-radius: var(--r-sm); background: var(--end-soft); color: var(--end-ink); font-size: 14px; }
.login-message.is-info { background: var(--agent-soft); color: var(--agent-ink); }
.login-foot { margin-top: 16px; font-size: 13px; color: var(--muted); }

/* ── Smaller screens ──────────────────────────────────────── */
@media (max-width: 1279px) {
  .layout { grid-template-columns: 360px minmax(0, 1fr); grid-template-rows: auto 1fr; height: auto; min-height: calc(100dvh - var(--top)); }
  .col-setup { grid-row: 1 / span 2; position: sticky; top: var(--top); height: calc(100dvh - var(--top)); }
  .col { overflow: visible; }
  .col-setup { overflow-y: auto; }
  .col-recent { border-inline-start: 0; border-top: 1px solid var(--line); background: var(--surface); }
}
@media (max-width: 899px) {
  :root { --top: 56px; }
  .layout { display: block; min-height: 0; padding-bottom: calc(var(--tabs) + env(safe-area-inset-bottom)); }
  .col, .col-setup { display: none; height: auto; position: static; border: 0; overflow: visible; }
  .layout.tab-setup .col-setup, .layout.tab-call .col-stage, .layout.tab-calls .col-recent { display: block; }
  .col-stage { padding: 18px 16px 28px; }
  .col-recent { min-height: calc(100dvh - var(--top) - var(--tabs)); }
  .scenario { top: var(--top); }
  .tabs { position: fixed; z-index: 30; inset-inline: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr); height: calc(var(--tabs) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); }
  .tab { display: grid; justify-items: center; align-content: center; gap: 3px; border: 0; background: none; color: var(--muted); font-size: 12px; font-weight: 500; cursor: pointer; }
  .tab.is-on { color: var(--ink); }
  .tab.is-on .ic { color: var(--agent); }
  .tab.is-live { color: var(--call-ink); }
  .tab.is-live .ic { color: var(--call); }
  .toasts { bottom: calc(var(--tabs) + 12px + env(safe-area-inset-bottom)); }
  .top { padding: 0 8px 0 16px; gap: 8px; }
  .line-name, .top-name, .top-link span, .events summary .muted { display: none; }
  .line-text::before { display: none; }
  .top-user { padding-inline-start: 6px; }
  .dial { margin-top: 10px; }
  .dial-form { margin-top: 24px; }
  .call-btn { width: 100%; }
  .oncall-head { gap: 12px; }
  .oncall-number { font-size: 19px; }
  .oncall-clock { font-size: 30px; }
  .wave { height: 130px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics > div:nth-child(3) { border-inline-start: 0; }
  .metrics > div:nth-child(n + 3) { border-top: 1px solid var(--line-soft); }
  .oncall-controls .hang { flex: 1 1 100%; margin: 0; }
  .say { max-width: 90%; }
  .login { grid-template-columns: 1fr; }
  .login-intro { display: none; }
  .form-grid, .grid2 { grid-template-columns: 1fr; }
  .key-row, .people-row { grid-template-columns: 1fr; gap: 6px; }
  .people-actions { justify-content: flex-start; }
  .panel { padding: 18px 16px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .login-wave span { transform: scaleY(0.5); }
}

/* The quick setup: three steps, then every other setting folded. */
.step { display: grid; gap: 12px; padding: 16px 18px 18px; border-bottom: 1px solid var(--line-soft); }
.step-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.step-n { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: var(--r-pill); background: var(--agent-soft); color: var(--agent-ink); font-size: 12px; font-weight: 600; }
.step-title { margin: 0; font-size: 14.5px; font-weight: 600; }
.step-hint { margin-inline-start: auto; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step .field + .field, .step .seg + .field { margin-top: 0; }
.link-row { display: flex; gap: 8px; }
.link-row .input { flex: 1; min-width: 0; }
.page-card { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.page-card-top { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); }
.page-card-title { flex: 1; min-width: 0; color: var(--ink); font-weight: 500; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-card-price { flex: none; font-size: 13px; font-weight: 600; color: var(--ink); }
.page-card-text { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link-btn { flex: none; padding: 0; border: 0; background: none; color: var(--agent-ink); font: inherit; font-size: 12.5px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.input.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; line-height: 1.5; }
.sub-title { margin: 18px 0 10px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.sub-title:first-child { margin-top: 4px; }
.examples { display: inline-flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); }
