/* Console, 2026 design system. Brand tokens live on :root so white-label themes replace values, not rules.
   Order: tokens and themes, base, app shell, components, workspace, then the page-specific rules.
   Layout is written in logical properties so Arabic mirrors it (the a11y test fails on left/right). */
:root {
  /* Colour: Ringura primary #2147c6 (light) and #8eaaff (dark); accent teal #0b6e5c and #5fd3b6. */
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-sunken: #f2f2f4;
  --text: #0f1115;
  --muted: #5b616e;
  --border: #e7e7ea;
  --border-strong: #d4d4d8;
  /* WCAG 1.4.11: the edge of a field or button keeps 3:1 against the page and cards. */
  --control-border: #7d879b;
  --accent: #2147c6;
  --accent-text: #ffffff;
  --accent-hover: #1a39a3;
  --accent-soft: #eef1fd;
  --teal: #0b6e5c;
  --teal-soft: #dff3ee;
  --danger: #b3261e;
  --danger-text: #ffffff;
  --danger-soft: #fdecea;
  --ok: #17683a;
  --ok-soft: #e3f4e8;
  --warn: #7a4e00;
  --warn-soft: #fff1cf;
  --call: #17803f;
  --call-hover: #126a33;
  --call-text: #ffffff;
  --ring: rgba(33, 71, 198, 0.16);
  /* WCAG 1.4.11: the focus ring keeps 3:1 against the page and cards; its 2px offset puts it beside
     those, never on a filled (accent) button. */
  --focus: #2147c6;
  --inverse-bg: #1b2030;
  --inverse-text: #f1f3f9;
  --row-hover: #f4f4f6;
  --scrim: rgba(12, 16, 28, 0.5);
  --bubble-in: #f0f0f3;
  --bubble-out: #e3eaff;
  /* Type scale (1.125 steps around a 15px body) and families: the system stack, no downloads. */
  --font: "Inter Variable", "Inter", "Geist", "Segoe UI Variable Text", system-ui, -apple-system, "Segoe UI Variable", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-md: 0.9375rem;
  --fs-lg: 1.0625rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.625rem;
  --fs-3xl: 2.125rem;
  /* Spacing on an 8px grid, with a 4px half step. */
  --sp-half: 4px;
  --sp-1: 8px;
  --sp-2: 16px;
  --sp-3: 24px;
  --sp-4: 32px;
  --sp-5: 48px;
  --sp-6: 64px;
  --gap: 16px;
  /* Radius, elevation, motion. */
  --radius: 8px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-pill: 999px;
  --sh-1: 0 1px 2px rgba(19, 23, 34, 0.06), 0 1px 1px rgba(19, 23, 34, 0.04);
  --sh-2: 0 6px 20px rgba(19, 23, 34, 0.12), 0 1px 3px rgba(19, 23, 34, 0.08);
  --sh-3: 0 24px 64px rgba(12, 16, 28, 0.28);
  --dur-fast: 120ms;
  --dur: 200ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  /* Shell dimensions. */
  --sb-w: 264px;
  --topbar-h: 56px;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #09090b;
    --surface: #131316;
    --surface-sunken: #0c0c0e;
    --text: #ededf0;
    --muted: #a1a3ad;
    --border: #26262c;
    --border-strong: #303037;
    --control-border: #78839a;
    --accent: #8eaaff;
    --accent-text: #0a1230;
    --accent-hover: #a9bfff;
    --accent-soft: #172042;
    --teal: #5fd3b6;
    --teal-soft: #11302a;
    --danger: #ff8a80;
    --danger-text: #3a0300;
    --danger-soft: #3a1618;
    --ok: #7bd88f;
    --ok-soft: #12301c;
    --warn: #f0b64a;
    --warn-soft: #33260a;
  --call: #4cc27a;
  --call-hover: #6bd493;
  --call-text: #04210f;
  --ring: rgba(142, 170, 255, 0.22);
    --focus: #8eaaff;
    --inverse-bg: #e8ebf3;
    --inverse-text: #09090b;
    --row-hover: #18181c;
    --scrim: rgba(2, 4, 10, 0.66);
    --bubble-in: #1b1b20;
    --bubble-out: #1c2a52;
    --sh-1: 0 1px 2px rgba(0, 0, 0, 0.5);
    --sh-2: 0 8px 24px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.04);
    --sh-3: 0 24px 64px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05);
    color-scheme: dark;
  }
}
/* The user's own choice (the appearance menu, kept in localStorage) wins over the system setting. */
:root[data-theme="light"] {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-sunken: #f2f2f4;
  --text: #0f1115;
  --muted: #5b616e;
  --border: #e7e7ea;
  --border-strong: #d4d4d8;
  --control-border: #7d879b;
  --accent: #2147c6;
  --accent-text: #ffffff;
  --accent-hover: #1a39a3;
  --accent-soft: #eef1fd;
  --teal: #0b6e5c;
  --teal-soft: #dff3ee;
  --danger: #b3261e;
  --danger-text: #ffffff;
  --danger-soft: #fdecea;
  --ok: #17683a;
  --ok-soft: #e3f4e8;
  --warn: #7a4e00;
  --warn-soft: #fff1cf;
  --call: #17803f;
  --call-hover: #126a33;
  --call-text: #ffffff;
  --ring: rgba(33, 71, 198, 0.16);
  --focus: #2147c6;
  --inverse-bg: #1b2030;
  --inverse-text: #f1f3f9;
  --row-hover: #f4f4f6;
  --scrim: rgba(12, 16, 28, 0.5);
  --bubble-in: #f0f0f3;
  --bubble-out: #e3eaff;
  --sh-1: 0 1px 2px rgba(19, 23, 34, 0.06), 0 1px 1px rgba(19, 23, 34, 0.04);
  --sh-2: 0 6px 20px rgba(19, 23, 34, 0.12), 0 1px 3px rgba(19, 23, 34, 0.08);
  --sh-3: 0 24px 64px rgba(12, 16, 28, 0.28);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #09090b;
  --surface: #131316;
  --surface-sunken: #0c0c0e;
  --text: #ededf0;
  --muted: #a1a3ad;
  --border: #26262c;
  --border-strong: #303037;
  --control-border: #78839a;
  --accent: #8eaaff;
  --accent-text: #0a1230;
  --accent-hover: #a9bfff;
  --accent-soft: #172042;
  --teal: #5fd3b6;
  --teal-soft: #11302a;
  --danger: #ff8a80;
  --danger-text: #3a0300;
  --danger-soft: #3a1618;
  --ok: #7bd88f;
  --ok-soft: #12301c;
  --warn: #f0b64a;
  --warn-soft: #33260a;
  --call: #4cc27a;
  --call-hover: #6bd493;
  --call-text: #04210f;
  --ring: rgba(142, 170, 255, 0.22);
  --focus: #8eaaff;
  --inverse-bg: #e8ebf3;
  --inverse-text: #09090b;
  --row-hover: #18181c;
  --scrim: rgba(2, 4, 10, 0.66);
  --bubble-in: #1b1b20;
  --bubble-out: #1c2a52;
  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.5);
  --sh-2: 0 8px 24px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --sh-3: 0 24px 64px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05);
  color-scheme: dark;
}
html[data-sidebar="collapsed"] { --sb-w: 72px; }

/* ---- Base ------------------------------------------------------------------------------ */
* { box-sizing: border-box; }
/* WCAG 2.4.11: a control scrolled to by focus is not hidden under the fixed toast or the call dock. */
html { scroll-padding-block: 72px 120px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: var(--fs-md); -webkit-font-smoothing: antialiased; }
/* WCAG 2.5.8: the padding gives a lone link the 24px target an inline box would not have. */
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; padding-block: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
/* Codes, numbers and ids keep their own direction inside right-to-left text. */
code, .mono, time, .secret { unicode-bidi: isolate; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-sunken); border-radius: var(--r-sm); padding: 1px 6px; }
kbd { font-family: var(--mono); font-size: var(--fs-xs); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: var(--r-sm); padding: 1px 6px; color: var(--muted); background: var(--surface); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.skip-link { position: absolute; inset-inline-start: 8px; top: 8px; background: var(--surface); color: var(--text); padding: 8px 12px; border-radius: var(--r-md); box-shadow: var(--sh-2); z-index: 100; transform: translateY(-200%); }
.skip-link:focus { transform: none; }

h1 { font-size: var(--fs-2xl); line-height: 1.25; letter-spacing: -0.015em; font-weight: 700; margin: 0 0 var(--sp-2); }
h2 { font-size: var(--fs-lg); line-height: 1.3; letter-spacing: -0.005em; font-weight: 650; margin: var(--sp-3) 0 var(--sp-1); }
h3 { font-size: var(--fs-md); font-weight: 650; margin: 0 0 var(--sp-half); }
p { margin-block: 0 var(--sp-1); }
.muted, .meta { color: var(--muted); }
.meta { font-size: var(--fs-sm); margin: 2px 0; }
.error { color: var(--danger); min-height: 1.5em; }

/* ---- App shell -------------------------------------------------------------------------- */
.app { display: grid; grid-template-columns: var(--sb-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns var(--dur) var(--ease); }
body:not(.authed) .app { grid-template-columns: minmax(0, 1fr); }
/* The sidebar column is painted for the full height of a long page; the sidebar inside it is sticky and scrolls on its own. */
body.authed .app::before { content: ""; grid-column: 1; grid-row: 1; background: var(--surface); border-inline-end: 1px solid var(--border); }
body.authed .app > .sidebar, body.authed .app > .app-main { grid-row: 1; }
body.authed .app > .sidebar { grid-column: 1; }
body.authed .app > .app-main { grid-column: 2; }
.app-main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }

.sidebar { position: sticky; top: 0; height: 100vh; max-height: 100dvh; overflow: hidden; align-self: start; display: flex; flex-direction: column; background: var(--surface); border-inline-end: 1px solid var(--border); z-index: 30; min-width: 0; }
.sb-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: var(--topbar-h); padding-inline: 16px 12px; border-block-end: 1px solid var(--border); flex: none; }
.sb-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: var(--fs-lg); letter-spacing: -0.01em; min-width: 0; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 9px; background: var(--accent); color: var(--accent-text); font-weight: 800; font-size: 1rem; line-height: 1; }
.sb-scroll { flex: 1; overflow-y: auto; padding: 12px 12px 24px; overscroll-behavior: contain; }
.nav { list-style: none; margin: 0; padding: 0; }
.nav ul { list-style: none; margin: 0; padding: 0; }
.nav-group + .nav-group { margin-block-start: 12px; }
.nav-group-label { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 28px; padding: 4px 10px; border: 0; background: transparent; color: var(--muted); font-size: var(--fs-xs); font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; border-radius: var(--r-sm); cursor: pointer; }
.nav-group-label:hover { color: var(--text); background: var(--row-hover); }
.nav-chevron { width: 14px; height: 14px; transition: transform var(--dur) var(--ease); }
.nav-group.is-folded .nav-chevron { transform: rotate(-90deg); }
[dir="rtl"] .nav-group.is-folded .nav-chevron { transform: rotate(90deg); }
.nav-group.is-folded > ul { display: none; }
.nav a { position: relative; display: flex; align-items: center; gap: 12px; min-height: 24px; padding: 8px 10px; margin-block: 1px; border-radius: var(--r-md); color: var(--text); text-decoration: none; font-size: var(--fs-md); font-weight: 500; transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
.nav a .icon { color: var(--muted); }
.nav a:hover { background: var(--row-hover); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.nav a[aria-current="page"] .icon { color: var(--accent); }
.nav-link .badge.unread { margin-inline-start: auto; }

/* Collapsed rail: icons only; the names stay in the page for screen readers and as tooltips. */
html[data-sidebar="collapsed"] .nav-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
html[data-sidebar="collapsed"] .sb-head { flex-direction: column; height: auto; padding: 12px 8px; justify-content: center; }
html[data-sidebar="collapsed"] .nav-group-label { min-height: 8px; height: 8px; padding: 0; margin-block: 6px; border-radius: 0; border-block-start: 1px solid var(--border); pointer-events: none; }
html[data-sidebar="collapsed"] .nav-group:first-child .nav-group-label { border-block-start: 0; }
html[data-sidebar="collapsed"] .nav-chevron { display: none; }
html[data-sidebar="collapsed"] .nav-group.is-folded > ul { display: block; }
html[data-sidebar="collapsed"] .nav a { justify-content: center; padding-inline: 0; }
html[data-sidebar="collapsed"] .nav-link .badge.unread { position: absolute; inset-block-start: 2px; inset-inline-end: 6px; margin: 0; padding: 0 5px; font-size: 0.65rem; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; height: var(--topbar-h); padding-inline: var(--sp-3); background: var(--surface); border-block-end: 1px solid var(--border); }
.top-spacer { flex: 1; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0; min-width: 44px; border-color: transparent; background: transparent; color: var(--text); }
.icon-btn:hover { background: var(--row-hover); border-color: transparent; }
.icon-btn[aria-pressed="true"], .icon-btn[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); }
.menu-btn { display: none; }
.logout { padding-inline: 10px; font-weight: 500; flex: none; white-space: nowrap; }
.sb-collapse { color: var(--muted); }
.cmd-trigger { display: inline-flex; align-items: center; gap: 10px; flex: 0 1 380px; min-width: 0; justify-content: flex-start; padding-inline: 12px; background: var(--surface-sunken); color: var(--muted); border-color: var(--border-strong); font-weight: 400; }
.cmd-trigger:hover { background: var(--row-hover); color: var(--text); }
.cmd-text { flex: 1; text-align: start; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-size: var(--fs-sm); min-width: 0; }
.who-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 22ch; }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--teal-soft); color: var(--teal); font-size: var(--fs-xs); font-weight: 700; flex: none; }
.tenant-chip { display: inline-flex; align-items: center; gap: 8px; max-width: 220px; flex: 0 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 5px 12px; border: 1px solid var(--border-strong); border-radius: var(--r-pill); color: var(--text); text-decoration: none; font-size: var(--fs-sm); font-weight: 500; }
a.tenant-chip:hover { background: var(--row-hover); }
.tenant-chip .icon { width: 16px; height: 16px; color: var(--muted); }
.tenant-chip.acting { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.tenant-chip.acting .icon { color: var(--warn); }
.chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px; border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: 600; background: var(--surface-sunken); color: var(--muted); white-space: nowrap; }
.pill-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill[data-kind="ok"] { background: var(--ok-soft); color: var(--ok); }
.pill[data-kind="warn"] { background: var(--warn-soft); color: var(--warn); }
.pill[data-kind="off"] { background: var(--surface-sunken); color: var(--muted); }
.appearance { position: relative; display: inline-flex; }
.popover { position: absolute; inset-block-start: calc(100% + 8px); inset-inline-end: 0; z-index: 40; min-width: 280px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-2); display: grid; gap: 12px; }
.seg-row { display: grid; gap: 6px; }
.seg-label { font-size: var(--fs-xs); font-weight: 650; color: var(--muted); letter-spacing: 0.04em; }
.seg { display: inline-flex; background: var(--surface-sunken); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.seg button { flex: 1; min-height: 32px; padding: 4px 10px; border: 0; background: transparent; border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: var(--sh-1); color: var(--accent); font-weight: 650; }
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 45; }
.acting { padding: 8px var(--sp-3); background: var(--warn-soft); color: var(--warn); font-weight: 500; border-block-end: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.acting .link-button { color: var(--warn); }
.estop { padding: 8px var(--sp-3); background: var(--danger-soft, #fde8e8); color: var(--danger, #9b1c1c); font-weight: 600; border-block-end: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.estop a { color: inherit; text-decoration: underline; }

main { flex: 1; width: 100%; max-width: 1280px; margin-inline: auto; padding: var(--sp-3) var(--sp-4) var(--sp-5); }
main:focus { outline: none; }
body:not(.authed) .app-main { justify-content: center; }
body:not(.authed) { background: radial-gradient(900px 420px at 50% -80px, var(--accent-soft), transparent 70%), var(--bg); }
body:not(.authed) main { flex: none; max-width: 480px; padding-block: var(--sp-4); }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.01em; margin-block: 0 var(--sp-2); }
.auth-brand .brand-mark { width: 40px; height: 40px; border-radius: 12px; font-size: 1.25rem; }

/* The command palette (Ctrl+K). */
.palette { width: min(640px, 94vw); max-height: 70vh; margin-block: 12vh auto; padding: 0; border: 1px solid var(--border-strong); border-radius: var(--r-lg); background: var(--surface); color: var(--text); box-shadow: var(--sh-3); overflow: hidden; }
.palette[open] { display: flex; flex-direction: column; }
.palette::backdrop { background: var(--scrim); }
.cmd-head { display: flex; align-items: center; gap: 12px; padding: 4px 16px; border-block-end: 1px solid var(--border); color: var(--muted); }
.cmd-input { flex: 1; border: 0; background: transparent; font-size: var(--fs-lg); padding: 14px 0; min-height: 52px; }
.cmd-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.cmd-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-md); cursor: pointer; }
.cmd-item .icon { color: var(--muted); }
.cmd-item[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.cmd-item[aria-selected="true"] .icon, .cmd-item[aria-selected="true"] .cmd-group { color: var(--accent); }
.cmd-label { flex: 1; font-weight: 500; }
.cmd-group { color: var(--muted); font-size: var(--fs-xs); }
.cmd-empty { padding: 24px; text-align: center; color: var(--muted); }
.cmd-foot { margin: 0; padding: 8px 16px; border-block-start: 1px solid var(--border); font-size: var(--fs-xs); color: var(--muted); }

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  body.authed .app::before { display: none; }
  body.authed .app > .app-main { grid-column: 1; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: min(300px, 86vw); transform: translateX(-100%); visibility: hidden; transition: transform var(--dur) var(--ease), visibility 0s linear var(--dur); z-index: 50; box-shadow: var(--sh-3); }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  body.nav-open .sidebar { transform: none; visibility: visible; transition-delay: 0s; }
  html[data-sidebar="collapsed"] .nav-text { position: static; width: auto; height: auto; clip: auto; overflow: visible; white-space: normal; }
  html[data-sidebar="collapsed"] .sb-head { flex-direction: row; height: var(--topbar-h); padding: 0 12px 0 16px; justify-content: space-between; }
  html[data-sidebar="collapsed"] .nav-group-label { min-height: 28px; height: auto; padding: 4px 10px; pointer-events: auto; border: 0; margin: 0; }
  html[data-sidebar="collapsed"] .nav-chevron { display: block; }
  html[data-sidebar="collapsed"] .nav a { justify-content: flex-start; padding-inline: 10px; }
  .sb-collapse { display: none; }
  .menu-btn { display: inline-flex; }
  .topbar { padding-inline: var(--sp-1); }
  main { padding: var(--sp-2) var(--sp-2) var(--sp-4); }
  .cmd-kbd { display: none; }
  .tenant-chip { max-width: 140px; }
  .who-text { display: none; }
}
@media (max-width: 640px) {
  .cmd-trigger { flex: 0 0 40px; padding-inline: 0; justify-content: center; }
  .cmd-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; flex: none; }
  .logout .btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .who { display: none; }
  .topbar { gap: 4px; padding-inline: 4px; overflow-x: clip; }
  .topbar .icon-btn { min-width: 40px; }
  .cmd-trigger { min-width: 40px; }
  .lang-picker { padding-inline: 2px; max-width: 96px; }
  .tenant-chip .chip-text { display: none; }
  .tenant-chip { padding: 6px 8px; }
  .pill { padding-inline: 8px; }
  .pill-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .top-spacer { flex: 1 1 0; }
  .popover { position: fixed; inset-inline: 12px; inset-block-start: calc(var(--topbar-h) + 4px); min-width: 0; }
}

/* ---- Components ------------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-3); margin-bottom: var(--gap); box-shadow: var(--sh-1); }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.narrow { max-width: 440px; margin: 0 auto var(--gap); padding: var(--sp-4); box-shadow: var(--sh-2); }
.narrow h1 { font-size: var(--fs-xl); }

label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: var(--fs-sm); }
input { width: 100%; padding: 8px 12px; min-height: 44px; font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--control-border); border-radius: var(--r-md); transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease); }
input:hover { border-color: var(--muted); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input[type="checkbox"], input[type="radio"] { width: 24px; height: 24px; min-height: 24px; padding: 0; accent-color: var(--accent); }
input[type="range"] { padding: 0; }
button { font: inherit; font-weight: 600; font-size: var(--fs-md); padding: 8px 16px; border-radius: var(--r-md); border: 1px solid var(--control-border); background: var(--surface); color: var(--text); cursor: pointer; min-height: 44px; transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease); }
button:hover:not(:disabled) { background: var(--row-hover); border-color: var(--text); }
button:active:not(:disabled) { background: var(--surface-sunken); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); box-shadow: var(--sh-1); }
button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { color: var(--danger); border-color: var(--danger); }
button.danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }
.link-button { background: none; border: none; color: var(--accent); text-decoration: underline; padding: 4px; min-height: 0; font-weight: 500; }
.link-button:hover:not(:disabled) { background: none; text-decoration-thickness: 2px; }
form button[type="submit"] { margin-top: 16px; width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.button-link { display: inline-flex; align-items: center; padding: 8px 16px; min-height: 44px; border-radius: var(--r-md); border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text); text-decoration: none; font-weight: 600; }
.button-link:hover { background: var(--accent-hover); }
textarea { font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--control-border); border-radius: var(--r-md); padding: 10px 12px; width: 100%; min-height: 44px; resize: vertical; }
textarea:hover { border-color: var(--muted); }
select, input[type="date"], input[type="file"] { font: inherit; min-height: 44px; max-width: 100%; }
select { color: inherit; background: var(--surface); border: 1px solid var(--control-border); border-radius: var(--r-md); padding: 0 10px; }
select:hover { border-color: var(--muted); }
input[type="file"] { padding: 6px 8px; height: auto; }
fieldset { border: 1px solid var(--border); border-radius: var(--r-md); }
legend { padding: 0 6px; font-weight: 600; font-size: var(--fs-sm); }
progress { accent-color: var(--accent); }
@media (pointer: fine) {
  button, select, input, input[type="date"] { min-height: 36px; }
  input[type="checkbox"], input[type="radio"] { min-height: 24px; }
  .icon-btn { min-width: 36px; }
  .button-link { min-height: 36px; }
  .cmd-input { min-height: 52px; }
}

/* Badges and status chips. */
.badge { display: inline-flex; align-items: center; padding: 1px 10px; border-radius: var(--r-pill); border: 1px solid var(--border-strong); background: var(--surface-sunken); color: var(--text); font-size: var(--fs-xs); font-weight: 600; line-height: 1.6; white-space: nowrap; }
.badge.unread { margin-inline-start: 6px; background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.badge.status-open, .badge.status-pass { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.status-pending, .badge.status-snoozed { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.status-resolved, .badge.status-closed { background: var(--surface-sunken); color: var(--muted); }
.badge.check-pass, .badge.domain-verified, .badge.campaign-active, .badge.alert-ok, .badge.schedule-active, .badge.listing-approved { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.check-missing, .badge.domain-pending, .badge.campaign-paused, .badge.listing-submitted { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.check-fail, .badge.check-error, .badge.domain-failed, .badge.breaker-open, .badge.kyb-rejected, .badge.dsar-refused, .badge.alert-firing, .badge.schedule-suspended, .badge.listing-rejected, .badge.listing-suspended { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.campaign-finished { color: var(--muted); }
.badge.rtc-rec { background: var(--danger); color: var(--danger-text); border-color: var(--danger); }
.badge.ai-generated, .badge.ad-source { background: var(--teal-soft); color: var(--teal); border-color: transparent; }

/* Notices. */
.notice { padding: 10px var(--gap); border-radius: var(--r-md); border: 1px solid var(--border-strong); background: var(--surface-sunken); }
.notice.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.notice.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.alert-banner { border: 1px solid var(--danger); background: var(--danger-soft); color: var(--danger); border-radius: var(--r-md); padding: 10px 14px; margin: 8px 0; font-weight: 600; }
.alert-banner[hidden] { display: none; }
.advisory { border-inline-start: 4px solid var(--warn); background: var(--warn-soft); color: var(--warn); border-radius: var(--r-sm); padding: 10px 14px; margin: 8px 0; }

/* Tables: sticky header, no zebra, row hover; the wrapper scrolls so the page never does. */
.table-wrap { overflow: auto; max-height: min(72vh, 760px); margin-bottom: var(--gap); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--sh-1); }
table { border-collapse: separate; border-spacing: 0; width: 100%; background: var(--surface); font-size: var(--fs-sm); }
.table-wrap table { margin: 0; }
th, td { text-align: start; padding: 10px 14px; border-bottom: 1px solid var(--border); }
thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-sunken); color: var(--muted); font-weight: 650; font-size: var(--fs-xs); letter-spacing: 0.02em; border-block-end: 1px solid var(--border-strong); white-space: nowrap; }
tbody tr:last-child td { border-block-end: 0; }
tbody tr:hover td { background: var(--row-hover); }
tfoot td { font-weight: 650; background: var(--surface-sunken); }
td { font-variant-numeric: tabular-nums; vertical-align: top; }
caption { text-align: start; color: var(--muted); padding: 10px 14px; font-size: var(--fs-sm); font-weight: 600; }
tr.shadow td { color: var(--muted); }
tr.recon-drift td:first-child, tr.recon-missing td:first-child, tr.recon-extra td:first-child { color: var(--danger); font-weight: 700; }
tr.spiking th, tr.spiking td { background: var(--surface); }
html[data-density="compact"] th, html[data-density="compact"] td { padding: 5px 10px; }
html[data-density="compact"] button, html[data-density="compact"] select, html[data-density="compact"] input { min-height: 30px; padding-block: 3px; }
html[data-density="compact"] input[type="checkbox"], html[data-density="compact"] input[type="radio"] { min-height: 24px; }
html[data-density="compact"] .card { padding: var(--sp-2); }
html[data-density="compact"] .nav a { padding-block: 5px; }
html[data-density="compact"] main { padding-block: var(--sp-2); }

/* Tabs. */
[role="tablist"], .tabs { display: flex; gap: 4px; border-block-end: 1px solid var(--border); margin-block: 0 var(--sp-2); overflow-x: auto; }
[role="tab"] { border: 0; border-block-end: 2px solid transparent; border-radius: var(--r-sm) var(--r-sm) 0 0; background: transparent; color: var(--muted); padding: 8px 14px; font-weight: 600; white-space: nowrap; }
[role="tab"]:hover:not(:disabled) { background: var(--row-hover); color: var(--text); border-color: transparent; border-block-end-color: var(--border-strong); }
[role="tab"][aria-selected="true"] { color: var(--accent); border-block-end-color: var(--accent); }

/* Toast. The text stays in the live region; .show only controls whether it is on screen. */
.toast { position: fixed; bottom: 16px; inset-inline: 16px; width: fit-content; max-width: min(480px, calc(100% - 32px)); margin-inline: auto; z-index: 60; text-align: start; pointer-events: none; visibility: hidden; transform: translateY(12px); transition: transform var(--dur) var(--ease), visibility 0s linear var(--dur); }
.toast.show:not(:empty) { visibility: visible; transform: none; transition-delay: 0s; }
.toast:not(:empty) { background: var(--inverse-bg); color: var(--inverse-text); padding: 10px 16px; border-radius: var(--r-md); box-shadow: var(--sh-2); font-weight: 500; }

/* Dialogs and drawers. */
dialog { border: 1px solid var(--border-strong); border-radius: var(--r-lg); background: var(--surface); color: var(--text); padding: var(--sp-3); box-shadow: var(--sh-3); }
dialog::backdrop { background: var(--scrim); }
dialog.drawer { margin-inline: auto 0; margin-block: 0; height: 100vh; max-height: none; width: min(480px, 100vw); border-radius: var(--r-lg) 0 0 var(--r-lg); }

/* Empty states and skeleton loaders. */
.empty-state { display: grid; justify-items: center; gap: 8px; text-align: center; padding: var(--sp-4) var(--sp-3); border: 1px dashed var(--border-strong); border-radius: var(--r-lg); color: var(--muted); background: var(--surface); }
.empty-state .icon { width: 28px; height: 28px; color: var(--muted); }
.empty-state p { margin: 0; }
#main > p[role="status"]:only-child:not([class]) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
main:has(> p[role="status"]:only-child:not([class]))::before, main:has(> p[role="status"]:only-child:not([class]))::after { content: ""; display: block; border-radius: var(--r-md); background: linear-gradient(90deg, var(--surface-sunken) 25%, var(--border) 50%, var(--surface-sunken) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
main:has(> p[role="status"]:only-child:not([class]))::before { height: 32px; width: min(280px, 60%); margin-bottom: var(--sp-3); }
main:has(> p[role="status"]:only-child:not([class]))::after { height: 220px; width: 100%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Lists, facts, KPIs. */
.facts { display: grid; grid-template-columns: fit-content(50%) minmax(0, 1fr); gap: 8px 16px; margin: 0; }
/* WCAG 1.4.10: the term column takes what it needs up to half the width, so a long event name
   or id wraps at phone width instead of widening the page. */
.facts dt { color: var(--muted); min-width: 0; overflow-wrap: anywhere; }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
.facts .money { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -0.01em; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--gap); margin: 0 0 var(--gap); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 16px; box-shadow: var(--sh-1); }
.kpi dt { color: var(--muted); font-size: var(--fs-sm); font-weight: 500; }
.kpi dd { margin: 6px 0 0; font-size: var(--fs-2xl); line-height: 1.15; font-weight: 700; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; }
.kpis.big .kpi dd { font-size: var(--fs-3xl); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 16px; box-shadow: var(--sh-1); }
.tile h3 { margin: 0 0 var(--sp-1); }
.tile .kpis { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin: 0; }
.tile .kpi { box-shadow: none; padding: 10px 12px; background: var(--surface-sunken); border-color: transparent; }
.tile .kpi dd { font-size: var(--fs-xl); }

/* ---- Workspace: inbox | conversation | details ------------------------------------------ */
main:has(.workspace) { max-width: none; padding: 0; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
.inbox-pane, .conversation-pane, .context-pane { min-width: 0; padding: var(--sp-2); }
.inbox-pane { background: var(--surface); border-block-end: 1px solid var(--border); }
.inbox-pane h1 { font-size: var(--fs-xl); margin-bottom: var(--sp-1); }
.inbox-pane h2 { font-size: var(--fs-xs); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: var(--sp-3) 0 var(--sp-1); }
.inbox-pane ul { list-style: none; margin: 0; padding: 0; }
.inbox-pane .card { box-shadow: none; border-radius: var(--r-md); padding: 12px; background: var(--surface-sunken); border-color: transparent; }
.inbox-pane .card p { margin-block: 0 6px; }
.conversation-pane { display: flex; flex-direction: column; gap: var(--sp-1); background: var(--bg); min-height: 60vh; }
.context-pane { background: var(--surface); border-block-start: 1px solid var(--border); display: grid; gap: var(--sp-2); align-content: start; }
.context-pane:empty { display: none; }
.context-pane h2 { margin: 0; }
.conv-head { display: grid; gap: 4px; padding-block-end: var(--sp-1); border-block-end: 1px solid var(--border); }
.conv-head h2 { margin: 0; font-size: var(--fs-xl); letter-spacing: -0.01em; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.conversation-pane .messages { flex: 1; min-height: 0; max-height: 60vh; overflow-y: auto; padding: 4px 2px; }
.presence select, .inline-form select, .composer select, .composer textarea { width: 100%; }
.presence-state { font-weight: 650; display: flex; align-items: center; gap: 8px; }
.presence-state::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: currentColor; flex: none; }
.state-ready { color: var(--ok); }
.state-not_ready { color: var(--warn); }
.state-not_responding, .state-offline { color: var(--danger); }
.offers { display: grid; gap: 8px; }
.offer { border-inline-start: 4px solid var(--accent) !important; background: var(--accent-soft) !important; }
.offer .actions { margin-top: 8px; }
.offer-line { display: flex; align-items: center; gap: 10px; }
.countdown { font-variant-numeric: tabular-nums; font-weight: 700; }
.conversation-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.conversation-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-inline-start: 3px solid transparent; border-radius: var(--r-md); color: inherit; text-decoration: none; transition: background var(--dur-fast) var(--ease); }
.conversation-row:hover { background: var(--row-hover); }
.conversation-row .contact { font-weight: 650; display: flex; align-items: center; gap: 10px; min-width: 0; overflow-wrap: anywhere; }
.conversation-row .subject { color: var(--muted); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.conversation-row .meta { font-size: var(--fs-sm); display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.inbox-pane .conversation-row { background: transparent; border-color: transparent; }
.inbox-pane .conversation-row:hover { background: var(--row-hover); }
.conversation-row[aria-current="page"] { background: var(--accent-soft); border-color: transparent; border-inline-start-color: var(--accent); }
.inbox-pane .conversation-row[aria-current="page"] { background: var(--accent-soft); }
.channel-ico { display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.channel-ico .icon { width: 16px; height: 16px; }
.channel-ico[data-channel="whatsapp"], .channel-ico[data-channel="voice"], .channel-ico[data-channel="viber"] { background: var(--teal-soft); color: var(--teal); }
.channel-ico[data-channel="sms"], .channel-ico[data-channel="rcs"], .channel-ico[data-channel="review"] { background: var(--warn-soft); color: var(--warn); }
.channel-ico[data-channel="instagram"], .channel-ico[data-channel="comments"] { background: var(--danger-soft); color: var(--danger); }
.channel-ico[data-channel="email"], .channel-ico[data-channel="telegram"] { background: var(--surface-sunken); color: var(--text); }
.conversation-row .meta .channel-ico { width: 20px; height: 20px; border-radius: 6px; }
.conversation-row .meta .channel-ico .icon { width: 12px; height: 12px; }

.messages { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 8px; }
.message { display: flex; flex-direction: column; max-width: min(80%, 620px); padding: 10px 14px; border-radius: var(--r-lg); background: var(--bubble-in); overflow-wrap: anywhere; }
.message.inbound { align-self: flex-start; border-start-start-radius: 4px; }
.message.outbound { align-self: flex-end; background: var(--bubble-out); border-start-end-radius: 4px; }
.message .author { order: -1; font-size: var(--fs-xs); color: var(--muted); margin: 0 0 4px; }
.message .body { margin: 0; white-space: pre-wrap; font-size: var(--fs-md); }
.message.note { align-self: stretch; max-width: none; border: 1px dashed var(--warn); background: var(--warn-soft); border-radius: var(--r-md); }
.message.note .author { color: var(--warn); }
.tick { font-weight: 700; }
.tick.status-read { color: var(--accent); }
.tick.status-failed { color: var(--danger); }
.window.closed { color: var(--danger); }
.window.open { color: var(--ok); }
.typing { min-height: 1.5em; }
.composer { position: sticky; bottom: 0; margin: 0; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-2); padding: 12px 16px; z-index: 2; }
.composer label { margin-top: 0; }
.composer .actions { justify-content: flex-end; }
.composer form button[type="submit"] { width: auto; margin-top: 0; }
.composer textarea { min-height: 84px; }
/* Wraps (WCAG 1.4.10): a row of channel checkboxes must not widen the page at phone width. */
.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inline input[type="checkbox"] { width: auto; min-height: 24px; min-width: 24px; }
.inline label { margin: 0; font-weight: 400; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.inline-form label { width: 100%; margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--sp-2) var(--gap); margin-block-end: var(--sp-2); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { margin: 0; font-weight: 500; }
.field :is(input, select) { width: 100%; }
.inline-form select { flex: 1; min-width: 160px; width: auto; }
.contact-panel summary { cursor: pointer; min-height: 36px; display: flex; align-items: center; font-weight: 650; }
.context-pane .conversation-actions { display: grid; gap: var(--sp-2); margin: 0; }
.context-pane .inline-form button { flex: none; }
.context-pane details { border: 1px solid var(--border); border-radius: var(--r-md); padding: 4px 12px; background: var(--surface); }
.context-pane details[open] { padding-bottom: 12px; }
.context-pane summary { cursor: pointer; font-weight: 650; min-height: 36px; display: flex; align-items: center; }
.rtc-controls { margin: 0; display: grid; gap: 8px; }
.rtc-history-panel summary { cursor: pointer; min-height: 36px; display: flex; align-items: center; }
@media (min-width: 760px) and (max-width: 1099px) {
  .workspace { grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); grid-template-areas: "inbox conv" "inbox ctx"; align-items: start; }
  .inbox-pane { grid-area: inbox; border-block-end: 0; border-inline-end: 1px solid var(--border); min-height: calc(100vh - var(--topbar-h)); }
  .conversation-pane { grid-area: conv; }
  .context-pane { grid-area: ctx; }
}
@media (min-width: 1100px) {
  .workspace { grid-template-columns: minmax(300px, 340px) minmax(0, 1fr) minmax(280px, 340px); height: calc(100vh - var(--topbar-h)); }
  .inbox-pane, .conversation-pane, .context-pane { overflow-y: auto; min-height: 0; padding: var(--sp-2) var(--sp-3); }
  .inbox-pane { border-block-end: 0; border-inline-end: 1px solid var(--border); padding-inline: var(--sp-2); }
  .context-pane { border-block-start: 0; border-inline-start: 1px solid var(--border); padding-inline: var(--sp-2); }
  .conversation-pane { min-height: 0; }
  .conversation-pane .messages { max-height: none; }
}
/* Phone: the open conversation comes first, the list below it. */
@media (max-width: 759px) {
  .workspace.has-selection .conversation-pane { order: -1; }
  .workspace.has-selection .context-pane { order: 0; }
  .message { max-width: 92%; }
}

/* Softphone and call controls. */
.softphone .status[data-state="registered"] { color: var(--ok); font-weight: 700; }
.softphone .status[data-state="not_connected"] { color: var(--danger); font-weight: 700; }
.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 72px)); gap: 10px; margin-top: 12px; }
.key { font-size: var(--fs-xl); font-weight: 600; min-height: 56px; border-radius: var(--r-lg); background: var(--surface-sunken); border-color: var(--border-strong); }
.call-state { font-weight: 700; }
.call-connected { color: var(--ok); }

.conversation-list .conversation-row .contact { font-weight: 650; }
.timeline { list-style: none; padding: 0; margin: 0; border-inline-start: 2px solid var(--border-strong); display: grid; gap: 12px; }
.interaction { margin-block: 0; margin-inline: 16px 0; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); position: relative; box-shadow: var(--sh-1); }
.interaction::before { content: ""; position: absolute; inset-inline-start: -23px; inset-block-start: 20px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent); }
.interaction.channel-voice::before, .interaction.channel-whatsapp::before { border-color: var(--teal); }
.interaction h3 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.identifiers { margin: 0; padding-inline-start: 20px; overflow-wrap: anywhere; }
.depth-1 { padding-inline-start: 24px; }
.depth-2 { padding-inline-start: 40px; }
.depth-3 { padding-inline-start: 56px; }

.steps { padding-inline-start: 20px; }
.step { margin-bottom: 16px; }
.step.result-pass strong { color: var(--ok); }
.step.result-fail strong { color: var(--danger); }
.step-form { display: grid; gap: 0 12px; }

@media (min-width: 640px) {
  .conversation-row { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
  .conversation-row .meta { grid-column: 1 / -1; }
  .inbox-pane .conversation-row { grid-template-columns: minmax(0, 1fr); }
  .step-form { grid-template-columns: 1fr 1fr; }
  .step-form label:nth-of-type(1) { grid-column: 1; grid-row: 1; }
  .step-form label:nth-of-type(2) { grid-column: 2; grid-row: 1; }
  .step-form .actions { grid-column: 1 / -1; }
}

/* ---- Page-specific rules ----------------------------------------------------------------- */
/* Billing: wallet facts, notices, ledger, usage and reconciliation. */
.totals { padding-inline-start: 1.2em; }
.runs { padding-inline-start: 1.2em; }

/* MFA and security */
.recovery-codes { columns: 2; font-family: var(--mono); }
.secret { font-size: 1.1rem; letter-spacing: 0.05em; word-break: break-all; }

/* E-mail and SMS */
.email-html { width: 100%; min-height: 320px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.attachments { margin: 4px 0; padding-inline-start: 1.2em; }
.sms-counter.over { color: var(--danger); font-weight: 700; }

/* The outbound desk (P4) and the wallboard (P5). */
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; max-width: 520px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
/* Outbound depth (0045): embed codes and long ids wrap at phone width; checkbox rows are touch-sized. */
pre.mono, td .mono, th .mono { white-space: pre-wrap; word-break: break-all; }
label.check { display: flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 500; }
.dialler .script { white-space: pre-wrap; background: var(--surface); border-inline-start: 3px solid var(--accent); padding: 8px 12px; margin: 6px 0; border-radius: var(--r-sm); }
.dialler .callback { display: grid; gap: 6px; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; }
.dialler .callback[hidden] { display: none; }
.dialler .check { display: flex; align-items: center; gap: 6px; }
.mapping { display: grid; gap: 6px; max-width: 720px; }
.agent-states .badge { margin-inline-end: 6px; }
@media (max-width: 480px) { .kpis.big .kpi dd { font-size: 1.75rem; } .tiles { grid-template-columns: 1fr; } }

.whisper { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 12px; margin: 16px 0; }
.whisper textarea { width: 100%; box-sizing: border-box; display: block; margin: 4px 0 8px; }
.internal-note { color: var(--muted); }
.confirm { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin: 8px 0; }
.confirm[hidden] { display: none; }

/* The analytics suite: saved reports, alerts, topics, auto-QA, revenue, my performance, margin, wallboard layouts. */
.wfm tr.short td[data-metric] { color: var(--danger); font-weight: 700; }
.bars { font-family: var(--mono); letter-spacing: 0.05em; white-space: nowrap; }
.checks { border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 12px; margin: 6px 0; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.checks legend { padding: 0 4px; }
.explain.link-button { font-size: 0.85rem; }
.explain-dialog { max-width: min(720px, 94vw); max-height: 80vh; overflow: auto; }
.record-list { padding-inline-start: 1.2em; max-height: 40vh; overflow: auto; }
.goals { list-style: none; padding: 0; display: grid; gap: 8px; }
.goals progress { width: 160px; vertical-align: middle; }
.board li.you { font-weight: 700; }
.wb-tile { margin-bottom: var(--gap); }
.tv-controls { display: flex; gap: 8px; }
/* TV mode: the console chrome goes, the figures grow. */
body.tv #topbar, body.tv nav, body.tv #acting, body.tv .skip-link, body.tv .sidebar, body.tv .scrim { display: none; }
body.tv .app { grid-template-columns: minmax(0, 1fr); }
body.tv main { max-width: none; padding: 16px 24px; }
body.tv .wallboard h1 { font-size: 1rem; color: var(--muted); }
body.tv .wallboard h2 { font-size: 2.2rem; margin: 0 0 12px; }
body.tv .kpi dd { font-size: 3rem; }
body.tv .kpi dt { font-size: 1.1rem; }
body.tv .wb-tile h3 { font-size: 1.2rem; color: var(--muted); }
body.tv .alert-banner { font-size: 1.6rem; }

/* CRM connectors (#/crm, #/crm/health): long URLs and ids wrap at phone width; checkboxes sit beside their text. */
.crm code { overflow-wrap: anywhere; }
.crm .check { display: flex; align-items: center; gap: 6px; }
.crm fieldset[hidden], .crm div[hidden] { display: none; }

/* Video calls and page sharing (OC-17): a dock that stays while the agent moves between conversations. */
.rtc-history { padding-inline-start: 20px; overflow-wrap: anywhere; }
.rtc-dock { position: fixed; z-index: 20; left: 8px; right: 8px; bottom: 8px; max-height: 85vh; overflow: auto; background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--r-lg); padding: 12px; box-shadow: var(--sh-3); }
.rtc-dock h2 { margin: 0 0 8px; font-size: 1.1rem; }
.rtc-stage { position: relative; background: #000; border-radius: var(--r-md); overflow: hidden; aspect-ratio: 4 / 3; }
.rtc-remote { width: 100%; height: 100%; object-fit: contain; display: block; }
.rtc-local { position: absolute; inset-inline-end: 8px; bottom: 8px; width: 28%; aspect-ratio: 4 / 3; object-fit: cover; border: 2px solid #fff; border-radius: 6px; background: #111; }
.rtc-page { direction: ltr; position: relative; overflow: hidden; background: #fff; color: #111; border: 1px solid var(--border); border-radius: 6px; cursor: crosshair; min-height: 120px; }
.rtc-box { position: absolute; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 10px; line-height: 1.15; pointer-events: none; }
.rtc-box.field { border: 1px solid #9ca3af; background: #fff; padding: 0 2px; }
.rtc-box.img { background: #e5e7eb; border: 1px dashed #9ca3af; color: #4b5563; }
.rtc-box.masked { background: repeating-linear-gradient(45deg, #e5e7eb, #e5e7eb 4px, #f9fafb 4px, #f9fafb 8px); color: #4b5563; border: 1px solid #9ca3af; }
.rtc-box[data-checked="true"]::after { content: "✓"; }
.rtc-confirm { max-width: min(520px, 94vw); }
@media (min-width: 960px) {
  .rtc-dock { inset-inline-start: auto; width: 440px; }
}

/* Round-2 gaps: secure forms, change approval, emergency mode, AI monitors. */
.secure-requests, .change-list, .emergency-list, .flag-list { list-style: none; padding: 0; }
.secure-view { border-inline-start: 4px solid var(--danger); }
.field-rows { padding-inline-start: 1.25rem; }
table.diff td { max-width: 24rem; overflow-wrap: anywhere; }
.diff-before { text-decoration: line-through; color: var(--muted); }
.emergency-on { border-inline-start: 4px solid var(--danger); }
@media (max-width: 40rem) { table.diff td { max-width: 10rem; } }

/* Enterprise admin (SSO, SCIM, help centre): long URLs and records wrap at phone width. */
.card code { overflow-wrap: anywhere; }
.card fieldset { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; }

/* Digital desk depth: the report builder's palette, drop zones and chips; charts scale to the column. */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: var(--gap); }
@media (max-width: 48rem) { .builder { grid-template-columns: minmax(0, 1fr); } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; padding: 0; }
.chip { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); cursor: grab; }
.drop-zone { min-height: 52px; padding: 8px; border: 2px dashed var(--border-strong); border-radius: var(--radius); list-style: none; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.drop-zone.over { border-color: var(--accent); background: var(--accent-soft); }
svg.chart { max-width: 100%; height: auto; display: block; margin: 8px 0; }
/* Platform (T5): the consent screen, apps, roles, legal holds, the data region, the language picker. */
.lang-picker { min-height: 32px; border-color: transparent; background: transparent; font-size: var(--fs-sm); font-weight: 500; }
.narrow-picker { max-width: 440px; margin: 0 auto; text-align: center; }
.consent { max-width: 640px; margin-inline: auto; }
.scope-list { padding-inline-start: 1.2em; }
.scope-list code { color: var(--muted); font-size: .85rem; }
.app-list, .hold-list { list-style: none; padding: 0; }
.secret-once code { overflow-wrap: anywhere; }
.hold-active { border-inline-start: 4px solid var(--danger); }
/* WCAG 1.4.10: a long option (an event name and its scope) wraps at phone width instead of widening the page. */
.checks label.inline { min-height: 24px; max-width: 100%; min-width: 0; overflow-wrap: anywhere; }
/* Voice AI: transcripts, the analytics question's SQL, JSON editors; one column on a phone. */
.transcript { list-style: none; padding: 0; margin: 0; }
.transcript-line { padding: 6px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.transcript-line .speaker { font-weight: 600; margin-inline-end: 6px; }
.transcript-line.speaker-bot .speaker::before { content: "◆ "; }
.transcript-line.interrupted .text { text-decoration: underline dotted; }
.split { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .split { grid-template-columns: 260px 1fr; } }
.chips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
textarea.code, pre.sql code { font-family: var(--mono); font-size: 0.85rem; }
pre.sql { overflow-x: auto; max-width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Brand mark: the ring-and-bead drawing, no letter tile */
.brand-mark.brand-mark--svg{background:none;border:0;box-shadow:none;width:auto;height:auto;padding:0;color:var(--color-primary, #2147c6);display:inline-flex;align-items:center}
.brand-mark--svg svg{display:block}
/* White-label: the brand's logo in the sidebar and on the sign-in page (src/static.js, js/app.js). */
.brand-logo{display:block;max-block-size:40px;max-inline-size:180px;inline-size:auto;object-fit:contain}

/* ---- The phone (floating, draggable; one panel for the whole session) ------------------------- */
.phone-toggle { position: relative; }
.phone-dot { position: absolute; inset-block-start: 7px; inset-inline-end: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--call); border: 2px solid var(--surface); display: none; }
.phone-toggle.is-live .phone-dot { display: block; }
.phone-toggle.is-ringing { animation: ring-shake 1s var(--ease) infinite; }
@keyframes ring-shake { 0%, 60%, 100% { transform: none; } 10%, 30%, 50% { transform: rotate(-12deg); } 20%, 40% { transform: rotate(12deg); } }

.phone { position: fixed; z-index: 55; inset-inline-end: 24px; inset-block-end: 24px; width: 352px; max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 28px; box-shadow: var(--sh-3); animation: phone-in var(--dur) var(--ease); }
.phone.is-dragging { box-shadow: var(--sh-3), 0 0 0 3px var(--ring); user-select: none; }
@keyframes phone-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
.sp-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 6px 14px; }
.sp-grip { display: inline-flex; align-items: center; gap: 6px; flex: 1; min-width: 0; justify-content: flex-start; min-height: 36px; padding: 0 8px; border-color: transparent; background: transparent; color: var(--muted); font-size: var(--fs-sm); cursor: grab; touch-action: none; }
.sp-grip:hover:not(:disabled) { background: var(--row-hover); border-color: transparent; }
.phone.is-dragging .sp-grip { cursor: grabbing; }
.sp-title { font-weight: 650; color: var(--text); }
.sp-pill { font-size: var(--fs-xs); padding: 3px 10px; flex: none; }
.sp-close { min-width: 36px; min-height: 36px; color: var(--muted); }
.sp-body { padding: 4px 20px 22px; overflow-y: auto; }
.sp-display { display: flex; align-items: center; gap: 4px; min-height: 64px; margin-block-end: 2px; }
.sp-display-gap { width: 40px; flex: none; }
input.sp-number { flex: 1; min-width: 0; border: 0; background: transparent; box-shadow: none; text-align: center; font-size: 1.85rem; font-weight: 500; letter-spacing: 0.01em; padding: 8px 0; min-height: 56px; font-variant-numeric: tabular-nums; unicode-bidi: plaintext; }
input.sp-number:hover { border-color: transparent; }
input.sp-number::placeholder { font-size: 1.05rem; font-weight: 400; letter-spacing: 0; }
input.sp-number:focus-visible { outline-offset: 0; border-radius: var(--r-md); }
.sp-back { width: 40px; min-width: 40px; min-height: 40px; padding: 0; display: inline-grid; place-items: center; border: 0; background: transparent; color: var(--muted); border-radius: 50%; }
.sp-back:hover:not(:disabled) { background: var(--row-hover); color: var(--text); }
.sp-hint { text-align: center; min-height: 1.4em; margin: 0 0 10px; font-size: var(--fs-sm); color: var(--muted); }
.sp-auto { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 12px 0 0; font-size: var(--fs-sm); color: var(--muted); cursor: pointer; }
.sp-auto input { margin: 0; }
.sp-keypad { display: grid; grid-template-columns: repeat(3, 72px); justify-content: space-between; row-gap: 12px; }
.sp-key { width: 72px; height: 72px; min-height: 72px; padding: 0; border: 0; border-radius: 50%; background: var(--surface-sunken); display: grid; align-content: center; justify-items: center; gap: 0; line-height: 1; transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease); }
.sp-key:hover:not(:disabled) { background: var(--accent-soft); border-color: transparent; }
.sp-key:active:not(:disabled) { transform: scale(0.94); background: var(--accent-soft); }
.sp-digit { font-size: 1.65rem; font-weight: 500; }
.sp-letters { font-size: 0.6rem; letter-spacing: 0.14em; color: var(--muted); font-weight: 650; min-height: 0.75rem; margin-block-start: 3px; }
.sp-actions { display: flex; justify-content: center; gap: 28px; margin-block-start: 18px; }
.sp-actions--two { gap: 56px; }
.sp-ctl { display: grid; justify-items: center; gap: 6px; }
.sp-cap { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; text-align: center; }
.sp-btn { width: 72px; height: 72px; min-height: 72px; padding: 0; border-radius: 50%; display: inline-grid; place-items: center; border: 0; box-shadow: var(--sh-1); }
.sp-btn .icon { width: 28px; height: 28px; stroke-width: 1.9; }
.sp-btn--call { background: var(--call); color: var(--call-text); }
.sp-btn--call:hover:not(:disabled) { background: var(--call-hover); border-color: transparent; }
.sp-btn--hang { background: var(--danger); color: var(--danger-text); }
.sp-btn--hang:hover:not(:disabled) { background: var(--danger); filter: brightness(1.08); border-color: transparent; }
.sp-btn--hang .icon { transform: rotate(135deg); }
.sp-btn--soft { background: var(--surface-sunken); color: var(--text); box-shadow: none; width: 64px; height: 64px; min-height: 64px; }
.sp-btn--soft:hover:not(:disabled) { background: var(--accent-soft); border-color: transparent; }
.sp-btn--soft[aria-pressed="true"] { background: var(--text); color: var(--surface); }
.sp-btn:disabled { opacity: 0.38; }
.sp-call { display: grid; justify-items: center; text-align: center; gap: 2px; padding-block-start: 8px; }
.sp-avatar { display: inline-grid; place-items: center; width: 84px; height: 84px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); margin-block-end: 8px; }
.sp-avatar .icon { width: 38px; height: 38px; }
.sp-peer { margin: 0; font-size: 1.5rem; font-weight: 650; letter-spacing: 0; overflow-wrap: anywhere; unicode-bidi: plaintext; }
.sp-timer { margin: 0; color: var(--muted); font-variant-numeric: tabular-nums; font-size: var(--fs-lg); }
.sp-sub { margin: 0; color: var(--muted); font-size: var(--fs-sm); min-height: 1.2em; }
.sp-err { margin: 4px 0 0; font-size: var(--fs-sm); min-height: 0; }
.sp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 8px; width: 100%; margin-block: 22px 4px; }
.sp-ringing .sp-avatar { animation: ring-pulse 1.4s ease-out infinite; }
@keyframes ring-pulse { 0% { box-shadow: 0 0 0 0 var(--ring); } 100% { box-shadow: 0 0 0 26px transparent; } }
.sp-dtmf { margin: 6px 0 12px; min-height: 1.6em; font-size: 1.35rem; letter-spacing: 0.08em; font-variant-numeric: tabular-nums; }
.sp-sheet { width: 100%; text-align: start; margin-block: 14px 4px; }
.sp-sheet label { margin-block-start: 0; }
.sp-stack { display: grid; gap: 8px; margin-block-start: 12px; }
.sp-sheet-back { margin-block-start: 8px; }
.sp-empty { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 28px 8px 8px; }
.sp-empty h2 { margin: 6px 0 0; font-size: var(--fs-lg); }
.sp-empty p { max-width: 28ch; margin: 0 0 8px; font-size: var(--fs-sm); }
.sp-empty-ico { display: inline-grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; background: var(--surface-sunken); color: var(--muted); }
.sp-empty-ico .icon { width: 32px; height: 32px; }
.sp-dock { display: grid; justify-items: start; }
.phone.sp-inline { position: static; animation: none; box-shadow: var(--sh-2); }
.phone.sp-inline .sp-grip { cursor: default; }
@media (max-width: 640px) {
  .phone { inset-inline: 0; inset-block-end: 0; width: auto; max-width: none; border-radius: 24px 24px 0 0; max-height: 92vh; }
  .phone.sp-inline { inset-inline: auto; border-radius: 24px; width: 100%; }
  .sp-grip { cursor: default; }
}

/* ---- Dashboard ---------------------------------------------------------------------------- */
.dash-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: var(--sp-2); margin-block-end: var(--sp-3); }
.dash-head h1 { margin-block-end: 2px; font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 650; }
.dash-greet { margin: 0; font-size: var(--fs-xl); font-weight: 650; letter-spacing: -0.01em; }
.dash-head .muted { margin: 2px 0 0; }
.dash-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--gap); margin: 0 0 var(--gap); }
.dash-tile { position: relative; display: grid; gap: 2px; align-content: start; padding: var(--sp-2) var(--sp-2) 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-1); transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease); }
.dash-tile:hover { box-shadow: var(--sh-2); transform: translateY(-1px); }
.dash-tile-ico { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); margin-block-end: 8px; }
.dash-tile[data-tile="answered"] .dash-tile-ico { background: var(--ok-soft); color: var(--ok); }
.dash-tile[data-tile="missed"] .dash-tile-ico { background: var(--danger-soft); color: var(--danger); }
.dash-tile[data-tile="aht"] .dash-tile-ico { background: var(--warn-soft); color: var(--warn); }
.dash-tile[data-tile="agents"] .dash-tile-ico { background: var(--teal-soft); color: var(--teal); }
.dash-tile dt { color: var(--muted); font-size: var(--fs-sm); font-weight: 600; }
.dash-tile dd { margin: 0; font-size: var(--fs-3xl); line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.dash-tile .meta { margin: 2px 0 0; }
.dash-tile dd.meta { font-size: var(--fs-sm); line-height: 1.4; font-weight: 400; letter-spacing: normal; }
.dash-cols { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.dash-card h2 { margin-block: 0 var(--sp-2); }
.dash-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-1); margin-block-end: var(--sp-1); }
.dash-card-head h2 { margin-block-end: 0; }
.dash-fig { margin: 0; }
.dash-chart { display: block; width: 100%; height: 170px; overflow: visible; }
.dash-chart .bar { fill: var(--accent); opacity: 0.85; }
.dash-chart .bar:hover { opacity: 1; }
.dash-chart .bar-peak { fill: var(--teal); opacity: 1; }
.dash-chart .bar-future { fill: var(--surface-sunken); }
.dash-chart .axis { stroke: var(--border-strong); stroke-width: 1; }
.dash-chart .tick { fill: var(--muted); font-size: 10px; }
.dash-fig figcaption { margin-block-start: 8px; }
.dash-recent { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.dash-row { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: var(--r-md); color: var(--text); text-decoration: none; }
.dash-row:hover { background: var(--row-hover); }
.dash-row-main { display: grid; min-width: 0; flex: 1; }
.dash-row-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-row-main .meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; }
.dash-row-side { display: grid; justify-items: end; gap: 2px; flex: none; }
.dash-row-side time { font-size: var(--fs-xs); }
.dash-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.dash-action { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 16px; border: 1px solid var(--border-strong); border-radius: var(--r-pill); background: var(--surface); color: var(--text); text-decoration: none; font: inherit; font-weight: 600; font-size: var(--fs-sm); cursor: pointer; transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease); }
.dash-action .icon { width: 18px; height: 18px; color: var(--accent); }
.dash-action:hover { background: var(--accent-soft); border-color: var(--accent); }
.dash-updated { text-align: end; margin-block: 0; }
@media (max-width: 900px) { .dash-cols { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) {
  .dash-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .dash-tile { padding: 12px; }
  .dash-tile dd { font-size: var(--fs-2xl); }
  .dash-greet { font-size: var(--fs-lg); }
}

/* ---- Polish ------------------------------------------------------------------------------- */
::selection { background: var(--accent-soft); color: var(--text); }
.card { transition: box-shadow var(--dur) var(--ease); }
.nav a[aria-current="page"]::before { content: ""; position: absolute; inset-inline-start: -12px; inset-block: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
[dir="rtl"] .nav a[aria-current="page"]::before { border-radius: 3px 0 0 3px; }
.sb-scroll { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
@media (max-height: 780px) {
  .sp-keypad { grid-template-columns: repeat(3, 60px); row-gap: 8px; }
  .sp-key { width: 60px; height: 60px; min-height: 60px; }
  .sp-digit { font-size: 1.45rem; }
  .sp-btn { width: 64px; height: 64px; min-height: 64px; }
  .sp-actions { margin-block-start: 12px; }
  .sp-display { min-height: 52px; }
  .sp-body { padding-block-end: 16px; }
}

/* WhatsApp connection (channel settings): quality rating and template status badges, copy rows. */
.badge.wa-GREEN, .badge.wa-t-approved, .badge.wa-t-reinstated { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.wa-YELLOW, .badge.wa-t-pending, .badge.wa-t-in_appeal, .badge.wa-t-paused, .badge.wa-t-flagged, .badge.wa-t-limit_exceeded { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.wa-RED, .badge.wa-t-rejected, .badge.wa-t-disabled { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.wa-UNKNOWN, .badge.wa-t-deleted, .badge.wa-t-pending_deletion { color: var(--muted); }
.copy-value { flex: 1 1 18rem; min-width: 0; font-family: var(--mono, ui-monospace, monospace); }
.wa-webhook ol { padding-inline-start: 1.25rem; }

/* ---- Phone mode (js/mobile.js): bottom tab bar, the phone as a full-screen tab ----------------------------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tabbar { display: none; }
body.is-phone .tabbar { position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 54; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface); border-block-start: 1px solid var(--border); padding-block-end: env(safe-area-inset-bottom); }
body.is-phone .tabbar[hidden] { display: none; }
.tabbar-item { display: grid; justify-items: center; align-content: center; gap: 2px; min-height: 56px; padding: 6px 4px; color: var(--muted); text-decoration: none; font-size: var(--fs-xs); font-weight: 600; }
.tabbar-item .icon { width: 24px; height: 24px; }
.tabbar-item[aria-current="page"] { color: var(--accent); }
.tabbar-item:focus-visible { outline-offset: -3px; }
body.is-phone main { padding-block-end: calc(72px + env(safe-area-inset-bottom)); }
body.is-phone .toast { inset-block-end: calc(72px + env(safe-area-inset-bottom)); }
/* The floating phone is replaced by the Phone tab; the topbar button goes with it. */
body.is-phone .phone:not(.sp-inline), body.is-phone .phone-toggle { display: none; }
.phone-tab { display: grid; gap: var(--sp-1); }
.phone-tab .card { margin-bottom: 0; }
.phone-tab .actions { display: flex; flex-wrap: wrap; gap: var(--sp-1); align-items: center; }
.phone-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.phone-seg button { min-height: 44px; padding-inline: 4px; }
.phone-tab-body { min-width: 0; }
.phone-list { list-style: none; margin: 0; padding: 0; display: grid; }
.phone-row { display: flex; align-items: center; gap: 4px; border-block-end: 1px solid var(--border); }
.phone-row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 6px 4px; border: 0; background: transparent; text-align: start; color: var(--text); }
.phone-row-main:hover:not(:disabled) { background: var(--row-hover); border-color: transparent; }
.phone-row-ico { display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%; background: var(--surface-sunken); color: var(--muted); }
.phone-row.is-missed .phone-row-ico { background: var(--danger-soft, var(--surface-sunken)); color: var(--danger); }
.phone-row-text { display: grid; min-width: 0; }
.phone-row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; unicode-bidi: plaintext; }
.phone-row.is-missed .phone-row-title { color: var(--danger); }
.phone-row-star { min-width: 44px; min-height: 44px; color: var(--muted); }
.phone-row-star[aria-pressed="true"] { color: var(--warn); }
.phone-row-star[aria-pressed="true"] .icon { fill: currentColor; }
.install-sheet { max-width: min(420px, 94vw); }
.install-sheet ol { padding-inline-start: 1.25rem; }
body.is-phone .phone.sp-inline { width: 100%; max-height: none; border: 0; border-radius: 0; box-shadow: none; background: transparent; }
body.is-phone .phone.sp-inline .sp-grip, body.is-phone .phone.sp-inline .sp-close { display: none; }
body.is-phone .phone.sp-inline .sp-head { justify-content: center; }
body.is-phone .phone.sp-inline .sp-body { padding-inline: 0; overflow: visible; }
body.is-phone .phone.sp-inline .sp-keypad { grid-template-columns: repeat(3, minmax(72px, 88px)); justify-content: space-evenly; row-gap: 14px; }
body.is-phone .phone.sp-inline .sp-key { width: 100%; max-width: 88px; height: auto; aspect-ratio: 1; }
body.is-phone .phone.sp-inline .sp-dock { width: 100%; }
body.is-phone .sp-dock { justify-items: stretch; }
/* ---- Analytics: chart tokens, KPI tiles, chart cards, the page furniture (charts.js, analytics*.js) ------------------ */
:root {
  --chart-1: #2f5bd8; --chart-2: #0f8f7a; --chart-3: #c47a12; --chart-4: #7a55c9; --chart-5: #c8435f; --chart-6: #2b8bc4; --chart-7: #6f9a2c; --chart-8: #5f6b80;
  --chart-grid: #ececef; --chart-axis: #525c6e; --chart-band: rgba(23, 104, 58, 0.07);
}
@media (prefers-color-scheme: dark) {
  :root {
    --chart-1: #7b9bff; --chart-2: #4fcfb3; --chart-3: #f0b45a; --chart-4: #a58df0; --chart-5: #f27a93; --chart-6: #6cc0ee; --chart-7: #a6cf5c; --chart-8: #98a2b3;
    --chart-grid: #222227; --chart-axis: #9ea8bc; --chart-band: rgba(123, 216, 143, 0.08);
  }
}
:root[data-theme="light"] {
  --chart-1: #2f5bd8; --chart-2: #0f8f7a; --chart-3: #c47a12; --chart-4: #7a55c9; --chart-5: #c8435f; --chart-6: #2b8bc4; --chart-7: #6f9a2c; --chart-8: #5f6b80;
  --chart-grid: #ececef; --chart-axis: #525c6e; --chart-band: rgba(23, 104, 58, 0.07);
}
:root[data-theme="dark"] {
  --chart-1: #7b9bff; --chart-2: #4fcfb3; --chart-3: #f0b45a; --chart-4: #a58df0; --chart-5: #f27a93; --chart-6: #6cc0ee; --chart-7: #a6cf5c; --chart-8: #98a2b3;
  --chart-grid: #222227; --chart-axis: #9ea8bc; --chart-band: rgba(123, 216, 143, 0.08);
}
.ch-s0 { --c: var(--chart-1); } .ch-s1 { --c: var(--chart-2); } .ch-s2 { --c: var(--chart-3); } .ch-s3 { --c: var(--chart-4); }
.ch-s4 { --c: var(--chart-5); } .ch-s5 { --c: var(--chart-6); } .ch-s6 { --c: var(--chart-7); } .ch-s7 { --c: var(--chart-8); }
.ch-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; }
.ch-figure { margin: 0; position: relative; direction: ltr; }
.ch-plot { position: relative; inline-size: 100%; direction: ltr; }
.ch-svg { display: block; max-inline-size: 100%; overflow: visible; font-variant-numeric: tabular-nums; }
.ch-svg:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.ch-grid { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.ch-tickmark { stroke: var(--chart-grid); shape-rendering: crispEdges; }
.ch-ytick, .ch-xtick { fill: var(--chart-axis); font-size: 11px; font-variant-numeric: tabular-nums; }
.ch-line { fill: none; stroke: var(--c); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ch-line.dashed { stroke-dasharray: 4 4; stroke-width: 1.5; opacity: 0.75; }
.ch-area { fill: var(--c); fill-opacity: 0.12; stroke: none; }
.ch-bar { fill: var(--c); }
.ch-dot { fill: var(--surface); stroke: var(--c); stroke-width: 2; }
.ch-dot.solid { fill: var(--c); stroke: var(--surface); stroke-width: 1.5; }
.ch-cross { stroke: var(--chart-axis); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.ch-hl { fill: var(--text); fill-opacity: 0.06; pointer-events: none; }
.ch-overlay { fill: transparent; cursor: crosshair; }
.ch-target { stroke: var(--ok); stroke-width: 1.25; stroke-dasharray: 5 4; }
.ch-target-label { fill: var(--ok); font-size: 11px; font-weight: 600; }
.ch-band { fill: var(--chart-band); }
.ch-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; list-style: none; margin: 0 0 8px; padding: 0; }
.ch-legend.stack { flex-direction: column; gap: 6px; margin: 0; }
.ch-key { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 0 2px; min-height: 28px; font-size: var(--fs-sm); color: var(--text); font-weight: 500; }
.ch-key[aria-pressed="false"] { opacity: 0.45; text-decoration: line-through; }
.ch-swatch { inline-size: 10px; block-size: 10px; border-radius: 3px; background: var(--c, var(--chart-8)); flex: none; }
.ch-swatch.none { background: transparent; }
.ch-key.dashed .ch-swatch { background: repeating-linear-gradient(90deg, var(--c) 0 4px, transparent 4px 7px); block-size: 3px; }
.ch-tip { position: absolute; inset-block-start: 0; inset-inline-start: 0; z-index: 5; min-inline-size: 150px; max-inline-size: 280px; padding: 8px 10px; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--r-md); box-shadow: var(--sh-2); pointer-events: none; font-size: var(--fs-sm); }
.ch-tip[hidden] { display: none; }
.ch-tip-title { font-weight: 700; margin-block-end: 4px; }
.ch-tip-row { display: flex; align-items: center; gap: 8px; line-height: 1.7; }
.ch-tip-row.total { border-block-start: 1px solid var(--border); margin-block-start: 4px; padding-block-start: 4px; font-weight: 700; }
.ch-tip-label { flex: 1; color: var(--muted); }
.ch-tip-row.total .ch-tip-label { color: var(--text); }
.ch-tip-value { font-variant-numeric: tabular-nums; font-weight: 600; }
.ch-hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ch-hrow { display: grid; grid-template-columns: minmax(80px, 34%) minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: var(--fs-sm); }
.ch-hlabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-htrack { block-size: 10px; background: var(--surface-sunken); border-radius: var(--r-pill); overflow: hidden; }
.ch-hfill { display: block; block-size: 100%; background: var(--c); border-radius: var(--r-pill); }
.ch-hvalue { font-variant-numeric: tabular-nums; font-weight: 600; min-inline-size: 3.5em; text-align: end; }
.ch-hsub { color: var(--muted); font-weight: 400; font-size: var(--fs-xs); }
.ch-donutbox { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 28px; justify-content: center; }
.ch-donut-track { stroke: var(--surface-sunken); }
.ch-donut-arc { stroke: var(--c); }
.ch-donut-value { fill: var(--text); font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ch-donut-label { fill: var(--muted); font-size: 12px; }
.ch-donutbox .ch-key { cursor: default; gap: 8px; }
.ch-key-value { margin-inline-start: auto; padding-inline-start: 18px; font-variant-numeric: tabular-nums; font-weight: 600; }
.ch-heat { display: grid; gap: 3px; font-size: var(--fs-xs); }
.ch-heat-row { display: grid; grid-template-columns: 2.6em repeat(var(--cols), minmax(0, 1fr)); gap: 3px; align-items: center; }
.ch-heat-rowlabel, .ch-heat-collabel { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ch-heat-collabel { overflow: visible; font-size: 10px; }
.ch-heat-cell { display: block; aspect-ratio: 1.5 / 1; min-block-size: 14px; border-radius: 3px; background: var(--surface-sunken); }
.ch-heat-cell.lv1 { background: color-mix(in srgb, var(--accent) 18%, var(--surface-sunken)); }
.ch-heat-cell.lv2 { background: color-mix(in srgb, var(--accent) 38%, var(--surface-sunken)); }
.ch-heat-cell.lv3 { background: color-mix(in srgb, var(--accent) 60%, var(--surface-sunken)); }
.ch-heat-cell.lv4 { background: color-mix(in srgb, var(--accent) 80%, var(--surface-sunken)); }
.ch-heat-cell.lv5 { background: var(--accent); }
.ch-heat-scale { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-block-start: 10px; color: var(--muted); font-size: var(--fs-xs); }
.ch-heat-ramp { display: flex; gap: 3px; }
.ch-heat-ramp .ch-heat-cell { inline-size: 18px; min-block-size: 10px; aspect-ratio: auto; block-size: 10px; }
.ch-spark { display: block; overflow: visible; }
.ch-spark .ch-line { stroke-width: 1.5; }

.an-page { display: flex; flex-direction: column; gap: var(--gap); }
.an-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; }
.an-head h1 { margin: 0; }
.an-head .meta { margin: 4px 0 0; }
.an-tabs { display: flex; flex-wrap: wrap; gap: 2px; border-block-end: 1px solid var(--border); margin-block-end: 4px; }
.an-tab { padding: 9px 14px; color: var(--muted); text-decoration: none; font-weight: 600; border-radius: var(--r-sm) var(--r-sm) 0 0; box-shadow: inset 0 -2px 0 transparent; min-block-size: 24px; }
.an-tab:hover { color: var(--text); background: var(--row-hover); }
.an-tab[aria-current="page"] { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.an-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.an-seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-sunken); border-radius: var(--r-md); flex-wrap: wrap; }
.an-seg button { min-height: 36px; padding: 4px 12px; border: 0; background: transparent; color: var(--muted); border-radius: var(--r-sm); font-weight: 600; font-size: var(--fs-sm); }
.an-seg button:hover { color: var(--text); }
.an-seg button[aria-pressed="true"] { background: var(--surface); color: var(--accent); box-shadow: var(--sh-1); }
.an-field { display: inline-flex; flex-direction: column; gap: 2px; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.an-field select, .an-field input { min-inline-size: 130px; max-inline-size: 190px; font-weight: 400; color: var(--text); }
.an-bar .grow { flex: 1; }
.an-custom { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.an-custom[hidden] { display: none; }
.an-check { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); }
.an-multi { position: relative; }
.an-multi-box > summary { cursor: pointer; min-inline-size: 130px; max-inline-size: 190px; min-block-size: 32px; display: flex; align-items: center; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--r-md, 6px); background: var(--surface); color: var(--text); font-weight: 400; font-size: var(--fs-sm); }
.an-multi-list { position: absolute; z-index: 5; inset-block-start: 100%; inset-inline-start: 0; display: flex; flex-direction: column; gap: 6px; min-inline-size: 200px; max-block-size: 260px; overflow: auto; padding: 10px; margin-block-start: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md, 6px); box-shadow: var(--sh-2, var(--sh-1)); color: var(--text); font-weight: 400; }
.an-targets > summary { cursor: pointer; font-size: var(--fs-sm); color: var(--muted); font-weight: 600; min-block-size: 24px; }
.an-targets .an-bar { margin-block-start: 8px; box-shadow: none; }
.an-state { padding: 28px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--r-lg); }
.an-skeleton { background: linear-gradient(90deg, var(--surface-sunken), var(--row-hover), var(--surface-sunken)); background-size: 200% 100%; animation: an-shimmer 1.4s infinite linear; border-radius: var(--r-lg); min-block-size: 96px; }
@keyframes an-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--gap); }
.kpi-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 16px 12px; box-shadow: var(--sh-1); display: flex; flex-direction: column; gap: 6px; min-inline-size: 0; position: relative; }
.kpi-tile.is-bad { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.kpi-tile.is-warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.kpi-top { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: var(--fs-sm); font-weight: 600; }
.kpi-hint { cursor: help; font-weight: 400; }
.kpi-main { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; min-block-size: 40px; }
.kpi-value { white-space: nowrap; font-size: var(--fs-2xl); line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-spark { color: var(--chart-1); flex: none; padding-block-end: 4px; }
.kpi-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 10px; font-size: var(--fs-xs); min-block-size: 20px; }
.kpi-delta { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-delta.good { color: var(--ok); } .kpi-delta.bad { color: var(--danger); } .kpi-delta.flat { color: var(--muted); }
.kpi-vs { font-weight: 400; color: var(--muted); }
.kpi-target { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); white-space: nowrap; }
.kpi-dot { inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--muted); }
.kpi-target.ok .kpi-dot { background: var(--ok); } .kpi-target.warn .kpi-dot { background: var(--warn); } .kpi-target.bad .kpi-dot { background: var(--danger); }
.kpi-band { position: relative; display: block; block-size: 6px; background: var(--surface-sunken); border-radius: var(--r-pill); margin-block-start: 2px; }
.kpi-band-fill { display: block; block-size: 100%; border-radius: var(--r-pill); background: var(--muted); }
.kpi-band-fill.ok { background: var(--ok); } .kpi-band-fill.warn { background: var(--warn); } .kpi-band-fill.bad { background: var(--danger); }
.kpi-band-tick { position: absolute; inset-block: -3px; inline-size: 2px; background: var(--text); border-radius: 1px; transform: translateX(-1px); }
.chart-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); align-items: stretch; }
.chart-card { grid-column: span 6; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 18px 14px; box-shadow: var(--sh-1); min-inline-size: 0; display: flex; flex-direction: column; gap: 10px; }
.chart-card.wide { grid-column: span 12; }
.chart-card.third { grid-column: span 4; }
.cc-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 8px 12px; }
.cc-titles h3 { margin: 0; font-size: var(--fs-md); }
.cc-sub { margin: 2px 0 0; color: var(--muted); font-size: var(--fs-xs); }
.cc-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cc-toggle { min-height: 32px; padding: 2px 12px; font-size: var(--fs-xs); }
.cc-body { min-inline-size: 0; flex: 1; }
.cc-table { font-size: var(--fs-sm); }
.cc-table td, .cc-table th { font-variant-numeric: tabular-nums; }
@media (max-width: 960px) { .chart-card, .chart-card.third { grid-column: span 12; } }
.an-table td, .an-table th { font-variant-numeric: tabular-nums; white-space: nowrap; padding: 9px 10px; font-size: var(--fs-sm); }
.an-table td.num, .an-table th.num { text-align: end; }
.an-table .spark-cell { padding-block: 4px; }
.an-table tbody tr[data-href] { cursor: pointer; }
.an-table th button.sort { background: none; border: 0; padding: 0; min-height: 24px; font: inherit; font-weight: 700; color: inherit; display: inline-flex; gap: 4px; align-items: center; }
.an-table th button.sort[aria-sort] { color: var(--accent); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 700; background: var(--surface-sunken); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.bad { background: var(--danger-soft); color: var(--danger); }
.an-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.an-timeline { display: flex; block-size: 22px; border-radius: var(--r-sm); overflow: hidden; background: var(--surface-sunken); }
.an-timeline span { display: block; min-inline-size: 1px; }
.an-timeline .st-ready { background: var(--ok); } .an-timeline .st-not_ready { background: var(--chart-3); } .an-timeline .st-offline { background: var(--surface-sunken); } .an-timeline .st-not_responding { background: var(--danger); }
.an-profile { display: grid; gap: var(--gap); }

/* The wallboard's big-number board. */
.wb { display: flex; flex-direction: column; gap: var(--gap); }
.wb-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--gap); }
.wb-big { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px 20px; box-shadow: var(--sh-1); display: flex; flex-direction: column; gap: 4px; border-inline-start: 6px solid var(--muted); min-inline-size: 0; }
.wb-big.ok { border-inline-start-color: var(--ok); } .wb-big.warn { border-inline-start-color: var(--warn); background: var(--warn-soft); } .wb-big.bad { border-inline-start-color: var(--danger); background: var(--danger-soft); }
.wb-big .wb-label { color: var(--muted); font-weight: 600; font-size: var(--fs-md); }
.wb-big .wb-value { white-space: nowrap; font-size: clamp(2.2rem, 4.2vw, 4rem); line-height: 1.05; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.wb-big .wb-sub { color: var(--muted); font-size: var(--fs-sm); }
.wb-big.bad .wb-value { color: var(--danger); } .wb-big.warn .wb-value { color: var(--warn); }
.wb-split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--gap); }
@media (max-width: 960px) { .wb-split { grid-template-columns: minmax(0, 1fr); } }
.wb-qrow { display: grid; grid-template-columns: minmax(120px, 1.4fr) repeat(4, minmax(60px, 1fr)); gap: 8px 12px; align-items: center; padding: 10px 0; border-block-end: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.wb-qrow:last-child { border-block-end: 0; }
.wb-qrow .name { font-weight: 700; } .wb-qrow .num { font-size: var(--fs-xl); font-weight: 700; text-align: end; }
.wb-qrow.head { color: var(--muted); font-size: var(--fs-xs); font-weight: 600; padding-block: 0 6px; }
.wb-qrow.head span:not(:first-child) { text-align: end; }
.wb-qrow .num.warn { color: var(--warn); } .wb-qrow .num.bad { color: var(--danger); }
.wb-agents { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.wb-agent { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r-md); background: var(--surface-sunken); font-size: var(--fs-sm); min-inline-size: 0; }
.wb-agent .dot { inline-size: 10px; block-size: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.wb-agent.ready .dot { background: var(--ok); } .wb-agent.not_ready .dot { background: var(--chart-3); } .wb-agent.busy .dot { background: var(--chart-1); } .wb-agent.not_responding .dot { background: var(--danger); }
.wb-agent .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.wb-agent .s { margin-inline-start: auto; color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
.wb-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; color: var(--muted); font-size: var(--fs-sm); }
.wb-live { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--ok); }
.wb-live::before { content: ""; inline-size: 8px; block-size: 8px; border-radius: 50%; background: currentColor; animation: wb-pulse 1.8s infinite; }
.wb-live.stale { color: var(--danger); }
@keyframes wb-pulse { 50% { opacity: 0.35; } }
body.tv .wb-big .wb-value { font-size: clamp(2.8rem, 5.4vw, 6rem); }
body.tv .wb-big .wb-label { font-size: 1.3rem; }
body.tv .wb-qrow .num { font-size: 2rem; } body.tv .wb-qrow .name { font-size: 1.4rem; }
body.tv .wb-agent { font-size: 1.05rem; }
@media (max-width: 520px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-tile { padding: 12px; }
  .kpi-value { font-size: var(--fs-xl); }
  .kpi-spark { display: none; }
  .an-bar { padding: 10px; }
  .an-field select, .an-field input { min-inline-size: 120px; }
  .chart-card { padding: 14px 12px 12px; }
  .wb-qrow { grid-template-columns: minmax(80px, 1.3fr) repeat(4, minmax(0, 1fr)); gap: 6px; }
  .wb-qrow .num { font-size: var(--fs-lg); }
  .wb-qrow.head { font-size: 0.65rem; }
  .wb-big { padding: 14px; }
}

/* ==== Everyday pages: shared furniture (ui.js) ================================================================ */
.ui-av { display: inline-grid; place-items: center; flex: none; border-radius: 50%; font-weight: 700; letter-spacing: 0.02em; line-height: 1; user-select: none;
  background: color-mix(in srgb, var(--av, var(--chart-1)) 20%, var(--surface)); color: color-mix(in srgb, var(--av, var(--chart-1)) 55%, var(--text)); }
.ui-av-sm { inline-size: 22px; block-size: 22px; font-size: 9px; }
.ui-av-md { inline-size: 38px; block-size: 38px; font-size: 13px; }
.ui-av-lg { inline-size: 48px; block-size: 48px; font-size: 16px; }
.ui-av-xl { inline-size: 64px; block-size: 64px; font-size: 21px; }
.tone-0 { --av: var(--chart-1); } .tone-1 { --av: var(--chart-2); } .tone-2 { --av: var(--chart-3); }
.tone-3 { --av: var(--chart-4); } .tone-4 { --av: var(--chart-5); } .tone-5 { --av: var(--chart-6); }

.ui-pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 650; line-height: 1.65; white-space: nowrap; background: var(--surface-sunken); color: var(--muted); }
.ui-pill .icon { inline-size: 12px; block-size: 12px; stroke-width: 2; margin: 0; }
.ui-dot::before { content: ""; inline-size: 6px; block-size: 6px; border-radius: 50%; background: currentColor; flex: none; }
.ui-ok { background: var(--ok-soft); color: var(--ok); }
.ui-warn { background: var(--warn-soft); color: var(--warn); }
.ui-danger { background: var(--danger-soft); color: var(--danger); }
.ui-info { background: var(--accent-soft); color: var(--accent); }
.ui-teal { background: var(--teal-soft); color: var(--teal); }
.ui-muted { background: var(--surface-sunken); color: var(--muted); }
.sla-pill { font-variant-numeric: tabular-nums; }
.sla-ok { background: var(--surface-sunken); color: var(--muted); }
.sla-warn { background: var(--warn-soft); color: var(--warn); }
.sla-breach { background: var(--danger); color: var(--danger-text); }

.ui-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--sp-2); margin-block-end: var(--sp-3); }
.ui-head h1 { margin: 0; font-size: var(--fs-2xl); }
.ui-head p { margin: 4px 0 0; max-inline-size: 70ch; }
.ui-head-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ui-empty { padding-block: var(--sp-4); }
.ui-empty-title { font-weight: 650; color: var(--text); }
.link-arrow { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-decoration: none; }
.link-arrow .icon { inline-size: 16px; block-size: 16px; }
.link-arrow:hover { text-decoration: underline; }
[dir="rtl"] .link-arrow .icon { transform: scaleX(-1); }
.button-link.ghost, button.ghost { background: var(--surface); color: var(--text); border-color: var(--control-border); box-shadow: none; }
.button-link.ghost:hover, button.ghost:hover:not(:disabled) { background: var(--row-hover); border-color: var(--text); }
.button-link .icon, button:not(.icon-btn) > .icon { inline-size: 16px; block-size: 16px; margin-inline-end: 6px; }
main button:has(> .icon), main .button-link:has(> .icon), dialog button:has(> .icon) { display: inline-flex; align-items: center; justify-content: center; }
.back-link .icon { transform: scaleX(-1); }
[dir="rtl"] .back-link .icon { transform: none; }

.ui-seg { display: flex; gap: 2px; padding: 3px; background: var(--surface-sunken); border-radius: var(--r-md); max-inline-size: 100%; }
.ui-seg-btn { flex: 1 1 auto; min-inline-size: 0; min-height: 30px !important; padding: 2px 8px; border: 0; background: transparent; color: var(--muted); font-size: 0.8rem; display: inline-flex; align-items: center; justify-content: center; gap: 5px; border-radius: var(--r-sm); white-space: nowrap; }
.ui-seg-btn:hover:not(:disabled) { background: var(--row-hover); border: 0; color: var(--text); }
.ui-seg-btn[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--sh-1); }
.ui-seg-count { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; background: var(--surface-sunken); border-radius: var(--r-pill); padding: 0 6px; }
.ui-seg-btn[aria-pressed="true"] .ui-seg-count { background: var(--accent-soft); color: var(--accent); }
.ui-seg-btn .icon { margin: 0; }

.ui-bar { block-size: 8px; border-radius: var(--r-pill); background: var(--surface-sunken); overflow: hidden; }
.ui-bar-fill { display: block; block-size: 100%; border-radius: var(--r-pill); background: var(--accent); transition: inline-size var(--dur) var(--ease); }
.ui-bar-ok .ui-bar-fill { background: var(--ok); } .ui-bar-warn .ui-bar-fill { background: var(--warn); } .ui-bar-danger .ui-bar-fill { background: var(--danger); } .ui-bar-teal .ui-bar-fill { background: var(--teal); }

.kbd-help { inline-size: min(440px, calc(100vw - 32px)); }
.kbd-help-head { display: flex; align-items: center; justify-content: space-between; margin-block-end: var(--sp-1); }
.kbd-help-head h2 { margin: 0; }
.kbd-list { list-style: none; margin: 0 0 var(--sp-1); padding: 0; display: grid; gap: 2px; }
.kbd-list li { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 4px; border-block-end: 1px solid var(--border); }
.kbd-list li:last-child { border-block-end: 0; }
.kbd-keys { display: inline-flex; gap: 4px; }

/* ---- Settings layout: left section nav, form groups, help text ---------------------------------------- */
.set-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--sp-3); align-items: start; }
.set-nav { position: sticky; inset-block-start: calc(var(--topbar-h) + 16px); display: grid; gap: 2px; }
.set-nav-btn { text-align: start; justify-content: flex-start; border: 0; background: transparent; min-height: 36px; padding: 6px 12px; color: var(--muted); font-weight: 600; border-radius: var(--r-md); border-inline-start: 3px solid transparent; }
.set-nav-btn:hover:not(:disabled) { background: var(--row-hover); border: 0; border-inline-start: 3px solid transparent; color: var(--text); }
.set-nav-btn[aria-current="true"] { background: var(--accent-soft); color: var(--accent); border-inline-start-color: var(--accent); }
.set-body { display: grid; gap: var(--gap); min-inline-size: 0; }
.set-section { margin: 0; padding: 0; scroll-margin-block-start: calc(var(--topbar-h) + 16px); }
.set-section-head { padding: var(--sp-2) var(--sp-3); border-block-end: 1px solid var(--border); }
.set-section-head h2 { margin: 0; font-size: var(--fs-lg); }
.set-section-head p { margin: 2px 0 0; font-size: var(--fs-sm); }
.set-section-body { padding: var(--sp-3); display: grid; gap: var(--sp-2); }
.set-section-body > :first-child { margin-block-start: 0; }
.set-section-body > .card { box-shadow: none; background: var(--surface-sunken); border-color: transparent; margin: 0; }
.set-section-body form { display: grid; gap: var(--sp-1); }
.set-section-body form button[type="submit"] { inline-size: auto; justify-self: start; }
.form-row { display: grid; gap: 4px; }
.form-row label { margin: 0; }
.form-help { margin: 0; }
@media (max-width: 899px) {
  .set-layout { grid-template-columns: minmax(0, 1fr); }
  .set-nav { position: static; display: flex; overflow-x: auto; gap: 6px; padding-block-end: 4px; }
  .set-nav-btn { flex: none; border: 1px solid var(--border-strong); border-radius: var(--r-pill); }
  .set-nav-btn[aria-current="true"] { border-color: var(--accent); }
  .set-nav-btn:hover:not(:disabled) { border: 1px solid var(--border-strong); }
}

/* ---- Inbox: list | thread | customer (conversations.js, workspace.js, thread.js) --------------------------- */
.inbox-pane { display: flex; flex-direction: column; gap: var(--sp-1); }
.inbox-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.inbox-head h1 { margin: 0; font-size: var(--fs-xl); }
.inbox-tools { display: grid; gap: 8px; }
.search-field { position: relative; display: block; }
.search-field > .icon { position: absolute; inset-inline-start: 10px; inset-block-start: 50%; transform: translateY(-50%); color: var(--muted); inline-size: 16px; block-size: 16px; pointer-events: none; }
.inbox-search, .search-field input { padding-inline-start: 34px; }
.inbox-tools .ui-seg { justify-self: start; max-inline-size: 100%; }
.inbox-channel { inline-size: 100%; }
.cv-box { min-block-size: 0; }
.cv-list { gap: 2px; }
.cv-row { display: flex; align-items: flex-start; gap: 12px; padding: 10px 10px; background: transparent; border: 0; border-radius: var(--r-md); border-inline-start: 3px solid transparent; color: var(--text); text-decoration: none; }
.cv-row:hover { background: var(--row-hover); }
.cv-row[aria-current="page"] { background: var(--accent-soft); border-inline-start-color: var(--accent); }
.cv-row .ui-av { margin-block-start: 2px; }
.cv-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; min-inline-size: 0; flex: 1; }
.cv-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.cv-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-age { flex: none; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.cv-sub { color: var(--muted); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 2px 0 0; }
.cv-meta > * { flex: none; }
.cv-meta .cv-owner { flex: 0 1 auto; }
.cv-meta .channel-ico { inline-size: 20px; block-size: 20px; border-radius: 6px; }
.cv-meta .channel-ico .icon { inline-size: 12px; block-size: 12px; margin: 0; }
.cv-owner { display: inline-flex; align-items: center; gap: 4px; margin-inline-start: auto; color: var(--muted); font-size: var(--fs-xs); min-inline-size: 0; }
.cv-owner-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-inline-size: 9ch; }
.cv-unassigned { font-style: italic; }
.inbox-pane .conversation-row[aria-current="page"] { background: var(--accent-soft); }
.inbox-pane .empty-state { padding: var(--sp-3) var(--sp-2); }

.conversation-pane { gap: 0; padding: 0; }
.thread-head { display: flex; align-items: center; gap: 14px; padding: 14px var(--sp-3); background: var(--surface); border-block-end: 1px solid var(--border); flex: none; }
.thread-head-main { min-inline-size: 0; flex: 1; display: grid; gap: 4px; }
.thread-head h2 { margin: 0; font-size: var(--fs-lg); letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-head-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0; font-size: var(--fs-sm); }
.chan-chip, .who-chip { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--fs-sm); }
.chan-chip .channel-ico { inline-size: 20px; block-size: 20px; border-radius: 6px; }
.chan-chip .channel-ico .icon { inline-size: 12px; block-size: 12px; margin: 0; }
.thread-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-inline-size: 28ch; }
.thread-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.thread-actions .back-link { display: none; }
.workspace.inbox-page:not(.has-selection) .conversation-pane { grid-column: 2 / -1; }
.conversation-pane > .ui-empty { margin: auto; max-inline-size: 440px; inline-size: calc(100% - 48px); }
.conversation-pane .thread-messages { flex: 1; min-height: 0; overflow-y: auto; padding: var(--sp-2) var(--sp-3); margin: 0; max-height: none; gap: 6px; }
.thread-foot { display: flex; align-items: center; gap: 8px; padding: 10px var(--sp-3); margin: 0; background: var(--surface); border-block-start: 1px solid var(--border); }
.thread-foot .icon { inline-size: 16px; block-size: 16px; }
.day-sep { align-self: stretch; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: var(--fs-xs); font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; margin-block: 10px 2px; }
.day-sep::before, .day-sep::after { content: ""; flex: 1; block-size: 1px; background: var(--border); }
.message { --out: var(--bubble-out); position: relative; padding: 9px 13px; border-radius: 16px; box-shadow: var(--sh-1); }
.message.outbound { background: var(--out); }
.message[data-channel="whatsapp"] { --out: color-mix(in srgb, var(--teal) 16%, var(--surface)); }
.message[data-channel="sms"], .message[data-channel="rcs"] { --out: color-mix(in srgb, var(--warn) 14%, var(--surface)); }
.message[data-channel="email"] { --out: var(--surface-sunken); }
.message[data-channel="instagram"], .message[data-channel="comments"] { --out: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.message .body { line-height: 1.45; }
.message .msg-foot { order: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 4px 0 0; font-size: var(--fs-xs); color: var(--muted); }
.message .msg-who { font-weight: 600; }
.message .msg-sep { opacity: 0.6; }
.message .tick { margin-inline-start: 2px; }
.message .msg-file { display: inline-flex; align-items: center; gap: 6px; margin-block-start: 6px; font-weight: 600; }
.message .msg-file .icon { inline-size: 16px; block-size: 16px; }
.message.note { position: relative; align-self: stretch; max-inline-size: none; border: 1px dashed color-mix(in srgb, var(--warn) 55%, transparent); border-inline-start: 4px solid var(--warn); background: var(--warn-soft); border-radius: var(--r-md); box-shadow: none; }
.message.note .note-flag { display: flex; align-items: center; gap: 6px; margin: 0 0 4px; font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--warn); }
.message.note .note-flag .icon { inline-size: 14px; block-size: 14px; }
.message.note .msg-foot { color: var(--warn); }
.call-card { align-self: stretch; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--sh-1); list-style: none; }
.call-card h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 2px; }
.call-card .call-time { margin-inline-start: auto; font-weight: 400; }
.call-card article > .meta { margin: 2px 0; }
.call-recordings { margin-block-start: 6px; }

.context-pane { padding: var(--sp-2); gap: var(--sp-2); background: var(--bg); }
.context-pane .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-2); box-shadow: var(--sh-1); }
.context-pane .panel h2, .context-pane .panel > h3 { margin: 0 0 var(--sp-1); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.context-pane .contact-card h2 { font-size: var(--fs-lg); text-transform: none; letter-spacing: -0.01em; color: var(--text); margin: 0; }
.contact-card-top { display: flex; align-items: center; gap: 14px; margin-block-end: var(--sp-1); }
.id-list { list-style: none; margin: 0 0 var(--sp-1); padding: 0; display: grid; gap: 6px; }
.id-list li { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); min-inline-size: 0; }
.id-list .icon { inline-size: 16px; block-size: 16px; color: var(--muted); }
.id-kind { color: var(--muted); }
.id-value { overflow-wrap: anywhere; }
.hist-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.hist-row { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-radius: var(--r-sm); color: var(--text); text-decoration: none; font-size: var(--fs-sm); }
.hist-row:hover { background: var(--row-hover); }
.hist-sub { flex: 1; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.hist-row time { font-size: var(--fs-xs); white-space: nowrap; }
.crm-records { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.crm-records li { display: flex; align-items: center; gap: 8px; }
.crm-records .icon { inline-size: 16px; block-size: 16px; color: var(--muted); }

@media (min-width: 1100px) {
  .workspace.inbox-page { grid-template-columns: minmax(300px, 360px) minmax(0, 1fr) minmax(260px, 320px); }
  .inbox-pane { padding: var(--sp-2) var(--sp-1) var(--sp-2) var(--sp-2); overflow: hidden; }
  .conversation-pane { padding-inline: 0; }
  .cv-box { overflow-y: auto; }
}
@media (max-width: 759px) {
  .workspace.inbox-page.has-selection .inbox-pane { display: none; }
  .workspace.inbox-page:not(.has-selection) .conversation-pane, .workspace.inbox-page:not(.has-selection) .context-pane { display: none; }
  .thread-actions .back-link { display: inline-flex; }
  .thread-head { flex-wrap: wrap; padding-inline: var(--sp-2); }
  .thread-actions { inline-size: 100%; justify-content: flex-start; order: 5; }
  .conversation-pane .thread-messages { padding-inline: var(--sp-2); max-height: none; }
}

/* ---- Workspace: presence, offers, composer ---------------------------------------------------------------- */
.ui-pill { flex: none; }
.presence-card { display: grid; gap: 8px; padding: 12px; background: var(--surface-sunken); border-radius: var(--r-lg); }
.presence-card .presence-state { margin: 0; font-size: var(--fs-sm); }
.presence-compact { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.presence-compact select { inline-size: 100%; min-inline-size: 0; }
.presence-compact #presence-reason { grid-column: 1 / -1; grid-row: 2; }
.presence-compact button[type="submit"] { margin: 0; inline-size: auto; }
.presence-links { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: var(--fs-sm); }
.presence-links .link-button { padding: 0; }
.pane-h { display: flex; align-items: center; gap: 8px; }
.inbox-pane .pane-h { margin-block: var(--sp-2) 4px; }
.inbox-pane .pane-h .ui-seg-count { background: var(--accent-soft); color: var(--accent); letter-spacing: 0; }
.offers { gap: 8px; }
.offer.card { padding: 12px; border-inline-start: 4px solid var(--accent) !important; }
.offer-line { display: flex; align-items: center; gap: 10px; margin: 0 0 4px; }
.offer-who { display: grid; min-inline-size: 0; flex: 1; }
.offer-who .meta { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.offer-who .channel-ico { inline-size: 18px; block-size: 18px; border-radius: 5px; }
.offer-who .channel-ico .icon { inline-size: 11px; block-size: 11px; margin: 0; }
.offer-timer { font-variant-numeric: tabular-nums; }
.offer .actions { margin-block-start: 8px; }
.offer .actions button { flex: 1; }
.team-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-block-end: 1px solid var(--border); }
.team-row:last-child { border-block-end: 0; }
.team-row button { min-height: 32px; padding: 2px 12px; font-size: var(--fs-sm); }
.team { list-style: none; margin: 0; padding: 0; }
.workspace .cv-unread, .cv-row .badge.unread { margin: 0; }

.workspace .composer { position: sticky; inset-block-end: 0; margin: 0; border-radius: 0; border-inline: 0; border-block-end: 0; box-shadow: 0 -6px 18px rgba(19, 23, 34, 0.06); padding: 12px var(--sp-3) 14px; background: var(--surface); }
.workspace .composer.is-note { background: color-mix(in srgb, var(--warn-soft) 70%, var(--surface)); }
.composer-form { display: grid; gap: 8px; }
.composer-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.composer-label { margin: 0; font-size: var(--fs-sm); color: var(--muted); }
.composer.is-note .composer-label { color: var(--warn); }
.composer textarea { min-height: 76px; resize: vertical; background: var(--surface); }
.composer.is-note textarea { border-color: var(--warn); }
.composer-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.composer-tools .composer-spacer { flex: 1; }
.composer-hint { margin: 0; font-size: var(--fs-xs); }
.tool-btn { min-height: 34px !important; padding: 2px 10px; font-size: var(--fs-sm); font-weight: 600; }
.tool-select { inline-size: auto; max-inline-size: 190px; min-height: 34px; font-size: var(--fs-sm); }
.composer .window { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 2px 10px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 650; }
.composer .window .icon { inline-size: 13px; block-size: 13px; }
.composer .window.open { background: var(--ok-soft); color: var(--ok); }
.composer .window.closed { background: var(--danger-soft); color: var(--danger); }
.file-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px 2px 10px; border: 1px solid var(--border-strong); border-radius: var(--r-pill); font-size: var(--fs-sm); max-inline-size: 240px; }
.file-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .icon { inline-size: 14px; block-size: 14px; flex: none; }
.file-chip .icon-btn { min-height: 24px; min-width: 24px; padding: 0; border: 0; }
.composer .composer-form button[type="submit"] { inline-size: auto; margin: 0; }
.composer .composer-form .icon { margin-inline-end: 6px; }
.composer .ui-seg-btn .icon { margin: 0; }
.template-form { display: grid; gap: 8px; }
.template-head { display: flex; gap: 12px; align-items: flex-start; }
.template-head .icon { inline-size: 22px; block-size: 22px; color: var(--teal); margin-block-start: 2px; }
.template-head p { margin: 0; }
.template-preview-label { margin: 4px 0 0; }
.template-bubble { margin: 0; padding: 10px 14px; background: color-mix(in srgb, var(--teal) 14%, var(--surface)); border-radius: 16px; border-end-end-radius: 4px; max-inline-size: 520px; white-space: pre-wrap; }
.template-form button[type="submit"] { inline-size: auto; justify-self: start; margin: 0; }
.composer-none { padding: var(--sp-2) var(--sp-3); margin: 0; }
.actions-panel { display: grid; gap: var(--sp-2); }
.ctx-calls { display: flex; align-items: center; gap: 8px; margin: 0; }
.ctx-calls .icon { inline-size: 16px; block-size: 16px; }
.context-pane .panel details { border: 0; padding: 0; background: transparent; }
.context-pane .conversation-actions { display: grid; }
.context-pane details.contact-panel, .context-pane > details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 4px var(--sp-2); box-shadow: var(--sh-1); }
.context-pane > details[open] { padding-block-end: 12px; }
.context-pane > details > summary { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.typing { padding-inline: var(--sp-3); margin: 0; min-height: 1.4em; font-size: var(--fs-sm); }
@media (min-width: 1100px) {
  .workspace:not(.inbox-page) { grid-template-columns: minmax(300px, 360px) minmax(0, 1fr) minmax(260px, 320px); }
  .workspace:not(.inbox-page) .inbox-pane { overflow-y: auto; }
  .workspace .conversation-pane { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
  .workspace .conversation-pane > .empty-state { margin: auto; }
}
@media (max-width: 759px) {
  .workspace.has-selection .inbox-pane { display: none; }
  .workspace:not(.has-selection) .conversation-pane, .workspace:not(.has-selection) .context-pane { display: none; }
  .workspace .composer { padding-inline: var(--sp-2); }
  .composer-hint { display: none; }
}

/* ---- Inbox refinements ------------------------------------------------------------------------------------- */
main .thread-actions .back-link { display: none; }
.thread-head { flex-wrap: wrap; row-gap: 10px; }
.thread-head-main { flex: 1 1 240px; }
.thread-actions { flex: 0 1 auto; }
.thread-actions .button-link, .thread-actions button { min-height: 34px; padding: 2px 12px; font-size: var(--fs-sm); }
.composer-labelrow { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.inbox-pane .ui-empty-title { font-weight: 500; color: var(--muted); }
.inbox-pane .ui-empty { padding: var(--sp-2); }
@media (max-width: 759px) {
  main .thread-actions .back-link { display: inline-flex; }
}

/* ---- Lists and tables: toolbars, responsive rows, chips (contacts, tickets, campaigns) ------------------------------ */
.list-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-block-end: var(--sp-2); }
.list-tools .search-field { flex: 1 1 260px; max-inline-size: 440px; }
.list-tools select { inline-size: auto; min-inline-size: 150px; }
.contacts-count { margin-block: 0 8px; min-height: 1.4em; }
.rtable-wrap { max-height: none; overflow-x: auto; }
.rtable td, .rtable th { vertical-align: middle; }
.rtable tbody td { padding-block: 12px; }
.rtable tr.row-link { cursor: pointer; }
.rtable tr.row-link:hover td { background: var(--row-hover); }
.contact-cell { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; min-inline-size: 0; padding: 0; }
.contact-cell:hover .contact-name { text-decoration: underline; }
.contact-cell-text { display: grid; min-inline-size: 0; }
.contact-name { font-weight: 650; }
.contact-cell-text .meta { margin: 0; }
.chan-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.chan-chips .channel-ico { inline-size: 24px; block-size: 24px; border-radius: 7px; }
.chan-chips .channel-ico .icon { inline-size: 14px; block-size: 14px; margin: 0; }
.tag-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.tag-chip { display: inline-flex; align-items: center; padding: 1px 9px; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent); font-size: var(--fs-xs); font-weight: 600; line-height: 1.6; white-space: nowrap; }
.tag-more { background: var(--surface-sunken); color: var(--muted); }
@media (max-width: 719px) {
  .rtable-wrap { border: 0; background: transparent; box-shadow: none; overflow: visible; }
  .rtable, .rtable tbody { display: block; background: transparent; }
  .rtable thead { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .rtable tbody tr { display: grid; gap: 6px; padding: 12px 14px; margin-block-end: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
  .rtable tbody td { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0; border: 0; background: transparent !important; }
  .rtable tbody td::before { content: attr(data-label); flex: none; color: var(--muted); font-size: var(--fs-xs); font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; }
  .rtable tbody td[data-empty] { display: none; }
  .rtable tbody td:first-child { padding-block-end: 6px; border-block-end: 1px solid var(--border); }
  .rtable tbody td:first-child::before { display: none; }
  .rtable tbody td > * { min-inline-size: 0; text-align: end; }
  .rtable tbody td:first-child > * { text-align: start; }
}

/* ---- Contact profile -------------------------------------------------------------------------------------- */
.contact-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--sp-3); align-items: start; }
.contact-profile { display: grid; gap: var(--gap); position: sticky; inset-block-start: calc(var(--topbar-h) + 16px); }
.contact-profile .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-2); box-shadow: var(--sh-1); }
.contact-profile .panel h2, .contact-profile .panel h3, .contact-profile .panel > summary { margin: 0 0 var(--sp-1); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 650; }
.contact-profile .panel > summary { margin: 0; cursor: pointer; min-height: 32px; display: flex; align-items: center; }
.contact-profile details[open] > summary { margin-block-end: var(--sp-1); }
.contact-profile .panel .profile-name { font-size: var(--fs-xl); text-transform: none; letter-spacing: -0.01em; color: var(--text); margin: 0; }
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 var(--sp-2); }
.stat-row > div { background: var(--surface-sunken); border-radius: var(--r-md); padding: 8px 10px; }
.stat-row dt { color: var(--muted); font-size: var(--fs-xs); font-weight: 600; }
.stat-row dd { margin: 2px 0 0; font-size: var(--fs-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
.profile-tags h3 { margin-block: 0 6px; }
.merge-form { display: grid; gap: 6px; }
.merge-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--gap); }
.merge-item { padding-block: 8px; border-block-end: 1px solid var(--border); }
.merge-item:last-child { border-block-end: 0; }
.tl-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-block-end: var(--sp-1); }
.tl-toolbar h2 { margin: 0; }
.tl { list-style: none; margin: 0; padding: 0; position: relative; display: grid; gap: 0; }
.tl::before { content: ""; position: absolute; inset-block: 8px; inset-inline-start: 17px; inline-size: 2px; background: var(--border); border-radius: 2px; }
.tl-item { position: relative; display: flex; gap: 14px; padding-block: 8px; }
.tl-dot { position: relative; z-index: 1; flex: none; display: grid; place-items: center; inline-size: 36px; block-size: 36px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border); color: var(--muted); }
.tl-dot .icon { inline-size: 16px; block-size: 16px; margin: 0; }
.tl-dot[data-channel="whatsapp"], .tl-dot[data-channel="voice"], .tl-dot[data-channel="viber"] { border-color: color-mix(in srgb, var(--teal) 55%, var(--border)); color: var(--teal); }
.tl-dot[data-channel="sms"], .tl-dot[data-channel="rcs"], .tl-dot[data-channel="review"] { border-color: color-mix(in srgb, var(--warn) 55%, var(--border)); color: var(--warn); }
.tl-dot[data-channel="webchat"], .tl-dot[data-channel="email"], .tl-dot[data-channel="messenger"] { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); color: var(--accent); }
.tl-dot[data-channel="instagram"], .tl-dot[data-channel="comments"] { border-color: color-mix(in srgb, var(--danger) 50%, var(--border)); color: var(--danger); }
.tl-body { flex: 1; min-inline-size: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 10px 14px; box-shadow: var(--sh-1); }
.tl-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin: 0 0 2px; }
.tl-title { font-weight: 650; }
.tl-head time { font-size: var(--fs-xs); white-space: nowrap; }
.tl-detail > p { margin: 4px 0 0; }
.tl-detail .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.tl-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.tl-item.note .tl-body { background: var(--warn-soft); border-style: dashed; border-color: color-mix(in srgb, var(--warn) 55%, transparent); }
.tl-item.restricted .tl-body { background: var(--surface-sunken); box-shadow: none; }
.tl-item[hidden] { display: none; }
.tl-body > .link-arrow { margin-block-start: 4px; font-size: var(--fs-sm); }
@media (max-width: 1019px) {
  .contact-layout { grid-template-columns: minmax(0, 1fr); }
  .contact-profile { position: static; order: -1; }
}
@media (max-width: 719px) { .tl::before { inset-inline-start: 13px; } .tl-dot { inline-size: 28px; block-size: 28px; } .tl-item { gap: 10px; } }

/* ---- Tickets: list pills, board, detail ------------------------------------------------------------------------- */
.tk-ref { white-space: nowrap; color: var(--muted); }
.tk-sla { font-variant-numeric: tabular-nums; }
.list-tools .check { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-weight: 500; }
.list-tools .check input { inline-size: 20px; block-size: 20px; min-height: 20px; }
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: var(--gap); overflow-x: auto; padding-block-end: 8px; align-items: start; }
.kan-col { background: var(--surface-sunken); border-radius: var(--r-lg); padding: 10px; min-inline-size: 0; }
.kan-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 10px; }
.kan-head h2 { margin: 0; font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.kan-col .ui-seg-count { background: var(--surface); }
.kan-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.kan-card { background: var(--surface); border: 1px solid var(--border); border-inline-start: 3px solid var(--border-strong); border-radius: var(--r-md); padding: 10px 12px; box-shadow: var(--sh-1); display: grid; gap: 6px; transition: box-shadow var(--dur) var(--ease); }
.kan-card:hover { box-shadow: var(--sh-2); }
.kan-card.prio-urgent { border-inline-start-color: var(--danger); }
.kan-card.prio-high { border-inline-start-color: var(--warn); }
.kan-card.prio-normal { border-inline-start-color: var(--accent); }
.kan-link { display: grid; gap: 4px; color: var(--text); text-decoration: none; padding: 0; }
.kan-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kan-top .meta { margin: 0; }
.kan-title { font-weight: 650; overflow-wrap: anywhere; }
.kan-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-block-start: 2px; }
.kan-empty { padding: 12px 4px; text-align: center; }
.ticket-pills { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 var(--sp-2); }
.sla-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--gap); margin-block-end: var(--sp-2); }
.sla-tile { display: grid; gap: 4px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-1); justify-items: start; }
.sla-tile.sla-breach { border-color: color-mix(in srgb, var(--danger) 55%, var(--border)); }
.sla-tile.sla-warn { border-color: color-mix(in srgb, var(--warn) 55%, var(--border)); }
.sla-tile-label { color: var(--muted); font-size: var(--fs-xs); font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; }
.sla-tile-time { font-size: var(--fs-md); }
.ticket-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.ticket-col { display: grid; gap: var(--gap); min-inline-size: 0; }
.ticket-col .card { margin: 0; }
.ticket-col .card select, .ticket-col .card input:not([type="checkbox"]) { inline-size: 100%; }
.ticket-col .card form button[type="submit"], .ticket-col .card .inline-form button { inline-size: auto; }
.plain-list { margin: 0; padding-inline-start: 18px; }
@media (max-width: 899px) { .ticket-layout { grid-template-columns: minmax(0, 1fr); } }

/* ---- Supervisor: queue cards, agent grid, monitor group -------------------------------------------------------- */
.sup-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); }
.sup-body h2 { margin: 0 0 var(--sp-1); font-size: var(--fs-md); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.sup-updated { margin: 0; }
.sup-today .kpis { margin: 0; }
.queue-grid, .agent-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--gap); }
.queue-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.agent-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.queue-card { display: grid; gap: 12px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-block-start: 4px solid var(--border-strong); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.queue-card.q-idle { border-block-start-color: var(--ok); }
.queue-card.q-busy { border-block-start-color: var(--accent); }
.queue-card.q-slow { border-block-start-color: var(--warn); }
.queue-card.q-late { border-block-start-color: var(--danger); background: color-mix(in srgb, var(--danger-soft) 40%, var(--surface)); }
.queue-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.queue-card-head h3 { margin: 0; font-size: var(--fs-md); }
.queue-big .metric-block { display: flex; align-items: baseline; gap: 8px; }
.queue-num { font-size: var(--fs-3xl); line-height: 1; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.queue-num-label { color: var(--muted); font-size: var(--fs-sm); font-weight: 600; }
.queue-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
.queue-stats .metric-block { background: var(--surface-sunken); border-radius: var(--r-md); padding: 6px 10px; }
.queue-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.queue-stats .metric-block:last-child { grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.queue-stats dt { color: var(--muted); font-size: var(--fs-xs); font-weight: 600; }
.queue-stats dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.queue-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.queue-foot .metric-block { display: flex; align-items: center; gap: 8px; }
.queue-foot .meta { margin: 0; }
.queue-channels { display: inline-flex; gap: 4px; }
.queue-channels .channel-ico { inline-size: 22px; block-size: 22px; border-radius: 6px; }
.queue-channels .channel-ico .icon { inline-size: 13px; block-size: 13px; margin: 0; }
.sup-agents-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-block-end: var(--sp-1); }
.sup-agents-head h2 { margin: 0; }
.agent-card { display: grid; gap: 12px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-1); --st: var(--muted); }
.agent-card.ag-ready { --st: var(--ok); }
.agent-card.ag-oncall { --st: var(--teal); border-color: color-mix(in srgb, var(--teal) 45%, var(--border)); }
.agent-card.ag-notready { --st: var(--warn); }
.agent-card.ag-alarm { --st: var(--danger); border-color: color-mix(in srgb, var(--danger) 55%, var(--border)); }
.agent-card.ag-offline { --st: var(--muted); background: var(--surface-sunken); box-shadow: none; }
.agent-card.ag-offline .agent-avatar { opacity: 0.55; }
.agent-head { display: flex; align-items: center; gap: 12px; }
.agent-avatar { border-radius: 50%; padding: 2px; box-shadow: 0 0 0 2px var(--st); display: inline-flex; }
.agent-who { min-inline-size: 0; flex: 1; }
.agent-who h3 { margin: 0; font-size: var(--fs-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-state { display: flex; align-items: center; gap: 6px; margin: 0; font-size: var(--fs-sm); font-weight: 650; color: var(--st); flex-wrap: wrap; }
.agent-state .meta { margin: 0; font-weight: 400; }
.state-dot { inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--st); flex: none; }
.ag-oncall .state-dot { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
.agent-timer { margin-inline-start: auto; font-variant-numeric: tabular-nums; font-weight: 650; color: var(--st); font-size: var(--fs-sm); background: color-mix(in srgb, var(--st) 12%, var(--surface)); border-radius: var(--r-pill); padding: 2px 10px; }
.agent-load { display: grid; gap: 6px; }
.agent-load .meta { margin: 0; }
.load-row { display: grid; grid-template-columns: 22px minmax(0, 84px) minmax(0, 1fr) auto; align-items: center; gap: 8px; font-size: var(--fs-sm); }
.load-row .channel-ico { inline-size: 22px; block-size: 22px; border-radius: 6px; }
.load-row .channel-ico .icon { inline-size: 13px; block-size: 13px; margin: 0; }
.load-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.load-num { font-variant-numeric: tabular-nums; font-weight: 650; min-inline-size: 2.4em; text-align: end; }
.agent-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding-block-start: 10px; border-block-start: 1px solid var(--border); }
.sup-actions { display: inline-flex; border: 1px solid var(--control-border); border-radius: var(--r-md); overflow: hidden; }
.sup-btn { border: 0; border-radius: 0; min-height: 34px !important; padding: 2px 10px; font-size: var(--fs-sm); background: var(--surface); border-inline-end: 1px solid var(--border-strong); }
.sup-btn:last-child { border-inline-end: 0; }
.sup-btn:hover:not(:disabled) { background: var(--accent-soft); border: 0; border-inline-end: 1px solid var(--border-strong); color: var(--accent); }
.sup-btn:last-child:hover:not(:disabled) { border-inline-end: 0; }
.sup-barge { color: var(--danger); }
.sup-barge:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
.sup-btn .icon { margin-inline-end: 5px; }
.force-btn { font-size: var(--fs-sm); margin-inline-start: auto; }
.metric-block { min-inline-size: 0; }

/* ---- Chat supervision ------------------------------------------------------------------------------------------ */
.chat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--sp-3); align-items: start; }
.chat-thread { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-2); min-block-size: 280px; }
.chat-thread .messages { margin: 0; }
.chat-side { display: grid; gap: var(--gap); position: sticky; inset-block-start: calc(var(--topbar-h) + 16px); }
.chat-side .card { margin: 0; }
.chat-side .internal-note { background: var(--warn-soft); color: var(--warn); border-radius: var(--r-md); padding: 8px 12px; }
.wait { font-variant-numeric: tabular-nums; font-weight: 650; }
@media (max-width: 1019px) { .chat-layout { grid-template-columns: minmax(0, 1fr); } .chat-side { position: static; } }
@media (prefers-reduced-motion: reduce) { .ag-oncall .state-dot { animation: none; } }
.wait-warn { background: var(--warn-soft); color: var(--warn); }
.wait-breach { background: var(--danger-soft); color: var(--danger); }

/* ---- Campaigns and the dialler --------------------------------------------------------------------------------- */
.camp-grid { list-style: none; margin: 0 0 var(--sp-3); padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--gap); }
.camp-card { display: grid; gap: 14px; padding: var(--sp-2) var(--sp-3); background: var(--surface); border: 1px solid var(--border); border-block-start: 4px solid var(--border-strong); border-radius: var(--r-lg); box-shadow: var(--sh-1); align-content: start; }
.camp-card.camp-active { border-block-start-color: var(--ok); }
.camp-card.camp-paused { border-block-start-color: var(--warn); }
.camp-card.camp-finished { border-block-start-color: var(--border-strong); background: var(--surface-sunken); box-shadow: none; }
.camp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.camp-title { min-inline-size: 0; }
.camp-title h3 { margin: 0; font-size: var(--fs-lg); overflow-wrap: anywhere; }
.camp-title .meta { margin: 2px 0 0; }
.camp-progress-line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-block-end: 6px; }
.camp-progress .ui-bar { block-size: 10px; }
.camp-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0; }
.camp-stats > div { background: var(--surface-sunken); border-radius: var(--r-md); padding: 8px 10px; min-inline-size: 0; }
.camp-stats dt { color: var(--muted); font-size: var(--fs-xs); font-weight: 600; line-height: 1.25; }
.camp-stats dd { margin: 2px 0 0; font-size: var(--fs-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
.camp-pacing { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: color-mix(in srgb, var(--accent-soft) 40%, var(--surface)); }
.camp-pacing-line { display: flex; align-items: center; gap: 8px; margin: 0; }
.camp-pacing-line .icon { inline-size: 16px; block-size: 16px; color: var(--accent); }
.camp-pacing .meta { margin: 0; }
.camp-cli { display: flex; align-items: center; gap: 8px; margin: 0; }
.camp-cli .icon { inline-size: 14px; block-size: 14px; }
.camp-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-block-start: 12px; border-block-start: 1px solid var(--border); }
.camp-actions button { padding-block: 4px; }
.camp-link { margin-inline-start: auto; font-size: var(--fs-sm); }
.import-row { padding-block: var(--sp-1); border-block-end: 1px solid var(--border); }
.import-row:last-child { border-block-end: 0; }
.import-row h3 { margin-block-end: 4px; }
.live-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; margin-block-end: var(--sp-1); }
.live-head h2, .live-head p { margin: 0; }
.live-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 0 0 var(--sp-2); }
.live-tile { background: var(--surface-sunken); border-radius: var(--r-md); padding: 12px 14px; display: grid; gap: 4px; align-content: start; }
.live-tile dt { color: var(--muted); font-size: var(--fs-xs); font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; }
.live-tile dd { margin: 0; display: grid; gap: 6px; }
.live-num { font-size: var(--fs-2xl); line-height: 1.1; font-variant-numeric: tabular-nums; }
.live-reason { overflow-wrap: anywhere; }
.floor-chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.floor-chip { display: flex; align-items: baseline; gap: 6px; font-size: var(--fs-sm); color: var(--muted); }
.floor-chip strong { color: var(--text); font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }
form.stack > fieldset { margin: 0 0 var(--gap); padding: var(--sp-2) var(--sp-3) var(--sp-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--sp-1) var(--gap); }
form.stack > fieldset > legend { font-size: var(--fs-md); font-weight: 650; padding: 0 8px; }
form.stack > fieldset > :is(.notice, details, p, ul, button, h3) { grid-column: 1 / -1; }
form.stack > fieldset .field label { font-weight: 600; }
form.stack > fieldset details > summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; font-weight: 600; }
@media (max-width: 520px) { .camp-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .camp-grid { grid-template-columns: minmax(0, 1fr); } }
form.stack:has(> fieldset) { max-inline-size: none; }

/* ---- Settings pages: stacks, brand preview, domains ------------------------------------------------------------ */
.set-stack { display: grid; gap: var(--gap); min-inline-size: 0; }
.set-stack > .card, .set-stack > form.card { margin: 0; }
.set-form { display: none; }
.set-section-body .form-row input:not([type="checkbox"]):not([type="color"]), .set-section-body .form-row select, .set-section-body .form-row textarea { inline-size: 100%; max-inline-size: 560px; }
.set-section-body input[type="color"] { inline-size: 64px; padding: 2px; }
.set-section-body fieldset { margin: 0; }
.set-section-body label.inline { margin: 0; font-weight: 500; }
.set-section-body .inline-form { align-items: flex-end; }
.brand-preview { --brand: var(--accent); --brand-accent: var(--teal); display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface-sunken); border-inline-start: 6px solid var(--brand); }
.brand-preview-name { font-weight: 700; font-size: var(--fs-lg); margin-inline-end: auto; }
.brand-preview-chip { inline-size: 28px; block-size: 28px; border-radius: 50%; background: var(--brand); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); }
.brand-preview-chip.accent { background: var(--brand-accent); }
.domain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.domain-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 14px; background: var(--surface-sunken); border-radius: var(--r-md); }
.domain-proof { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; max-inline-size: 100%; }
.domain-proof code { overflow-wrap: anywhere; }
@media (max-width: 759px) { .workspace .composer { position: static; box-shadow: none; border-block-start: 1px solid var(--border); } }

/* ==== Admin pages: owner and admin furniture (ui.js: dataTable, statTiles, sectionCard, callout, confirmButton) ====== */
.ui-page { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); min-inline-size: 0; align-content: start; }
.ui-page > .card, .ui-page > .table-wrap, .ui-page > .ui-head { margin: 0; }
/* A wide table inside a grid item must scroll in its own wrapper, not widen the page. */
.ui-page > * { min-width: 0; }
.ui-page > h2 { margin: var(--sp-2) 0 0; font-size: var(--fs-lg); }
.ui-card { padding: 0; }
.ui-card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--sp-1) var(--sp-2); padding: var(--sp-2) var(--sp-3); border-block-end: 1px solid var(--border); }
.ui-card-head h2 { margin: 0; font-size: var(--fs-lg); }
.ui-card-head p { margin: 2px 0 0; font-size: var(--fs-sm); max-inline-size: 70ch; }
.ui-card-body { padding: var(--sp-3); display: grid; gap: var(--sp-2); min-inline-size: 0; }
.ui-card-body > :first-child { margin-block-start: 0; }
.ui-card-body > .table-wrap { margin: 0; box-shadow: none; }
.ui-card-body form { display: grid; gap: var(--sp-1); }
.ui-card-body form button[type="submit"] { inline-size: auto; justify-self: start; margin-top: 4px; }
.ui-card-body .form-row input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .ui-card-body .form-row select, .ui-card-body .form-row textarea { inline-size: 100%; max-inline-size: 520px; }
.ui-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: var(--sp-2); align-items: start; }
.ui-form-status { margin: 0; min-block-size: 1.2em; color: var(--muted); font-size: var(--fs-sm); }
.ui-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: var(--gap); margin: 0; }
.ui-stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-2) var(--sp-3); box-shadow: var(--sh-1); min-inline-size: 0; }
.ui-card-body > .ui-stats .ui-stat { box-shadow: none; background: var(--surface-sunken); border-color: transparent; }
.ui-stat dt { color: var(--muted); font-size: var(--fs-sm); font-weight: 600; }
.ui-stat dd { margin: 2px 0 0; font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ui-stat p { margin: 2px 0 0; }
.ui-stat dd.meta { font-size: var(--fs-sm); font-weight: 400; letter-spacing: normal; color: var(--muted); }
.ui-stat-ok dd { color: var(--ok); } .ui-stat-warn dd { color: var(--warn); } .ui-stat-danger dd { color: var(--danger); }
.ui-table td.num, .ui-table th.num { text-align: end; font-variant-numeric: tabular-nums; }
.ui-table td .actions { margin: 0; }
.ui-table tbody tr:hover td { background: var(--row-hover); }
.ui-table td code { overflow-wrap: anywhere; }
.ui-callout { padding: 10px var(--gap); border-radius: var(--r-md); border: 1px solid transparent; background: var(--accent-soft); color: var(--text); display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.ui-callout > p { margin: 0; }
.ui-callout-ok { background: var(--ok-soft); } .ui-callout-warn { background: var(--warn-soft); } .ui-callout-danger { background: var(--danger-soft); }
.ui-confirm { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.ui-confirm-q { font-size: var(--fs-sm); font-weight: 600; color: var(--danger); }
.ui-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ui-kv { display: grid; grid-template-columns: fit-content(40%) minmax(0, 1fr); gap: 6px 16px; margin: 0; }
.ui-kv dt { color: var(--muted); }
.ui-kv dd { margin: 0; overflow-wrap: anywhere; }
.ui-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ui-toolbar .search-field { flex: 1 1 220px; max-inline-size: 360px; }
@media (max-width: 640px) { .ui-card-head, .ui-card-body { padding-inline: var(--sp-2); } .ui-table th, .ui-table td { padding: 8px 10px; } }
.ui-reason { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; max-inline-size: 100%; }
.ui-reason input { inline-size: min(100%, 260px); min-inline-size: 11rem; min-height: 36px; padding-block: 4px; text-overflow: ellipsis; }
.ui-table td .ui-reason, .ui-table td .ui-confirm { min-inline-size: min(100%, 17rem); }
.ui-table td .ui-reason input { flex: 1 1 11rem; inline-size: auto; }
.ui-row-actions { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin: 0; }
.ui-row-actions button { white-space: nowrap; }
.ui-state-on { border-inline-start: 3px solid var(--danger); }
.ui-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--gap); }
.ui-list > li { margin: 0; }
.ui-hit { padding: var(--sp-1) 0; border-block-end: 1px solid var(--border); }
.ui-hit:last-child { border-block-end: 0; }
.ui-hit p { margin: 2px 0 0; }
.ui-subform { display: grid; gap: var(--sp-1); padding: var(--sp-2); background: var(--surface-sunken); border-radius: var(--r-md); }
.ui-subform h3 { margin: 0; font-size: var(--fs-md); }
.ui-dest { display: grid; gap: 6px; min-inline-size: 160px; }
.ui-dest select, .ui-dest input { min-height: 36px; }
.ui-add-row { padding-block-end: var(--sp-1); }
.ui-table tr.is-current td { background: var(--accent-soft); }
.ui-live { min-inline-size: 0; }
.ui-gen-out { display: grid; gap: 6px; }
.ui-pay { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-3); align-items: start; }
.ui-pay img { border-radius: var(--r-md); border: 1px solid var(--border); background: #fff; padding: 6px; max-inline-size: 100%; block-size: auto; }
@media (max-width: 640px) { .ui-pay { grid-template-columns: minmax(0, 1fr); } }
.chat-page .inbox-pane { gap: var(--sp-1); }
.chat-page .room-list { display: grid; gap: 2px; }
.ui-list-title { margin: var(--sp-1) 0 0; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.chat-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--sp-2); padding: var(--sp-2) var(--sp-3); border-block-end: 1px solid var(--border); background: var(--surface); }
.chat-head h2 { margin: 0; font-size: var(--fs-lg); margin-inline-end: auto; }
.chat-head p { margin: 0; }
.chat-page .conversation-pane > .messages { padding: var(--sp-2) var(--sp-3); }
.chat-page .conversation-pane > .composer, .chat-page .conversation-pane > .mention-list { margin: var(--sp-2) var(--sp-3); }
.chat-page .mention-list { list-style: none; padding: 0; display: grid; gap: var(--sp-1); }
.ui-mention.unread { border-inline-start: 3px solid var(--accent); }
.chat-dm { align-items: flex-end; }
.ui-details { border: 1px solid var(--border); border-radius: var(--r-md); padding: 4px var(--sp-2); }
.ui-details > summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.ui-details[open] { padding-block-end: var(--sp-2); display: grid; gap: var(--sp-1); }
.ui-filters { align-items: flex-end; gap: var(--sp-2); }
.ui-filters .form-row { min-inline-size: 150px; }
.ui-filters button, .ui-filters .button { margin: 0; }
.ui-report-list { display: grid; gap: var(--gap); }
.ui-report-list > .card { margin: 0; }
.ui-schedules { display: grid; gap: var(--sp-1); }
.ui-schedules h4 { margin: 0; }
.ui-form-status:empty { display: none; }
ul.ui-chips { list-style: none; padding: 0; margin: 0; }
.ui-card-body > p.ui-form-status { margin: 0; }
form.ui-card button[type="submit"] { inline-size: auto; justify-self: start; margin-top: 4px; }
.ui-card-body:empty { display: none; }
.ui-card-body > div:empty { display: none; }
.chat-dm { flex-direction: column; align-items: stretch; }
.chat-dm select { inline-size: 100%; }
.chat-dm button { align-self: flex-start; }
.ui-chips .ui-pill { white-space: normal; }

/* ---- Polish 3: add-rows, form grids, logs ---------------------------------------------------- */
/* One labelled row of inputs and a button: a line on a wide screen, stacked on a phone. */
.ui-add-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: var(--sp-1) var(--sp-2); align-items: end; padding-block-end: var(--sp-1); }
.ui-add-row .form-row { min-inline-size: 0; }
.ui-add-row .form-row input:not([type="checkbox"]), .ui-add-row .form-row select, .ui-add-row .form-row textarea, .ui-add-row > input, .ui-add-row > select { inline-size: 100%; max-inline-size: none; }
.ui-add-row > button, .ui-add-btn button, .ui-add-row button[type="submit"] { margin: 0; inline-size: auto; justify-self: start; }
.ui-add-btn { align-content: end; }
@media (min-width: 760px) { .ui-add-row:not(form) { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) auto; } .ui-add-row:not(form) > .ui-add-btn { grid-column: auto; } }
@media (max-width: 759px) { .ui-add-row > button, .ui-add-btn button, .ui-add-row button[type="submit"] { inline-size: 100%; justify-self: stretch; } }
/* A form of labelled fields in columns; long fields and the button take the whole row. */
.ui-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: var(--sp-2); align-items: start; }
.ui-form-grid > .form-row:has(textarea), .ui-form-grid > fieldset, .ui-form-grid > button[type="submit"], .ui-form-grid > label.check { grid-column: 1 / -1; }
.ui-form-grid .form-row input:not([type="checkbox"]):not([type="radio"]), .ui-form-grid .form-row select, .ui-form-grid .form-row textarea { inline-size: 100%; max-inline-size: none; }
.ui-card-body form.ui-form-grid > button[type="submit"] { justify-self: start; margin-top: 0; }
.ui-sub { margin: var(--sp-1) 0 0; font-size: var(--fs-md); }
.ui-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.ui-log > li { display: grid; grid-template-columns: minmax(120px, 190px) minmax(0, 1fr); gap: 4px var(--sp-2); padding: 8px 0; border-block-end: 1px solid var(--border); }
.ui-log > li:last-child { border-block-end: 0; }
.ui-log blockquote { margin: 4px 0; padding-inline-start: var(--sp-2); border-inline-start: 3px solid var(--border-strong); color: var(--muted); }
@media (max-width: 640px) { .ui-log > li { grid-template-columns: minmax(0, 1fr); } }
.ui-stack-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.ui-code { margin: 0; max-inline-size: 360px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-xs); }
.ui-overdue { margin-block-start: 4px; }
.ui-table td .ui-reason input, .ui-table td .ui-reason { max-inline-size: 100%; }
.ui-details > summary + * { margin-block-start: var(--sp-1); }
.ui-add-row :is(input, select) { block-size: 40px; min-block-size: 40px; }
.ui-add-row > button, .ui-add-btn button { min-block-size: 40px; }
.ui-card-body > .ui-seg { inline-size: fit-content; }
.ui-table .mono, .ui-table td button, .ui-table td .button-link { white-space: nowrap; }
.ui-table td .actions { flex-wrap: wrap; }
/* Pages not yet on .ui-head: their title and intro line sit at the same rhythm. */
main > section > h1:first-child { margin-block-end: 4px; }
main > section > h1:first-child + :is(p.meta, p.muted) { margin-block-start: 0; margin-block-end: var(--sp-3); max-inline-size: 70ch; }
.alert-banner:empty { display: none; }
.ui-plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.search-list { list-style: none; margin: 0; padding: 0; }
.ui-callout[hidden] { display: none; }
.ui-switch-btn[aria-pressed="true"] { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.nowrap { white-space: nowrap; }
.ui-table tbody th[scope="row"] { vertical-align: top; }
.ui-reason-q { flex: 1 0 100%; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
.ui-table td .ui-reason input { min-inline-size: 12rem; }

/* QA-007: the phone-system set-up steps (client notice and the owner panel). */
.phone-steps { list-style: none; margin: 0 0 var(--sp-2); padding: 0; display: grid; gap: 6px; }
.phone-step { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--r-md); }
.phone-step-current { border-color: var(--accent); background: var(--accent-soft); }
.phone-step-done .phone-step-name { color: var(--muted); }
#phone-admin h3, #phone-setup h3 { margin: var(--sp-2) 0 6px; font-size: var(--fs-md); }
#sa-phone-box:not(:empty) { margin-block: var(--sp-2); }

/* QA-013: a field the API refused. */
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }

/* QA-015: the floating softphone does not cover the page. It is 352 px wide at 24 px from the edge. */
@media (min-width: 900px) {
  body.phone-open #main { padding-inline-end: calc(352px + 48px); transition: padding var(--dur-fast) var(--ease); }
}
@media (max-width: 899px) {
  body.phone-open #main { padding-block-end: 70vh; }
}

/* QA-017: the top bar's items stay on one line; QA-018: the set-up links sit apart; QA-016: a single dashboard card spans the row. */
.topbar > * { flex-shrink: 0; }
.topbar > .cmd-trigger, .topbar > .tenant-chip, .topbar > .who { flex-shrink: 1; }
.dash-setup-links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.dash-cols-one { grid-template-columns: minmax(0, 1fr); }

/* QA-025: a hidden select stays hidden whatever its class says. */
.tool-select[hidden], .secure-panel [hidden] { display: none !important; }
/* QA-035: a table scrolls sideways when it must, never up and down inside the page. */
.table-wrap { max-height: none; }
/* QA-021: my numbers on a phone: the rows are cards like every data table (.rtable, QA-035); the destination form sits under its
   name, full width. */
@media (max-width: 719px) {
  #my-numbers td:has(> .ui-dest) { flex-direction: column; align-items: stretch; }
  #my-numbers .ui-dest { min-inline-size: 0; }
  #my-numbers .ui-dest select, #my-numbers .ui-dest input, #my-numbers .ui-dest button { width: 100%; }
}

/* QA-035: every data table (ui.js dataTable) becomes a stack of cards on a phone instead of scrolling sideways inside the page.
   A row's heading cell (th scope=row) leads its card like a first td. */
@media (max-width: 719px) {
  .rtable tbody th { display: block; padding: 0; padding-block-end: 6px; border: 0; border-block-end: 1px solid var(--border); background: transparent !important; text-align: start; }
  .rtable tbody td.num { text-align: end; }
  /* The visually hidden header row stays within its 1 px box: a sticky, unwrapped header cell widened the page by its text. */
  .rtable thead th { position: static; white-space: normal; }
  /* A long column name wraps beside its value instead of pushing the card wider than the screen. */
  .rtable tbody td::before { flex: 0 1 auto; max-inline-size: 55%; overflow-wrap: anywhere; }
  .rtable tbody td:empty { display: none; }
  .rtable tfoot, .rtable tfoot tr { display: block; }
  .rtable tfoot :is(th, td) { display: inline-block; padding-block: 4px; padding-inline: 0 8px; border: 0; }
}

/* QA-016: six figures sit in two even rows of three (not five and one), and a duration such as "5 min 46 s" stays on one line. */
.dash-tile dd { white-space: nowrap; }
@media (min-width: 720px) {
  .dash-tiles:has(> :nth-child(6)) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1500px) {
  .dash-tiles:has(> :nth-child(6)) { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* Post-call transcripts on a call card (js/transcripts.js). */
.call-transcript { margin-top: 8px; }
.transcript-box { margin-top: 8px; display: grid; gap: 8px; }
.transcript-summary { padding: 10px var(--gap); border-radius: var(--r-md); background: var(--accent-soft); color: var(--text); }
.transcript-summary h4 { margin: 0 0 6px; display: flex; gap: 8px; align-items: center; }
.transcript-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; }
.transcript-facts dt { font-weight: 600; }
.transcript-facts dd { margin: 0; }
.transcript-facts ul { margin: 0; padding-inline-start: 18px; }
.transcript-turns { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 420px; overflow-y: auto; }
.transcript-turn { line-height: 1.45; }
.transcript-turn.role-customer .transcript-who { color: var(--accent); }
.transcript-seek { padding: 0 4px; min-height: 0; background: none; border: 0; cursor: pointer; color: var(--muted); }
.transcript-seek:hover, .transcript-seek:focus-visible { color: var(--accent); text-decoration: underline; }
.transcript-player audio { width: 100%; }
@media (max-width: 600px) { .transcript-facts { grid-template-columns: 1fr; } }

/* Wide tables fit a 1280 px screen (ready-2026-10-24): a figure and its trend or detail stacked in one cell, a report row's
   other figures under a disclosure, the Explain links under the topic. No table scrolls sideways inside its card. */
.an-stack { display: inline-grid; justify-items: end; gap: 2px; }
.an-stack .meta { font-size: var(--fs-xs); }
.an-table td, .an-table th { white-space: normal; }
.an-table td.num, .an-table .pill, .an-table .kpi-delta { white-space: nowrap; }
.ui-table.report-fit th[scope="col"] { white-space: normal; vertical-align: bottom; }
.ui-table.report-fit td.num { white-space: nowrap; }
.report-more summary { cursor: pointer; color: var(--accent); font-weight: 600; white-space: nowrap; }
.report-more-list { display: grid; grid-template-columns: minmax(0, 1fr) max-content; gap: 4px 12px; margin: 8px 0 0; min-inline-size: 16rem; }
.report-more-list > div { display: contents; }
.report-more-list dt { color: var(--muted); }
.report-more-list dd { margin: 0; text-align: end; font-variant-numeric: tabular-nums; }
.ui-explain { margin-block-start: 2px; font-weight: 400; }
.ui-explain .explain { font-size: var(--fs-xs); }
@media (max-width: 719px) {
  .an-stack { justify-items: end; }
  .report-more-list { min-inline-size: 0; }
  .rtable tbody td.report-more-cell { display: block; }
  .rtable tbody td.report-more-cell::before { display: block; margin-block-end: 4px; }
}
/* ---- Dashboards: the customisable landing page (dashboards.js, dashgrid.js, dashwidgets.js) -------------------------------- */
main:has(> .dsh) { max-width: 1680px; }
.dsh { display: flex; flex-direction: column; gap: var(--gap); }
.dsh .dash-head { margin-block-end: 0; }
.dsh-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.dsh-tabs { display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; overflow-x: auto; padding: 4px; background: var(--surface-sunken); border-radius: var(--r-lg); scrollbar-width: thin; }
.dsh-tab { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 14px; border: 0; border-radius: var(--r-md); background: transparent; color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; }
.dsh-tab:hover:not(:disabled) { background: var(--row-hover); color: var(--text); border-color: transparent; }
.dsh-tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--sh-1); }
.dsh-tab-ico .icon { inline-size: 14px; block-size: 14px; color: var(--teal); }
.dsh-add-tab { min-height: 40px; min-width: 40px; }
.dsh-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.dsh-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 16px; border: 1px solid var(--control-border); border-radius: var(--r-md); background: var(--surface); color: var(--text); font-weight: 600; font-size: var(--fs-md); text-decoration: none; cursor: pointer; }
.dsh-btn:hover { background: var(--row-hover); border-color: var(--text); }
.dsh-menu { position: relative; }
.dsh-menu > summary { list-style: none; }
.dsh-menu > summary::-webkit-details-marker { display: none; }
.dsh-menu-list { position: absolute; z-index: 20; inset-block-start: calc(100% + 6px); inset-inline-end: 0; display: grid; gap: 2px; min-inline-size: 220px; padding: 6px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-lg); box-shadow: var(--sh-2); }
.dsh-menu-list > button, .dsh-menu-list > a { justify-content: flex-start; text-align: start; border-color: transparent; background: transparent; font-weight: 500; font-size: var(--fs-sm); min-height: 40px; }
.dsh-menu-list > button.danger { color: var(--danger); }
.dsh-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 14px; border-radius: var(--r-md); background: var(--accent-soft); color: var(--text); font-size: var(--fs-sm); }
.dsh-banner[hidden] { display: none; }
.dsh-banner > .icon { color: var(--accent); inline-size: 18px; block-size: 18px; }
.dsh-banner > span { flex: 1; min-width: 12em; }
.dsh-banner button { min-height: 36px; padding: 4px 12px; font-size: var(--fs-sm); }
.dsh-updated { text-align: end; margin: 0; }
.dsh-empty { display: grid; justify-items: center; gap: 8px; padding: var(--sp-5) var(--sp-3); text-align: center; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--r-lg); }
.dsh-empty h2 { margin: 0; }

/* The grid. Placement is set through the CSSOM (grid-column and grid-row), so the strict style-src holds. */
.dg { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-rows: 68px; gap: 16px; position: relative; }
.dg.is-phone { grid-template-columns: minmax(0, 1fr); grid-auto-rows: auto; }
.dg-item { position: relative; min-width: 0; min-height: 0; transition: transform 220ms var(--ease); }
.dg-item.is-dragging { z-index: 5; transition: none; }
.dg-item.is-dragging .dw { box-shadow: var(--sh-3); border-color: var(--accent); }
.dg.is-editing .dw { border-style: dashed; border-color: var(--border-strong); }
.dg.is-editing .dw:hover { border-color: var(--accent); }
.dg-edit { position: absolute; inset-block-start: -10px; inset-inline-start: 50%; transform: translateX(-50%); display: flex; gap: 4px; z-index: 3; }
[dir="rtl"] .dg-edit { transform: translateX(50%); }
.dg-handle { min-height: 28px; min-width: 44px; padding: 0 10px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--sh-1); cursor: grab; touch-action: none; color: var(--muted); }
.dg-handle:active { cursor: grabbing; }
.dg-handle .icon { inline-size: 16px; block-size: 16px; }
.dg-order { display: none; min-height: 28px; min-width: 36px; padding: 0 8px; border-radius: var(--r-pill); }
.dg.is-phone .dg-order { display: inline-flex; align-items: center; justify-content: center; }
.dg.is-phone .dg-handle { cursor: default; }
.dg-resize { position: absolute; inset-block-end: 2px; inset-inline-end: 2px; inline-size: 20px; block-size: 20px; cursor: nwse-resize; touch-action: none; z-index: 3; border-inline-end: 3px solid var(--accent); border-block-end: 3px solid var(--accent); border-end-end-radius: 8px; opacity: 0.7; }
[dir="rtl"] .dg-resize { cursor: nesw-resize; }
.dg.is-phone .dg-resize { display: none; }

/* A widget. */
.dw { position: relative; display: flex; flex-direction: column; block-size: 100%; min-block-size: 0; padding: 14px 16px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-1); overflow: hidden; transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.dw:hover { box-shadow: var(--sh-2); }
.dw.is-warn { box-shadow: inset 0 3px 0 var(--warn), var(--sh-1); }
.dw.is-bad { box-shadow: inset 0 3px 0 var(--danger), var(--sh-1); }
.dw.is-ok { box-shadow: inset 0 3px 0 var(--ok), var(--sh-1); }
.dw-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-block-end: 8px; min-block-size: 32px; }
.dw-titles { min-width: 0; }
.dw-title { margin: 0; font-size: var(--fs-sm); font-weight: 650; color: var(--text); letter-spacing: 0.005em; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dw-sub { margin: 1px 0 0; font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dw-tools { display: flex; gap: 2px; flex: none; }
.dw-tool { min-height: 32px; min-width: 32px; }
.dw-tool .icon { inline-size: 16px; block-size: 16px; }
.dw-body { position: relative; flex: 1; min-block-size: 0; display: flex; flex-direction: column; justify-content: center; }
.dw-body > * { min-block-size: 0; }
.dw-scroll { overflow: auto; max-block-size: 100%; scrollbar-width: thin; }
.dw-muted { color: var(--muted); font-size: var(--fs-sm); margin: 6px 0 0; }
.dw-mono { font-family: var(--mono); font-size: var(--fs-sm); }
.dw-state { display: grid; justify-items: center; align-content: center; gap: 6px; block-size: 100%; text-align: center; color: var(--muted); font-size: var(--fs-sm); }
.dw-state p { margin: 0; max-inline-size: 28ch; }
.dw-state-ico { display: inline-grid; place-items: center; inline-size: 36px; block-size: 36px; border-radius: 12px; background: var(--surface-sunken); color: var(--muted); }
.dw-state-ico .icon { inline-size: 18px; block-size: 18px; }
.dw-skel { display: grid; gap: 10px; block-size: 100%; align-content: center; }
.dw-skel > span { display: block; block-size: 14px; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--surface-sunken), var(--row-hover), var(--surface-sunken)); background-size: 200% 100%; animation: an-shimmer 1.4s infinite linear; }
.dw-skel > span:nth-child(1) { inline-size: 55%; block-size: 28px; }
.dw-skel > span:nth-child(2) { inline-size: 85%; }
.dw-skel > span:nth-child(3) { inline-size: 70%; }
.dw-skel-line > span:nth-child(1), .dw-skel-bar > span:nth-child(1), .dw-skel-heatmap > span:nth-child(1) { block-size: 60%; min-block-size: 60px; inline-size: 100%; }

/* KPI and gauge. */
.dw-kpi { display: flex; flex-direction: column; justify-content: center; gap: 6px; block-size: 100%; }
.dw-kpi-main { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; min-width: 0; }
.dw-kpi-value { font-size: clamp(1.75rem, 2.4vw, 2.5rem); font-weight: 720; line-height: 1.05; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dw.is-bad .dw-kpi-value { color: var(--danger); }
.dw.is-warn .dw-kpi-value { color: var(--warn); }
.dw-kpi-spark { flex: none; }
.dw-kpi-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: var(--fs-xs); min-block-size: 18px; }
.dw-kpi-foot .kpi-delta, .dw-kpi-foot .kpi-target { font-size: var(--fs-xs); }
.dw-gauge { display: grid; place-items: center; block-size: 100%; }
.ch-gauge { max-inline-size: 100%; block-size: auto; }
.ch-gauge-track { fill: none; stroke: var(--surface-sunken); stroke-width: 16; stroke-linecap: round; }
.ch-gauge-fill { fill: none; stroke: var(--chart-1); stroke-width: 16; stroke-linecap: round; transition: stroke-dashoffset 700ms var(--ease); }
.ch-gauge-fill.is-ok { stroke: var(--ok); }
.ch-gauge-fill.is-warn { stroke: var(--warn); }
.ch-gauge-fill.is-bad { stroke: var(--danger); }
.ch-gauge-target { stroke: var(--text); stroke-width: 2.5; stroke-linecap: round; }
.ch-gauge-value { fill: var(--text); font-size: 30px; font-weight: 720; font-variant-numeric: tabular-nums; }
.ch-gauge-label { fill: var(--muted); font-size: 12px; }

/* Tables and boards. */
.dw-table { inline-size: 100%; border-collapse: collapse; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.dw-table th, .dw-table td { padding: 6px 8px; border-block-end: 1px solid var(--border); text-align: end; white-space: nowrap; }
.dw-table th:first-child { text-align: start; font-weight: 600; max-inline-size: 16em; overflow: hidden; text-overflow: ellipsis; }
.dw-table thead th { position: sticky; inset-block-start: 0; background: var(--surface); color: var(--muted); font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.dw-table .is-sort { color: var(--text); font-weight: 650; }
.dw-table tbody tr:hover { background: var(--row-hover); }
.dw-board { list-style: none; margin: 0; padding: 0; display: grid; align-content: start; gap: 4px; overflow: auto; max-block-size: 100%; }
.dw-board-row { display: grid; grid-template-columns: 1.8em 30px minmax(0, 1fr) minmax(60px, 34%) auto; align-items: center; gap: 10px; padding: 5px 6px; border-radius: var(--r-md); font-size: var(--fs-sm); }
.dw-board-row:not(:has(.dw-board-bar)) { grid-template-columns: 1.8em 30px minmax(0, 1fr) auto; }
.dw-board-row.is-you { background: var(--accent-soft); }
.dw-rank { color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; }
.dw-board-row:nth-child(-n+3) .dw-rank { color: var(--accent); }
.dw-avatar { display: inline-grid; place-items: center; inline-size: 30px; block-size: 30px; border-radius: 50%; background: var(--surface-sunken); color: var(--muted); font-size: 11px; font-weight: 700; }
.dw-board-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.dw-board-value { font-weight: 650; font-variant-numeric: tabular-nums; text-align: end; }

/* Live panels. */
.dw-live { display: flex; flex-direction: column; gap: 10px; block-size: 100%; min-block-size: 0; }
.dw-live-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; }
.dw-live-fig { display: grid; gap: 2px; padding: 8px 10px; border-radius: var(--r-md); background: var(--surface-sunken); }
.dw-live-label { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.dw-live-value { font-size: var(--fs-xl); font-weight: 720; font-variant-numeric: tabular-nums; line-height: 1.15; }
.dw-live-fig.is-ok { background: var(--ok-soft); }
.dw-live-fig.is-warn { background: var(--warn-soft); }
.dw-live-fig.is-warn .dw-live-value { color: var(--warn); }
.dw-live-fig.is-bad { background: var(--danger-soft); }
.dw-live-fig.is-bad .dw-live-value { color: var(--danger); }
.dw-num { display: inline-block; min-inline-size: 2.2em; padding: 0 6px; border-radius: var(--r-pill); text-align: center; }
.dw-num.is-warn { background: var(--warn-soft); color: var(--warn); font-weight: 700; }
.dw-num.is-bad { background: var(--danger-soft); color: var(--danger); font-weight: 700; }
.dw-states { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.dw-state-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--r-pill); background: var(--surface-sunken); font-size: var(--fs-xs); font-weight: 600; }
.dw-state-chip strong { font-variant-numeric: tabular-nums; }
.dw-dot { inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.state-ready .dw-dot { background: var(--ok); }
.state-not_ready .dw-dot { background: var(--warn); }
.state-not_responding .dw-dot { background: var(--danger); }
.state-offline .dw-dot { background: var(--border-strong); }
.dw-agents { list-style: none; margin: 0; padding: 0; display: grid; align-content: start; gap: 2px; flex: 1; min-block-size: 0; }
.dw-body:has(> .table-wrap, > .dw-board, > .dw-live, > .dw-scroll) { justify-content: flex-start; }
.dw-agent { color: var(--text); display: grid; grid-template-columns: 30px minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 4px 6px; border-radius: var(--r-md); font-size: var(--fs-sm); }
.dw-agent:hover { background: var(--row-hover); }
.dw-agent-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.dw-agent-state { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
.dw-agent-load { font-variant-numeric: tabular-nums; font-weight: 650; min-inline-size: 1.5em; text-align: end; }
.dw-agent.state-offline { opacity: 0.6; }

/* Funnel. */
.ch-funnel { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ch-funnel-row { display: grid; grid-template-columns: minmax(70px, 28%) minmax(0, 1fr) auto 4.5em; align-items: center; gap: 10px; font-size: var(--fs-sm); }
.ch-funnel-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-weight: 600; }
.ch-funnel-track { display: block; block-size: 22px; }
.ch-funnel-bar { display: block; block-size: 100%; border-radius: 6px; background: var(--c); margin-inline: auto; }
.ch-funnel-value { font-weight: 700; font-variant-numeric: tabular-nums; text-align: end; }
.ch-funnel-step { font-size: var(--fs-xs); color: var(--muted); text-align: end; font-variant-numeric: tabular-nums; }

/* Wallet, numbers, phrases, alerts, notes, links. */
.dw-wallet { display: grid; gap: 4px; align-content: center; block-size: 100%; }
.dw-wallet-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.dw-level.is-ok { background: var(--ok-soft); color: var(--ok); }
.dw-level.is-low { background: var(--warn-soft); color: var(--warn); }
.dw-level.is-empty { background: var(--danger-soft); color: var(--danger); }
.dw-wallet-spark .ch-spark { inline-size: 100%; }
.dw-numbers { display: flex; flex-direction: column; gap: 10px; block-size: 100%; min-block-size: 0; }
.dw-stack { display: flex; gap: 3px; block-size: 14px; border-radius: var(--r-pill); overflow: hidden; }
.dw-stack-seg { display: block; flex-basis: 0; }
.dw-stack-seg.is-good, .dw-legend .is-good .dw-dot { background: var(--ok); }
.dw-stack-seg.is-watch, .dw-legend .is-watch .dw-dot { background: var(--warn); }
.dw-stack-seg.is-at_risk, .dw-legend .is-at_risk .dw-dot { background: var(--danger); }
.dw-stack-seg.is-rested, .dw-legend .is-rested .dw-dot { background: var(--chart-4); }
.dw-stack-seg.is-unscored, .dw-legend .is-unscored .dw-dot { background: var(--border-strong); }
.dw-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: var(--fs-xs); color: var(--muted); }
.dw-legend li { display: inline-flex; align-items: center; gap: 6px; }
.dw-legend strong { color: var(--text); }
.dw-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: var(--fs-sm); }
.dw-list li { display: flex; align-items: center; gap: 8px; }
.dw-badge { margin-inline-start: auto; padding: 0 8px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 650; background: var(--surface-sunken); }
.dw-badge.is-at_risk { background: var(--danger-soft); color: var(--danger); }
.dw-badge.is-watch { background: var(--warn-soft); color: var(--warn); }
.dw-badge.is-rested { background: var(--accent-soft); color: var(--accent); }
.dw-phrases { display: flex; flex-direction: column; gap: 12px; block-size: 100%; min-block-size: 0; }
.dw-alerts { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.dw-alert { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-md); background: var(--danger-soft); }
.dw-alert-ico { color: var(--danger); display: inline-flex; }
.dw-alert-main { display: grid; flex: 1; min-width: 0; }
.dw-alert time { font-size: var(--fs-xs); }
.dw-note { font-size: var(--fs-sm); line-height: 1.55; block-size: 100%; }
.dw-note h4 { margin: 0 0 6px; font-size: var(--fs-md); }
.dw-note p, .dw-note ul { margin: 0 0 8px; }
.dw-note ul { padding-inline-start: 1.2em; }
.dw-note code { font-family: var(--mono); font-size: 0.9em; padding: 1px 4px; border-radius: 4px; background: var(--surface-sunken); }
.dw-body:has(> .dw-note) { justify-content: flex-start; }
.dw.dw--link { padding: 0; }
.dw-link { display: flex; align-items: center; gap: 12px; block-size: 100%; padding: 0 16px; color: var(--text); text-decoration: none; font-weight: 650; }
.dw-link:hover { background: var(--accent-soft); color: var(--accent); }
.dw-link-ico { display: inline-grid; place-items: center; inline-size: 32px; block-size: 32px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); flex: none; }
.dw-link-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dw-funnel { display: grid; gap: 8px; }
.dw .ch-donutbox { flex-wrap: nowrap; gap: 16px; justify-content: space-around; block-size: 100%; }
.dw-donut-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; min-inline-size: 0; flex: 1; max-inline-size: 14em; overflow: auto; max-block-size: 100%; font-size: var(--fs-xs); }
.dw-donut-legend li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.dw-donut-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dw-donut-share { font-weight: 650; font-variant-numeric: tabular-nums; }
.dg.is-phone .dw { block-size: auto; min-block-size: 120px; max-block-size: 560px; }
.dg.is-phone .dw-body { min-block-size: 80px; }
.dg.is-phone .dw.dw--link { min-block-size: 56px; }
.dg.is-phone .dw--link .dw-link { min-block-size: 56px; }

.dw .ch-legend { font-size: var(--fs-xs); }

/* First paint: the charts draw themselves in (never again on a refresh; the reduced-motion rule turns it all off). */
.dw.is-entering .ch-plot svg { animation: dsh-reveal 900ms var(--ease) both; }
.dw.is-entering .ch-bar { transform-box: fill-box; transform-origin: 50% 100%; animation: dsh-grow-y 700ms var(--ease) both; }
.dw.is-entering .ch-hfill, .dw.is-entering .ch-funnel-bar, .dw.is-entering .dw-stack-seg { transform-origin: 0 50%; animation: dsh-grow-x 750ms var(--ease) both; }
[dir="rtl"] .dw.is-entering .ch-hfill, [dir="rtl"] .dw.is-entering .ch-funnel-bar { transform-origin: 100% 50%; }
.dw.is-entering .ch-donut-arc { animation: dsh-fade 800ms var(--ease) both; }
.dw.is-entering .ch-gauge-fill { animation: dsh-sweep 900ms var(--ease) both; }
.dw.is-entering .ch-heat-cell { animation: dsh-fade 600ms var(--ease) both; }
@keyframes dsh-reveal { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes dsh-grow-y { from { transform: scaleY(0); } }
@keyframes dsh-grow-x { from { transform: scaleX(0); } }
@keyframes dsh-fade { from { opacity: 0; } }
@keyframes dsh-sweep { from { stroke-dashoffset: 1; } }

/* Dialogs: widget settings, the catalogue, publishing. */
dialog.dsh-dialog { inline-size: min(560px, calc(100vw - 32px)); max-block-size: calc(100vh - 48px); padding: var(--sp-3); overflow: auto; }
dialog.dsh-dialog.is-wide { inline-size: min(820px, calc(100vw - 32px)); }
dialog.dsh-dialog h2 { margin: 0 0 var(--sp-2); font-size: var(--fs-xl); }
.dsh-form { display: grid; gap: var(--sp-2); }
.dsh-fields { display: grid; gap: 12px; }
.dsh-field { display: grid; gap: 4px; }
.dsh-field[hidden], .dsh-row[hidden] { display: none; }
.dsh-field label { font-weight: 600; font-size: var(--fs-sm); }
.dsh-field .meta { margin: 0; }
.dsh-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.dsh-more { border: 1px solid var(--border); border-radius: var(--r-md); padding: 8px 12px; }
.dsh-more > summary { cursor: pointer; font-weight: 600; min-block-size: 28px; }
.dsh-more[open] > summary { margin-block-end: 8px; }
.dsh-checks { display: flex; flex-wrap: wrap; gap: 0 14px; border: 0; padding: 0; margin: 0 0 8px; }
.dsh-checks legend { font-weight: 600; font-size: var(--fs-sm); margin-block-end: 4px; }
.dsh-form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.dsh-form .error:empty { display: none; }
.dsh-catalogue { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.dsh-type { display: grid; justify-items: start; align-content: start; gap: 4px; padding: 12px; text-align: start; min-block-size: 108px; border-color: var(--border); border-radius: var(--r-lg); font-weight: 500; }
.dsh-type:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.dsh-type strong { font-size: var(--fs-sm); }
.dsh-type .meta { font-size: var(--fs-xs); margin: 0; line-height: 1.4; }
.dsh-type-ico { display: inline-grid; place-items: center; inline-size: 32px; block-size: 32px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); margin-block-end: 4px; }
.dsh-type-ico .icon { inline-size: 18px; block-size: 18px; }
.dsh-swatches { display: flex; flex-wrap: wrap; gap: 8px; border: 0; padding: 0; margin: 0; }
.dsh-swatches legend { font-weight: 600; font-size: var(--fs-sm); margin-block-end: 6px; }
.dsh-swatch { position: relative; display: inline-grid; place-items: center; inline-size: 36px; block-size: 36px; cursor: pointer; }
.dsh-swatch input { position: absolute; inset: 0; opacity: 0; margin: 0; inline-size: 100%; block-size: 100%; cursor: pointer; }
.dsh-swatch span { inline-size: 26px; block-size: 26px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 2px var(--surface); border: 2px solid transparent; }
.dsh-swatch input:checked + span { border-color: var(--text); }
.dsh-swatch input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* TV mode: full screen, larger type, the next dashboard's progress. */
.dsh-tv-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; position: relative; padding-block-end: 10px; }
.dsh-tv-title { margin: 0; flex: 1; font-size: 1.6rem; letter-spacing: -0.01em; }
.dsh-tv-clock { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }
.dsh-tv-ctl { display: flex; gap: 8px; }
.dsh-tv-progress { position: absolute; inset-inline: 0; inset-block-end: 0; block-size: 3px; background: var(--accent); transform: scaleX(0); transform-origin: 0 50%; border-radius: 2px; }
[dir="rtl"] .dsh-tv-progress { transform-origin: 100% 50%; }
.dsh-tv-progress.is-running { animation: dsh-progress linear forwards; }
.dsh-tv-progress.is-paused { animation-play-state: paused; }
@keyframes dsh-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }
body.tv main:has(> .dsh) { max-width: none; }
body.tv.authed .app > .app-main { grid-column: 1 / -1; }
body.tv .dsh-banner { display: none; }
body.tv .dsh .dg { grid-auto-rows: 76px; }
body.tv .dw-title { font-size: var(--fs-md); }
body.tv .dw-kpi-value { font-size: clamp(2.2rem, 3.4vw, 3.6rem); }

@media (max-width: 760px) {
  .dsh-bar { align-items: stretch; }
  .dsh-tabs { inline-size: 100%; }
  .dsh-tools { inline-size: 100%; }
  .dsh-tools > * { flex: 1 1 auto; }
  .dsh-menu-list { inset-inline-end: auto; inset-inline-start: 0; }
  .dg.is-phone .dg-edit { inset-block-start: 6px; inset-inline-start: auto; inset-inline-end: 52px; transform: none; }
  .dg.is-phone.is-editing .dw { padding-block-start: 40px; }
  .dw-kpi-value { font-size: 2rem; }
}

/* Print to PDF: the dashboard only, in colour, a widget never split across pages. */
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body.dsh-printing { background: #fff; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  body.dsh-printing .sidebar, body.dsh-printing .topbar, body.dsh-printing .dsh-bar, body.dsh-printing .dash-setup, body.dsh-printing .dsh-banner,
  body.dsh-printing .toast, body.dsh-printing .skip-link, body.dsh-printing .acting, body.dsh-printing .estop, body.dsh-printing .dg-edit, body.dsh-printing .dg-resize { display: none !important; }
  body.dsh-printing .app { display: block; }
  body.dsh-printing main { max-width: none; padding: 0; }
  body.dsh-printing .dg-item { break-inside: avoid; }
  body.dsh-printing .dw { box-shadow: none; }
}

/* ---- Feature access (0078): the matrix, people, teams and the package builder ---- */
.fa-page { display: grid; gap: var(--gap); }
.fa-status:empty { display: none; }
.fa-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 6px 14px; margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-lg); }
.fa-checks legend { padding: 0 6px; font-weight: 650; }
.fa-check { display: flex; align-items: center; gap: 8px; min-block-size: 44px; }
.fa-check input { inline-size: 20px; block-size: 20px; flex: none; }
.fa-form { display: grid; gap: 10px; }
.fa-total-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: var(--r-lg); background: var(--accent-soft); }
.fa-total { font-size: 1.15rem; font-weight: 700; }
.fa-matrix select, .fa-cell { min-inline-size: 7.5rem; min-block-size: 40px; }
.fa-cell-on { border-color: var(--ok); }
.fa-cell-off { border-color: var(--danger); }
.fa-quote-items, .fa-items, .fa-statement { margin: 6px 0; padding-inline-start: 1.2rem; }
.fa-team .ui-details { margin-block: 8px; }
@media (max-width: 640px) {
  .fa-matrix select, .fa-cell { min-inline-size: 0; max-inline-size: 60vw; }
  .fa-total-row { flex-direction: column; align-items: stretch; }
}
/* Grid and flex children shrink to the page instead of pushing it wider: the matrix scrolls inside its own frame. */
.fa-page, .fa-page > *, .fa-page .ui-page, .fa-page .ui-page > *, .fa-page .ui-card-body, .fa-page .ui-card-body > *, .fa-page .form-row { min-inline-size: 0; max-inline-size: 100%; }
.fa-page select, .fa-form select, .fa-form input:not([type=checkbox]) { max-inline-size: 100%; }
@media (max-width: 640px) {
  .fa-page .rtable tbody td { flex-wrap: wrap; min-inline-size: 0; }
  .fa-page .rtable tbody td > select { flex: 1 1 100%; inline-size: 100%; min-inline-size: 0; max-inline-size: 100%; text-align: start; }
  .fa-page .rtable tbody tr { min-inline-size: 0; max-inline-size: 100%; }
}
@media (min-width: 641px) { .fa-matrix tbody th[scope=row] { min-inline-size: 15rem; } }

/* The native app's biometric unlock (js/native.js): covers the console until the person unlocks. */
.native-lock { position: fixed; inset: 0; z-index: 1000; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 24px;
  padding-block: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-bottom)); background: var(--bg); text-align: center; }
.native-lock h1 { margin: 0; }
.native-lock .primary { min-height: 44px; min-width: 200px; }

/* Live call transcripts (livetranscript.js): the phone's in-call strip and the supervisor's followed call. */
.lt-box { display: grid; gap: 4px; }
.lt-box .lt-title { margin: 0; font-size: var(--fs-sm, 0.875rem); }
.lt-box .lt-lines { max-height: 14rem; overflow-y: auto; }
.lt-box .lt-partial { font-style: italic; min-height: 1.2em; margin: 0; }
.lt-box .lt-status { margin: 0; }
.phone .sp-transcript { padding: 8px 20px 12px; border-top: 1px solid var(--border); }
.phone .sp-transcript .lt-lines { max-height: 9rem; }
.sup-transcript-wrap { position: relative; margin-block: 8px 16px; padding: 12px var(--gap); border: 1px solid var(--border); border-radius: var(--r-md); }
.sup-transcript-wrap .lt-close { position: absolute; inset-block-start: 8px; inset-inline-end: 8px; }

/* Typed voice prompts (js/typedprompts.js): the editor opens in place under a recording field and on #/typed-prompts.
   Everything stacks and takes the full width, so the editor works at 390 px without scrolling sideways. */
.tp-field { margin-top: 4px; }
.tp-panel { margin-top: 8px; padding: 12px; border: 1px solid var(--border, #d0d5dd); border-radius: 8px; background: var(--surface, transparent); }
.tp-editor { display: grid; gap: 10px; min-width: 0; }
.tp-row { display: grid; gap: 4px; min-width: 0; }
.tp-row select, .tp-row textarea, .tp-row input { inline-size: 100%; max-inline-size: 100%; box-sizing: border-box; }
.tp-row textarea { min-block-size: 6rem; resize: vertical; }
.tp-name { display: flex; align-items: center; gap: 4px; min-width: 0; }
.tp-name input { flex: 1 1 auto; min-width: 0; }
.tp-pick { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); }
.tp-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tp-problems { margin: 0; padding-inline-start: 1.2em; }
.tp-player audio { inline-size: 100%; max-inline-size: 28rem; }
.tp-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.tp-item { border-block-end: 1px solid var(--border, #d0d5dd); padding-block-end: 12px; min-width: 0; }
.tp-item-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tp-item code, .tp-text { overflow-wrap: anywhere; }
.tp-new, .tp-edit { margin-block: 12px; }

/* 2026 refresh (2026-10-28). Flat surfaces: a hairline border instead of a shadow, tighter type, quieter chrome, so the data
   carries the page. Shadows stay only on things that float (menus, dialogs, toasts, the phone). Last in the file so it wins
   over the component rules above without raising their specificity. */
body { -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01", "ss03"; }
h1 { font-weight: 650; letter-spacing: -0.025em; }
h2, h3 { letter-spacing: -0.015em; }
.card, .kpi, .tile, .chart-card, .table-wrap, .interaction, .dw { box-shadow: none; }
.card:hover, .chart-card:hover { border-color: var(--border-strong); }
button.primary { box-shadow: none; }
button, .dsh-btn { font-weight: 550; }

/* Shell: the sidebar sits on the page colour, the top bar is translucent over the content. */
.sidebar { background: var(--bg); }
.nav a { font-size: var(--fs-sm); font-weight: 500; padding: 7px 10px; color: var(--muted); }
.nav a:hover { color: var(--text); }
.nav a .icon { inline-size: 16px; block-size: 16px; }
.nav a[aria-current="page"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: inset 0 0 0 1px var(--border); }
.nav-group-label { font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.08em; }
.topbar { background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px); }

/* Tables: quiet header, more air per row, no heavy rule under the header. */
thead th { background: var(--surface); font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; border-block-end-color: var(--border); }
tbody tr:hover td { background: var(--row-hover); }
tbody tr:last-child td { border-bottom: 0; }

/* Dashboard: segmented tabs, flat widgets with a status hairline, large tabular figures. */
.dsh-tabs { background: transparent; border: 1px solid var(--border); padding: 3px; border-radius: var(--r-md); }
.dsh-tab { border-radius: 6px; font-weight: 500; }
.dsh-tab[aria-selected="true"] { box-shadow: inset 0 0 0 1px var(--border); background: var(--surface-sunken); font-weight: 600; }
.dsh-banner { background: transparent; border: 1px solid var(--border); }
.dw { padding: 16px 18px 14px; transition: border-color var(--dur-fast) var(--ease); }
.dw:hover { box-shadow: none; border-color: var(--border-strong); }
.dw.is-ok, .dw.is-warn, .dw.is-bad { box-shadow: none; }
.dw.is-ok::before, .dw.is-warn::before, .dw.is-bad::before { content: ""; position: absolute; inset-block-start: -1px; inset-inline: 16px; block-size: 2px; border-radius: 0 0 2px 2px; background: var(--ok); }
.dw.is-warn::before { background: var(--warn); }
.dw.is-bad::before { background: var(--danger); }
.dw-title { font-size: var(--fs-sm); font-weight: 550; color: var(--muted); letter-spacing: 0; }
.dw-sub { font-size: 0.6875rem; opacity: 0.85; }
.dw-kpi-value { font-weight: 600; letter-spacing: -0.035em; font-size: clamp(1.875rem, 2.6vw, 2.75rem); }
.kpi dd, .kpi-value { font-weight: 600; letter-spacing: -0.03em; }
.dw-state-ico { border-radius: var(--r-md); border: 1px solid var(--border); background: transparent; }

/* Charts: dashed grid, rounded bar tops, thinner gauge and donut. */
.ch-grid { stroke-dasharray: 2 4; }
.ch-bar { rx: 2px; }
.ch-gauge-track, .ch-gauge-fill { stroke-width: 12; }

/* Refresh, second pass: a compact page header, lighter toolbar buttons, filled trends, slimmer bars and quieter empty states. */
.dash-head { margin-block-end: var(--sp-2); }
.dash-head h1 { font-size: 0.6875rem; letter-spacing: 0.1em; font-weight: 600; margin-block-end: 4px; }
.dash-greet { font-size: clamp(1.375rem, 1.8vw, 1.75rem); font-weight: 600; letter-spacing: -0.03em; line-height: 1.2; }
.dash-head .muted { font-size: var(--fs-sm); }
.dsh-bar { padding-block: 4px; }
.dsh-btn, .dsh-tools > button, .dsh-menu > summary { font-size: var(--fs-sm); font-weight: 500; border-color: var(--border-strong); background: var(--surface); }
.dsh-btn:hover, .dsh-tools > button:hover { border-color: var(--control-border); background: var(--row-hover); }
.dsh-btn .icon { inline-size: 15px; block-size: 15px; color: var(--muted); }
.ch-spark .ch-area { fill-opacity: 0.2; }
.ch-spark .ch-line { stroke-width: 1.75; }
.ch-area { fill-opacity: 0.16; }
.dw-stack { block-size: 8px; gap: 2px; }
.dw-stack-seg.is-unscored { background: var(--surface-sunken); box-shadow: inset 0 0 0 1px var(--border-strong); }
.dw-state { gap: 8px; font-size: var(--fs-xs); }
.dw-state-ico { inline-size: 32px; block-size: 32px; border-style: dashed; }
.dw-state-ico .icon { inline-size: 16px; block-size: 16px; }
.dw-kpi-foot { color: var(--muted); }
.notice, .dsh-banner { border-radius: var(--r-md); }
