/* ==========================================================================
   NethraCX -- AI Observability for Contact Centers
   Design system: premium dark enterprise interface. Tokens first, then the
   app shell, then reusable components (Metric, StatusBadge, SeverityBadge,
   InsightCard, EvidenceCard, Timeline, DataTable, HealthIndicator,
   EmptyState, LoadingState, ConfidenceIndicator...), then per-screen rules.
   ========================================================================== */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/inter/inter-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/inter/inter-latin-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/inter/inter-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/inter/inter-latin-700-normal.woff2") format("woff2");
}

:root {
  /* Surfaces -- layered dark, never pure black */
  --bg: #0b0f14;
  --surface: #11161d;
  --surface-2: #151b23;
  --surface-3: #1a212a;
  --surface-hover: #1c232d;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);
  --overlay-scrim: rgba(5, 7, 10, 0.6);

  /* Text -- brightened from the initial pass: --muted now clears 4.5:1
     (WCAG AA for normal text) against every surface it's used on, so it's
     safe for labels/timestamps/headers, not just decorative copy. --dim is
     reserved for genuinely decorative elements (placeholders, icon glyphs)
     and is not relied on for readable text. */
  --text: #e8ebf0;
  --text-secondary: #b8bfcc;
  --muted: #99a2b3;
  --dim: #6b7486;

  /* Accent -- restrained, meaning-bearing only. NethraCX signal blue is the
     one identity color; everything else is status. */
  --accent: #4a86ff;
  --accent-dim: rgba(74, 134, 255, 0.14);
  --accent-border: rgba(74, 134, 255, 0.35);

  --critical: #f0473f;
  --critical-dim: rgba(240, 71, 63, 0.13);
  --critical-border: rgba(240, 71, 63, 0.35);

  --warning: #f2a93c;
  --warning-dim: rgba(242, 169, 60, 0.13);
  --warning-border: rgba(242, 169, 60, 0.35);

  --positive: #35c17c;
  --positive-dim: rgba(53, 193, 124, 0.13);
  --positive-border: rgba(53, 193, 124, 0.35);

  --observation: #8b93a7;
  --observation-dim: rgba(139, 147, 167, 0.13);
  --observation-border: rgba(139, 147, 167, 0.32);

  --radius-sm: 5px;
  --radius: 7px;
  --radius-lg: 10px;

  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

/* --- Light theme -----------------------------------------------------------
   Same accent/severity hues as dark (brand + status meaning stays constant),
   different surfaces/text so it reads as a deliberate second theme rather
   than an inverted one. Toggled via [data-theme] on <html> -- see the
   theme-toggle button in the topbar and applyTheme()/initTheme() in app.js. */
:root[data-theme="light"] {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --surface-3: #eef1f6;
  --surface-hover: #e7ebf2;
  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.16);
  --overlay-scrim: rgba(15, 23, 42, 0.35);

  --text: #10151d;
  --text-secondary: #3d4657;
  --muted: #5b6478;
  --dim: #7c8698;

  --accent: #2f66e0;
  --accent-dim: rgba(47, 102, 224, 0.10);
  --accent-border: rgba(47, 102, 224, 0.35);

  --critical: #c92f27;
  --critical-dim: rgba(201, 47, 39, 0.09);
  --critical-border: rgba(201, 47, 39, 0.30);

  --warning: #a3690a;
  --warning-dim: rgba(163, 105, 10, 0.11);
  --warning-border: rgba(163, 105, 10, 0.30);

  --positive: #1c8f56;
  --positive-dim: rgba(28, 143, 86, 0.10);
  --positive-border: rgba(28, 143, 86, 0.30);

  --observation: #5b6478;
  --observation-dim: rgba(91, 100, 120, 0.09);
  --observation-border: rgba(91, 100, 120, 0.26);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
a { color: inherit; }
button { font-family: inherit; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 20px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); }

/* --- Auth gate -------------------------------------------------------- */
.auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(560px 380px at 18% 8%, rgba(74, 134, 255, 0.09), transparent 60%),
    var(--bg);
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 30px 32px;
  max-width: 400px;
  width: 100%;
}
.auth-brand { display: flex; align-items: center; gap: 9px; margin-bottom: 18px; }
.auth-brand .brand-mark { width: 26px; height: 26px; }
.auth-brand .brand-word { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.auth-card h1 { font-size: 15px; font-weight: 600; margin: 0 0 6px; color: var(--text); }
.auth-card p { color: var(--muted); font-size: 12.5px; line-height: 1.55; margin: 0 0 4px; }
.auth-card code { background: var(--surface-3); color: var(--text-secondary); padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }

.auth-tabs { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 3px; margin: 16px 0 4px; }
.auth-tab { flex: 1; padding: 7px 10px; border: none; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600; border-radius: 5px; cursor: pointer; }
.auth-tab.active { background: var(--surface); color: var(--text); }
.auth-tab:hover:not(.active) { color: var(--text-secondary); }

.auth-panel { margin-top: 12px; }

.auth-input, #api-key-input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 13px;
  margin: 0 0 8px;
  background: var(--surface-2);
  color: var(--text);
  display: block;
}
.auth-input:focus, #api-key-input:focus { outline: none; border-color: var(--accent-border); }
.auth-hint { display: block; color: var(--muted); font-size: 11.5px; margin: -2px 0 10px; }
.auth-hint strong { color: var(--text-secondary); font-weight: 600; }

.auth-submit, #api-key-submit {
  width: 100%;
  padding: 9px 11px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}
.auth-submit:hover, #api-key-submit:hover { filter: brightness(1.1); }
.auth-submit:disabled { opacity: 0.6; cursor: default; }

.auth-link {
  display: block;
  width: 100%;
  text-align: center;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  margin-top: 14px;
  padding: 4px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.auth-link:hover { color: var(--text-secondary); }

.error-text { color: var(--critical); font-size: 12px; min-height: 15px; margin-top: 8px; }

/* --- App shell ---------------------------------------------------------
   Left rail (fixed) + a right column of topbar (fixed) over a scrolling
   content area. No box-shadows -- separation comes from surface deltas
   and 1px hairline borders only. */
.shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.sidebar-logo { display: flex; align-items: center; gap: 8px; padding: 17px 18px 15px; }
.sidebar-logo .brand-mark { width: 20px; height: 20px; flex-shrink: 0; }
.sidebar-logo .brand-word { font-weight: 700; font-size: 14.5px; letter-spacing: -0.01em; color: var(--text); }
.sidebar-logo .brand-sub { display: block; font-size: 9.5px; font-weight: 500; color: var(--dim); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 1px; }

.sidebar-nav { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 10px; display: flex; flex-direction: column; gap: 1px; }
.sidebar-nav-lower { padding: 8px 10px 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 1px; }

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px 7px 8px;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12.5px; font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  background: none;
  text-align: left;
  width: 100%;
}
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.75; }
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--text); font-weight: 600; border-left-color: var(--accent); }
.nav-item.active svg { opacity: 1; color: var(--accent); }

/* --- Top bar ------------------------------------------------------------ */
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 52px; flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-chip {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; color: var(--text-secondary);
  padding: 4px 9px; border-radius: var(--radius-sm);
  background: var(--surface-3);
  white-space: nowrap;
}
.topbar-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--positive); flex-shrink: 0; }
.topbar-sep { width: 1px; height: 18px; background: var(--border-strong); flex-shrink: 0; }

.topbar-search { position: relative; width: 260px; margin-left: 4px; }
.topbar-search svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 13px; height: 13px; color: var(--dim); }
.topbar-search input {
  width: 100%; padding: 6px 10px 6px 28px;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 12px;
}
.topbar-search input::placeholder { color: var(--dim); }
.topbar-search input:focus { outline: none; border-color: var(--accent-border); }

.topbar-spacer { flex: 1; }

.topbar select, .topbar-btn {
  font-size: 12px; padding: 6px 9px;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface-3); color: var(--text-secondary);
  cursor: pointer; font-weight: 500;
}
.topbar select:hover, .topbar-btn:hover { border-color: var(--border-strong); color: var(--text); }
.topbar-btn.primary { background: var(--accent-dim); border-color: var(--accent-border); color: var(--accent); }
.topbar-btn.primary:hover { background: rgba(74, 134, 255, 0.22); }
.topbar-btn.icon-only { padding: 6px 7px; display: flex; align-items: center; }
.topbar-btn.icon-only svg { width: 14px; height: 14px; }

.topbar-bell { position: relative; }
.topbar-bell .bell-count {
  position: absolute; top: -4px; right: -4px;
  min-width: 14px; height: 14px; padding: 0 3px;
  border-radius: 8px; background: var(--critical); color: #fff;
  font-size: 9px; font-weight: 700; line-height: 14px; text-align: center;
}

.topbar-profile {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 9px 4px 4px; border-radius: var(--radius);
  cursor: pointer; border: 1px solid transparent;
}
.topbar-profile:hover { background: var(--surface-3); border-color: var(--border); }
.profile-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-dim); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700;
}
.profile-role { font-size: 11.5px; font-weight: 600; color: var(--text-secondary); }

/* --- Dropdown panels (notifications, profile) --------------------------- */
.dropdown-wrap { position: relative; }
.dropdown-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 40;
  width: 320px; max-height: 380px; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); padding: 6px;
}
.dropdown-header { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 8px 10px 6px; }
.dropdown-item { padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; }
.dropdown-item:hover { background: var(--surface-hover); }
.dropdown-item .di-title { font-size: 12px; font-weight: 600; color: var(--text); }
.dropdown-item .di-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.dropdown-empty { padding: 16px 10px; text-align: center; color: var(--muted); font-size: 12px; }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 2px; }
.dropdown-action { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: var(--radius-sm); background: none; border: none; color: var(--text-secondary); font-size: 12px; cursor: pointer; }
.dropdown-action:hover { background: var(--surface-hover); color: var(--text); }

/* --- Content area --------------------------------------------------------*/
.content { flex: 1; overflow-y: auto; padding: 22px 26px 60px; }
.view { display: none; }
.view.active { display: block; }

.page-head { margin-bottom: 4px; }
.page-eyebrow { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--accent); margin-bottom: 4px; }
.page-title { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); margin: 0; }
.page-sub { font-size: 12.5px; color: var(--muted); margin: 5px 0 0; }

.page-actions { display: flex; align-items: center; gap: 8px; }

/* --- Telemetry strip (operational, not marketing) ------------------------ */
.telemetry-strip {
  display: flex; align-items: stretch; gap: 0;
  margin: 16px 0 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.telemetry-item { flex: 1; padding: 10px 16px; border-right: 1px solid var(--border); }
.telemetry-item:last-child { border-right: none; }
.telemetry-label { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.telemetry-value { font-size: 15px; font-weight: 600; color: var(--text); margin-top: 3px; font-variant-numeric: tabular-nums; }
.telemetry-value.accent { color: var(--accent); }

/* --- Section headers ------------------------------------------------------*/
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 0 12px; }
.section-head:first-child { margin-top: 0; }
.section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.section-hint { font-size: 11.5px; color: var(--muted); }
.section-link { font-size: 11.5px; color: var(--accent); background: none; border: none; cursor: pointer; font-weight: 600; }
.section-link:hover { text-decoration: underline; }

/* --- Layout helpers -------------------------------------------------------*/
.layout-2col { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
@media (max-width: 1180px) { .layout-2col { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* --- Panel (generic surface container) ------------------------------------*/
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 16px; }
.panel-title { font-size: 12.5px; font-weight: 700; color: var(--text); margin: 0 0 3px; }
.panel-sub { font-size: 11.5px; color: var(--muted); margin: 0 0 12px; line-height: 1.5; }
.muted { color: var(--muted); }

/* --- Health grid (Overview) -----------------------------------------------*/
.health-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 22px; }
@media (max-width: 1180px) { .health-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.health-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1180px) { .health-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.health-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.health-tile-top { display: flex; align-items: center; justify-content: space-between; }
.health-tile-label { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.health-dot { width: 7px; height: 7px; border-radius: 50%; }
.health-dot.good { background: var(--positive); }
.health-dot.fair { background: var(--warning); }
.health-dot.poor { background: var(--critical); }
.health-tile-value { font-size: 25px; font-weight: 700; margin-top: 6px; color: var(--text); font-variant-numeric: tabular-nums; }
.health-tile-bar { height: 3px; border-radius: 3px; background: var(--surface-3); margin-top: 9px; overflow: hidden; }
.health-tile-bar-fill { height: 100%; border-radius: 3px; }
.health-tile-bar-fill.good { background: var(--positive); }
.health-tile-bar-fill.fair { background: var(--warning); }
.health-tile-bar-fill.poor { background: var(--critical); }

/* --- Insight / prioritized-intelligence cards -----------------------------
   The flagship "What Changed?" component. Deliberately asymmetric from
   generic KPI cards: a severity rail (2px, not a stripe treatment), dense
   metadata row, inline impact deltas, one primary action. */
.insight-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 2px solid var(--observation);
  border-radius: var(--radius);
  padding: 14px 16px 14px 15px;
  margin-bottom: 10px;
}
.insight-card.critical { border-left-color: var(--critical); }
.insight-card.warning { border-left-color: var(--warning); }
.insight-card.observation { border-left-color: var(--observation); }

.insight-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.insight-sev {
  font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 3px;
}
.insight-sev.critical { background: var(--critical-dim); color: var(--critical); }
.insight-sev.warning { background: var(--warning-dim); color: var(--warning); }
.insight-sev.observation { background: var(--observation-dim); color: var(--observation); }
.insight-time { font-size: 11px; color: var(--muted); }
.insight-conf { margin-left: auto; }

.insight-title { font-size: 14.5px; font-weight: 700; color: var(--text); margin: 0 0 8px; }

.insight-cause { font-size: 12px; color: var(--text-secondary); margin-bottom: 10px; line-height: 1.55; }
.insight-cause strong { color: var(--text); font-weight: 600; }

.insight-impact { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.impact-chip { font-size: 12px; font-weight: 600; }
.impact-chip.adverse { color: var(--critical); }
.impact-chip .impact-label { color: var(--muted); font-weight: 500; margin-left: 4px; }

.insight-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.insight-meta-line { font-size: 11px; color: var(--muted); }

.btn {
  font-size: 12px; font-weight: 600; padding: 6px 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface-3); color: var(--text); cursor: pointer;
}
.btn:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: none; border-color: var(--border); color: var(--text-secondary); }
.btn.ghost:hover { color: var(--text); border-color: var(--border-strong); }
.btn.danger-ghost { background: none; border-color: var(--border); color: var(--text-secondary); }
.btn.danger-ghost:hover { color: var(--critical); border-color: var(--critical-border); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; gap: 6px; }

/* --- Confidence indicator --------------------------------------------------*/
.confidence-indicator { display: flex; align-items: center; gap: 6px; }
.confidence-indicator .ci-track { width: 44px; height: 4px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.confidence-indicator .ci-fill { height: 100%; background: var(--accent); border-radius: 3px; }
.confidence-indicator .ci-value { font-size: 11px; font-weight: 700; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* --- Data table ------------------------------------------------------------*/
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
td { color: var(--text-secondary); }
tbody tr:hover { background: var(--surface-hover); }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { color: var(--text); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.badge.positive, .badge.resolved, .badge.good { background: var(--positive-dim); color: var(--positive); }
.badge.neutral, .badge.unknown { background: var(--surface-3); color: var(--muted); }
.badge.negative, .badge.unresolved { background: var(--critical-dim); color: var(--critical); }
.badge.critical { background: var(--critical-dim); color: var(--critical); }
.badge.warning, .badge.pending, .badge.medium { background: var(--warning-dim); color: var(--warning); }
.badge.observation, .badge.info, .badge.low { background: var(--observation-dim); color: var(--observation); }
.badge.open { background: var(--warning-dim); color: var(--warning); }
.badge.acknowledged { background: var(--accent-dim); color: var(--accent); }

.table-more-row { display: flex; justify-content: center; margin-top: 12px; }

/* --- Loading / empty states -------------------------------------------------*/
.chart-box { position: relative; height: 220px; }
.chart-box canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.chart-box-donut { height: 200px; }
.chart-loading {
  position: absolute; inset: 0; z-index: 2;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--surface); color: var(--muted); font-size: 12px;
}
.spinner { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: cco-spin .7s linear infinite; }
@keyframes cco-spin { to { transform: rotate(360deg); } }
td.loading-row { text-align: center; color: var(--muted); padding: 20px 10px; white-space: normal; }

.empty-state { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-state .es-icon { width: 34px; height: 34px; margin: 0 auto 14px; color: var(--dim); }
.empty-state .es-icon svg { width: 100%; height: 100%; }
.empty-state .es-title { font-size: 13.5px; font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; }
.empty-state .es-body { font-size: 12px; max-width: 340px; margin: 0 auto; line-height: 1.6; }
.empty-note { color: var(--muted); font-size: 12.5px; padding: 14px; text-align: center; border: 1px dashed var(--border-strong); border-radius: var(--radius); }

/* --- Toast -------------------------------------------------------------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(8px);
  background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text);
  padding: 9px 16px; border-radius: var(--radius); font-size: 12.5px;
  opacity: 0; transition: opacity .18s ease, transform .18s ease; z-index: 200; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --- Investigation view (Root Cause) ---------------------------------------*/
.inv-back { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); background: none; border: none; cursor: pointer; margin-bottom: 14px; }
.inv-back:hover { color: var(--text); }
.inv-back svg { width: 13px; height: 13px; }

.inv-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.inv-title { font-size: 20px; font-weight: 700; color: var(--text); margin: 0 0 6px; letter-spacing: -0.01em; }
.inv-meta-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.stat-row { display: flex; gap: 0; margin-bottom: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.stat-item { flex: 1; padding: 12px 16px; border-right: 1px solid var(--border); }
.stat-item:last-child { border-right: none; }
.stat-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.stat-value { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-value.critical { color: var(--critical); }
.stat-value.accent { color: var(--accent); }

.inv-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1180px) { .inv-grid { grid-template-columns: 1fr; } }

/* --- Timeline ----------------------------------------------------------- */
.timeline { position: relative; padding-left: 2px; }
.timeline-item { position: relative; padding: 0 0 18px 26px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: ""; position: absolute; left: 4px; top: 3px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--observation); border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border-strong);
}
.timeline-item.marker-event::before { background: var(--accent); box-shadow: 0 0 0 1px var(--accent-border); }
.timeline-item.marker-anomaly::before { background: var(--warning); box-shadow: 0 0 0 1px var(--warning-border); }
.timeline-item.marker-status::before { background: var(--positive); box-shadow: 0 0 0 1px var(--positive-border); }
.timeline-item::after { content: ""; position: absolute; left: 7px; top: 12px; bottom: 0; width: 1px; background: var(--border); }
.timeline-item:last-child::after { display: none; }
.timeline-time { font-size: 11px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.timeline-label { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; line-height: 1.5; }
.timeline-label strong { color: var(--text); font-weight: 600; }

/* --- Root cause analysis ------------------------------------------------ */
.rca-hypothesis { font-size: 13px; color: var(--text); line-height: 1.6; margin-bottom: 14px; }
.rca-evidence-list { display: flex; flex-direction: column; gap: 8px; }
.rca-evidence-item { display: flex; gap: 8px; font-size: 12px; color: var(--text-secondary); line-height: 1.55; }
.rca-evidence-item .rca-bullet { color: var(--accent); flex-shrink: 0; }

.action-callout {
  background: var(--accent-dim); border: 1px solid var(--accent-border);
  border-radius: var(--radius); padding: 11px 13px; font-size: 12.5px; color: var(--text);
  margin-top: 14px; line-height: 1.55;
}
.action-callout strong { color: var(--accent); font-weight: 700; }

.linked-event-card { background: var(--surface-3); border-radius: var(--radius); padding: 11px 13px; margin-top: 14px; }
.linked-event-card .lec-kicker { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 4px; }
.linked-event-card .lec-title { font-size: 13px; font-weight: 600; color: var(--text); }
.linked-event-card .lec-desc { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.5; }

.evid-chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.evid-chip {
  font-size: 11px; font-weight: 600; padding: 4px 9px; border-radius: 20px;
  background: var(--surface-3); border: 1px solid var(--border); color: var(--text-secondary); cursor: pointer;
}
.evid-chip:hover { border-color: var(--accent-border); color: var(--accent); }

/* --- What Changed --------------------------------------------------------*/
.wc-intro { font-size: 12px; color: var(--muted); line-height: 1.55; margin: 0 0 14px; }
.subnav { display: flex; gap: 5px; margin-bottom: 4px; flex-wrap: wrap; }
.subnav-btn {
  border: 1px solid var(--border); background: var(--surface-3);
  padding: 5px 11px; border-radius: 20px; cursor: pointer;
  font-size: 11px; font-weight: 600; color: var(--muted);
}
.subnav-btn:hover { border-color: var(--border-strong); color: var(--text-secondary); }
.subnav-btn.active { background: var(--accent-dim); border-color: var(--accent-border); color: var(--accent); }

.wc-panel-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }

.event-list { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; }
.event-item { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 11.5px; }
.event-item .evt-title { font-weight: 600; color: var(--text); }
.event-item .evt-meta { color: var(--muted); margin-top: 2px; }

.wc-event-form { display: flex; flex-direction: column; gap: 8px; }
.wc-event-form input, .wc-event-form select, .wc-event-form textarea {
  font-size: 12px; padding: 7px 9px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; background: var(--surface-3); color: var(--text);
}
.wc-event-form input::placeholder, .wc-event-form textarea::placeholder { color: var(--dim); }
.wc-event-entity-row { display: flex; gap: 6px; }
.wc-event-entity-row select, .wc-event-entity-row input { flex: 1; }
.wc-event-form button { padding: 8px 10px; background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm); cursor: pointer; font-size: 12px; font-weight: 600; }
.wc-event-form button:hover { filter: brightness(1.1); }
.wc-event-status { font-size: 11.5px; margin-top: 4px; min-height: 14px; }
.wc-event-status.ok { color: var(--positive); }
.wc-event-status.err { color: var(--critical); }

/* --- Evidence / interaction slide-over ------------------------------------*/
.drawer-scrim { position: fixed; inset: 0; background: var(--overlay-scrim); z-index: 90; opacity: 0; pointer-events: none; transition: opacity .16s ease; }
.drawer-scrim.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 480px; max-width: 92vw;
  background: var(--surface-2); border-left: 1px solid var(--border-strong);
  z-index: 91; transform: translateX(100%); transition: transform .2s ease;
  display: flex; flex-direction: column;
}
.drawer.show { transform: translateX(0); }
.drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.drawer-header h3 { font-size: 13.5px; margin: 0; font-weight: 700; }
.drawer-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 2px 4px; }
.drawer-close:hover { color: var(--text); }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px; }

.conv-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.conv-header h3 { margin: 0 0 4px; font-size: 14px; }
.conv-meta-line { color: var(--muted); font-size: 11.5px; }
.score-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 12px 0; }
.score-box { background: var(--surface-3); border-radius: var(--radius-sm); padding: 8px 10px; }
.score-box .score-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; font-weight: 700; letter-spacing: 0.02em; }
.score-box .score-value { font-size: 15.5px; font-weight: 700; margin-top: 2px; color: var(--text); }
.section-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; color: var(--muted); margin: 16px 0 8px; letter-spacing: 0.03em; }
.transcript { max-height: 280px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface-3); }
.turn { margin-bottom: 8px; font-size: 12.5px; line-height: 1.45; color: var(--text-secondary); }
.turn .speaker { font-weight: 700; margin-right: 6px; }
.turn.agent .speaker { color: var(--accent); }
.turn.customer .speaker { color: var(--warning); }
.finding { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; margin-bottom: 8px; font-size: 12px; }
.finding .evidence { margin-top: 4px; color: var(--muted); font-style: italic; }
.evidence-quote { color: var(--muted); font-style: italic; }

footer.legend { font-size: 11px; color: var(--muted); margin-top: 10px; }

/* --- Grid utility (kept for future screens / charts) ----------------------*/
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }

/* --- Coming-soon placeholder for not-yet-redesigned screens ---------------*/
.coming-soon { display: flex; align-items: center; justify-content: center; min-height: 60vh; }

/* --- Coming-soon sub-section (smaller, inline within an otherwise-live
   screen -- e.g. Settings' key-management block) ---------------------------*/
.coming-soon-inline { display: flex; align-items: center; justify-content: center; padding: 30px 20px; }
.coming-soon-inline .empty-state { padding: 0; }

/* --- Filter bar (Interactions, Actions) ------------------------------------*/
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.filter-bar select, .filter-bar input {
  font-size: 12px; padding: 6px 9px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; background: var(--surface-3); color: var(--text);
}
.filter-bar input::placeholder { color: var(--dim); }
.filter-bar select:focus, .filter-bar input:focus { outline: none; border-color: var(--accent-border); }
.filter-bar input[type="text"] { width: 168px; }
.filter-bar .filter-spacer { flex: 1; }
.filter-bar .filter-count { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

/* --- Pagination (Interactions) ---------------------------------------------*/
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; }
.pagination .page-info { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* --- Sample/illustrative-data banner (AI Agents bot section) ---------------
   Used only where the underlying entity genuinely isn't modeled yet
   (bot-level AI agents) -- see AI_OBSERVABILITY.md. Deliberately
   warning-toned so it reads as "not real data" at a glance, not just a
   caption easy to skim past. */
.sample-banner {
  display: flex; align-items: flex-start; gap: 9px;
  background: var(--warning-dim); border: 1px solid var(--warning-border);
  border-radius: var(--radius); padding: 10px 13px; font-size: 12px; color: var(--text-secondary);
  line-height: 1.55; margin-bottom: 14px;
}
.sample-banner svg { width: 15px; height: 15px; color: var(--warning); flex-shrink: 0; margin-top: 1px; }
.sample-banner strong { color: var(--warning); font-weight: 700; }

/* --- Key/value rows (Settings, Data Health detail) -------------------------*/
.kv-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.kv-row:last-child { border-bottom: none; }
.kv-label { font-size: 12px; color: var(--muted); }
.kv-value { font-size: 12.5px; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.kv-value.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-weight: 500; }

/* --- Integration / connector cards -----------------------------------------*/
.integration-card { display: flex; flex-direction: column; gap: 10px; }
.integration-head { display: flex; align-items: center; gap: 10px; }
.integration-icon {
  width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0;
  background: var(--surface-3); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.integration-icon svg { width: 17px; height: 17px; }
.integration-name { font-size: 13px; font-weight: 700; color: var(--text); }
.integration-desc { font-size: 12px; color: var(--muted); line-height: 1.55; margin: 0; }

/* --- Report section (Reports screen) ---------------------------------------*/
.report-section { margin-bottom: 22px; }
.report-section:last-child { margin-bottom: 0; }
