:root {
    color-scheme: light;

    /* ----- Rauda brand palette (rauda.ai) ----- */
    --brand-volt: #3c5fff;     /* voltblue — primary accent */
    --brand-pulse: #002eff;    /* pulse — hover / emphasis */
    --brand-naval: #0e1f40;    /* naval — headings / text */
    --brand-slate: #5a6b88;    /* slatelight — muted text */
    --brand-frost: #eaf0f8;    /* frost — light tint */
    --brand-mist: #d3ddea;     /* mist — light blue-grey */

    /* ----- Semantic tokens (light theme) ----- */
    --bg: #f4f7fc;             /* app canvas */
    --surface: #ffffff;        /* cards / sidebar / panels */
    --surface-2: #eef2f9;      /* nested fills / hover / code */
    --border: #dde5f0;         /* hairline borders */
    --text: #0e1f40;           /* primary text (~14:1 on white) */
    --muted: #5a6b88;          /* secondary text (AA on white) */
    --accent: #3c5fff;         /* active states, links, focus, chart series 1 */
    --accent-strong: #2d40ea;  /* fills carrying white text (AA) */
    --accent-text: #002eff;    /* accent used AS text on white (AA) */
    --accent-soft: #e8ecff;    /* active nav / assistant bubble */
    --danger: #d11f3a;
    --danger-soft: #fdecef;
    --ok: #136d58;
    --ok-soft: #e7f6f0;
    --warning: #b45309;
    --warning-soft: #fdf3e7;
    --focus-ring: 0 0 0 3px rgba(60, 95, 255, .30);
    --shadow-sm: 0 1px 2px rgba(14, 31, 64, .05), 0 1px 3px rgba(14, 31, 64, .07);
    --shadow-md: 0 4px 12px rgba(14, 31, 64, .07), 0 2px 4px rgba(14, 31, 64, .05);
    --font-main: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ----- Vendored fonts (IBM Plex) ----- */
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("../vendor/fonts/plex-sans-400.77bc02670657.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("../vendor/fonts/plex-sans-500.f7016cd446d2.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("../vendor/fonts/plex-sans-600.196e3cbc5fee.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 700; font-display: swap; src: url("../vendor/fonts/plex-sans-700.c277d7b83f8a.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("../vendor/fonts/plex-mono-400.79936b18df9f.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("../vendor/fonts/plex-mono-500.b1c8a895f5fd.woff2") format("woff2"); }

* { box-sizing: border-box; }

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

code, kbd, samp, pre { font-family: var(--font-mono); }

/* Visible keyboard focus (WCAG 2.4.7) */
a:focus-visible, button:focus-visible, summary:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible, .chip:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: 6px;
}

/* ----- App layout ----- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1rem 0.75rem;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: -0.01em;
    padding: 0.5rem 0.75rem 1rem;
}
.brand-icon { width: 20px; height: 20px; flex-shrink: 0; color: var(--accent); }

/* Nav icons (Heroicons SVG) — consistent size across all OS/browsers */
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.65; }
.nav-item.active a .nav-icon, .nav-item a:hover .nav-icon { opacity: 1; }

.sidebar-nav { flex: 1; }
.nav-section { margin-bottom: 1.5rem; }
.nav-section-title {
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin: 0 0.75rem 0.4rem;
}
.nav-section ul { list-style: none; margin: 0; padding: 0; }

.nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 8px;
    margin-bottom: 2px;
}
.nav-item a, .nav-item > span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    color: var(--text);
    text-decoration: none;
    border-radius: 8px;
}
.nav-item a:hover { background: var(--surface-2); }
.nav-item.active a {
    background: var(--accent-soft);
    color: var(--accent-text);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--accent);
}
.nav-item.disabled { color: var(--muted); }
.nav-item.disabled > span:first-child { color: var(--muted); cursor: default; }
.nav-tag {
    font-size: 0.6rem;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1px 6px;
    margin-right: 0.5rem;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 0.75rem;
    font-size: 0.8rem;
}
.user-email { color: var(--muted); margin: 0 0 0.5rem; word-break: break-all; }
.logout-link { color: var(--accent-text); text-decoration: none; }
.logout-link:hover { text-decoration: underline; }

/* ----- Content ----- */
.content { flex: 1; padding: 1.5rem 2rem; min-width: 0; }
.page-header h1 { margin: 0 0 0.25rem; font-size: 1.5rem; letter-spacing: -0.01em; }
.page-subtitle { margin: 0 0 1.25rem; font-size: 0.85rem; color: var(--muted); }
.muted { color: var(--muted); }
.placeholder {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow-sm);
}

/* ----- Messages ----- */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.message { padding: 0.6rem 0.9rem; border-radius: 8px; margin-bottom: 0.5rem; }
.message.error { background: var(--danger-soft); border: 1px solid var(--danger); color: var(--danger); }
.message.success { background: var(--ok-soft); border: 1px solid var(--ok); color: var(--ok); }
.message.info { background: var(--surface-2); border: 1px solid var(--border); }

/* ----- Login ----- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 2rem;
    width: 360px;
    max-width: 90vw;
    box-shadow: var(--shadow-md);
}
.login-brand { font-size: 1.4rem; font-weight: 700; margin-bottom: 1.5rem; letter-spacing: -0.01em; }
.login-card h1 { font-size: 1.2rem; margin: 0 0 1rem; }
.login-card label { display: block; margin: 0.75rem 0 0.25rem; color: var(--muted); }
.login-card input {
    width: 100%;
    padding: 0.6rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}
.login-card button, .content button {
    margin-top: 1rem;
    width: 100%;
    padding: 0.6rem;
    border: none;
    border-radius: 8px;
    background: var(--accent-strong);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}
.login-card button:hover, .content button:hover { background: var(--accent-text); }

/* ----- Metrics ----- */
.metrics { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.metric {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    min-width: 140px;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    box-shadow: var(--shadow-sm);
}
.metric-value { font-size: 1.5rem; font-weight: 700; }
.metric-label { font-size: 0.75rem; color: var(--muted); }

/* ----- Collapsible panels & forms ----- */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.5rem 1rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow-sm);
}
.panel > summary { cursor: pointer; font-weight: 600; padding: 0.25rem 0; }
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem 1rem;
    padding: 0.75rem 0;
}
.form-grid label { display: flex; flex-direction: column; gap: 0.25rem; color: var(--muted); font-size: 0.85rem; }
.form-grid label.full { grid-column: 1 / -1; }
.form-grid label.checkbox { flex-direction: row; align-items: center; gap: 0.4rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea {
    padding: 0.5rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--focus-ring);
}
.form-grid button { width: auto; padding: 0.55rem 1.2rem; }

/* ================= Human review: triage inbox + focus ==================== */
/* ----- Severity dot (shared) ----- */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot.sev-crit   { background: #8c1326; }
.dot.sev-high   { background: var(--danger); }
.dot.sev-medium { background: var(--warning); }
.dot.sev-low, .dot.sev-none { background: var(--mist); }

/* ----- Status / verdict tags (shared) ----- */
.rev-status {
    font-size: 0.72rem; font-weight: 500; padding: 0.1rem 0.6rem; border-radius: 999px;
    border: 1px solid var(--border); color: var(--muted); flex-shrink: 0; white-space: nowrap;
}
.rev-status.st-in_progress { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.rev-status.st-reviewed    { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.vtag { font-size: 0.72rem; font-weight: 600; padding: 0.1rem 0.55rem; border-radius: 999px; flex-shrink: 0; }
.vtag.v-correct        { background: var(--ok-soft); color: var(--ok); }
.vtag.v-false_positive { background: var(--danger-soft); color: var(--danger); }

/* ----- Queue header + segmented filter + stats ----- */
.rev { max-width: 1040px; }
.rev-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.rev-title { font-size: 1.35rem; margin: 0; }
.rev-sub { font-size: 0.85rem; color: var(--muted); margin: 0.15rem 0 0; }
.segmented {
    display: inline-flex; background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; overflow: hidden; font-size: 0.82rem; flex-shrink: 0;
}
.segmented a { padding: 0.4rem 0.8rem; color: var(--muted); text-decoration: none; border-left: 1px solid var(--border); }
.segmented a:first-child { border-left: 0; }
.segmented a:hover { color: var(--text); }
.segmented a.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 500; }
.stat-strip { display: flex; gap: 1.25rem; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); margin-bottom: 1rem; }
.stat-strip strong { color: var(--text); font-weight: 600; }
.stat-dot { display: inline-flex; align-items: center; gap: 0.4rem; }

/* ----- Queue list (triage inbox) ----- */
.rev-list { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.rev-row {
    display: flex; align-items: center; gap: 0.9rem; padding: 0.8rem 1rem;
    border-top: 1px solid var(--border); text-decoration: none; color: inherit; transition: background .1s;
}
.rev-row:first-child { border-top: 0; }
.rev-row:hover { background: var(--surface-2); }
.rev-main { flex: 1; min-width: 0; }
.rev-reason { font-size: 0.9rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rev-meta { font-size: 0.78rem; color: var(--muted); margin-top: 0.2rem; }
.rev-meta .sep { opacity: .4; margin: 0 0.35rem; }
.rev-fam { color: var(--accent-text); }
.rev-chevron {
    width: 7px; height: 7px; border-top: 1.5px solid var(--muted); border-right: 1.5px solid var(--muted);
    transform: rotate(45deg); opacity: .5; flex-shrink: 0; margin-left: 0.2rem;
}

/* ----- Focus (full-screen review) ----- */
.focus { max-width: 820px; margin: 0 auto; padding-bottom: 1.5rem; }
.focus-bar {
    position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 0.85rem;
    background: var(--bg); padding: 0.55rem 0; margin-bottom: 0.85rem; border-bottom: 1px solid var(--border);
}
.focus-back { text-decoration: none; color: var(--muted); font-size: 0.85rem; }
.focus-back:hover { color: var(--accent-text); }
.focus-count { font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.focus-navbtns { margin-left: auto; display: flex; gap: 0.4rem; }
.icon-btn {
    width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 8px; color: var(--muted); text-decoration: none;
    font-size: 1.1rem; line-height: 1; background: var(--surface);
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent-text); }
.icon-btn.disabled { opacity: .4; pointer-events: none; }

.focus-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem 1.4rem; }
.focus-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.focus-head h1 { font-size: 1.25rem; margin: 0; font-weight: 600; }
.fam-chip { font-size: 0.74rem; font-weight: 500; padding: 0.12rem 0.6rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); }
.focus-channel { font-size: 0.8rem; color: var(--muted); }
.focus-zendesk { margin-left: auto; font-size: 0.8rem; color: var(--accent-text); text-decoration: none; }
.focus-zendesk:hover { text-decoration: underline; }
.focus-dates { font-size: 0.78rem; color: var(--muted); margin: 0.35rem 0 1.1rem; }

.flag-callout { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 0.65rem 0.85rem; margin-bottom: 1.25rem; }
.flag-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 0.2rem; }
.flag-text { font-size: 0.9rem; color: var(--text); line-height: 1.5; }

/* ----- Action dock (verdict + save) ----- */
.action-dock {
    position: sticky; bottom: 0; z-index: 6; display: flex; flex-direction: column; gap: 0.7rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: var(--shadow-md); padding: 0.85rem 1rem; margin-top: 1rem;
}
.dock-main { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; }
.dock-q { font-size: 0.85rem; color: var(--muted); }
.verdict-toggle { display: inline-flex; gap: 0.5rem; }
.vbtn { position: relative; cursor: pointer; }
.vbtn input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.vbtn span {
    display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.4rem 0.85rem;
    border: 1px solid var(--border); border-radius: 8px; font-size: 0.85rem; color: var(--muted);
}
.vbtn input:focus-visible + span { box-shadow: var(--focus-ring); }
.vbtn-correct input:checked + span        { border: 2px solid var(--ok); background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.vbtn-false_positive input:checked + span { border: 2px solid var(--danger); background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.vbtn kbd, .action-dock kbd {
    font-family: var(--font-mono); font-size: 0.66rem; border: 1px solid var(--border); border-radius: 4px;
    padding: 0 0.25rem; opacity: .6; color: inherit;
}
.dock-actions { margin-left: auto; display: flex; gap: 0.5rem; align-items: center; }
.content .btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.content .btn-secondary:hover { border-color: var(--accent); }
.content button.primary { background: var(--accent-strong); color: #fff; border-color: var(--accent-strong); display: inline-flex; align-items: center; gap: 0.4rem; }
.content button.primary:hover { background: var(--brand-pulse); }
.content button.primary kbd { border-color: rgba(255,255,255,.4); opacity: .85; }
.dock-extra { display: flex; gap: 0.6rem; align-items: center; }
.dock-extra input, .dock-extra select {
    padding: 0.45rem 0.55rem; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font-family: inherit; font-size: 0.85rem;
}
.dock-extra input { flex: 1; }
.dock-extra select { max-width: 180px; }
.dock-extra input:focus, .dock-extra select:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }

.btn-ghost {
    text-decoration: none; color: var(--accent-text); font-size: 0.85rem; font-weight: 500;
    padding: 0.35rem 0.7rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
}
.btn-ghost:hover { border-color: var(--accent); }
.btn-ghost.disabled { color: var(--muted); opacity: .5; pointer-events: none; }
.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: 1.5rem 0 0.5rem; }
.pager-pos { font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ----- Scope filter chips ----- */
.scope-filter { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip {
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    font-size: 0.85rem;
}
.chip:hover { background: var(--surface-2); }
.chip.active { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }

/* ----- Table + detail layout ----- */
.table-detail { display: grid; grid-template-columns: 3fr 2fr; gap: 1.25rem; align-items: start; }
.grid { height: 620px; width: 100%; }
.detail-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    max-height: 70vh;
    overflow-y: auto;
    box-shadow: var(--shadow-sm);
}
.empty {
    color: var(--muted);
    padding: 2.5rem 2rem;
    text-align: center;
    background: var(--surface-2);
    border: 1px dashed var(--border);
    border-radius: 10px;
    font-size: 0.9rem;
}

/* ----- Detail card ----- */
.detail-card h2 { font-size: 1.05rem; margin: 0; }
.detail-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.badge { font-size: 0.7rem; padding: 2px 8px; border-radius: 6px; }
.badge.danger { background: var(--danger-soft); border: 1px solid var(--danger); color: var(--danger); }
.btn-link { color: var(--accent-text); text-decoration: none; }
.btn-link:hover { text-decoration: underline; }
.detail-card code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-family: var(--font-mono); }

/* ----- Conversation ----- */
.conversation { display: flex; flex-direction: column; gap: 0.4rem; }
.msg { display: flex; }
.msg-user { justify-content: flex-start; }
.msg-assistant { justify-content: flex-end; }
.bubble {
    max-width: 85%;
    padding: 0.5rem 0.75rem;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.msg-assistant .bubble { background: var(--accent-soft); }
.msg-warning { color: var(--warning); font-size: 0.85rem; }
.msg-time { font-size: 0.7rem; color: var(--muted); margin: 0 0 0.4rem; }
.msg-details { font-size: 0.8rem; color: var(--muted); }
.msg-details .details-title { font-weight: 600; margin: 0.4rem 0 0.2rem; color: var(--text); }
.msg-details ul { margin: 0; padding-left: 1.2rem; }

@media (max-width: 1100px) {
    .table-detail { grid-template-columns: 1fr; }
}

/* ----- Analytics ----- */
/* ----- Zone labels & section separators ----- */
.zone-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.badge-muted {
    font-size: 0.72rem;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--muted);
    text-transform: none;
    letter-spacing: 0;
    white-space: nowrap;
}

.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.section-head h2 { margin: 0; }

.zone-separator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-top: 2px solid var(--border);
    padding-top: 1.25rem;
    margin: 0.5rem 0 1rem;
}
.zone-separator-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}

.filter-bar {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.9rem 1rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}
.filter-bar-label {
    align-self: center;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding-right: 0.75rem;
    border-right: 1px solid var(--border);
}
.filter-hint {
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: 0.15rem;
}
.btn--loading { opacity: 0.65; cursor: not-allowed; }
.filter-bar label { display: flex; flex-direction: column; gap: 0.25rem; color: var(--muted); font-size: 0.8rem; }
.filter-bar input, .filter-bar select {
    padding: 0.5rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
}
.filter-bar input:focus, .filter-bar select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--focus-ring);
}
.filter-bar button { margin-top: 0; width: auto; padding: 0.55rem 1.2rem; }

.analytics-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}
.analytics-section h2 { font-size: 1.1rem; margin: 0 0 1rem; }

.metric-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.metric-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.6rem 0.9rem;
    box-shadow: var(--shadow-md);
}
.metric-card .metric-value { font-size: 1.25rem; font-weight: 700; }
.metric-card .metric-label { font-size: 0.72rem; color: var(--muted); }
.metric-card .metric-unit {
    font-size: 0.68rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}
.metric-card .metric-delta { font-size: 0.75rem; color: var(--accent-text); margin: 0.2rem 0 0; }
.metric-card .metric-note { font-size: 0.72rem; color: var(--muted); font-style: italic; margin: 0.15rem 0 0; }

.metric-card--hero {
    background: var(--accent-soft);
    border-color: rgba(60, 95, 255, 0.25);
}
.metric-value--hero { font-size: 1.6rem !important; }

.metric-group-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin: 1rem 0 0.4rem;
}
.metric-group-label:first-of-type { margin-top: 0; }

.metric-delta--up { color: var(--ok) !important; }
.metric-delta--down { color: var(--danger) !important; }

.chart-block { margin-top: 1.25rem; }
/* chart-title is a sub-heading within a section — keep it clearly below h2 in hierarchy */
.chart-title { font-size: 0.9rem; font-weight: 600; color: var(--text); margin: 0 0 0.2rem; }
.chart-caption { font-size: 0.8rem; margin: 0 0 0.4rem; color: var(--muted); }
.plotly-chart { width: 100%; min-height: 60px; overflow: visible; }

.chart-notes { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.4rem; }
.chart-note {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--muted);
    padding: 0.35rem 0.75rem;
    background: var(--warning-soft);
    border-left: 3px solid var(--warning);
    border-radius: 0 6px 6px 0;
}
.chart-note-icon { color: var(--warning); flex-shrink: 0; }
.chart-note-month { color: var(--text); font-size: 0.75rem; white-space: nowrap; }

@media (max-width: 900px) {
    .metric-grid { grid-template-columns: 1fr 1fr; }
}

/* ----- Escalation analysis ----- */
.metric-grid-6 { grid-template-columns: repeat(6, 1fr); }
.bordered-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow-sm);
}
.bordered-card p { margin: 0.25rem 0; }
.bordered-card code, .group-title + .bordered-card code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-family: var(--font-mono); }
.group-title { font-size: 1rem; margin: 1.25rem 0 0.5rem; }
.chart-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 0.5rem;
}
.case-layout { grid-template-columns: 1fr 2fr; margin-top: 1rem; }
.btn-download {
    display: inline-block;
    padding: 0.55rem 1.2rem;
    border-radius: 8px;
    background: var(--accent-strong);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
}
.btn-download:hover { background: var(--accent-text); }

@media (max-width: 1100px) {
    .chart-pair { grid-template-columns: 1fr; }
    .metric-grid-6 { grid-template-columns: repeat(3, 1fr); }
}

/* ----- AG Grid (light quartz, aligned to brand) ----- */
.ag-theme-quartz {
    --ag-active-color: var(--accent);
    --ag-selected-row-background-color: var(--accent-soft);
    --ag-row-hover-color: var(--surface-2);
    --ag-border-color: var(--border);
    --ag-header-background-color: var(--brand-frost);
    --ag-background-color: var(--surface);
    --ag-odd-row-background-color: var(--surface);
    --ag-font-family: var(--font-main);
    --ag-foreground-color: var(--text);
    --ag-secondary-foreground-color: var(--muted);
    --ag-wrapper-border-radius: 12px;
    --ag-border-radius: 8px;
}
