/* Conversation Monitoring Dashboard — light blue internal-tool theme. No CDN
   font, no framework, no inline style anywhere in index.html/dashboard.js so
   the app's default helmet() CSP (script-src 'self', no 'unsafe-inline')
   needs no changes for this to render. Every dynamic SVG color below is set
   via a presentation attribute (fill / stroke / fill-opacity), not a
   style="" attribute — presentation attributes are plain CSS property values
   but are not governed by style-src, and they may reference the custom
   properties defined here with var(), so the whole page still themes from
   one palette. */

/* The browser's own [hidden]{display:none} lives in the UA stylesheet, which
   ANY author rule of equal specificity overrides regardless of source order
   — so any element that also gets its own `display` declaration (.auth-gate,
   .app-shell) silently ignores its `hidden` attribute without this. One
   global, high-priority rule fixes it everywhere, for every element, rather
   than patching each class that happens to set `display`. */
[hidden] {
  display: none !important;
}

:root {
  color-scheme: light;

  --page-bg: #eef3fb;
  --surface: #ffffff;
  --surface-alt: #f4f8fd;
  --border: rgba(29, 78, 156, 0.12);
  --border-strong: rgba(29, 78, 156, 0.22);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 6px 18px rgba(20, 55, 120, 0.08), 0 1px 2px rgba(16, 24, 40, 0.05);

  --text-primary: #0f1b2d;
  --text-secondary: #4b5d78;
  --text-muted: #869ab8;

  --radius-lg: 14px;
  --radius-md: 11px;
  --radius-sm: 8px;

  /* Primary accent: light blue. Secondary accents: soft purple / green /
     orange / red, used consistently for the same kind of signal (blue =
     volume/neutral, green = healthy, orange = elevated, red = failing,
     purple = cost/voice). */
  --blue: #2f7de1;
  --blue-ink: #1c5cab;
  --blue-soft: #e5f0fe;
  --blue-deep: #123a75;
  --purple: #7c5cf0;
  --purple-ink: #5636c9;
  --purple-soft: #f1edfe;
  --green: #17a862;
  --green-ink: #0f7a48;
  --green-soft: #e5f8ee;
  --orange: #e08324;
  --orange-ink: #b8650f;
  --orange-soft: #fdf1e2;
  --red: #de3b3b;
  --red-ink: #b32424;
  --red-soft: #fdeaea;

  --chart-blue: var(--blue);
  --chart-orange: var(--orange);
  --chart-purple: var(--purple);
  --chart-red: var(--red);
  --chart-green: var(--green);

  --grid-line: #e3eaf6;
  --axis-line: #c3d3ea;

  --sidebar-w: 208px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text-primary);
  font:
    13.5px/1.45 system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
}

code {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
}

/* ---------- Page-entry authorization gate ---------- */
/* See #authGate's HTML comment and dashboard.js's startDashboard/attemptEntry
   — shown alone, full-viewport, until a token is verified server-side; #appShell
   stays `hidden` until then, so nothing in it loads first. */

.auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page-bg);
  padding: 24px;
}

.auth-gate-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 28px 26px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-gate-card h1 {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
}

.auth-gate-hint {
  margin: -8px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.auth-gate-btn {
  width: 100%;
  justify-content: center;
  padding: 9px;
}

.auth-gate-error {
  font-size: 12px;
  color: var(--red-ink, #b42318);
}

/* ---------- App shell: fixed sidebar + scrolling main column ---------- */

.app-shell {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- Sidebar ---------- */

.sidebar {
  flex: none;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 10px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 14px;
}

.brand-mark {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
  flex: none;
}

.brand-name {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--blue-deep);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--text-muted);
}

.nav-item:hover {
  background: var(--surface-alt);
  color: var(--text-primary);
}

.nav-item:hover svg {
  color: var(--blue);
}

.nav-item.is-active {
  background: var(--blue-soft);
  color: var(--blue-deep);
  border-color: var(--border);
}

.nav-item.is-active svg {
  color: var(--blue);
}

.nav-item:focus-visible,
.control select:focus-visible,
.drill-item:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

/* ---------- Header ---------- */

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-heading h1 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.topbar-heading .subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.topbar-controls {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.control label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.control select {
  background: var(--surface-alt);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  font-size: 12.5px;
  min-width: 100px;
}

/* ---------- Layout ---------- */

main {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 18px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.notice {
  border: 1px solid var(--orange);
  background: var(--orange-soft);
  color: var(--orange-ink);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  font-size: 12.5px;
}

/* Same shape as .notice, neutral rather than orange — this is context, not a
   warning: the Historical Conversations section is working as designed, it
   is just telling the reader what it can and cannot derive. */
.info-note {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-secondary, var(--text-muted));
  border-radius: var(--radius-md);
  padding: 11px 14px;
  font-size: 12.5px;
  line-height: 1.5;
  margin-bottom: 12px;
}

/* ---------- Local access-token panel (testing/demo only) ---------- */

.token-panel-hint {
  margin: 0 0 11px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  max-width: 74ch;
}

.token-panel-body {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.token-control {
  flex: 1 1 220px;
  min-width: 200px;
}

.token-control input {
  width: 100%;
  background: var(--surface-alt);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  font: inherit;
  font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.token-control input:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

.token-panel-actions {
  display: flex;
  gap: 8px;
  flex: none;
}

.token-btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.token-btn:hover {
  border-color: var(--blue);
  color: var(--blue-ink);
}

.token-btn-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.token-btn-primary:hover {
  background: var(--blue-ink);
  border-color: var(--blue-ink);
  color: #fff;
}

section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 15px 17px 17px;
  box-shadow: var(--shadow-sm);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding-left: 9px;
  border-left: 3px solid var(--blue);
}

.section-head h2 {
  font-size: 12.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--blue-deep);
}

.section-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.kpi-group-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 2px 0 7px;
}

.kpi-group-label:not(:first-of-type) {
  margin-top: 14px;
}

.state {
  font-size: 12.5px;
  color: var(--text-muted);
  padding: 2px 0 10px;
}

.state:empty {
  display: none;
}

.state.error {
  color: var(--red-ink);
}

.state.empty {
  color: var(--text-muted);
}

/* ---------- Empty states ---------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 3px;
  color: var(--text-muted);
  padding: 20px 12px;
  width: 100%;
}

.empty-state .empty-icon {
  color: var(--blue);
  opacity: 0.45;
  margin-bottom: 3px;
}

.empty-state-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
}

.empty-state-hint {
  font-size: 11px;
  color: var(--text-muted);
  max-width: 32ch;
  line-height: 1.4;
}

.empty-state-compact {
  padding: 12px 8px;
  gap: 2px;
}

.empty-state-compact .empty-state-title {
  font-size: 11.5px;
}

.empty-state-compact .empty-state-hint {
  font-size: 10.5px;
}

.empty-card {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-alt);
}

/* ---------- KPI cards ---------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(164px, 1fr));
  gap: 9px;
}

.kpi-card {
  position: relative;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 12px 9px 13px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
}

/* Left accent bar carries the signal color instead of a dot + wide label
   row — denser, and the color reads before anything else does. */
.kpi-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
}

.kpi-card.accent-blue::before {
  background: var(--blue);
}
.kpi-card.accent-purple::before {
  background: var(--purple);
}
.kpi-card.accent-green::before {
  background: var(--green);
}
.kpi-card.accent-orange::before {
  background: var(--orange);
}
.kpi-card.accent-red::before {
  background: var(--red);
}

.kpi-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-value-row {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.kpi-value {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.kpi-delta {
  font-size: 10.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.kpi-delta.up {
  color: var(--green-ink);
}
.kpi-delta.down {
  color: var(--red-ink);
}
.kpi-delta.flat {
  color: var(--text-muted);
}

.kpi-sub {
  font-size: 10px;
  color: var(--text-muted);
}

.kpi-spark {
  display: block;
  width: 100%;
  height: 20px;
}

/* ---------- Charts ---------- */

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 12px;
}

.chart-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 13px 15px 8px;
  box-shadow: var(--shadow-sm);
  position: relative;
  display: flex;
  flex-direction: column;
}

.chart-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.chart-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

.chart-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.legend-dot.c-blue {
  background: var(--chart-blue);
}
.legend-dot.c-orange {
  background: var(--chart-orange);
}
.legend-dot.c-purple {
  background: var(--chart-purple);
}
.legend-dot.c-red {
  background: var(--chart-red);
}
.legend-dot.c-green {
  background: var(--chart-green);
}

.chart-card svg.main-chart {
  display: block;
  width: 100%;
  height: 210px;
}

.chart-card .empty-state {
  min-height: 210px;
  justify-content: center;
}

/* ---------- Tool judgment section ---------- */

.judgment-hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.hero-stat {
  background: var(--blue-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
}

.hero-stat .kpi-label {
  margin-bottom: 5px;
  color: var(--blue-deep);
}

.hero-stat .kpi-value {
  font-size: 22px;
}

/* The one hero stat where up is bad — a red tint reads that before the
   number does, the same way accent-red already does on a KPI card. */
.hero-stat-negative {
  background: var(--red-soft);
}

.hero-stat-negative .kpi-label {
  color: var(--red-ink);
}

.hero-empty {
  grid-column: 1 / -1;
  background: var(--surface-alt);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.summary-pill {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 13px;
}

.summary-pill .source {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.summary-pill .rate-row {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-bottom: 7px;
}

.summary-pill .rate {
  font-size: 18px;
  font-weight: 800;
}

.summary-pill .count {
  font-size: 11px;
  color: var(--text-muted);
}

.summary-pill svg.meter {
  display: block;
  width: 100%;
  height: 7px;
}

/* ---------- Conversation drill-down: users -> conversations -> transcript ---------- */

.drilldown-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1.2fr;
  gap: 10px;
  align-items: stretch;
}

/* ---------- Conversation Drill-Down: dedicated full-page view ---------- */
/* Same three panes as .drilldown-grid above (same element ids, same JS) —
   only the surrounding page gets more room: no 1440px cap, and each pane's
   own scroll area is taller, since it no longer shares a page with six other
   sections. See #conversationsPageView and wireSidebarNav in dashboard.js. */

.conversations-page {
  max-width: 1800px;
  width: 100%;
  margin: 0 auto;
  padding: 18px 24px 48px;
  min-height: 100vh;
  box-sizing: border-box;
}

.drilldown-grid-full {
  min-height: calc(100vh - 140px);
}

.drilldown-grid-full .drill-list {
  max-height: none;
  flex: 1;
}

.drilldown-grid-full .drill-detail-body {
  max-height: none;
  flex: 1;
}

.drill-connector {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--border-strong);
  width: 16px;
}

.drill-connector svg {
  width: 16px;
  height: 16px;
}

.drill-pane {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 11px 11px 7px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.drill-pane-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.drill-pane-head h3 {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.drill-pane-hint {
  font-size: 10px;
  color: var(--text-muted);
}

.drill-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 2px;
}

.drill-item {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.drill-item:hover {
  border-color: var(--border-strong);
  background: var(--blue-soft);
}

.drill-item.is-selected {
  border-color: var(--blue);
  background: var(--blue-soft);
  box-shadow: 0 0 0 1px var(--blue) inset;
}

.drill-item-top {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
}

.drill-item-id {
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.conv-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drill-item-meta {
  margin-top: 3px;
  font-size: 10.5px;
  color: var(--text-muted);
}

.drill-pane-detail {
  background: var(--surface);
}

.drill-detail-body {
  max-height: 420px;
  overflow-y: auto;
  padding-right: 2px;
}

/* ---------- Panel 1: recent users ---------- */

.user-item-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.user-avatar {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--blue-soft);
  color: var(--blue-ink);
  font-size: 11px;
  font-weight: 800;
}

.user-item-info {
  min-width: 0;
  flex: 1;
}

.user-item-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Panel 3: conversation transcript ---------- */

.chat-timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble {
  max-width: 88%;
  border-radius: var(--radius-md);
  padding: 9px 12px;
  border: 1px solid var(--border);
}

/* User turns lead the left edge, assistant turns the right — the same
   left/right vocabulary an actual chat UI uses, so a transcript reads at a
   glance instead of needing the role label read on every line. */
.chat-bubble-user {
  align-self: flex-start;
  background: var(--surface-alt);
}

.chat-bubble-assistant {
  align-self: flex-end;
  background: var(--blue-soft);
}

.chat-bubble-head {
  margin-bottom: 3px;
}

.chat-bubble-role {
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.chat-bubble-text {
  font-size: 12.5px;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-bubble-time {
  margin-top: 5px;
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* `:::compare` / `:::chart` — the ranked-bar blocks the real WealthQ chat
   apps render (CompareBlock.tsx) and this transcript now matches, rather
   than showing their raw `label|value` source text. Sits as a block inside
   `.chat-bubble-text`'s pre-wrapped text — the plain-text runs around it are
   unaffected. */
.dsl-compare {
  margin: 8px 0;
  padding: 9px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  white-space: normal;
}

.dsl-compare-title {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 7px;
}

.dsl-compare-row {
  margin-bottom: 7px;
}

.dsl-compare-row:last-child {
  margin-bottom: 0;
}

.dsl-compare-row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  margin-bottom: 3px;
}

.dsl-compare-label {
  color: var(--text-primary);
}

.dsl-compare-value {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dsl-compare-track {
  height: 5px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.dsl-compare-fill {
  height: 100%;
  border-radius: 999px;
  /* `width` and `background` are set per row in JS — see COMPARE_SLICE_SHADES
     in dashboard.js, the same 3-color palette CompareBlock.tsx cycles
     through, reproduced verbatim rather than mapped onto this dashboard's
     own accent tokens. */
}

/* Tool calls inside an assistant turn — visually distinct from the reply
   text itself, per the requirement that a tool call read as its own kind of
   thing rather than blend into the prose around it. */
.chat-tool-calls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.chat-tool-call {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
}

.chat-tool-call-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-tool-call-name {
  font-size: 11px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--blue-deep);
}

.chat-tool-call-reason {
  margin-top: 4px;
  font-size: 10.5px;
  color: var(--text-secondary);
}

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

.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.table-card-scroll {
  max-height: 440px;
  overflow-y: auto;
}

.judgments-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  min-width: 720px;
}

.judgments-table th,
.judgments-table td {
  text-align: left;
  padding: 9px 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.judgments-table tbody tr:last-child td {
  border-bottom: none;
}

.judgments-table tbody tr:hover {
  background: var(--surface-alt);
}

.judgments-table th {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.judgments-table td.calls,
.judgments-table td.when {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.judgments-table td.findings {
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: capitalize;
}

.badge.pass {
  background: var(--green-soft);
  color: var(--green-ink);
}

.badge.fail {
  background: var(--red-soft);
  color: var(--red-ink);
}

.badge.unknown {
  background: var(--surface-alt);
  color: var(--text-muted);
}

.source-tag {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 10.5px;
  font-weight: 600;
  background: var(--blue-soft);
  color: var(--blue-ink);
}

/* ---------- Footer ---------- */

.page-footer {
  padding: 0 24px 28px;
  color: var(--text-muted);
  font-size: 11px;
}

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
  .drilldown-grid {
    grid-template-columns: 1fr 1fr;
  }
  .drill-connector {
    display: none;
  }
  .drill-pane-detail {
    grid-column: 1 / -1;
  }
}

@media (max-width: 880px) {
  .app-shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    overflow-y: visible;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 8px 10px;
    gap: 0;
  }
  .sidebar-brand {
    padding: 4px 10px 4px 4px;
  }
  .sidebar-nav {
    flex-direction: row;
    gap: 2px;
  }
}

@media (max-width: 620px) {
  .sidebar .nav-label {
    display: none;
  }
  .nav-item {
    padding: 8px;
  }
  .topbar {
    padding: 12px 14px;
  }
  main {
    padding: 14px 12px 36px;
  }
  section {
    padding: 12px 12px 14px;
  }
  .kpi-grid {
    grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  }
  .chart-grid {
    grid-template-columns: 1fr;
  }
  .drilldown-grid {
    grid-template-columns: 1fr;
  }
  .drill-pane-detail {
    grid-column: auto;
  }
}
