/* Component styles built from tokens.css -- every color here is a token
   reference, never a literal, so the light/dark toggle (see tokens.css's
   [data-theme] blocks) recolors every component below automatically. */

body {
  font-family: var(--font-sans);
  background: var(--bg-canvas);
  color: var(--text-primary);
}

:root { --sidebar-w: 240px; }

/* Base link color: nothing set this before, so a plain in-content <a>
   (table cells, empty-state prompts, inline body text) fell through to the
   browser/Bootstrap default -- blue, always underlined -- which is exactly
   what reads as an unstyled, generic page. Kept at bare-element specificity
   (0,0,1) deliberately: every styled link in the app (.btn, .nav-link,
   .icon-action, badges...) already carries a class, so this can never
   outrank them regardless of load order or DOM nesting -- it only reaches
   links that have no class of their own. */
a {
  color: var(--accent);
  text-decoration: none;
  transition: color .12s ease;
}
a:hover, a:focus-visible {
  color: var(--btn-primary-bg-hover);
  text-decoration: none;
}
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* One orchestrated page-load moment (not per-card/per-section -- see the
   frontend-design skill's own warning that staggered fade-ins everywhere
   read as generic/AI-generated): the whole content area settles in once
   per navigation, giving page changes some life without becoming noise. */
.content { animation: content-in .28s var(--ease); }
@keyframes content-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .content { animation: none; } }

/* ---- Bootstrap primitive overrides (5.3 exposes these as --bs-* vars) ---- */

/* .btn-dark is the app's de-facto primary-action button (Connect & Talk,
   Start Call, New Campaign, Save...) -- Steel Blue, the one colored fill in
   the app, as a subtle gradient rather than a flat tint (background-image
   layers over Bootstrap's own --bs-btn-bg background-color, so this reads
   correctly in both themes without touching the token values themselves).
   Kept as the Bootstrap ".btn-dark" class name for zero template churn. */
.btn-dark {
  --bs-btn-color: var(--btn-primary-ink);
  --bs-btn-bg: var(--btn-primary-bg);
  --bs-btn-border-color: var(--btn-primary-bg);
  --bs-btn-hover-color: var(--btn-primary-ink);
  --bs-btn-hover-bg: var(--btn-primary-bg-hover);
  --bs-btn-hover-border-color: var(--btn-primary-bg-hover);
  --bs-btn-active-bg: var(--btn-primary-bg-hover);
  --bs-btn-active-border-color: var(--btn-primary-bg-hover);
  --bs-btn-border-radius: var(--radius-sm);
  background-image: linear-gradient(135deg, var(--btn-primary-bg), var(--btn-primary-bg-hover));
  font-weight: 600;
  transition: background-color .12s ease, box-shadow .12s ease, transform .05s ease;
}
.btn-dark:hover, .btn-dark:active { background-image: linear-gradient(135deg, var(--btn-primary-bg-hover), var(--btn-primary-bg)); }
.btn-dark:hover { box-shadow: var(--shadow-md); }
.btn-dark:active { transform: translateY(1px); }

.btn {
  --bs-btn-border-radius: var(--radius-sm);
  transition: transform .05s ease, box-shadow .12s ease, background-color .12s ease, border-color .12s ease, color .12s ease;
}
/* Tactile press feedback on every button, not just .btn-dark -- a small,
   cheap "this registered" cue on click, same category as .icon-action's
   existing hover lift below. */
.btn:active { transform: translateY(1px); }
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } .btn:active { transform: none; } }

/* Secondary/outline actions -- a clean ghost button: neutral border, fills
   with a soft inset wash on hover rather than the semantic color itself
   (that stays reserved for the danger/success/warning variants below). */
.btn-outline-dark, .btn-outline-secondary {
  --bs-btn-color: var(--text-secondary);
  --bs-btn-border-color: var(--border-strong);
  --bs-btn-hover-color: var(--text-primary);
  --bs-btn-hover-bg: var(--bg-inset);
  --bs-btn-hover-border-color: var(--border-strong);
  --bs-btn-active-color: var(--text-primary);
  --bs-btn-active-bg: var(--bg-inset);
  --bs-btn-active-border-color: var(--border-strong);
  --bs-btn-disabled-color: var(--text-muted);
  --bs-btn-disabled-border-color: var(--border-subtle);
  --bs-btn-border-radius: var(--radius-sm);
}
.btn-outline-danger, .btn-outline-success, .btn-outline-warning {
  --bs-btn-border-radius: var(--radius-sm);
}
.btn-outline-danger { --bs-btn-color: var(--danger-text); --bs-btn-border-color: var(--danger); --bs-btn-hover-bg: var(--danger); --bs-btn-hover-border-color: var(--danger); }
.btn-outline-success { --bs-btn-color: var(--success-text); --bs-btn-border-color: var(--success); --bs-btn-hover-bg: var(--success); --bs-btn-hover-border-color: var(--success); }
.btn-outline-warning { --bs-btn-color: var(--warning-text); --bs-btn-border-color: var(--warning); --bs-btn-hover-bg: var(--warning); --bs-btn-hover-border-color: var(--warning); }

/* Cards: white surface, a real-but-soft border, minimal shadow -- "subtle
   border or soft shadow, not heavy" per the reference direction. */
.card {
  --bs-card-bg: var(--bg-surface);
  --bs-card-border-color: var(--border-subtle);
  --bs-card-border-radius: var(--radius-md);
  --bs-card-box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  background: var(--bg-surface);
  position: relative;
}
/* Cards with no card-header (a floating handle, same reveal-on-hover). */
.card > .drag-handle { position: absolute; top: .6rem; right: .6rem; z-index: 1; }
.card-header { background: var(--bg-surface); border-bottom-color: var(--border-subtle); font-weight: 700; font-size: 1.05rem; padding: 1.1rem 1.25rem; display: flex; align-items: center; gap: .5rem; }

/* Drag-to-reorder (see card-drag.js): a dedicated grip handle is the only
   part of a card that can start a drag -- the rest of the card (buttons,
   chart hovers, links) behaves like normal content. */
.drag-handle {
  cursor: grab; color: var(--text-muted); font-size: .95rem;
  opacity: 0; transition: opacity .12s ease; margin-right: .1rem; flex: none;
}
.card:hover .drag-handle { opacity: .6; }
.drag-handle:hover { opacity: 1 !important; }
[data-draggable-row] > * { transition: transform .1s ease; }
[data-draggable-row] > *.dragging { opacity: .4; }
[data-draggable-row] > *.drag-over > .card { border-color: var(--text-muted); border-style: dashed; }
.card-body { padding: 1.25rem; }

/* A labeled settings/preference row -- label+description+control, with the
   generous vertical rhythm the dense original was missing ("more line-
   height and spacing between form fields"). Reusable anywhere a form is a
   list of named fields rather than a single free-flowing form (App
   Settings today; Provider Settings' field lists are the same shape). */
.setting-row { padding: 1.35rem 0; border-bottom: 1px solid var(--border-subtle); }
.setting-row:last-child { border-bottom: none; }
.setting-row .setting-label { font-size: .92rem; font-weight: 600; color: var(--text-primary); margin-bottom: .3rem; }
.setting-row .setting-description { color: var(--text-secondary); font-size: .82rem; line-height: 1.5; margin-bottom: .35rem; }
.setting-row .setting-meta { color: var(--text-muted); font-size: .8rem; }

.badge {
  --bs-badge-border-radius: var(--radius-pill);
}

/* Forms: white fields, a visible-but-soft border, generous focus ring.
   More breathing room between fields is a template-level spacing change
   (see app_settings.html), not something this rule can add on its own. */
.form-control, .form-select {
  background-color: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
}
.form-control:focus, .form-select:focus {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle-bg);
}
.form-label { color: var(--text-primary); font-weight: 500; margin-bottom: .35rem; }
.form-text { color: var(--text-muted); margin-top: .35rem; }

/* JSON-editing textareas (Script.states/faq/objections, the only place
   .font-monospace is used app-wide) get a visually distinct inset
   background, marking them as structured/code content rather than a plain
   text field -- no JS JSON validator, purely a visual cue. */
.form-control.font-monospace { background-color: var(--bg-inset); }

.text-muted { color: var(--text-muted) !important; }

/* ---- Search bar (topbar) -- pill-shaped, per the reference screenshots ---- */

.search-bar {
  display: flex; align-items: center; gap: .5rem;
  background: var(--bg-inset); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill); padding: .45rem .9rem;
  color: var(--text-muted); font-size: .85rem;
  transition: border-color .12s ease, background-color .12s ease;
  max-width: 360px; width: 100%;
}
.search-bar:focus-within { border-color: var(--accent); background: var(--bg-surface); box-shadow: 0 0 0 .2rem var(--accent-subtle-bg); }
.search-bar input {
  border: none; background: transparent; outline: none; flex: 1;
  color: var(--text-primary); font-size: .85rem; min-width: 0;
}
.search-bar input::placeholder { color: var(--text-muted); }
.search-bar i { color: var(--text-muted); font-size: .95rem; flex: none; }

/* ---- Bootstrap dropdown (the notifications bell is this app's first use
   of Bootstrap's own .dropdown-menu component -- everywhere else either
   has its own custom-select.js widget or a hand-rolled menu, so nothing
   themed this yet. Overriding Bootstrap's own --bs-dropdown-* variables,
   same approach .btn-dark/.form-control above already use, rather than
   fighting Bootstrap's default light-theme CSS on specificity.) ---- */
.dropdown-menu {
  --bs-dropdown-bg: var(--bg-surface-raised);
  --bs-dropdown-border-color: var(--border-subtle);
  --bs-dropdown-link-color: var(--text-primary);
  --bs-dropdown-link-hover-bg: var(--bg-inset);
  --bs-dropdown-link-hover-color: var(--text-primary);
  --bs-dropdown-link-active-bg: var(--bg-inset);
  --bs-dropdown-link-active-color: var(--text-primary);
  --bs-dropdown-border-radius: var(--radius-sm);
  /* --bs-dropdown-box-shadow (below) resolves fine as a custom property
     but this Bootstrap build's own .dropdown-menu rule never actually
     reads it for its box-shadow -- confirmed by computed style: the
     variable was rgba(...) as expected, the applied box-shadow was still
     `none`. Setting box-shadow directly instead of trusting that
     variable. Without it, the panel had only a 7%-opacity border for
     definition -- background is near-identical to the page behind it in
     light mode (#fff panel on an off-white/white page), so with no
     shadow it was effectively invisible, not just hard to see. */
  --bs-dropdown-box-shadow: var(--shadow-lg);
  box-shadow: var(--shadow-lg);
}

/* ---- Theme toggle (light / dark / match-system) ---- */

.theme-toggle {
  display: flex; align-items: center; gap: 2px; background: var(--bg-inset);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-pill); padding: 3px; flex: none;
}
.theme-toggle-btn {
  border: none; background: transparent; color: var(--text-muted); width: 28px; height: 26px;
  border-radius: var(--radius-pill); display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: .85rem; transition: background-color .12s ease, color .12s ease;
}
.theme-toggle-btn:hover { color: var(--text-primary); }
.theme-toggle-btn.active { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-sm); }

/* ---- Custom select (see custom-select.js) ---- */

.cs-select { position: relative; }
.cs-trigger {
  display: flex; align-items: center; gap: .55rem; width: 100%; text-align: left; cursor: pointer;
  background-color: var(--bg-surface); color: var(--text-primary);
  transition: border-color .12s ease, box-shadow .12s ease;
  /* Also carries Bootstrap's own .form-select class (see custom-select.js,
     for its border/padding/font styling) -- that class paints its own
     background-image chevron too, which without this stacked visibly next
     to .cs-chevron below as a second, redundant arrow. */
  background-image: none;
}
.cs-trigger:hover { border-color: var(--accent); }
.cs-trigger:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle-bg); outline: none; }
.cs-select.cs-disabled .cs-trigger { opacity: .6; cursor: not-allowed; background-color: var(--bg-inset); }
.cs-trigger-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .875rem; }
.cs-chevron { color: var(--text-muted); font-size: .8rem; transition: transform .2s var(--ease); flex: none; }
.cs-trigger[aria-expanded="true"] .cs-chevron { transform: rotate(180deg); }
.cs-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

.cs-menu {
  /* position: fixed (not absolute-relative-to-.cs-select) + top/left/
     min-width set inline by custom-select.js's positionMenu(), in real
     viewport coordinates -- an absolute position relative to the trigger
     got silently clipped/mispositioned the moment the trigger sat inside
     any scrolling ancestor (e.g. a .table-responsive column), since the
     menu was still a layout child of that same clipped container. Fixed
     positioning escapes that entirely. width: max-content (capped by
     max-width) still lets the menu grow wider than a narrow trigger
     column when an option's label needs it, e.g. a provider row's
     "Name -- Vendor / model" text. */
  position: fixed; z-index: 1040; width: max-content; max-width: min(420px, calc(100vw - 2rem));
  background: var(--bg-elevated, var(--bg-surface)); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); padding: 6px; transform: scale(.96) translateY(-4px); opacity: 0; transform-origin: top center;
  transition: transform .2s var(--ease), opacity .16s var(--ease);
}
.cs-menu.open { transform: scale(1) translateY(0); opacity: 1; }
.cs-search {
  width: 100%; margin-bottom: 6px; padding: 7px 10px; font-size: .85rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg-inset); color: var(--text-primary);
}
.cs-search:focus { outline: none; border-color: var(--accent); }
.cs-options { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.cs-option {
  display: flex; align-items: center; gap: .55rem; padding: 7px 10px; border-radius: var(--radius-sm);
  font-size: .875rem; color: var(--text-primary); cursor: pointer;
  transition: background-color .1s ease;
}
.cs-option:hover, .cs-option.selected { background: var(--bg-inset); }
.cs-option.selected { font-weight: 600; }
.cs-option.disabled { color: var(--text-muted); cursor: not-allowed; }
/* Wraps rather than truncating -- .cs-menu now sizes itself to its
   longest option (up to max-width) specifically so this text can be read
   in full; a long provider label (e.g. "Name -- Vendor / model") that
   still exceeds that cap wraps to a second line instead of clipping. */
.cs-option-label { flex: 1; min-width: 0; white-space: normal; word-break: break-word; }
@media (prefers-reduced-motion: reduce) { .cs-menu { transition: none; } }

/* ---- Tables ---- */

.table-head th {
  background: var(--bg-inset);
  color: var(--text-secondary);
  font-size: .78rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-subtle);
}
/* Bootstrap's own `.table > :not(caption) > * > *` rule sets
   background-color: var(--bs-table-bg), which resolves to Bootstrap's
   LIGHT-mode white (#fff) -- this app never sets Bootstrap's own
   data-bs-theme="dark" attribute (it runs its own separate [data-theme]
   system), so every table cell was rendering an opaque white square in
   dark mode regardless of the surface it sat on. Pinning it to
   --bg-surface makes cells blend with their card in both themes (a no-op
   in light mode, since --bg-surface is already white there). */
.table > :not(caption) > * > * { color: var(--text-primary); background-color: var(--bg-surface); border-bottom-color: var(--border-subtle); }
.table-hover > tbody > tr:hover > * { background-color: var(--bg-inset); }

/* ---- Status/sentiment/latency badges ----
   Subtle-bg + colored-text, never a solid semantic color with white text
   (kept from the prior audit -- still the right call on a light surface:
   a filled saturated badge reads as louder/heavier than this system wants). */

.badge-status-success, .badge-latency-good { background: var(--success-subtle-bg); color: var(--success-text); }
.badge-status-danger, .badge-latency-bad { background: var(--danger-subtle-bg); color: var(--danger-text); }
.badge-status-warning, .badge-latency-warn { background: var(--warning-subtle-bg); color: var(--warning-text); }
.badge-status-neutral { background: var(--neutral-subtle-bg); color: var(--neutral-text); }
.badge-status-success, .badge-status-danger, .badge-status-warning, .badge-status-neutral,
.badge-latency-good, .badge-latency-bad, .badge-latency-warn {
  font-weight: 600;
  border: none;
}

/* Informational tags, not primary actions -- neutral, not the accent. */
.badge-state { background: var(--neutral-subtle-bg); color: var(--neutral-text); border: 1px solid var(--border-subtle); }

code, pre { font-size: .85em; }
/* Numeric/ID/timestamp columns get the monospace face + tabular figures --
   IDs, durations, costs, timestamps -- everything else stays sans-serif. */
.mono-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
/* Icon-only row actions (edit/delete) get a subtle lift on hover, not just
   a color change -- a small, cheap "this is interactive" cue. */
.icon-action { transition: transform .12s ease, background-color .12s ease, color .12s ease; }
.icon-action:hover { transform: scale(1.08); }
.icon-action:active { transform: scale(.94); }
.placeholder-panel {
  background: repeating-linear-gradient(45deg, var(--bg-canvas), var(--bg-canvas) 10px, var(--bg-inset) 10px, var(--bg-inset) 20px);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-sm);
}

/* ---- Sidebar / topbar / shell -- sidebar is the one fixed-dark surface ---- */

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--sidebar-bg); color: var(--sidebar-text); overflow-y: auto; z-index: 1000;
}
.sidebar .brand { padding: 1.25rem 1.25rem 1rem; font-weight: 700; color: var(--sidebar-text-hover); font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; }
.sidebar .brand i { color: var(--accent); }
.sidebar .nav { padding: 0 .6rem; }
.sidebar .nav-link {
  color: var(--sidebar-text); padding: .5rem .65rem; border-radius: var(--radius-sm); font-size: .87rem;
  display: flex; align-items: center; gap: .65rem; position: relative;
  transition: background-color .12s ease, color .12s ease;
}
.sidebar .nav-link:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-text-hover); }
/* Active is a distinct, quieter treatment from :hover -- a tinted
   background + a Steel Blue left rail, not the same "loud" state as a
   plain hover. */
.sidebar .nav-link.active { background: var(--sidebar-active-bg); color: var(--sidebar-text-active); font-weight: 600; }
.sidebar .nav-link.active::before {
  content: ""; position: absolute; left: 0; top: .3rem; bottom: .3rem; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}
.sidebar .nav-link i { width: 16px; text-align: center; flex: none; font-size: .92rem; }
.sidebar .section-label { padding: 1.1rem .85rem .3rem; font-family: var(--font-mono); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--sidebar-section-label); font-weight: 500; }
.sidebar-footer { border-top: 1px solid var(--sidebar-border); }
.sidebar-username { color: var(--sidebar-text); }

.main { margin-left: var(--sidebar-w); min-height: 100vh; }
.topbar {
  background: var(--bg-surface); border-bottom: 1px solid var(--border-subtle);
  padding: .85rem 1.75rem; display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-between; gap: 1.25rem;
}
.page-title { font-size: 1.375rem; font-weight: 700; color: var(--text-primary); letter-spacing: -.02em; white-space: nowrap; flex: none; }
.topbar-right { display: flex; flex-wrap: nowrap; align-items: center; gap: 1rem; margin-left: auto; flex: none; }
.topbar-actions { display: flex; flex-wrap: nowrap; align-items: center; gap: .5rem; color: var(--text-secondary); font-size: .85rem; white-space: nowrap; }
.content { padding: 1.75rem; }
/* Numeric readouts (stat cards, latency, cost/duration figures) get the
   monospace face -- an instrument-panel touch that fits a voice/audio
   product, and tabular-nums keeps columns of digits aligned. */
.stat-card .stat-value { font-family: var(--font-mono); font-size: 1.7rem; font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.stat-card { display: flex; align-items: flex-start; gap: .85rem; }
.stat-card .card-body { display: flex; align-items: flex-start; gap: .85rem; width: 100%; }
.stat-icon {
  flex: none; width: 38px; height: 38px; border-radius: var(--radius-sm);
  background: var(--bg-inset); border: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); font-size: 1.05rem;
}

/* ---- Charts (SVG, hand-authored -- see dataviz skill's mark specs) ---- */

.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
/* pointer-events: none on every purely-visual mark is required, not
   cosmetic -- same category of bug as the donut center-label fix below.
   .chart-bar is painted AFTER (on top of) its sibling .chart-hit rect, so
   without this, hovering the visible bar itself (the most natural place
   for a real user to point) hits the opaque bar instead of the transparent
   hit-rect underneath, and gets no tooltip at all. Confirmed via
   Playwright: a bar tall enough to cover the hit-rect's bounding-box
   center made hover time out completely until this was added -- it had
   been silently working before only because the specific bars tested
   earlier happened to be short enough to leave empty (unpainted) hit-rect
   area exposed above them. */
.chart-bar { fill: var(--chart-1); transition: opacity .1s ease; pointer-events: none; }
.chart-hit { fill: transparent; cursor: pointer; }
.chart-hit:hover + .chart-bar, .chart-hit:focus-visible + .chart-bar { opacity: .8; }
.chart-axis-label { fill: var(--text-muted); font-size: 11px; font-family: var(--font-sans); pointer-events: none; }
.chart-gridline { stroke: var(--border-subtle); stroke-width: 1; pointer-events: none; }
.chart-baseline { stroke: var(--border-strong); stroke-width: 1; pointer-events: none; }
.chart-area { fill: var(--chart-1); opacity: .12; pointer-events: none; }
.chart-line { fill: none; stroke: var(--chart-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; pointer-events: none; }
.chart-dot { fill: var(--chart-1); stroke: var(--bg-surface); stroke-width: 2; opacity: 0; transition: opacity .08s ease; pointer-events: none; }
.chart-crosshair { stroke: var(--border-strong); stroke-width: 1; opacity: 0; pointer-events: none; }
.chart-hbar-label { fill: var(--text-secondary); font-size: 13px; font-family: var(--font-sans); pointer-events: none; }
.chart-hbar-value { fill: var(--text-primary); font-size: 13px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; pointer-events: none; }

/* ---- Donut / ring chart ---- */

.donut-row { display: flex; align-items: center; gap: 1.25rem; }
.donut-svg { flex: none; width: 132px; height: 132px; }
.donut-track { fill: none; stroke: var(--bg-inset); stroke-width: 14; }
.donut-segment { fill: none; stroke-width: 14; transition: stroke-width .12s ease, opacity .12s ease; cursor: pointer; }
.donut-segment:hover, .donut-segment:focus-visible { stroke-width: 16; }
/* pointer-events: none is required, not cosmetic -- a segment spanning
   more than half the ring has a bounding box that includes the center
   point, so without this the center label sits on top and silently
   swallows hover/click for that segment (confirmed via Playwright). */
.donut-center-value { fill: var(--text-primary); font-family: var(--font-mono); font-weight: 600; font-variant-numeric: tabular-nums; pointer-events: none; }
.donut-center-label { fill: var(--text-muted); font-family: var(--font-sans); font-size: 9.5px; text-transform: uppercase; letter-spacing: .04em; pointer-events: none; }
.donut-legend { display: flex; flex-direction: column; gap: .45rem; flex: 1; min-width: 0; }
.donut-legend-row { display: flex; align-items: center; gap: .5rem; font-size: .88rem; }
.donut-legend-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; }
.donut-legend-label { color: var(--text-secondary); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend-value { font-family: var(--font-mono); color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }
.donut-legend-pct { color: var(--text-muted); font-size: .8rem; min-width: 2.5em; text-align: right; }

.chart-tooltip {
  position: absolute; pointer-events: none; z-index: 20;
  background: var(--text-primary); color: var(--bg-surface); border: none;
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  padding: .4rem .6rem; font-size: .85rem; white-space: nowrap;
  opacity: 0; transform: translateY(2px); transition: opacity .08s ease, transform .08s ease;
}
.chart-tooltip.show { opacity: 1; transform: translateY(0); }
.chart-tooltip .tt-value { font-family: var(--font-mono); font-weight: 700; color: var(--bg-surface); font-variant-numeric: tabular-nums; }
.chart-tooltip .tt-label { color: var(--bg-inset); margin-top: 1px; }
.chart-wrap { position: relative; }

/* ---- KPI cards (Call Analytics Section A) ---- */

.kpi-card .kpi-label { color: var(--text-muted); font-family: var(--font-mono); font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; margin-bottom: .3rem; }
.kpi-card .kpi-value { font-family: var(--font-mono); font-size: 1.55rem; font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.kpi-delta { font-size: .78rem; font-weight: 600; display: inline-flex; align-items: center; gap: .2rem; margin-top: .3rem; }
.kpi-delta.up { color: var(--success-text); }
.kpi-delta.down { color: var(--danger-text); }
.kpi-delta.flat { color: var(--text-muted); }
.kpi-caption { color: var(--text-muted); font-size: .72rem; margin-top: .3rem; line-height: 1.4; }

/* ---- Call funnel (Section B) ---- */

.funnel-row { display: flex; align-items: stretch; gap: 0; overflow-x: auto; padding-bottom: .25rem; }
.funnel-step { flex: 1; min-width: 130px; display: flex; flex-direction: column; }
.funnel-step .funnel-label { font-size: .82rem; color: var(--text-secondary); margin-bottom: .3rem; text-transform: capitalize; }
.funnel-step .funnel-value { font-family: var(--font-mono); font-size: 1.4rem; font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.funnel-step .funnel-pct { font-size: .74rem; color: var(--text-muted); margin-top: .15rem; }
.funnel-bar-track { height: 8px; border-radius: var(--radius-pill); background: var(--bg-inset); margin-top: .6rem; overflow: hidden; }
.funnel-bar-fill { height: 100%; background: var(--chart-1); border-radius: var(--radius-pill); }
.funnel-step.non-sequential .funnel-bar-fill { background: var(--text-muted); }
.funnel-arrow { flex: none; width: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-muted); }
.funnel-arrow .conv-pct { font-family: var(--font-mono); font-size: .78rem; font-weight: 600; color: var(--text-secondary); margin-top: .2rem; }

/* ---- Call-progress stepper ---- */

.stage-stepper { user-select: none; }
.stage-step { display: flex; flex-direction: column; align-items: center; min-width: 84px; }
.stage-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--border-subtle); border: 2px solid var(--border-subtle); transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease; }
.stage-label { font-size: .8rem; color: var(--text-muted); margin-top: 4px; white-space: nowrap; }
.stage-line { flex: 1; height: 2px; background: var(--border-subtle); margin: 0 2px; margin-bottom: 19px; transition: background-color .2s ease; }
.stage-step.done .stage-dot { background: var(--text-primary); border-color: var(--text-primary); }
.stage-step.done .stage-label { color: var(--text-primary); }
.stage-line.done { background: var(--text-primary); }
.stage-step.active .stage-dot { background: var(--bg-surface); border-color: var(--text-primary); box-shadow: 0 0 0 3px var(--border-subtle); }
.stage-step.active .stage-label { color: var(--text-primary); font-weight: 600; }
.stage-step.active.completed .stage-dot { border-color: var(--success); box-shadow: 0 0 0 3px var(--success-subtle-bg); }
.stage-step.active.completed .stage-label { color: var(--success-text); }
.stage-step.active.failed .stage-dot, .stage-step.active.busy .stage-dot, .stage-step.active.no_answer .stage-dot { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-subtle-bg); }
.stage-step.active.failed .stage-label, .stage-step.active.busy .stage-label, .stage-step.active.no_answer .stage-label { color: var(--danger-text); }

/* ---- Live transcript / chat bubbles ---- */

#transcriptBox { max-height: 380px; overflow-y: auto; font-size: .85rem; }
.state-pill { display: inline-block; padding: .25rem .6rem; border-radius: var(--radius-pill); background: var(--neutral-subtle-bg); color: var(--neutral-text); border: 1px solid var(--border-subtle); font-size: .84rem; margin: 2px; }

.transcript-line { display: flex; margin-bottom: 8px; animation: transcript-in .18s ease; }
@keyframes transcript-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.transcript-line.role-agent { justify-content: flex-start; }
.transcript-line.role-user { justify-content: flex-end; }
.transcript-bubble { max-width: 78%; padding: .5rem .75rem; border-radius: .75rem; line-height: 1.35; border: 1px solid var(--border-subtle); }
/* Both roles stay neutral -- distinguished by alignment + surface shade,
   not color-coding. The one exception is a small accent dot next to
   "You," marking whose turn it is without tinting the whole bubble. */
.role-agent .transcript-bubble { background: var(--bg-surface-raised); color: var(--text-primary); border-bottom-left-radius: .2rem; }
.role-user .transcript-bubble { background: var(--bg-inset); color: var(--text-primary); border-bottom-right-radius: .2rem; }
.transcript-speaker { font-size: .76rem; font-weight: 600; text-transform: uppercase; color: var(--text-muted); margin-bottom: 2px; display: flex; align-items: center; gap: 5px; }
.role-user .transcript-speaker::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); display: inline-block; }

.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--success); margin-right: 5px; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* Latency badges fade in rather than popping in abruptly once resolved. */
.latency-badge { transition: opacity .15s ease; }
.latency-badge, .badge-latency-good, .badge-latency-warn, .badge-latency-bad {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Call Analytics Phase 2 -- percentile mini-stats (Section D), the fast vs
   backstop tier bar, and the Script Comparison low-sample flag. */
.stat-strip { display: flex; gap: 1.75rem; flex-wrap: wrap; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border-subtle); }
.stat-chip-label { font-family: var(--font-mono); font-size: .7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .15rem; }
.stat-chip-value { font-family: var(--font-mono); font-size: 1.15rem; font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }

.tier-bar-track { height: 10px; border-radius: var(--radius-pill); background: var(--bg-inset); overflow: hidden; display: flex; margin-top: .3rem; }
.tier-bar-fast { background: var(--success); height: 100%; }
.tier-bar-backstop { background: var(--warning); height: 100%; }
.tier-legend { display: flex; gap: 1.25rem; margin-top: .5rem; font-size: .78rem; color: var(--text-secondary); }
.tier-legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .3rem; }
.tier-legend-dot.fast { background: var(--success); }
.tier-legend-dot.backstop { background: var(--warning); }

.badge-low-sample { background: var(--warning-subtle-bg); color: var(--warning-text); font-size: .68rem; font-weight: 600; padding: .1rem .4rem; border-radius: var(--radius-pill); margin-left: .4rem; white-space: nowrap; }
