/* Quality Scanner — dashboard SPA stylesheet
 *
 * Visual system from the Claude Design handoff (May 2026 reskin).
 * Tokens are OKLCH-based and parameterized so the same primitives
 * support light/dark, an accent picker (green/cyan/violet/amber),
 * a density toggle (comfortable/compact), and a severity-style
 * toggle (chip/bar) — all switched via data-attrs on <html>.
 *
 * Two token vocabularies live here: the design's canonical names
 * (--bg-elev, --line, --row-h, --pad, --shadow-card, etc.) and
 * legacy names from the previous emerald palette (--surface,
 * --border, --shadow-sm, etc.) that screen-specific styles below
 * still reference.  Both resolve to the same OKLCH values so the
 * cascade lands on a coherent palette regardless of which name
 * a rule uses.
 */

:root {
    /* --- Design tokens (canonical names) ----------------------
       "Signal" system (Aug 2026 redesign): cool neutral workspace,
       always-dark command bar, violet accent.  Severity palettes
       are CVD-validated per mode (all six checks pass; see PR). */
    --accent-h: 155;
    --accent-c: 0.14;
    --accent-l: 0.62;
    --accent: oklch(var(--accent-l) var(--accent-c) var(--accent-h));
    --accent-soft: oklch(var(--accent-l) var(--accent-c) var(--accent-h) / 0.12);
    --accent-strong: oklch(0.42 var(--accent-c) var(--accent-h));
    --accent-fg: white;

    --sev-error: oklch(0.565 0.21 27);
    --sev-error-soft: oklch(0.565 0.21 27 / 0.11);
    --sev-warning: oklch(0.67 0.14 83);
    --sev-warning-soft: oklch(0.67 0.14 83 / 0.14);
    --sev-info: oklch(0.55 0.2 262);
    --sev-info-soft: oklch(0.55 0.2 262 / 0.11);
    /* Success is its own hue — with a violet accent, "good" must not
       inherit the brand color. */
    --good: oklch(0.60 0.13 163);
    --good-soft: oklch(0.60 0.13 163 / 0.12);

    --row-h: 32px;
    --pad: 18px;

    --bg: oklch(0.965 0.004 260);
    --bg-elev: #ffffff;
    --bg-sunk: oklch(0.945 0.005 260);
    --line: oklch(0.915 0.006 260);
    --line-strong: oklch(0.85 0.008 260);
    --text: oklch(0.185 0.012 265);
    --text-muted: oklch(0.51 0.015 260);
    --text-faint: oklch(0.66 0.012 260);
    --grid: oklch(0.915 0.006 260);
    --shadow-card: 0 1px 2px oklch(0.2 0.015 265 / 0.06), 0 0 0 0.5px oklch(0.2 0.015 265 / 0.03);
    --shadow-pop: 0 14px 40px -10px oklch(0.2 0.015 265 / 0.16), 0 2px 6px oklch(0.2 0.015 265 / 0.06);

    /* Command bar — dark in BOTH themes (the Signal signature). */
    --topbar-bg: oklch(0.205 0.01 265);
    --topbar-text: oklch(0.95 0.005 260);
    --topbar-muted: oklch(0.70 0.012 262);
    --topbar-line: oklch(0.30 0.012 262);
    --topbar-on: oklch(0.28 0.014 265);

    /* --- Legacy aliases (kept so existing screen styles don't break) --- */
    --surface: var(--bg-elev);
    --surface-2: var(--bg-sunk);
    --surface-3: oklch(var(--accent-l) var(--accent-c) var(--accent-h) / 0.22);
    --border: var(--line);
    --border-strong: var(--line-strong);
    --text-subtle: var(--text-faint);
    --brand: var(--accent-strong);
    --brand-2: var(--accent);
    --accent-hover: oklch(0.55 var(--accent-c) var(--accent-h));
    --danger: var(--sev-error);
    --danger-hover: oklch(0.5 0.2 25);
    --warning: var(--sev-warning);
    --success: var(--good);
    --info: var(--sev-info);
    --shadow-sm: var(--shadow-card);
    --shadow-md: 0 4px 12px oklch(0.2 0.015 265 / 0.08);
    --shadow-lg: var(--shadow-pop);
    --radius: 8px;
    --radius-sm: 6px;
    --radius-lg: 10px;
    --header-h: 52px;
    --sidebar-w: 220px;
}

/* Dark theme — overrides every neutral and the accent for dark
   surfaces.  Triggered by data-theme="dark" on <html> from the
   pre-paint script + applyAppearance() in app.js. */
[data-theme="dark"] {
    --bg: oklch(0.155 0.009 262);
    --bg-elev: oklch(0.19 0.011 264);
    --bg-sunk: oklch(0.125 0.008 262);
    --line: oklch(0.27 0.012 262);
    --line-strong: oklch(0.35 0.014 262);
    --text: oklch(0.955 0.005 260);
    --text-muted: oklch(0.70 0.012 262);
    --text-faint: oklch(0.53 0.012 262);
    --grid: oklch(0.25 0.012 262);
    --accent: oklch(0.7 0.14 var(--accent-h));
    --accent-soft: oklch(0.7 0.14 var(--accent-h) / 0.16);
    --accent-strong: oklch(0.85 0.11 var(--accent-h));
    --accent-fg: oklch(0.14 0.01 265);
    /* Severity — re-stepped for the dark surface (validated). */
    --sev-error: oklch(0.55 0.177 28);
    --sev-error-soft: oklch(0.55 0.177 28 / 0.16);
    --sev-warning: oklch(0.63 0.128 78);
    --sev-warning-soft: oklch(0.63 0.128 78 / 0.16);
    --sev-info: oklch(0.635 0.155 262);
    --sev-info-soft: oklch(0.635 0.155 262 / 0.15);
    --good: oklch(0.62 0.128 165);
    --good-soft: oklch(0.62 0.128 165 / 0.15);
    --shadow-card: 0 1px 0 oklch(0.27 0.012 262), 0 1px 2px oklch(0.05 0 0 / 0.4);
    --shadow-pop: 0 18px 50px -10px oklch(0.05 0 0 / 0.6), 0 4px 12px oklch(0.05 0 0 / 0.4);
    /* Command bar blends with the dark workspace but keeps its own
       plane — slightly lighter than --bg, hairline below. */
    --topbar-bg: oklch(0.225 0.012 265);
    --topbar-line: oklch(0.32 0.012 262);
    --topbar-on: oklch(0.30 0.014 265);
    /* Re-derive legacy aliases against dark palette */
    --surface-3: oklch(0.7 0.14 var(--accent-h) / 0.24);
    --shadow-md: 0 4px 12px oklch(0.05 0 0 / 0.45);
    color-scheme: dark;
}

/* Compact density: tighter rows + smaller card padding. */
[data-density="compact"] {
    --row-h: 28px;
    --pad: 12px;
}

/* Sidebar nav layout — applied via data-nav="sidebar" on <html>.
   The sidebar lives inside #app-body alongside #app-content so the
   header stays full-width above both columns. */
.sidebar { display: none; }
[data-nav="sidebar"] #app-body {
    display: flex;
    align-items: stretch;
    min-height: calc(100vh - var(--header-h));
}
[data-nav="sidebar"] .sidebar {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 18px 12px;
    position: sticky;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    overflow-y: auto;
}
[data-nav="sidebar"] #app-content { flex: 1; min-width: 0; }
[data-nav="sidebar"] .header-nav { display: none; }

.sidebar a, .sidebar .sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    background: none;
    border: 0;
    cursor: pointer;
    text-align: left;
    width: 100%;
    font-family: inherit;
    line-height: 1.2;
}
.sidebar a:hover, .sidebar .sidebar-link:hover {
    background: var(--surface-2);
    color: var(--accent);
    text-decoration: none;
}
.sidebar a.active {
    background: var(--accent-soft);
    color: var(--accent-hover);
}
.sidebar-section-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-subtle);
    font-weight: 600;
    padding: 14px 12px 6px;
}
.sidebar-spacer { flex: 1; }

@media (max-width: 720px) {
    /* On narrow viewports the sidebar takes too much room; fall back
       to the top-bar nav regardless of preference. */
    [data-nav="sidebar"] #app-body { display: block; }
    [data-nav="sidebar"] .sidebar { display: none; }
    [data-nav="sidebar"] .header-nav { display: flex; }
}

/* Appearance form on the Settings view — radio group styled as a
   segmented control so theme + nav choices are visually obvious. */
.appearance-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.appearance-row:last-child { margin-bottom: 0; }
.appearance-row > label:first-child {
    flex: 0 0 120px;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 13px;
}
.appearance-segmented {
    display: inline-flex;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface);
}
.appearance-segmented label {
    padding: 6px 14px;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    border-right: 1px solid var(--border);
    user-select: none;
    transition: background 0.12s, color 0.12s;
}
.appearance-segmented label:last-child { border-right: 0; }
.appearance-segmented label:hover { color: var(--text); background: var(--surface-2); }
.appearance-segmented input { display: none; }
/* Highlight the wrapping label, not the inner span — the label
   already covers the full pill area and `input:checked + span`
   was layering a second background inside it.  `:has()` is the
   only selector here so the active pill is a single solid fill. */
.appearance-segmented label:has(input:checked) {
    background: var(--accent-soft);
    color: var(--accent-hover);
    font-weight: 500;
}

* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    font-feature-settings: 'cv11', 'ss01', 'ss03';
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.45;
    letter-spacing: -0.005em;
    -webkit-font-smoothing: antialiased;
}
body { min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: 'JetBrains Mono', 'SF Mono', ui-monospace, Consolas, monospace; font-size: 0.9em;
    background: var(--bg-sunk); padding: 1px 5px; border-radius: 3px; }
pre code { background: transparent; padding: 0; }

::selection { background: var(--accent-soft); color: var(--text); }

/* Utility classes */
.mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; font-feature-settings: 'ss05'; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }

/* ────────── Header — Signal command bar (dark in both themes) ── */
.header {
    position: sticky; top: 0; z-index: 50;
    height: var(--header-h);
    display: flex; align-items: center;
    gap: 22px;
    padding: 0 22px;
    background: var(--topbar-bg);
    color: var(--topbar-text);
    border-bottom: 1px solid var(--topbar-line);
}
[data-nav="sidebar"] .header { padding-left: 16px; }
.header-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -0.02em; font-size: 14px; }
/* Brand mark — accent tile with monogram (replaces emerald-logo SVG).
   We keep the existing <img> as a fallback for legacy markup but re-skin
   it as a small square block matching the new design. */
.header-logo {
    width: 28px; height: 28px;
    border-radius: 7px;
    object-fit: cover;
    /* favicon.svg has its own gradient — no bg needed here */
}
.header-brand .brand-mark {
    width: 28px; height: 28px;
    border-radius: 7px;
    background: var(--accent);
    color: var(--accent-fg);
    display: grid; place-items: center;
    font-weight: 700;
    font-size: 14px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    letter-spacing: -0.04em;
}
.header-title {
    font-weight: 600;
    font-size: 14px;
    letter-spacing: -0.015em;
    color: var(--topbar-text);
    line-height: 1.1;
}
.header-divider { width: 1px; height: 18px; background: var(--topbar-line); }
.header-nav {
    display: flex; gap: 2px;
    flex: 1;
}
/* Header nav rides the dark bar; the sidebar variant of .nav-link
   below re-scopes these colors back to workspace tokens. */
.header .nav-link {
    padding: 6px 11px; border-radius: 7px;
    color: var(--topbar-muted);
    font-weight: 500; font-size: 13.5px;
    display: inline-flex; align-items: center; gap: 8px;
}
.header .nav-link:hover { background: var(--topbar-on); color: var(--topbar-text); text-decoration: none; }
.header .nav-link.active { color: var(--topbar-text); background: var(--topbar-on); }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.kbd {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 4px;
    border: 1px solid var(--line);
    background: var(--bg-sunk);
    color: var(--text-muted);
}

.hamburger-btn {
    display: none;
    background: none; border: none; cursor: pointer;
    padding: 8px; margin-left: auto;
}
.hamburger-btn span {
    display: block; width: 20px; height: 2px;
    background: var(--topbar-text); margin: 4px 0; border-radius: 2px;
}

.user-menu { position: relative; }
.user-menu-btn {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 6px 4px 12px;
    border-radius: 999px;
    background: transparent;
    color: var(--topbar-text); font-size: 13px;
    border: 1px solid var(--topbar-line);
    cursor: pointer;
    font-weight: 500;
    transition: border-color 0.12s, background 0.12s;
}
.user-menu-btn:hover { background: var(--topbar-on); border-color: var(--topbar-line); }
.user-name { font-weight: 500; }
.user-menu-arrow { font-size: 10px; opacity: 0.6; margin-left: 2px; }
.user-menu-dropdown {
    position: absolute; top: calc(100% + 6px); right: 0;
    min-width: 180px;
    background: var(--bg-elev);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow-pop);
    display: none;
    z-index: 100;
    overflow: hidden;
}
.user-menu.open .user-menu-dropdown { display: block; }
.user-menu-item {
    display: block; width: 100%;
    padding: 10px 14px;
    background: none; border: none; cursor: pointer;
    text-align: left; font-size: 14px;
    color: var(--text);
    font-family: inherit;
}
.user-menu-item:hover { background: var(--surface-2); }
.user-menu-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ────────── Layout ────────── */
#app-body { min-height: calc(100vh - var(--header-h)); }
#app-content { padding: 18px 24px; }
.container { max-width: 1200px; margin: 0 auto; }

.view { display: none; }
.view.active { display: block; }

.view-header {
    display: flex; justify-content: space-between; align-items: center;
    gap: 16px; margin-bottom: 14px;
    flex-wrap: wrap;
}
#view-commit .view-header { margin-bottom: 10px; }
#view-commit .card:first-of-type { margin-top: 0; }
.view-header-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.view-header h1 { margin: 0; font-size: 20px; font-weight: 600; }
.view-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.back-link { color: var(--text-muted); font-size: 13px; }
.back-link:hover { color: var(--accent); text-decoration: none; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}
.card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.muted { color: var(--text-muted); font-size: 13px; }

/* ────────── Buttons ────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-family: inherit; font-size: 13px; font-weight: 500;
    cursor: pointer; border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s;
    text-decoration: none;
    line-height: 1.2;
}
.btn-primary {
    background: var(--accent); color: #fff; border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary {
    background: var(--surface); color: var(--text); border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-2); text-decoration: none; }
.btn-danger {
    background: var(--danger); color: #fff; border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn-link {
    background: transparent; color: var(--accent); border-color: transparent;
    padding: 6px 8px;
}
.btn-link:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

.btn-google {
    margin-top: 12px;
    padding: 12px 20px;
}

/* ────────── Login ────────── */
.login-wrapper {
    min-height: calc(100vh - 48px);
    display: flex; align-items: center; justify-content: center;
    padding: 48px 16px;
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 32px;
    max-width: 380px; width: 100%;
    text-align: center;
}
.login-card h2 { margin: 16px 0 8px; font-size: 22px; }
.login-card p { color: var(--text-muted); margin: 8px 0 16px; }
.login-logo { height: 48px; }
.login-error { color: var(--danger); margin-top: 12px; font-size: 13px; }

/* ────────── Badges ────────── */
.badge {
    display: inline-block; padding: 2px 8px;
    font-size: 11px; font-weight: 600;
    border-radius: 999px;
    text-transform: uppercase; letter-spacing: 0.3px;
    background: var(--surface-3); color: var(--brand);
}
/* OKLCH badge palette — tracks light/dark via the theme block above. */
.badge-role { background: var(--accent-soft); color: var(--accent-strong); border: 1px solid transparent; }
/* On the dark command bar the light-theme soft/strong pair vanishes —
   re-key the header's role chip against the dark plane. */
.header .badge-role {
    background: oklch(0.7 0.14 var(--accent-h) / 0.25);
    color: oklch(0.87 0.09 var(--accent-h));
}
.badge-sev-error    { background: var(--sev-error-soft);   color: var(--sev-error); }
.badge-sev-warning  { background: var(--sev-warning-soft); color: oklch(0.45 0.14 60); }
.badge-sev-info     { background: var(--sev-info-soft);    color: var(--sev-info); }
.badge-status-open      { background: var(--accent-soft); color: var(--accent-strong); }
.badge-status-dismissed { background: var(--bg-sunk);     color: var(--text-muted); }
.badge-status-fixed     { background: var(--sev-info-soft); color: var(--sev-info); }
.badge-status-snoozed   { background: var(--sev-warning-soft); color: oklch(0.45 0.14 60); }
/* 'regressed' = fixed-then-reappeared.  Distinct violet so a regression
   stands out from a fresh 'open' finding in the active list. */
.badge-status-regressed { background: oklch(0.7 0.16 320 / 0.18); color: oklch(0.5 0.18 320); }
/* Role badges on the Users admin page — admin keeps the accent,
   manager gets info-blue, dev stays neutral so admins pop. */
.badge-role.role-manager { background: var(--sev-info-soft); color: var(--sev-info); }
.badge-role.role-dev { background: var(--bg-sunk); color: var(--text-muted); border-color: var(--line); }
.badge-mode-off  { background: var(--bg-sunk); color: var(--text-muted); border: 1px solid var(--line); }
.badge-mode-soft { background: oklch(0.82 0.12 80 / 0.2); color: oklch(0.42 0.14 60); }
.badge-mode-hard { background: var(--sev-error-soft); color: var(--sev-error); }
.badge-kind-pr_scan  { background: oklch(0.7 0.14 290 / 0.16); color: oklch(0.5 0.14 290); }
.badge-kind-baseline { background: var(--accent-soft); color: var(--accent-strong); }
.badge-scan-running   { background: var(--sev-info-soft);    color: var(--sev-info); }
.badge-scan-queued    { background: var(--sev-warning-soft); color: oklch(0.45 0.14 60); }
.badge-scan-completed { background: var(--good-soft);        color: var(--good); }
.badge-scan-failed    { background: var(--sev-error-soft);   color: var(--sev-error); }
.badge-scan-cancelled { background: var(--bg-sunk);          color: var(--text-muted); }
[data-theme="dark"] .badge-sev-warning,
[data-theme="dark"] .badge-status-snoozed,
[data-theme="dark"] .badge-mode-soft,
[data-theme="dark"] .badge-scan-queued { color: oklch(0.85 0.13 80); }
[data-theme="dark"] .badge-status-regressed { color: oklch(0.85 0.14 320); }

/* ────────── Dashboard grid (design's 2-col layout) ────────── */
.repo-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}
@media (max-width: 1100px) { .repo-grid { grid-template-columns: 1fr; } }
.repo-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s;
    box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; gap: 10px;
}
.repo-card:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.repo-card-title { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.repo-card-title-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.repo-card-title-row .repo-card-title { flex: 1; min-width: 0; }
.repo-card-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; color: var(--text-muted); font-size: 12px; }
.repo-counts { display: flex; gap: 12px; font-size: 13px; }
.repo-count { display: flex; align-items: center; gap: 4px; }
.repo-count-label { color: var(--text-muted); }
.repo-count-value { font-weight: 600; }
.repo-count.err .repo-count-value { color: var(--danger); }
.repo-count.warn .repo-count-value { color: oklch(0.45 0.14 60); }
[data-theme="dark"] .repo-count.warn .repo-count-value { color: oklch(0.85 0.13 80); }
.repo-count.info .repo-count-value { color: var(--info); }
.repo-last-scan { color: var(--text-muted); font-size: 12px; }
.sparkline { display: block; width: 100%; height: 32px; }
.empty-state { color: var(--text-muted); text-align: center; padding: 32px; font-style: italic; }

/* ────────── Tables ────────── */
.table-wrap { overflow-x: auto; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
    text-align: left; padding: 10px 12px;
    background: var(--surface-2);
    font-weight: 600; font-size: 12px;
    text-transform: uppercase; letter-spacing: 0.3px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }

.findings-table .col-line { white-space: nowrap; color: var(--text-muted); font-family: monospace; }
.findings-table .col-rule { white-space: nowrap; }
.findings-table .col-rule .rule-code { font-family: monospace; font-size: 12px; }
.findings-table .col-rule .source-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    vertical-align: middle;
    background: var(--surface-3);
    color: var(--text-muted);
}
.findings-table .source-ruff   { background: var(--accent-soft);    color: var(--accent-strong); }
.findings-table .source-mypy   { background: var(--sev-info-soft);  color: var(--sev-info); }
.findings-table .source-eslint { background: var(--sev-warning-soft); color: oklch(0.45 0.14 60); }
.findings-table .source-ai     { background: oklch(0.7 0.14 290 / 0.16); color: oklch(0.5 0.14 290); }
.findings-table .col-file { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: monospace; font-size: 12px; }
.findings-table .col-msg { max-width: 420px; }
.findings-count { margin-left: auto; color: var(--text-muted); font-size: 12px; }

.simple-table td, .simple-table th { white-space: nowrap; }
.simple-table td.cell-truncate { max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
.row-clickable { cursor: pointer; }
.row-clickable:hover { background: var(--surface-2); }
.drawer-subhead { font-size: 14px; margin: 18px 0 2px; }
.decision-findings-hint { margin: 0 0 8px; font-size: 12px; }
.decision-finding { display: flex; align-items: baseline; gap: 8px; padding: 7px 8px; border-top: 1px solid var(--border); cursor: pointer; font-size: 13px; }
.decision-finding:hover { background: var(--surface-2); }
.decision-finding-rule { color: var(--text); font-weight: 600; }
.decision-finding-file { color: var(--text-muted); white-space: nowrap; }
.decision-finding-msg { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.decision-group-summary { margin: 4px 0 12px; padding: 8px 10px; background: var(--surface-2); border-radius: 6px; }
.decision-group-caption { margin: 0 0 6px; font-size: 12px; }
.decision-group-line { display: flex; align-items: baseline; gap: 8px; padding: 3px 0; font-size: 13px; }
.decision-group-count { color: var(--text); font-weight: 600; }
.decision-group-msg { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.mapping-warning { background: #fef3c7; border: 1px solid #fcd34d; border-radius: 6px; padding: 10px 12px; margin: 10px 0; }
.mapping-warning p { margin: 0 0 8px; color: #92400e; font-size: 13px; }
.dispatch-choice { margin-top: 14px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; }
.dispatch-choice-head { font-weight: 600; margin-bottom: 6px; font-size: 13px; }
.dispatch-opt { display: flex; align-items: flex-start; gap: 8px; padding: 4px 0; cursor: pointer; font-size: 13px; }
.dispatch-opt input { margin-top: 3px; }
.dispatch-opt-desc { color: var(--text-muted); font-size: 12px; }
.dispatch-opt-disabled { opacity: 0.55; cursor: not-allowed; }
.dispatch-note { margin-top: 14px; padding: 8px 12px; background: rgba(147,197,253,0.08); border: 1px solid rgba(147,197,253,0.22); border-radius: 6px; color: var(--text-muted); font-size: 12px; }
.agent-unmapped { margin-left: 6px; }
.activity-outcome { white-space: normal; }
.activity-outcome-text { color: var(--text-muted); }
.activity-outcome .btn { margin-left: 8px; }
.repos-search { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); color: var(--text); font-size: 13px; min-width: 200px; }
.repos-sort { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); color: var(--text); font-size: 13px; }
.card-head-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.muted-link { color: var(--text-muted); font-size: 12px; text-decoration: none; white-space: nowrap; }
.muted-link:hover { color: var(--text); text-decoration: underline; }

/* ────────── Filter toolbar ────────── */
.filter-toolbar {
    display: flex; gap: 12px; align-items: center;
    padding: 12px 14px; margin-bottom: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex-wrap: wrap;
}
.filter-toolbar label { display: flex; flex-direction: column; font-size: 11px; color: var(--text-muted); gap: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.filter-toolbar input, .filter-toolbar select,
.inline-form input, .form-row input, .form-row textarea, .form-row select,
.view-actions select {
    padding: 6px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-family: inherit; font-size: 13px;
    color: var(--text);
    min-width: 120px;
}
.view-actions label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.view-actions label select { min-width: 110px; }

.pager {
    display: flex; justify-content: center; align-items: center; gap: 12px;
    padding: 16px;
    color: var(--text-muted); font-size: 12px;
}

/* ────────── Users admin page ────────── */
.users-toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.users-search, .users-role-filter {
    padding: 6px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-family: inherit; font-size: 13px;
    color: var(--text);
}
.users-search { flex: 1; min-width: 220px; max-width: 380px; }
.users-cell { display: flex; align-items: center; gap: 10px; }
.users-avatar {
    width: 28px; height: 28px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 999px;
    background: var(--accent-soft); color: var(--accent-strong);
    font-size: 11px; font-weight: 700;
}
.users-name { font-weight: 600; }
.users-email { font-size: 12px; color: var(--text-muted); }
.users-access-col { text-align: right; }
.users-role-select {
    padding: 4px 8px; min-width: 110px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text);
    font-family: inherit; font-size: 12px;
}
.users-role-select:disabled { opacity: 0.55; cursor: not-allowed; }

/* ────────── Forms ────────── */
form { margin: 0; }
.form-row { margin-bottom: 14px; display: flex; flex-direction: column; gap: 4px; }
.form-row label { font-weight: 500; font-size: 13px; }
.form-row input, .form-row textarea, .form-row select { width: 100%; }
.form-row textarea { min-height: 80px; font-family: inherit; resize: vertical; }
.form-hint { font-size: 12px; color: var(--text-muted); margin: 0; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; align-items: center; justify-content: flex-end; }
.form-status { font-size: 12px; color: var(--text-muted); margin-left: auto; }
.form-status.error { color: var(--danger); }
.form-status.success { color: var(--success); }

.inline-form { display: flex; gap: 8px; margin-bottom: 12px; }
.inline-form input { flex: 1; }

.radio-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; font-weight: normal; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-weight: normal; }

/* ────────── Scan Exclusions modal (tree picker) ──────────
 *
 * The modal is a fixed-height flex column: header (auto), body
 * (flex: 1 with its own scroller), footer (auto, sticky border).
 * Setting overflow: hidden on the modal prevents the parent from
 * scrolling too — the *tree inside* is the only scroller, which keeps
 * the Cancel/Save row anchored at the bottom of the modal instead of
 * being pushed below the viewport on tall content.
 */
.modal-wide {
    max-width: 680px;
    max-height: calc(100vh - 48px);
    height: min(84vh, 820px);
    display: flex; flex-direction: column;
    overflow: hidden;
    padding: 0;  /* children own their own padding */
}
.modal-wide > .modal-header { flex: 0 0 auto; }
.modal-wide > .scan-exclusions-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px 20px;
    display: flex; flex-direction: column; gap: 10px;
    overflow: hidden;  /* inner tree handles scroll */
}
.modal-wide > .form-actions {
    flex: 0 0 auto;
    margin: 0;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    justify-content: flex-end;
    gap: 10px;
    align-items: center;
}
.scan-exclusions-body .muted { margin: 0; }
.scan-exclusions-tree {
    flex: 1 1 auto;
    min-height: 180px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    background: var(--surface-2);
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 13px;
}
.tree-node {
    display: flex; align-items: center; gap: 6px;
    padding: 2px 0;
    line-height: 1.4;
}
.tree-node .tree-caret {
    width: 14px;
    text-align: center;
    color: var(--text);
    cursor: pointer;
    user-select: none;
    font-size: 11px;
}
.tree-node.tree-file .tree-caret { color: var(--text-subtle); cursor: default; }
.tree-node input[type=checkbox] { cursor: pointer; margin: 0; }
.tree-node .tree-label { cursor: pointer; user-select: none; }
.tree-node.tree-file .tree-label { cursor: default; color: var(--text-muted); }
.tree-node.tree-covered .tree-label { color: var(--text-subtle); text-decoration: line-through; }
.tree-node.tree-excluded .tree-label { color: var(--accent); font-weight: 500; }
.tree-loading { color: var(--text-muted); font-style: italic; padding: 4px 0 4px 20px; }
.tree-error { color: var(--danger); padding: 4px 0 4px 20px; }

#repo-excluded-paths-summary code {
    display: inline-block; margin: 2px 4px 2px 0;
    padding: 2px 6px; font-size: 11px;
}

/* ────────── Promise-based confirm / info dialog ────────── */
.dialog-overlay { z-index: 2000; }
.dialog-modal { max-width: 520px; padding: 24px; }
.dialog-title { margin: 0 0 12px; font-size: 16px; font-weight: 600; }
.dialog-body { font-size: 13px; color: var(--text-muted); line-height: 1.55; margin-bottom: 18px; }
.dialog-body p { margin: 0 0 8px; }
.dialog-body p:last-child { margin-bottom: 0; }
.dialog-body .simple-table { margin: 8px 0 0; background: var(--surface-2); }
.dialog-body .simple-table th {
    padding: 6px 10px; font-size: 11px; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.3px; width: 90px;
    text-align: left; background: transparent;
}
.dialog-body .simple-table td { padding: 6px 10px; color: var(--text); font-size: 13px; }
.dialog-actions { margin-top: 0; }

/* ────────── Modals (design's `.modal-back` + card spec) ─────────
   Existing markup uses `.modal-overlay` + `.modal` + `.modal-header`
   so we restyle those names rather than rewriting templates. */
.modal-overlay {
    position: fixed; inset: 0;
    background: oklch(0.1 0.005 240 / 0.32);
    backdrop-filter: blur(4px);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 80px 20px 40px;
    z-index: 1000;
    overflow-y: auto;
    animation: fadeIn 0.12s ease-out;
}
[data-theme="dark"] .modal-overlay { background: oklch(0.05 0.005 240 / 0.55); }
.modal {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow-pop);
    width: 100%; max-width: 560px;
    max-height: calc(100vh - 120px);
    overflow: hidden;
    display: flex; flex-direction: column;
    animation: slideUp 0.18s cubic-bezier(.4,0,.2,1);
}
.modal-header {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 22px 14px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}
.modal-header h3 {
    margin: 0; font-size: 16px; font-weight: 600;
    letter-spacing: -0.01em;
    flex: 1;
}
.modal-close {
    background: none; border: none; cursor: pointer;
    width: 28px; height: 28px;
    border-radius: 6px;
    font-size: 14px; color: var(--text-muted);
    display: inline-flex; align-items: center; justify-content: center;
    transition: background 0.12s, color 0.12s;
}
.modal-close:hover { background: var(--bg-sunk); color: var(--text); }
.modal form {
    padding: 18px 22px 8px;
    overflow-y: auto;
    flex: 1;
}
/* Footer-style action row: when .form-actions is the last child of
   the form, give it a sunk bg + top border + flush margin to read
   as the design's modal footer.  No HTML changes required. */
.modal form > .form-actions:last-child {
    margin: 16px -22px -8px;
    padding: 14px 22px;
    border-top: 1px solid var(--line);
    background: var(--bg-sunk);
    justify-content: flex-end;
    gap: 10px;
}

.report-modal-overlay {
    align-items: center;
    padding: 24px;
}
.report-modal {
    max-width: min(1120px, calc(100vw - 48px));
    height: min(900px, calc(100vh - 48px));
}
.report-modal .modal-header {
    background: #0d1118;
    color: #fff;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}
.report-modal-close {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    margin-left: 4px;
    border: 1px solid #2f3a46;
    background: #131920;
    color: #c7cedb;
    font-size: 16px;
    font-weight: 700;
}
.report-modal-close:hover {
    background: #1c2631;
    color: #fff;
}
.report-modal-title {
    flex: 1;
    min-width: 220px;
}
.report-modal-title h3 {
    margin: 0;
}
.report-modal-title p {
    margin: 4px 0 0;
    color: #8a93a3;
    font-size: 13px;
}
.report-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.report-pdf-btn {
    background: #f5a623;
    border-color: #f5a623;
    color: #17130a;
    font-weight: 700;
}
.report-pdf-btn:hover {
    background: #ffb83d;
    border-color: #ffb83d;
}
.report-include-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #8a93a3;
}
.report-include-label select {
    border: 1px solid #2f3a46;
    border-radius: var(--radius-sm);
    background: #131920;
    color: #fff;
    padding: 5px 8px;
    font: inherit;
}
.report-preview-frame-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
    background: #eef2f7;
    overflow: hidden;
}
.report-preview-status {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 24px;
    background: #eef2f7;
    color: #1f2430;
}
.report-preview-status.is-hidden {
    display: none;
}
.report-preview-status.is-error {
    color: #8f1530;
}
.report-preview-status.is-error .report-preview-spinner {
    display: none;
}
.report-preview-status strong,
.report-preview-status span:not(.report-preview-spinner) {
    display: block;
}
.report-preview-status strong {
    margin-bottom: 4px;
    font-size: 15px;
}
.report-preview-status span:not(.report-preview-spinner) {
    color: #5b6472;
    font-size: 13px;
}
.report-preview-spinner {
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    border: 3px solid #c7d2e1;
    border-top-color: #004cf7;
    border-radius: 50%;
    animation: reportPreviewSpin 0.8s linear infinite;
}
#report-preview-frame {
    width: 100%;
    height: 100%;
    border: 0;
    background: #fff;
    opacity: 1;
    transition: opacity 0.12s ease-out;
}
#report-preview-frame.is-loading {
    opacity: 0;
}

@keyframes reportPreviewSpin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
    .report-modal-overlay { padding: 12px; }
    .report-modal {
        max-width: calc(100vw - 24px);
        height: calc(100vh - 24px);
    }
    .report-modal .modal-header {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 10px;
        padding: 14px;
    }
    .report-modal-title {
        min-width: 0;
        flex: 1 1 calc(100% - 48px);
    }
    .report-header-actions {
        order: 3;
        flex: 0 0 100%;
        justify-content: flex-start;
    }
    .report-modal-close {
        order: 2;
        margin-left: 0;
    }
    .report-include-label {
        width: 100%;
    }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ────────── Drawer (design's slide-in spec) ─────────
   Slides over the full viewport (top:0) so the header doesn't gap
   above the drawer.  Backdrop comes from a sibling overlay div the
   render adds when the drawer opens. */
.drawer {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: 520px; max-width: 92vw;
    background: var(--bg-elev);
    border-left: 1px solid var(--line);
    box-shadow: var(--shadow-pop);
    z-index: 900;
    display: flex; flex-direction: column;
    animation: slideInRight 0.22s cubic-bezier(.4,0,.2,1);
}
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
.drawer-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 10px;
}
.drawer-header-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: 1; }
.drawer-rule {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 14px; font-weight: 600;
}
.drawer-status { font-size: 12px; color: var(--text-muted); }
.drawer-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    display: flex; flex-direction: column; gap: 18px;
}
.drawer-message { font-size: 14px; margin: 0; line-height: 1.55; }
.drawer-file {
    margin: 0;
    display: flex; align-items: center; gap: 8px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12.5px;
    padding: 8px 10px;
    background: var(--bg-sunk);
    border: 1px solid var(--line);
    border-radius: 7px;
}
.drawer-file strong { font-weight: 600; color: var(--text); }
.drawer-snippet {
    background: var(--bg-sunk);
    border: 1px solid var(--line);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 12px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    max-height: 220px;
    margin: 0;
    white-space: pre;
}
.drawer-meta { font-size: 12px; color: var(--text-muted); }
.drawer-actions {
    display: flex; gap: 8px; flex-wrap: wrap;
    padding: 16px 20px;
    border-top: 1px solid var(--line);
    margin: 0;
}

/* ────────── Toasts ────────── */
.toast-container {
    position: fixed; top: calc(var(--header-h) + 16px); right: 16px;
    z-index: 1100;
    display: flex; flex-direction: column; gap: 8px;
    pointer-events: none;
}
.toast {
    background: var(--surface);
    border-left: 4px solid var(--accent);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    max-width: 360px;
    font-size: 13px;
    pointer-events: auto;
    animation: slideInRight 0.2s;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

/* ────────── Chat fob + panel ────────── */
.chat-fab {
    position: fixed; right: 20px; bottom: 20px;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-fg);
    border: none;
    /* Accent-tinted glow — derived from the current accent hue so the
       FAB tracks the user's accent choice (green/cyan/violet/amber). */
    box-shadow: 0 12px 32px -8px oklch(0.4 0.14 var(--accent-h) / 0.5),
                0 2px 6px oklch(0.2 0 0 / 0.18);
    cursor: pointer;
    font-size: 22px;
    z-index: 800;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.15s, box-shadow 0.2s;
}
.chat-fab:not(.dragging):not(.snapping):hover {
    transform: translateY(-2px) scale(1.06);
    box-shadow: 0 18px 40px -10px oklch(0.4 0.14 var(--accent-h) / 0.6),
                0 3px 10px oklch(0.2 0 0 / 0.22);
}
.chat-fab.dragging {
    box-shadow: 0 24px 50px -10px oklch(0.4 0.14 var(--accent-h) / 0.7),
                0 4px 14px oklch(0.2 0 0 / 0.25);
}
/* FAB avatar — pinned absolutely so no flex-sizing weirdness can warp
   the aspect.  Explicit pixel dimensions match the FAB.  ``box-sizing:
   border-box`` prevents any inherited padding from making the rendered
   box rectangular. */
.chat-fab-img {
    position: absolute;
    top: 0; left: 0;
    width: 56px; height: 56px;
    border-radius: 50%;
    object-fit: cover;
    box-sizing: border-box;
    display: block;
}
.chat-fab-emoji {
    line-height: 1;
    font-size: 22px;
}
/* Drop the gradient backdrop when an avatar is set — Slack-edge
   avatars often have semi-transparent edges so peek-through reads
   as a green rim.  Neutral surface colour gives a clean ring. */
.chat-fab.has-avatar { background: var(--surface); }

/* Header avatar — same trick as the FAB: a real <img> for the
   avatar, with the legacy <div> kept as a letter fallback when
   no avatar URL is configured.  Using an <img> rather than
   ``background-image`` on the div sidesteps the shorthand-reset
   gotcha that was hiding the avatar earlier. */
.chat-header-avatar-img {
    width: 32px; height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

/* Drag affordances.  FAB is grabbable; panel header is grabbable in
   the floating state but not while docked or expanded — those modes
   own their own layout. */
.chat-fab { cursor: grab; touch-action: none; user-select: none; }
.chat-fab.dragging { cursor: grabbing; transform: scale(1.08); }
.chat-fab.snapping {
    transition: left 0.32s cubic-bezier(0.34,1.56,0.64,1),
                top  0.32s cubic-bezier(0.34,1.56,0.64,1),
                transform 0.2s ease;
}
.chat-header { cursor: grab; user-select: none; }
.chat-panel.panel-dragging { transition: none !important; }
.chat-panel.panel-dragging .chat-header { cursor: grabbing; }
/* Smooth re-anchor animation when the panel is released without
   docking — left/top transition into the new resting position. */
.chat-panel.panel-snapping {
    transition: top 0.3s cubic-bezier(0.34,1.56,0.64,1),
                left 0.3s cubic-bezier(0.34,1.56,0.64,1) !important;
}
.chat-fab-badge {
    position: absolute; top: -4px; right: -4px;
    background: var(--sev-error); color: white;
    border-radius: 999px;
    min-width: 20px; height: 20px; padding: 0 5px;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    /* Cut the badge out of the FAB shape using the page bg, not white,
       so dark mode keeps the silhouette visible. */
    border: 2px solid var(--bg);
}

.chat-panel {
    position: fixed; right: 20px; bottom: 88px;
    width: 400px; max-width: calc(100vw - 40px);
    height: 540px; max-height: calc(100vh - 120px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 850;
    /* Fade in/out using opacity + visibility + transform — the panel
       stays in the layout (display: flex) so the transition can run
       in both directions.  visibility: hidden suppresses pointer
       events and keyboard focus while closed. */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: opacity 0.22s ease,
                transform 0.22s ease,
                visibility 0.22s;
}
.chat-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}
/* Docked / expanded panels are part of the layout — opacity and
   transform must be reset so the fade rules don't render them
   half-faded or scaled. */
.chat-panel.docked,
.chat-panel.expanded {
    opacity: 1;
    visibility: visible;
    transform: none;
}

.chat-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff;
}
.chat-header-info { display: flex; align-items: center; gap: 10px; }
.chat-header-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    border: 1px solid rgba(255,255,255,0.2);
}
.chat-header-text { display: flex; flex-direction: column; line-height: 1.2; }
.chat-header-title { font-weight: 600; font-size: 14px; }
.chat-header-status { font-size: 11px; opacity: 0.85; }
.chat-header-actions { display: flex; gap: 4px; }
.chat-icon-btn {
    width: 28px; height: 28px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.12);
    color: #fff; border: none;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background 0.15s ease;
}
.chat-icon-btn:hover { background: rgba(255,255,255,0.22); }
.chat-icon-btn svg { display: block; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex; flex-direction: column; gap: 12px;
    background: var(--bg);
}
.chat-welcome { color: var(--text-muted); font-size: 13px; padding: 8px 4px; }
.chat-welcome ul { margin: 8px 0 0 20px; padding: 0; }
.chat-welcome li { margin: 4px 0; }
.chat-msg { display: flex; gap: 8px; }
.chat-msg.user { justify-content: flex-end; }
.chat-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.45;
    word-wrap: break-word;
}
.chat-msg.user .chat-bubble {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg.bot .chat-bubble {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.chat-bubble p { margin: 0 0 8px; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble pre {
    background: var(--surface-2);
    padding: 8px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 12px;
    margin: 8px 0;
}
.chat-bubble table {
    font-size: 12px; margin: 8px 0;
    display: block;
    max-width: 100%;
    overflow-x: auto;
    width: max-content;
}
.chat-bubble thead th { font-size: 11px; padding: 6px 8px; }
.chat-bubble tbody td { padding: 6px 8px; }
.chat-typing {
    padding: 10px 14px;
    color: var(--text-muted); font-size: 13px; font-style: italic;
}
.chat-error { color: var(--danger); padding: 8px 12px; font-size: 12px; }

.chat-input-area {
    display: flex; gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}
.chat-input-area textarea {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-family: inherit; font-size: 13px;
    resize: none;
    max-height: 120px;
    min-height: 36px;
    line-height: 1.4;
}
.chat-action-col {
    display: flex; flex-direction: column; gap: 6px;
    align-items: stretch;
}
.chat-send-btn, .chat-mic-btn {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    border: none; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background 0.15s ease, transform 0.1s ease;
}
.chat-send-btn { background: var(--accent); color: #fff; }
.chat-send-btn:hover:not(:disabled) { background: var(--accent-hover); }
/* Disabled needs to look unambiguously inert — full-opacity green
   reads as "enabled" to most users even with `not-allowed` cursor, so
   we recolour rather than dimming the brand colour. */
.chat-send-btn:disabled {
    background: var(--surface-2, #2a2a2a);
    color: var(--text-faint, rgba(255,255,255,0.4));
    cursor: not-allowed;
    opacity: 0.7;
}
.chat-mic-btn {
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.chat-mic-btn:hover { color: var(--brand); border-color: var(--accent); }
.chat-mic-btn.recording {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
    animation: chat-mic-pulse 1.2s ease-in-out infinite;
}
@keyframes chat-mic-pulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.45); }
    50%     { box-shadow: 0 0 0 6px rgba(220,38,38,0); }
}

/* Expanded (fullscreen-ish) chat panel.  Keeps a small inset so the
   FAB stays clickable and the page chrome is still visible. */
.chat-panel.expanded {
    right: 20px; bottom: 20px;
    width: calc(100vw - 40px);
    height: calc(100vh - 40px);
    max-width: 1400px;
    max-height: none;
}

/* Docked-to-sidebar mode.  When ``#app-body`` gets ``.chat-docked``,
   it switches to a flex row and the chat panel sits as a flex sibling
   of ``#app-content`` instead of a fixed-position overlay. */
#app-body.chat-docked {
    display: flex;
    flex-direction: row;
    align-items: flex-start;  /* don't stretch — panel gets its own height */
}
#app-body.chat-docked > #app-content {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
}
.chat-panel.docked {
    /* Sticky to keep the panel pinned to the viewport as the user scrolls
       through long #app-content.  Without this, ``align-items: stretch``
       grew the panel to match content height, pushing the input area off
       the bottom of the page. */
    position: sticky;
    top: var(--header-h);
    /* Reset the floating-mode offsets — sticky respects right/bottom and
       the inherited ``right: 20px; bottom: 88px`` from the base rule
       leaves a margin between the panel and the viewport edge. */
    right: auto;
    bottom: auto;
    left: auto;
    align-self: flex-start;
    width: auto;
    /* Floating mode also caps width at ``calc(100vw - 40px)``, which is
       fine there but irrelevant when docked.  Drop the cap so the panel
       fills its flex-basis exactly. */
    max-width: none;
    height: calc(100vh - var(--header-h));
    max-height: calc(100vh - var(--header-h));
    border-radius: 0;
    box-shadow: none;
    border: none;
    flex: 0 0 auto;
    flex-basis: 420px;
    min-width: 280px;
    overflow: hidden;
    transition: none;
}
.chat-panel.docked.dock-right { border-left: 1px solid var(--border); }
.chat-panel.docked.dock-left  { border-right: 1px solid var(--border); }
.chat-dock-divider {
    flex: 0 0 4px;
    /* Parent #app-body uses ``align-items: flex-start`` so the panel
       and content don't get coerced to equal heights.  The divider
       has no intrinsic content though — without ``align-self:
       stretch`` it collapses to 0px tall, leaving the visible bar
       invisible and the drag hit-area empty (the bug Mason hit).
       Stretch makes it match the panel's full height. */
    align-self: stretch;
    background: var(--border);
    cursor: col-resize;
    transition: background 0.15s ease;
    position: relative;
}
.chat-dock-divider::before {
    /* Generous hit-area: extend 4px on each side and the full height
       of the divider so users don't have to pixel-target the 4px bar. */
    content: ''; position: absolute;
    left: -4px; right: -4px; top: 0; bottom: 0;
}
.chat-dock-divider:hover, .chat-dock-divider.dragging { background: var(--accent); }

/* Dock + expand controls disappear on narrow viewports — both modes
   need real estate the layout doesn't have on phones. */
@media (max-width: 720px) {
    .chat-panel.docked, .chat-panel.expanded { /* coerce back to floating */
        position: fixed; right: 20px; bottom: 88px;
        width: 400px; height: 540px;
        max-width: calc(100vw - 40px);
        max-height: calc(100vh - 120px);
        border-radius: var(--radius-lg);
        border: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
    }
    #chat-dock-btn, #chat-expand-btn { display: none; }
}


/* Voice-mode toggle — tap to enable continuous recognition + TTS read-
   back.  Distinct from push-to-talk (which is hold-to-record on the
   mic button below it). */
.chat-voice-mode-btn {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.chat-voice-mode-btn:hover { color: var(--brand); border-color: var(--accent); }
.chat-voice-mode-btn.active {
    background: var(--accent); color: #fff; border-color: var(--accent);
}
.voice-bars {
    display: inline-flex; align-items: flex-end; gap: 2px;
    height: 14px;
}
.voice-bars .vbar {
    width: 2px; height: 4px;
    background: currentColor;
    border-radius: 1px;
    display: inline-block;
}
.chat-voice-mode-btn.active .voice-bars .vbar {
    animation: vbar-pulse 1s ease-in-out infinite;
}
.chat-voice-mode-btn.active .voice-bars .vbar:nth-child(1) { animation-delay: 0s;    height: 4px; }
.chat-voice-mode-btn.active .voice-bars .vbar:nth-child(2) { animation-delay: 0.15s; height: 9px; }
.chat-voice-mode-btn.active .voice-bars .vbar:nth-child(3) { animation-delay: 0.3s;  height: 4px; }
@keyframes vbar-pulse {
    0%, 100% { transform: scaleY(0.4); }
    50%      { transform: scaleY(1.4); }
}

/* Same animated bars on the FAB itself when voice mode is on, so the
   user can see the bot is listening even with the panel closed. */
.chat-fab-voice {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    color: #fff;
    display: none;
    align-items: center; justify-content: center;
    gap: 3px;
}
.chat-fab-voice .vbar { width: 3px; height: 6px; background: #fff; border-radius: 1.5px; }
.chat-fab.voice-active .chat-fab-voice { display: flex; }
.chat-fab.voice-active .chat-fab-voice .vbar { animation: vbar-pulse 1s ease-in-out infinite; }
.chat-fab.voice-active .chat-fab-voice .vbar:nth-child(1) { animation-delay: 0s;    height: 6px; }
.chat-fab.voice-active .chat-fab-voice .vbar:nth-child(2) { animation-delay: 0.15s; height: 12px; }
.chat-fab.voice-active .chat-fab-voice .vbar:nth-child(3) { animation-delay: 0.3s;  height: 6px; }

/* ────────── Misc ────────── */
.token-new {
    background: var(--sev-warning-soft);
    border: 1px solid var(--sev-warning);
    border-radius: var(--radius-sm);
    padding: 12px; margin: 12px 0;
    font-size: 13px;
}
.token-value {
    display: inline-block;
    background: var(--bg-elev);
    padding: 6px 10px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12px;
    margin-right: 8px;
    word-break: break-all;
    color: var(--text);
}

/* ────────── Rating badge ────────── */
.rating-badge {
    display: inline-grid; place-items: center;
    width: 28px; height: 28px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    letter-spacing: -0.04em;
    border: 0;
}
/* Theme-aware rating colors using OKLCH so light/dark both look right. */
.rating-badge[data-grade^="A"] { background: var(--good-soft); color: var(--good); }
.rating-badge[data-grade^="B"] { background: oklch(0.85 0.10 130 / 0.25); color: oklch(0.40 0.13 130); }
.rating-badge[data-grade^="C"] { background: oklch(0.82 0.13 80 / 0.25); color: oklch(0.40 0.14 60); }
.rating-badge[data-grade^="D"] { background: oklch(0.78 0.16 50 / 0.25); color: oklch(0.42 0.14 40); }
.rating-badge[data-grade^="F"] { background: var(--sev-error-soft); color: var(--sev-error); }
[data-theme="dark"] .rating-badge[data-grade^="B"] { background: oklch(0.45 0.13 130 / 0.3); color: oklch(0.85 0.13 130); }
[data-theme="dark"] .rating-badge[data-grade^="C"] { background: oklch(0.45 0.14 80 / 0.3); color: oklch(0.85 0.13 80); }
[data-theme="dark"] .rating-badge[data-grade^="D"] { background: oklch(0.45 0.14 50 / 0.3); color: oklch(0.85 0.13 50); }
.rating-badge .rating-score { font-size: 11px; opacity: 0.85; margin-left: 6px; font-weight: 500; }

/* ────────── Charts grid on repo detail ──────────
   Inline-SVG renderers size themselves to content, so the wrap
   doesn't need a fixed height anymore.  Legacy CSS kept as a
   no-op fallback for any code still expecting the canvas height. */
.charts-grid {
    display: grid;
    grid-template-columns: 1.4fr 2fr;
    gap: 20px;
    margin-bottom: 20px;  /* gap between charts row and files-by-rating */
    align-items: stretch;
}
.chart-card { margin-bottom: 0; }
.chart-wrap { position: relative; width: 100%; min-height: 200px; }

.file-list { padding-left: 18px; margin: 0; font-size: 13px; }
.file-list li { margin: 4px 0; }
.file-list .file-name { font-family: monospace; font-size: 12px; }
.file-list .file-score { color: var(--text-muted); float: right; }

/* ────────── Repo picker (autocomplete) ────────── */
.repo-picker { position: relative; }
.repo-picker input[type="text"] { width: 100%; }
.repo-dropdown {
    position: absolute; top: 100%; left: 0; right: 0;
    max-height: 260px; overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 200;
    display: none;
    margin-top: 2px;
}
.repo-dropdown.open { display: block; }
.repo-option {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}
.repo-option:last-child { border-bottom: none; }
.repo-option:hover, .repo-option.active {
    background: var(--accent-soft);
    color: var(--brand);
}
.repo-option-name { font-weight: 600; font-size: 13px; }
.repo-option-desc { font-size: 12px; color: var(--text-muted); }
.repo-option-loading, .repo-option-empty {
    padding: 12px;
    text-align: center; color: var(--text-muted); font-size: 12px; font-style: italic;
}
.repo-selected {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    background: var(--accent-soft);
    border: 1px solid var(--surface-3);
    border-radius: var(--radius-sm);
}
.repo-selected strong { font-size: 14px; color: var(--brand); }
.repo-clear {
    margin-left: auto;
    background: none; border: none; cursor: pointer;
    font-size: 14px; color: var(--text-muted);
    padding: 2px 6px;
}
.repo-clear:hover { color: var(--danger); }

.form-details { margin: 12px 0; }
.form-details summary { cursor: pointer; color: var(--accent); font-size: 13px; padding: 6px 0; }
.form-details[open] summary { margin-bottom: 8px; }

/* ────────── Repo access members ────────── */
.access-members {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0 4px;
}
.access-member {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 6px 3px 9px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--bg-sunk);
    font-size: 12px;
}
.access-member-remove {
    border: none;
    background: none;
    color: var(--text-faint);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
    border-radius: 50%;
}
.access-member-remove:hover { color: var(--sev-error); background: var(--sev-error-soft); }
.access-add-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 12px 0 6px;
    font-size: 13px;
}
.access-add-row select {
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--bg-elev);
    color: var(--text);
    font-size: 13px;
    min-width: 240px;
}

/* ────────── Code snippet inside drawer ────────── */
.code-snippet {
    background: var(--bg-sunk);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12px;
    line-height: 1.6;
    margin: 0 0 12px;
    overflow: hidden;
    max-height: 320px;
    overflow-y: auto;
}
.code-snippet .code-line {
    display: flex;
    padding: 2px 12px;
    white-space: pre;
}
.code-snippet .code-line.focus {
    background: oklch(from var(--sev-warning) l c h / 0.12);
    border-left: 3px solid var(--sev-warning);
    padding-left: 9px;
}
.code-snippet .code-line-num {
    flex: 0 0 42px;
    color: var(--text-faint);
    text-align: right;
    padding-right: 12px;
    user-select: none;
}
.code-snippet .code-line-text { white-space: pre; }
.snippet-empty { padding: 12px 16px; }

/* ────────── Image strip (chat attachments) ────────── */
.image-strip {
    display: flex; gap: 6px; margin-top: 6px;
    flex-wrap: wrap;
}
.image-strip:empty { display: none; }
.image-thumb {
    position: relative;
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}
.image-thumb img { width: 100%; height: 100%; object-fit: cover; }
.image-thumb-remove {
    position: absolute; top: 2px; right: 2px;
    width: 16px; height: 16px;
    padding: 0;
    border: none;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 10px;
    line-height: 1;
    display: flex; align-items: center; justify-content: center;
}

/* ────────── Chat quick-action buttons ────────── */
.chat-actions-row {
    display: flex; gap: 6px; flex-wrap: wrap;
    margin-top: 10px;
}
.chat-action-btn {
    padding: 6px 12px;
    border: 1px solid var(--surface-3);
    border-radius: 999px;
    background: var(--surface);
    color: var(--brand);
    cursor: pointer;
    font-size: 12px; font-weight: 500;
    font-family: inherit;
}
.chat-action-btn:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
}

/* ────────── EasyMDE tweaks inside chat ──────────
   The CodeMirror editor and the toolbar both come from EasyMDE's
   stylesheet (CDN) which assumes a light theme; explicit overrides
   here so the editor reads well in dark mode and the input area
   has visible contrast against the panel.  The editor sits on the
   page bg (sunk relative to the chat panel's --bg-elev), with text
   and caret colored from the design tokens so the placeholder and
   typed characters are always readable. */
.chat-editor-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-editor-wrap .EasyMDEContainer { flex: 1; min-width: 0; }
.chat-editor-wrap .EasyMDEContainer .CodeMirror {
    min-height: 64px;
    max-height: 180px;
    font-size: 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
}
.chat-editor-wrap .CodeMirror-cursor { border-left-color: var(--text); }
.chat-editor-wrap .CodeMirror-placeholder,
.chat-editor-wrap .CodeMirror pre.CodeMirror-placeholder { color: var(--text-faint); }
.chat-editor-wrap .CodeMirror-selected { background: var(--accent-soft); }
.chat-editor-wrap .CodeMirror-line,
.chat-editor-wrap .CodeMirror-line span { color: var(--text); }
.chat-editor-wrap .EasyMDEContainer .CodeMirror.CodeMirror-focused {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    outline: 0;
}
.chat-editor-wrap .editor-toolbar {
    border: 1px solid var(--line);
    border-bottom: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    background: var(--bg-sunk);
    padding: 3px 6px;
    opacity: 1;
}
.chat-editor-wrap .editor-toolbar button {
    font-size: 12px;
    color: var(--text-muted);
    border-color: transparent;
}
.chat-editor-wrap .editor-toolbar button:hover,
.chat-editor-wrap .editor-toolbar button.active {
    color: var(--text);
    background: var(--bg-elev);
    border-color: var(--line);
}
.chat-editor-wrap .editor-toolbar i.separator { border-left: 1px solid var(--line); border-right: 0; }
.chat-editor-wrap .editor-toolbar + .CodeMirror { border-top-left-radius: 0; border-top-right-radius: 0; }

/* ────────── Quality evolution card ────────── */
.quality-evo-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}
.quality-evo-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; margin-bottom: 14px; flex-wrap: wrap;
}
.quality-evo-title { font-size: 16px; font-weight: 600; margin: 0; }
.quality-evo-window {
    display: inline-flex;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface);
}
.quality-evo-window button {
    background: none; border: none; cursor: pointer;
    padding: 6px 14px;
    font-size: 12px; font-weight: 500;
    color: var(--text-muted);
    border-right: 1px solid var(--border);
    font-family: inherit;
}
.quality-evo-window button:last-child { border-right: none; }
.quality-evo-window button:hover { background: var(--surface-2); color: var(--text); }
.quality-evo-window button.active {
    background: var(--accent-soft);
    color: var(--accent-hover);
    font-weight: 600;
}

.quality-evo-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    margin: 0 0 18px;
    border-bottom: 1px solid var(--border);
}
.quality-evo-tab {
    background: none; border: none; cursor: pointer;
    padding: 12px 14px 14px;
    text-align: left;
    border-bottom: 2px solid transparent;
    font-family: inherit;
    display: flex; flex-direction: column; gap: 4px;
    min-width: 0;
    color: var(--text);
}
.quality-evo-tab:hover { background: var(--surface-2); }
.quality-evo-tab.active { border-bottom-color: var(--accent); background: var(--accent-soft); }
.quality-evo-tab.disabled { opacity: 0.45; cursor: not-allowed; }
.quality-evo-tab-label {
    font-size: 12px; color: var(--text-muted);
    display: flex; align-items: center; gap: 6px;
    text-transform: none;
}
.quality-evo-tab-dot {
    width: 8px; height: 8px; border-radius: 50%;
    display: inline-block;
}
.quality-evo-tab[data-metric="issues"] .quality-evo-tab-dot { background: #dc2626; }
.quality-evo-tab[data-metric="complexity"] .quality-evo-tab-dot { background: var(--good); }
.quality-evo-tab[data-metric="duplication"] .quality-evo-tab-dot { background: #f59e0b; }
.quality-evo-tab[data-metric="coverage"]    .quality-evo-tab-dot { background: #0284c7; }
.quality-evo-tab-value {
    font-size: 22px; font-weight: 700; line-height: 1.1;
    color: var(--text);
}
.quality-evo-tab-unit { font-size: 13px; color: var(--text-muted); margin-left: 2px; font-weight: 500; }
.quality-evo-tab-delta { font-size: 12px; font-weight: 600; margin-left: 4px; }

.quality-evo-chart-wrap {
    position: relative;
    height: 280px;
    width: 100%;
}

/* Compact chart row under the quality evolution card.
   Two-column layout: severity donut gets a narrow column (it's already
   tiny), Top-rules gets the wider column so its axis labels aren't cut
   off.  Files-by-rating moved to its own card below. */
/* Compact-charts is paired with split-2 in markup now; the inline-SVG
   renderers size to content, so we don't constrain the chart-wrap
   height here.  Legacy 240px constraint removed when we retired
   Chart.js. */
.compact-charts { gap: 20px; }

/* Delta arrows + colouring (shared across commit history, PR list, metrics). */
.delta-arrow { font-size: 11px; margin-left: 3px; }

/* ────────── Category rollup card ────────── */
/* Dashboard split: design's 1.4fr 2fr ratio puts category card on
   left, repo grid (2-col) on right. */
.dashboard-split {
    display: grid;
    grid-template-columns: 1.4fr 2fr;
    gap: 20px;
    align-items: start;
}
.category-card {
    padding: 22px 24px;
    align-self: start;
}
.category-card .category-total {
    display: flex; flex-direction: column; gap: 4px;
    margin-bottom: 24px;
    border-bottom: 0; padding-bottom: 0;
}
.category-total-num {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 56px; font-weight: 600;
    letter-spacing: -0.04em;
    color: var(--accent-strong);
    line-height: 1;
}
.category-total-label {
    font-size: 12px;
    color: var(--text-muted);
    max-width: 220px;
    line-height: 1.45;
}
.category-list {
    display: flex; flex-direction: column;
    gap: 6px;
}
.category-row {
    display: grid;
    grid-template-columns: 130px 1fr 56px;
    gap: 14px; align-items: center;
    padding: 4px 0;
    font-size: 13px;
}
.category-row .category-row-name { font-size: 13px; font-weight: 500; }
.category-row .category-row-bar {
    height: 12px;
    background: var(--bg-sunk);
    border-radius: 3px;
    overflow: hidden;
    width: 100%;
}
.category-row .category-row-bar-fill {
    height: 100%; background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s;
}
.category-row .category-row-count {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    font-size: 13px;
    text-align: right;
}
.category-row-zero { display: none; }  /* compact: hide zero-count categories */
.category-fix-btn {
    background: transparent;
    border: none;
    color: var(--accent);
    font-size: 13px;
    padding: 2px 4px;
    cursor: pointer;
    font-family: inherit;
    opacity: 0;
    transition: opacity 0.15s;
    line-height: 1;
}
.category-row:hover .category-fix-btn { opacity: 1; }
.category-fix-btn:hover { color: var(--accent-hover); text-shadow: 0 0 0.4px currentColor; }
.category-fix-btn:focus-visible { opacity: 1; outline: 2px solid var(--accent); border-radius: 3px; }
.remediations-table td { font-size: 12px; }
.remediations-table .status-queued,
.remediations-table .status-dispatched  { color: var(--sev-info); font-weight: 600; }
.remediations-table .status-pr_opened    { color: oklch(0.45 0.14 60); font-weight: 600; }
.remediations-table .status-pr_merged    { color: var(--accent-strong); font-weight: 600; }
.remediations-table .status-pr_declined,
.remediations-table .status-failed,
.remediations-table .status-stopped      { color: var(--sev-error); font-weight: 600; }
[data-theme="dark"] .remediations-table .status-pr_opened { color: oklch(0.85 0.13 80); }
.remediations-table .status-tag {
    display: inline-block; padding: 1px 8px;
    border-radius: 999px;
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.3px;
}
/* OKLCH category palette — same hue family across light/dark.
   Order roughly mirrors design mocks: red → orange → blue → green
   → cyan → violet → pink. */
.category-row.category-0 .category-row-bar-fill { background: var(--text-faint); }
.category-row[data-category="Security"]        .category-row-bar-fill { background: var(--sev-error); }
.category-row[data-category="Error prone"]     .category-row-bar-fill { background: oklch(0.65 0.18 40); }
.category-row[data-category="Best practice"]   .category-row-bar-fill { background: oklch(0.6 0.15 240); }
.category-row[data-category="Code style"]      .category-row-bar-fill { background: var(--accent); }
.category-row[data-category="Documentation"]   .category-row-bar-fill { background: oklch(0.6 0.14 200); }
.category-row[data-category="Unused code"]     .category-row-bar-fill { background: oklch(0.55 0.16 290); }
.category-row[data-category="Code complexity"] .category-row-bar-fill { background: oklch(0.65 0.2 350); }

/* Repo detail's category card is compact — horizontal chip row, small
   inline bars.  Designed to fit the user's feedback that this card was
   eating too much vertical real estate on the repo detail page. */
#repo-category-card {
    padding: 14px 16px;
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 20px;
    align-items: center;
}
#repo-category-card .category-total { border-bottom: none; padding-bottom: 0; margin-bottom: 0; flex-direction: column; gap: 0; }
#repo-category-card .category-total-num { font-size: 26px; }
#repo-category-card .category-total-label { font-size: 11px; }
#repo-category-card .category-list {
    flex-direction: row;
    gap: 12px 16px;
    flex-wrap: wrap;
}
#repo-category-card .category-row {
    display: inline-grid;
    grid-template-columns: auto 60px auto 18px;
    gap: 6px;
    align-items: center;
    font-size: 12px;
}
#repo-category-card .category-row:not(:hover) .category-fix-btn { opacity: 0; }
#repo-category-card .category-row-bar { height: 6px; }
#repo-category-card .category-row-count { min-width: 22px; font-size: 12px; }

/* ────────── Split-grid (PR list + commit history) ────────── */
.split-grid {
    display: grid;
    /* Give the commit history roughly 1.5× the PR column — commit
       messages are long and there's more metric columns to fit. */
    grid-template-columns: minmax(0, 4fr) minmax(0, 7fr);
    gap: 16px;
    margin-bottom: 16px;
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-header h3 { margin: 0; }
.card-header select { min-width: 110px; padding: 4px 8px; font-size: 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }

.pr-table td, .commit-table td { font-size: 12px; }
.commit-table .commit-msg {
    font-family: inherit;
    max-width: 340px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.commit-table .commit-msg a { color: var(--text); font-weight: 500; }
.commit-table .commit-msg a:hover { color: var(--accent); }
.commit-table .commit-sha { font-family: monospace; color: var(--text-muted); font-size: 11px; }
.pr-table .pr-title { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pr-table .pr-branch { font-family: monospace; font-size: 11px; color: var(--text-muted); }
.delta-pos { color: var(--danger); font-weight: 600; }
.delta-neg { color: var(--success); font-weight: 600; }
.delta-zero { color: var(--text-muted); }
.scan-none { color: var(--text-subtle); font-style: italic; }

/* ────────── Commit detail view ────────── */
.commit-meta { color: var(--text-muted); font-size: 13px; margin-bottom: 10px; }
.commit-meta strong { color: var(--text); font-weight: 600; }
.commit-message {
    white-space: pre-wrap;
    font-family: inherit;
    background: var(--surface-2);
    padding: 12px;
    border-radius: var(--radius-sm);
    margin: 0;
    font-size: 13px;
    max-height: 200px;
    overflow-y: auto;
}
.commit-metrics-card {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
.commit-metric { text-align: center; }
.commit-metric-label {
    text-transform: uppercase;
    font-size: 11px; font-weight: 600; letter-spacing: 0.4px;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.commit-metric-value { font-size: 24px; font-weight: 700; color: var(--brand); line-height: 1; }
.commit-metric-delta { font-size: 12px; margin-top: 4px; }

/* Diff styling */
.diff-file {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    overflow: hidden;
    background: var(--surface);
}
.diff-file-header {
    background: var(--surface-2);
    padding: 8px 12px;
    font-family: monospace;
    font-size: 12px;
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    gap: 10px;
}
.diff-file-path { font-weight: 600; }
.diff-file-findings { color: var(--danger); font-weight: 600; font-size: 11px; }
.diff-hunk {
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 12px;
    overflow-x: auto;
}
.diff-line { display: flex; white-space: pre; }
.diff-line-num {
    flex: 0 0 42px;
    color: var(--text-subtle);
    text-align: right;
    padding: 0 8px;
    background: var(--surface-2);
    user-select: none;
    border-right: 1px solid var(--border);
}
.diff-line-text { padding: 1px 10px; flex: 1; }
.diff-line.add   { background: oklch(0.9 0.10 145 / 0.4); }
.diff-line.add .diff-line-text { color: oklch(0.45 0.13 145); }
.diff-line.del   { background: var(--sev-error-soft); }
.diff-line.del .diff-line-text { color: var(--sev-error); }
.diff-line.ctx .diff-line-text { color: var(--text); }
[data-theme="dark"] .diff-line.add { background: oklch(0.45 0.13 145 / 0.25); }
[data-theme="dark"] .diff-line.add .diff-line-text { color: oklch(0.85 0.13 145); }
.diff-hunk-header {
    background: var(--bg-sunk);
    color: var(--text-muted);
    font-size: 11px;
    padding: 4px 12px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}
.diff-finding-marker {
    background: oklch(from var(--sev-error) l c h / 0.18);
    border-left: 3px solid var(--sev-error);
    padding-left: 9px;
}
.diff-finding-tooltip {
    display: block;
    padding: 6px 12px;
    font-family: inherit;
    font-size: 11px;
    color: var(--sev-error);
    background: var(--sev-error-soft);
    border-top: 1px dashed var(--sev-error);
}

/* ────────── Gate settings form ────────── */
.gate-metric-row {
    display: grid;
    grid-template-columns: auto 1fr 140px 80px auto;
    gap: 12px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.gate-metric-row:last-child { border-bottom: none; }
.gate-metric-row .gate-metric-label { font-weight: 500; font-size: 13px; }
.gate-metric-row .gate-metric-help { font-size: 12px; color: var(--text-muted); grid-column: 2 / 5; margin: 0; }
.gate-metric-row .gate-source-tag { font-size: 11px; color: var(--text-muted); }
.gate-metric-row .gate-source-tag.override { color: var(--accent); font-weight: 600; }
.gate-metric-row input[type="number"] { width: 100%; }
.gate-experimental { opacity: 0.7; }
.gate-experimental::after {
    content: 'experimental';
    display: inline-block;
    background: var(--surface-3); color: var(--text-muted);
    font-size: 10px; padding: 1px 6px;
    border-radius: 999px; margin-left: 8px;
    text-transform: uppercase; letter-spacing: 0.3px;
}

/* Responsive — mobile nav */
@media (max-width: 820px) {
    .hamburger-btn { display: block; order: 3; }
    .header-nav {
        display: none;
        position: absolute; top: var(--header-h); left: 0; right: 0;
        flex-direction: column;
        padding: 8px 16px 12px;
        background: var(--topbar-bg);
        border-bottom: 1px solid var(--topbar-line);
        margin-left: 0;
        box-shadow: var(--shadow-md);
    }
    .header-nav.open { display: flex; }
    .header-actions { order: 2; }
    #app-content { padding: 16px; }
    .drawer { width: 100%; }
    .chat-panel { width: calc(100vw - 32px); height: calc(100vh - 120px); right: 16px; }
    .repo-grid { grid-template-columns: 1fr; }
    .charts-grid { grid-template-columns: 1fr; }
    .dashboard-split { grid-template-columns: 1fr; }
    .split-grid { grid-template-columns: 1fr; }
    #repo-category-card { grid-template-columns: 1fr; }
    .commit-metrics-card { grid-template-columns: repeat(2, 1fr); }
    .view-header { flex-direction: column; align-items: stretch; }
    .view-actions { justify-content: flex-start; }
    .gate-metric-row { grid-template-columns: auto 1fr; gap: 8px; }
}

/* Coverage tokens (repo settings) */
.coverage-tokens-list { margin: 12px 0; }
.coverage-tokens-table { width: 100%; }
.coverage-tokens-table tr.revoked { color: var(--text-faint); }
.coverage-tokens-table td code { font-size: 0.85em; color: var(--text-muted); }
.token-reveal {
    display: flex; gap: 8px; align-items: center;
    background: var(--bg-sunk); color: var(--text);
    border: 1px solid var(--line);
    padding: 12px 14px;
    border-radius: 8px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12.5px; word-break: break-all; margin-top: 12px;
}
.token-reveal code { color: var(--text); background: transparent; flex: 1; }
.token-reveal .btn { flex-shrink: 0; }
.pipeline-snippet {
    background: var(--bg-sunk); color: var(--text);
    border: 1px solid var(--line);
    padding: 12px 14px;
    border-radius: 8px; margin-top: 8px; overflow-x: auto;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12px; line-height: 1.5;
}
.btn-danger-link { color: var(--sev-error); }
.btn-danger-link:hover { color: oklch(0.5 0.2 25); }

/* README badges (repo settings) ────────────────────────────
   Each .badge-snippet row lays the live SVG preview next to
   the markdown source + a copy button so users can verify
   the badge before pasting into their README. */
.badge-snippet {
    display: flex; align-items: center; gap: 14px;
    margin-top: 12px;
    padding: 10px 12px;
    background: var(--bg-sunk);
    border: 1px solid var(--line);
    border-radius: 8px;
}
.badge-snippet .badge-preview {
    flex: 0 0 auto;
    /* Live SVG sets its own width; cap height to the shields.io
       baseline so a long grade like "A+" doesn't shift layout. */
    height: 20px;
}
.badge-snippet-body {
    flex: 1 1 auto;
    display: flex; align-items: center; gap: 10px;
    min-width: 0;
}
.badge-snippet-body pre {
    flex: 1 1 auto;
    margin: 0; padding: 8px 10px;
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: 6px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12px; line-height: 1.4;
    overflow-x: auto; white-space: pre;
}
.badge-snippet-body .btn { flex-shrink: 0; }

/* Code browser — file list */
.compact-select {
    padding: 6px 10px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: var(--bg-elev);
    color: var(--text);
    font-size: 0.9em;
}
.code-file-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; }
.code-file-table th, .code-file-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid #f1f5f9; }
.code-file-table th { background: #f8fafc; font-weight: 600; font-size: 0.85em; color: #475569; text-transform: uppercase; letter-spacing: 0.3px; }
.code-file-table th.col-rating,   .code-file-table td.col-rating   { width: 70px; text-align: center; }
.code-file-table th.col-coverage, .code-file-table td.col-coverage { width: 220px; }
.code-file-table th.col-lines,    .code-file-table td.col-lines    { width: 120px; }
.code-file-table th.col-issues,   .code-file-table td.col-issues   { width: 80px; text-align: center; }
.code-file-row:hover { background: #f8fafc; }
.file-path-cell code { background: transparent; font-size: 0.9em; color: #1e293b; }
.coverage-bar { display: inline-block; width: 120px; height: 8px; border-radius: 4px; background: #f1f5f9; vertical-align: middle; overflow: hidden; }
.coverage-bar-fill { height: 100%; transition: width 0.2s ease; }
.coverage-bar-low  .coverage-bar-fill { background: #dc2626; }
.coverage-bar-mid  .coverage-bar-fill { background: #f59e0b; }
.coverage-bar-high .coverage-bar-fill { background: var(--good); }
.coverage-pct { margin-left: 10px; font-variant-numeric: tabular-nums; font-size: 0.9em; color: #1e293b; }
.issues-pill { display: inline-block; padding: 2px 10px; background: #fee2e2; color: #991b1b; border-radius: 10px; font-size: 0.85em; font-weight: 600; }

/* Code browser — source view */
.code-legend { font-size: 0.85em; color: #64748b; display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 2px; }
.legend-swatch.covered    { background: #86efac; }
.legend-swatch.uncovered  { background: #fca5a5; }
.legend-swatch.unmeasured { background: #e5e7eb; }
/* Code file view layout: narrow sidebar with the rated file list, wide
   source pane on the right.  Collapses to stacked on narrow screens. */
.code-file-layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 16px;
    margin-top: 16px;
    min-height: 600px;
}
.code-file-sidebar {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    padding: 12px;
    gap: 8px;
}
.code-file-filter-input {
    margin: 0;
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--bg-sunk);
    font: inherit;
    font-size: 13px;
    color: var(--text);
}
.code-file-filter-input:focus {
    outline: 0;
    border-color: var(--accent);
    background: var(--bg-elev);
}
.code-file-sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 4px 0 0;
    display: flex; flex-direction: column; gap: 1px;
}
/* Tree rows — design's tree-row spec.  Active state uses the accent
   so it tracks the user's accent picker; theming lands automatically. */
.tree-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text);
    font-size: 13px; line-height: 1;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    cursor: pointer;
    user-select: none;
}
.tree-row:hover { background: var(--bg-sunk); }
.tree-row.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 500; }
.tree-chevron {
    display: inline-block; width: 12px;
    color: var(--text-faint); font-size: 10px;
    transition: transform .12s;
    flex-shrink: 0;
}
.tree-row.open > .tree-chevron { transform: rotate(90deg); }
.tree-folder-icon {
    font-size: 11px;
    color: var(--text-muted);
}
.tree-name {
    flex: 1;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.tree-dir .tree-name { color: var(--text); font-weight: 500; }
.sidebar-issue-count {
    flex-shrink: 0;
    background: var(--bg-sunk);
    color: var(--text-faint);
    padding: 1px 7px;
    border-radius: 999px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10.5px;
    font-weight: 600;
}
.tree-row.active .sidebar-issue-count {
    background: oklch(var(--accent-l) var(--accent-c) var(--accent-h) / 0.2);
    color: var(--accent-strong);
}
/* Smaller rating badge for the compact sidebar */
.rating-badge.rating-sm {
    width: 22px; height: 18px;
    border-radius: 6px;
    font-size: 9px;
    min-width: 0;
}
@media (max-width: 900px) {
    .code-file-layout { grid-template-columns: 1fr; }
    .code-file-sidebar { max-height: 300px; }
}
/* Code source panel — design's `.cb-source` color tokens override the
   legacy slate.  Wrapped with the id so it beats lower-specificity
   class rules when the body has both `.code-file-body` + `.cb-source`. */
#code-file-body {
    background: oklch(0.20 0.025 195);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0;
    overflow: auto;
    max-height: 80vh;
}
[data-theme="dark"] #code-file-body { background: oklch(0.16 0.025 195); }
.code-browser { width: 100%; border-collapse: collapse; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; line-height: 1.55; }
.code-browser tbody td {
    padding: 0 8px;
    vertical-align: top;
    white-space: pre;
    /* Override the global tbody border-bottom; the colour-coded gutter
       already marks row boundaries, so horizontal lines just add visual
       noise in a monospaced source view. */
    border-bottom: none;
}
.code-line td { border-left: 3px solid transparent; }
.code-line.cov-hit        td { background: rgba(22,163,74,0.07); }
.code-line.cov-miss       td { background: rgba(220,38,38,0.10); }
.code-line.cov-unmeasured td { background: transparent; }
.code-line.cov-hit     .code-gutter { border-left: 3px solid #16a34a; }
.code-line.cov-miss    .code-gutter { border-left: 3px solid #dc2626; }
.code-line.cov-unmeasured .code-gutter { border-left: 3px solid #334155; }
.code-browser .code-gutter { color: #64748b; user-select: none; text-align: right; width: 50px; padding-right: 12px; }
.code-browser .coverage-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: transparent; margin-right: 6px; }
.code-line.cov-hit  .coverage-dot { background: #16a34a; }
.code-line.cov-miss .coverage-dot { background: #dc2626; }
.code-browser .code-findings-cell { width: 60px; text-align: center; }
.code-browser .finding-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin: 0 1px; vertical-align: middle; }
.finding-dot.sev-error   { background: #dc2626; }
.finding-dot.sev-warning { background: #f59e0b; }
.finding-dot.sev-info    { background: #3b82f6; }
.code-browser .code-src  { color: #e2e8f0; width: 100%; }
.code-browser .code-src code { background: transparent; color: inherit; font: inherit; }
/* Inline finding annotation row — renders beneath a code line with
   the rule id + message so issues are visible at a glance.  Tinted by
   severity; left-border-highlighted so it reads as an annotation of
   the row above it. */
.code-annotation td { padding: 6px 10px !important; white-space: normal !important; }
.code-annotation .code-annotation-body { color: #fee2e2; font-family: system-ui, sans-serif; font-size: 12px; line-height: 1.5; }
.code-annotation.sev-error   td { background: rgba(220,38,38,0.22); border-top: 1px solid rgba(220,38,38,0.5); }
.code-annotation.sev-warning td { background: rgba(245,158,11,0.18); border-top: 1px solid rgba(245,158,11,0.5); }
.code-annotation.sev-info    td { background: rgba(59,130,246,0.18); border-top: 1px solid rgba(59,130,246,0.5); }
.code-annotation.sev-error   .code-annotation-body { color: #fecaca; }
.code-annotation.sev-warning .code-annotation-body { color: #fde68a; }
.code-annotation.sev-info    .code-annotation-body { color: #bfdbfe; }
.code-annotation .finding-sev-label { font-weight: 700; font-size: 10px; letter-spacing: 0.5px; padding: 1px 6px; border-radius: 3px; background: rgba(255,255,255,0.12); }
.code-annotation .finding-rule { background: rgba(0,0,0,0.25); padding: 1px 6px; border-radius: 3px; font-size: 11px; }
.code-annotation .finding-message { margin-left: 4px; }
.code-annotation .finding-tool-tag { margin-left: 10px; font-size: 10px; opacity: 0.75; padding: 1px 5px; border-radius: 3px; background: rgba(255,255,255,0.08); text-transform: uppercase; letter-spacing: 0.4px; }
/* AI Fix button on the annotation — floats right, themed by severity
   so it doesn't compete with the message text. */
.code-annotation .code-annotation-body { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.code-annotation .finding-message { flex: 1; min-width: 200px; }
.finding-fix-btn {
    margin-left: auto;
    padding: 4px 12px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.10);
    color: inherit;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.finding-fix-btn:hover { background: rgba(255,255,255,0.20); border-color: rgba(255,255,255,0.45); }
.finding-fix-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.code-line.has-findings .code-src { font-weight: 500; }

/* In-chat ui_intent rendering — bot's structured outputs land
   inside the chat-bubble. */
.chat-ui-title {
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.4px;
    color: var(--text-muted);
    margin: 8px 0 4px;
}
.chat-ui-table-wrap { margin-top: 8px; max-width: 100%; overflow-x: auto; }
.chat-ui-table { font-size: 12px; width: 100%; }
.chat-ui-table th, .chat-ui-table td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}
.chat-ui-chart-wrap {
    margin-top: 8px;
    padding: 10px;
    background: var(--bg-elev, #fff);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
}
.chat-ui-chart {
    width: 100%;
    overflow: hidden;
}
.chat-ui-chart svg { display: block; max-width: 100%; height: auto; }
.chat-ui-chart-legend {
    display: flex; flex-wrap: wrap; gap: 10px;
    margin-top: 6px;
    font-size: 11px; color: var(--text-muted);
}
.chat-ui-chart-legend-item {
    display: inline-flex; align-items: center; gap: 5px;
}
.chat-ui-chart-swatch {
    width: 10px; height: 10px;
    border-radius: 2px;
    display: inline-block;
}
.chat-ui-actions {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-top: 10px;
}
.chat-ui-actions .chat-action-btn {
    text-decoration: none;
    display: inline-block;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    color: var(--brand);
    border: 1px solid var(--border);
    font-size: 12px;
    cursor: pointer;
}
.chat-ui-actions .chat-action-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Bot-rendered Mermaid diagrams — the visual wrapper carries a light
   surface so the SVG (which can be transparent) reads against the
   chat-bubble background. */
.chat-ui-diagram-wrap {
    margin-top: 8px; padding: 10px;
    background: var(--bg-elev, #fff);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
}
.chat-ui-diagram {
    display: flex; justify-content: center;
    overflow-x: auto;
}
.chat-ui-diagram svg { max-width: 100%; height: auto; }
.chat-ui-diagram-caption {
    margin-top: 6px;
    font-size: 11px; color: var(--text-muted);
    text-align: center; font-style: italic;
}
.chat-ui-diagram-fallback {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12px;
    background: var(--bg);
    color: var(--text);
    padding: 8px;
    border-radius: var(--radius-sm, 6px);
    white-space: pre-wrap;
    text-align: left;
}

/* Copy / download toolbar that sits under a chart / table / diagram —
   small ghost buttons; "copied" turns them green for ~1.8s for a
   confirmation flash. */
.chat-visual-toolbar {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-top: 6px;
}
.chat-visual-toolbar-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-sm, 6px);
    background: var(--accent-soft, rgba(0,0,0,0.04));
    color: var(--text);
    border: 1px solid var(--border);
    font-size: 11px; font-weight: 500;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.chat-visual-toolbar-btn:hover:not(:disabled) {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.chat-visual-toolbar-btn:disabled {
    opacity: 0.6; cursor: wait;
}
.chat-visual-toolbar-btn.copied {
    background: var(--accent); color: var(--accent-fg); border-color: var(--accent);
}
.chat-visual-toolbar-btn.failed {
    background: #dc2626; color: #fff; border-color: #dc2626;
}

/* Fullscreen overlay — escape the chat bubble entirely so charts and
   diagrams can use the whole viewport. The wrapper goes position:fixed
   and the SVG inside scales to fill the available space. Body scroll
   is locked so the page doesn't scroll behind the overlay. */
.chat-visual-fullscreen {
    position: fixed !important;
    inset: 0;
    z-index: 9999;
    margin: 0 !important;
    padding: 24px 32px !important;
    background: var(--bg, #0a0a0a);
    border: none !important;
    border-radius: 0 !important;
    display: flex; flex-direction: column;
    overflow: auto;
}
.chat-visual-fullscreen > .chat-ui-title {
    font-size: 16px; margin: 0 0 12px;
}
.chat-visual-fullscreen .chat-ui-chart,
.chat-visual-fullscreen .chat-ui-diagram {
    flex: 1 1 auto;
    min-height: 0;
    display: flex; align-items: center; justify-content: center;
}
.chat-visual-fullscreen .chat-ui-chart svg,
.chat-visual-fullscreen .chat-ui-diagram svg {
    width: 100%; height: 100%;
    max-width: 100%; max-height: 100%;
}
.chat-visual-fullscreen .chat-visual-toolbar {
    margin-top: 12px;
    justify-content: flex-end;
}
.chat-visual-fullscreen-lock { overflow: hidden; }

/* Clickable scan-history rows — hover affordance + pointer cursor.
   The row click handler routes to the scan-detail view. */
.scan-row-clickable,
.finding-row-clickable {
    cursor: pointer;
    transition: background 0.1s ease;
}
.scan-row-clickable:hover,
.finding-row-clickable:hover { background: var(--accent-soft); }

/* Scan-detail summary block — re-uses ``.insights-stat`` cards
   already styled below to avoid a parallel set of rules. */
.scan-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

/* Severity stat cards on the scan-detail view double as toggle
   filters — pointer cursor + subtle hover, ``.active`` ring on the
   selected one, dim the others to make the active filter obvious. */
.insights-stat.stat-filter {
    cursor: pointer;
    transition: background 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}
.insights-stat.stat-filter:hover {
    background: var(--accent-soft);
}
.insights-stat.stat-filter.active {
    box-shadow: 0 0 0 2px var(--accent), var(--shadow-md);
    background: var(--accent-soft);
}
/* When ANY filter is active, fade the inactive sev cards so the
   selected one stands out.  Selector: a stat-filter that's NOT active,
   while the parent contains an active sibling. */
.scan-summary-grid:has(.stat-filter.active) .stat-filter:not(.active) {
    opacity: 0.55;
}

/* ────────── PR verdict panels (scan-detail view) ─────────────── */
/* Verdict banner — one glance answers "does this block my merge?".
   Variants mirror the PR-comment language: blocked / warn / note /
   ok / progress / neutral. */
.scan-verdict {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius, 10px);
    border: 1px solid var(--border);
    background: var(--surface);
    margin-bottom: 14px;
}
.scan-verdict-icon { font-size: 22px; line-height: 1.2; }
.scan-verdict-title { font-weight: 650; font-size: 15px; }
.scan-verdict-sub { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.scan-verdict-blocked {
    border-color: var(--sev-error);
    background: var(--sev-error-soft);
}
.scan-verdict-blocked .scan-verdict-title { color: var(--sev-error); }
.scan-verdict-warn {
    border-color: var(--sev-warning);
    background: var(--sev-warning-soft);
}
.scan-verdict-note { background: var(--sev-warning-soft); }
.scan-verdict-ok {
    border-color: var(--good);
    background: var(--good-soft);
}
.scan-verdict-ok .scan-verdict-title { color: var(--good); }
.scan-verdict-progress .scan-verdict-icon { animation: verdict-pulse 1.6s ease-in-out infinite; }
@keyframes verdict-pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) {
    .scan-verdict-progress .scan-verdict-icon { animation: none; }
}

/* Access-restricted panel (scan-detail view) — same layout as
   .scan-verdict but neutral-toned: this is a permissions issue, not a
   lint verdict, so it shouldn't borrow error/warn/ok coloring. */
.access-denied-panel {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius, 10px);
    border: 1px solid var(--border);
    background: var(--surface);
    margin-bottom: 14px;
}
.access-denied-icon { font-size: 22px; line-height: 1.2; }
.access-denied-title { font-weight: 650; font-size: 15px; }
.access-denied-sub { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* PR meta strip — title link, state, author, branches, commit, mode,
   rating. */
.scan-pr-strip {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
    font-size: 13px;
}
.scan-pr-title { font-weight: 600; }
.scan-pr-meta { color: var(--text-muted); }
.scan-pr-commit {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12px;
    padding: 2px 7px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
}
.badge-pr-state { background: var(--bg-sunk); color: var(--text-muted); border: 1px solid var(--line); }
.badge-pr-open { background: var(--accent-soft); color: var(--accent-strong); border: none; }
.badge-pr-merged { background: var(--good-soft); color: var(--good); border: none; }
.badge-pr-declined { background: var(--sev-error-soft); color: var(--sev-error); border: none; }

/* Quality-gate table */
.badge-gate-pass { background: var(--good-soft); color: var(--good); }
.badge-gate-fail { background: var(--sev-error-soft); color: var(--sev-error); }
.badge-gate-skipped { background: var(--bg-sunk); color: var(--text-faint); border: 1px solid var(--line); }
.gate-row-fail { background: var(--sev-error-soft); }
.gate-detail { color: var(--text-muted); font-size: 12px; }

/* Findings grouped by file (PR scans) */
.file-group-row td {
    background: var(--surface-2);
    border-top: 1px solid var(--border);
    padding-top: 8px;
    padding-bottom: 8px;
}
.file-group-path {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12.5px;
    font-weight: 600;
}
.file-group-count {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 11px;
    font-weight: 600;
}
.file-group-link { margin-left: 10px; font-size: 12px; white-space: nowrap; }

/* Inline code excerpts under finding rows (PR view) */
.row-chevron {
    display: inline-block;
    width: 14px;
    margin-right: 4px;
    color: var(--text-faint);
    font-size: 11px;
}
tr.row-expanded td { border-bottom: none; }
.finding-code-row td {
    padding: 0 12px 12px 32px;
    background: var(--surface);
}
.finding-code-panel .code-snippet { margin-bottom: 0; }
/* Focus-line tint follows the finding's severity, not a fixed color. */
.code-snippet .code-line.focus-error {
    background: var(--sev-error-soft);
    border-left-color: var(--sev-error);
}
.code-snippet .code-line.focus-warning {
    background: var(--sev-warning-soft);
    border-left-color: var(--sev-warning);
}
.code-snippet .code-line.focus-info {
    background: var(--sev-info-soft);
    border-left-color: var(--sev-info);
}
/* Annotation attached under the highlighted line: the linter message
   lives inside the code block, Codacy/Sonar style. */
.code-snippet .code-annotation {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 0 12px 4px 54px;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: var(--surface);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 12.5px;
    line-height: 1.45;
    white-space: normal;
}
.code-snippet .code-annotation .badge { flex: 0 0 auto; }
.code-annotation-rule {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11.5px;
    color: var(--text-muted);
    flex: 0 0 auto;
}
.code-annotation-msg { color: var(--text); }
.code-annotation-error   { border-left: 3px solid var(--sev-error); }
.code-annotation-warning { border-left: 3px solid var(--sev-warning); }
.code-annotation-info    { border-left: 3px solid var(--sev-info); }

.finding-code-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    padding: 8px 2px 0;
    font-size: 12.5px;
}
.finding-code-rule {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12px;
    color: var(--text-muted);
}
.finding-code-bar .btn { margin-left: auto; }

/* ────────── Insights view & narrative card ───────────────────── */
.insights-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.insights-stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow-sm);
}
.insights-stat-num {
    font-size: 24px;
    font-weight: 700;
    color: var(--brand);
    line-height: 1.1;
}
.insights-stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.insights-stat-error .insights-stat-num { color: var(--danger); }
.insights-stat-warning .insights-stat-num { color: var(--warning); }
.insights-stat-info .insights-stat-num { color: var(--info); }

.insights-grid { gap: 16px; margin-bottom: 16px; }

.col-mix { font-variant-numeric: tabular-nums; white-space: nowrap; }

#repo-insights-card .card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-header-actions { display: flex; align-items: center; gap: 8px; }
.insights-meta { font-size: 12px; color: var(--text-muted); }

.markdown-body {
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
}
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
    margin: 16px 0 8px;
    font-weight: 700;
    color: var(--brand);
}
.markdown-body h1 { font-size: 18px; }
.markdown-body h2 { font-size: 16px; }
.markdown-body h3 { font-size: 14px; }
.markdown-body h4 { font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
.markdown-body p  { margin: 6px 0 10px; }
.markdown-body ul, .markdown-body ol { margin: 6px 0 10px; padding-left: 22px; }
.markdown-body li { margin: 2px 0; }
.markdown-body code {
    background: var(--surface-2);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.9em;
}
.markdown-body strong { font-weight: 700; color: var(--brand-2); }

.insights-details {
    margin-top: 14px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
}
.insights-details > summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    padding: 4px 0;
}
.insights-details > summary:hover { color: var(--brand); }
.insights-rollup-tables h4 {
    margin: 14px 0 6px;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.insights-rollup-tables h4:first-child { margin-top: 8px; }

/* ── Plan view ────────────────────────────────────────────────
   Today's plan + execution state.  Each step renders as a card
   inside a status bucket; pending_review steps show an Approve
   button that calls the admin ack endpoint. */

.plan-date-input {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    background: var(--surface);
    color: var(--text);
}

.plan-bucket {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    margin-bottom: 16px;
}
.plan-bucket-title {
    margin: 0 0 12px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}
.plan-bucket-count {
    font-size: 11px;
    background: var(--surface-2);
    color: var(--text);
    padding: 1px 8px;
    border-radius: 999px;
    font-weight: 500;
    letter-spacing: 0;
}

/* Per-bucket accent colours so the operator scans status visually.
   OKLCH so they shift in dark mode automatically. */
.plan-bucket--review .plan-bucket-title { color: oklch(0.5 0.15 70); }
.plan-bucket--review { border-left: 3px solid var(--sev-warning); }
.plan-bucket--running .plan-bucket-title { color: var(--sev-info); }
.plan-bucket--running { border-left: 3px solid var(--sev-info); }
.plan-bucket--pending .plan-bucket-title { color: var(--text-muted); }
.plan-bucket--done .plan-bucket-title { color: var(--accent-strong); }
.plan-bucket--done { border-left: 3px solid var(--accent); }
.plan-bucket--skipped { opacity: 0.85; }
.plan-bucket--failed .plan-bucket-title { color: var(--sev-error); }
.plan-bucket--failed { border-left: 3px solid var(--sev-error); }
.plan-bucket--offplan .plan-bucket-title { color: oklch(0.55 0.14 290); }
.plan-bucket--offplan { border-left: 3px solid oklch(0.55 0.14 290); }

/* Off-plan table — long rationales would otherwise blow past the
   parent because .simple-table's global nowrap forces single-line
   cells.  Fix the layout, let rationale + artifacts wrap, keep the
   timestamp column on one line. */
.plan-bucket--offplan .simple-table {
    width: 100%;
    table-layout: fixed;
}
.plan-bucket--offplan .simple-table th,
.plan-bucket--offplan .simple-table td {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    vertical-align: top;
}
.plan-bucket--offplan .simple-table th:nth-child(1),
.plan-bucket--offplan .simple-table td:nth-child(1) { width: 18%; }
.plan-bucket--offplan .simple-table th:nth-child(2),
.plan-bucket--offplan .simple-table td:nth-child(2) { width: 42%; }
.plan-bucket--offplan .simple-table th:nth-child(3),
.plan-bucket--offplan .simple-table td:nth-child(3) { width: 22%; }
.plan-bucket--offplan .simple-table th:nth-child(4),
.plan-bucket--offplan .simple-table td:nth-child(4) {
    width: 18%;
    white-space: nowrap;
}

.plan-step-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
}

.plan-step-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.plan-step-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.plan-step-id code {
    font-size: 12px;
    background: var(--surface);
    padding: 2px 6px;
    border-radius: 4px;
}
.plan-step-meta {
    font-size: 12px;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.plan-step-meta code {
    font-size: 11px;
    background: var(--surface);
    padding: 1px 4px;
    border-radius: 3px;
}
.plan-step-rationale {
    margin: 0;
    font-size: 13px;
    color: var(--text);
    line-height: 1.5;
    white-space: pre-wrap;  /* preserve [calibration] footer line breaks */
}
.plan-step-calibration {
    background: var(--surface);
    border-left: 2px solid var(--accent);
    padding: 6px 10px;
    border-radius: 0 4px 4px 0;
    font-size: 12px;
}
.plan-step-calibration ul {
    margin: 4px 0 0;
    padding-left: 16px;
}
.plan-step-reason {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--surface);
    padding: 6px 10px;
    border-radius: 4px;
}
.plan-step-artifacts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.plan-step-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}

/* Per-outcome card accent — subtle so the bucket border carries
   most of the visual weight. */
.plan-step--pending_review { background: #fffbeb; }  /* amber-50 */
.plan-step--running { background: #eff6ff; }         /* blue-50 */
.plan-step--done    { background: var(--accent-soft); }
.plan-step--failed  { background: #fef2f2; }         /* red-50 */

.plan-artifact {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 11px;
}
.plan-artifact-type {
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-size: 10px;
}
.plan-artifact code {
    background: transparent;
    padding: 0;
    font-size: 11px;
}
.plan-artifact--link { color: var(--accent); }

.badge.badge-warn {
    background: #fef3c7;     /* amber-100 */
    color: #92400e;          /* amber-800 */
    border-color: #fcd34d;
}
.badge.badge-ok {
    background: #dcfce7;     /* green-100 */
    color: #166534;          /* green-800 */
    border-color: #86efac;
}
.badge.badge-err {
    background: #fee2e2;     /* red-100 */
    color: #991b1b;          /* red-800 */
    border-color: #fca5a5;
}
.card .card-title { margin: 0 0 4px; font-size: 15px; }
.badge.badge-priority {
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* ============================================================
   DESIGN HANDOFF — new component primitives (May 2026 reskin)
   ============================================================
   Anything below this line was added during the migration to the
   new visual system.  Where it overlaps with screen-specific
   selectors above, the cascade order favours these — that's
   intentional, the design is the source of truth.
*/

/* ── Severity / status / tag chips (design's chip set) ──────── */
.sev {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 2px 8px 2px 6px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.sev::before {
    content: ""; width: 4px; height: 4px; border-radius: 1px;
    background: currentColor;
}
.sev-error   { background: var(--sev-error-soft);   color: var(--sev-error); }
.sev-warning { background: var(--sev-warning-soft); color: oklch(0.45 0.14 60); }
.sev-info    { background: var(--sev-info-soft);    color: var(--sev-info); }
[data-theme="dark"] .sev-warning { color: oklch(0.85 0.13 80); }

[data-sev-style="bar"] .sev { padding-left: 8px; position: relative; padding-right: 8px; background: transparent; border-radius: 0; }
[data-sev-style="bar"] .sev::before { display: none; }
[data-sev-style="bar"] .sev::after { content: ""; position: absolute; left: 0; top: 1px; bottom: 1px; width: 3px; border-radius: 2px; background: currentColor; }

.status-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    border: 1px solid var(--line);
    color: var(--text-muted);
}
.status-chip.s-open { color: var(--accent-strong); border-color: var(--accent-soft); background: var(--accent-soft); }
.status-chip.s-dismissed { color: var(--text-faint); }
.status-chip.s-fixed { color: var(--sev-info); border-color: var(--sev-info-soft); }
.status-chip .dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }

.tag {
    display: inline-flex; align-items: center;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    background: var(--bg-sunk);
    color: var(--text-muted);
    border: 1px solid var(--line);
}

/* Rating badge — A/B/C/D/F squared tile.  The existing app uses
   `rating-badge` with a data-grade attribute and `--grade-*` vars
   for color; we keep that working but ALSO support the design's
   `.rating .rating-A` etc. classes via an additive ruleset. */
.rating {
    display: inline-grid; place-items: center;
    width: 28px; height: 28px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    letter-spacing: -0.04em;
}
.rating-A { background: var(--good-soft); color: var(--good); }
.rating-B { background: oklch(0.85 0.10 130 / 0.25); color: oklch(0.40 0.13 130); }
.rating-C { background: oklch(0.82 0.13 80 / 0.25); color: oklch(0.40 0.14 60); }
.rating-D { background: oklch(0.78 0.16 50 / 0.25); color: oklch(0.42 0.14 40); }
.rating-F { background: var(--sev-error-soft); color: var(--sev-error); }
[data-theme="dark"] .rating-B { background: oklch(0.45 0.13 130 / 0.3); color: oklch(0.85 0.13 130); }
[data-theme="dark"] .rating-C { background: oklch(0.45 0.14 80 / 0.3); color: oklch(0.85 0.13 80); }
[data-theme="dark"] .rating-D { background: oklch(0.45 0.14 50 / 0.3); color: oklch(0.85 0.13 50); }

.mode-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.mode-soft { background: oklch(0.82 0.12 80 / 0.2); color: oklch(0.42 0.14 60); }
.mode-hard { background: var(--sev-error-soft); color: var(--sev-error); }
.mode-off  { background: var(--bg-sunk); color: var(--text-muted); border: 1px solid var(--line); }
[data-theme="dark"] .mode-soft { background: oklch(0.45 0.14 70 / 0.3); color: oklch(0.85 0.13 80); }

/* ── View bar — sticky strip below the header (Repo Detail etc.) ── */
.view-bar {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 28px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-elev);
    flex-wrap: wrap;
}
.view-bar .crumb {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 12px; color: var(--text-muted); font-weight: 500;
}
.view-bar .crumb:hover { color: var(--text); }
.view-bar .view-title {
    font-size: 18px; font-weight: 600; letter-spacing: -0.015em;
    display: flex; align-items: center; gap: 10px; margin: 0;
}
.view-bar .view-title .repo-name {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 16px; font-weight: 600;
}
.view-bar .spacer { flex: 1; }
.divider-v { width: 1px; height: 18px; background: var(--line); }

/* Button cluster — segmented row of buttons sharing one outline. */
.btn-cluster {
    display: inline-flex;
    border: 1px solid var(--line);
    background: var(--bg-elev);
    border-radius: 8px;
    overflow: hidden;
}
.btn-cluster .btn {
    border-radius: 0;
    border: 0;
    border-right: 1px solid var(--line);
    height: 32px;
}
.btn-cluster .btn:last-child { border-right: 0; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg-sunk); }
.btn-icon { width: 32px; padding: 0; justify-content: center; }
.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; gap: 6px; border-radius: 6px; }

/* ── Quality Evolution hero (used on Dashboard + Repo Detail) ─── */
.qe-hero { padding: 22px 24px 8px; }
.qe-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.qe-title {
    font-size: 13px; text-transform: uppercase; letter-spacing: 0.1em;
    font-weight: 600; color: var(--text-muted);
}
.qe-summary {
    font-size: 28px; font-weight: 600; letter-spacing: -0.02em;
    margin: 4px 0 18px;
}
.qe-summary .accent-num { font-family: 'JetBrains Mono', ui-monospace, monospace; font-weight: 600; }
.qe-summary em { font-style: normal; color: var(--text-muted); font-weight: 400; }

.qe-tabs {
    display: inline-flex; align-items: center; gap: 0;
    border: 1px solid var(--line); border-radius: 8px;
    padding: 2px; background: var(--bg-elev);
}
.qe-tabs button {
    padding: 5px 10px; font-size: 12px; font-weight: 500;
    border-radius: 6px; color: var(--text-muted);
    background: none; border: 0; cursor: pointer; font-family: inherit;
}
.qe-tabs button.active { background: var(--bg-sunk); color: var(--text); }
.qe-tabs button:hover:not(.active) { color: var(--text); }

.qe-metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    margin: 16px -24px 0;
    padding: 0;
}
.qe-metric {
    padding: 14px 24px;
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column; gap: 2px;
    cursor: pointer;
    position: relative;
    background: none; border-top: 0; border-bottom: 0; border-left: 0;
    text-align: left; font-family: inherit;
}
.qe-metric:last-child { border-right: 0; }
.qe-metric .lbl {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; color: var(--text-muted); font-weight: 500;
}
.qe-metric .lbl .dot {
    width: 8px; height: 8px; border-radius: 2px;
    background: var(--metric-color, var(--accent));
}
.qe-metric .val {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 26px; font-weight: 600; letter-spacing: -0.025em;
}
.qe-metric .val .unit {
    font-size: 13px; color: var(--text-muted);
    margin-left: 4px; font-weight: 500;
}
.qe-metric .delta {
    font-size: 11.5px; font-weight: 500;
    display: inline-flex; align-items: center; gap: 3px;
}
.qe-metric.active::before {
    content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
    height: 2px; background: var(--metric-color, var(--accent));
}
.delta-up { color: var(--sev-error); }
.delta-down { color: oklch(0.55 0.14 145); }
.delta-flat { color: var(--text-muted); }

.qe-chart {
    height: 240px;
    margin: 0 -8px;
    padding: 16px 8px 8px;
}

/* ── QE hero loading skeleton ─────────────────────────────────
   While the trend fetch is in flight the tiles/summary/chart show
   shimmer placeholders instead of bare em-dashes ("no data"). */
@keyframes qe-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.qe-chart-skel {
    height: 100%;
    border-radius: var(--radius);
    background: linear-gradient(100deg,
        var(--bg-sunk) 40%, var(--bg-elev) 50%, var(--bg-sunk) 60%);
    background-size: 200% 100%;
    animation: qe-shimmer 1.4s linear infinite;
}
.qe-loading [data-qe-num],
.qe-loading .qe-metric .delta {
    color: transparent !important;
    border-radius: 5px;
    background: linear-gradient(100deg,
        var(--bg-sunk) 40%, var(--bg-elev) 50%, var(--bg-sunk) 60%);
    background-size: 200% 100%;
    animation: qe-shimmer 1.4s linear infinite;
    user-select: none;
}
.qe-loading [data-qe-num] { display: inline-block; min-width: 64px; }
.qe-loading .qe-summary {
    min-height: 1.25em;
    border-radius: 6px;
    max-width: 420px;
    background: linear-gradient(100deg,
        var(--bg-sunk) 40%, var(--bg-elev) 50%, var(--bg-sunk) 60%);
    background-size: 200% 100%;
    animation: qe-shimmer 1.4s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
    .qe-chart-skel,
    .qe-loading [data-qe-num],
    .qe-loading .qe-metric .delta,
    .qe-loading .qe-summary { animation: none; }
}

/* ── Cards (design's variant) — additive over the existing .card ── */
.card-h {
    padding: 16px 20px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}
.card-h h3 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.card-h .meta { font-size: 12px; color: var(--text-muted); }
.card-h .spacer { flex: 1; }
.card-b { padding: 16px 20px 20px; }

/* Two splits used heavily in the design */
.split-2  { display: grid; grid-template-columns: 1.4fr 2fr; gap: 20px; align-items: stretch; }
.split-1-1 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: stretch; }
@media (max-width: 1100px) {
    .split-2, .split-1-1 { grid-template-columns: 1fr; }
}

/* Content container — wider than the legacy 1200 max-width to give
   the design's denser layout breathing room. */
.content-wide {
    padding: 24px 28px 80px;
    max-width: 1480px;
    margin: 0 auto;
    display: flex; flex-direction: column;
    gap: 20px;
}

/* ── Tables (design's `.tbl`) ──────────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl thead th {
    text-align: left;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-sunk);
    position: sticky; top: 0;
}
.tbl tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    height: var(--row-h);
    vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--bg-sunk); }
.tbl tbody tr.is-selected { background: var(--accent-soft); }
.tbl tbody td.num, .tbl thead th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-tight tbody td { padding: 7px 12px; }

.tbl-wrap { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg-elev); }

.path { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12.5px; color: var(--text); }
.path .dim { color: var(--text-faint); }

/* ── Filter bar (design) ──────────────────────────────────────── */
.filter-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-sunk);
    flex-wrap: wrap;
}
.filter-bar .field { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.filter-bar .field label {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--text-faint); font-weight: 600;
}
.filter-bar .field select, .filter-bar .field input {
    height: 30px; padding: 0 10px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: var(--bg-elev);
    color: var(--text);
    font-size: 13px;
    min-width: 110px;
}
.filter-bar .field input:focus,
.filter-bar .field select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.filter-bar .spacer { flex: 1; }
.filter-bar .count { color: var(--text-muted); font-size: 12px; font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* ── Files-by-rating list (Repo Detail) ────────────────────────── */
.fbr { display: flex; flex-direction: column; }
.fbr-row {
    display: grid;
    grid-template-columns: 28px 32px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dashed var(--line);
    font-size: 13px;
}
.fbr-row:last-child { border-bottom: 0; }
.fbr-row .idx {
    color: var(--text-faint);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11.5px; text-align: right;
}
.fbr-row .score {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    color: var(--text-muted); font-size: 12px;
}
.fbr-row:hover { background: var(--bg-sunk); }

/* ── Category banner (Repo Detail) ─────────────────────────────── */
.cat-banner {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 28px; align-items: center;
    padding: 22px 24px;
}
.cat-total .num-big {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 56px; font-weight: 600;
    letter-spacing: -0.04em;
    color: var(--accent-strong);
    line-height: 1;
}
.cat-total .lbl {
    font-size: 11.5px; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.1em;
    font-weight: 600; margin-top: 6px;
}
.cat-list {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 18px;
}
.cat-item { display: flex; flex-direction: column; gap: 6px; }
.cat-item .top {
    display: flex; justify-content: space-between; align-items: baseline;
}
.cat-item .name { font-size: 12.5px; font-weight: 500; }
.cat-item .v {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 13px; font-weight: 600;
}
.cat-bar {
    height: 4px; border-radius: 2px;
    background: var(--bg-sunk);
    overflow: hidden; position: relative;
}
.cat-bar > span {
    display: block; height: 100%; border-radius: 2px;
}
@media (max-width: 1100px) { .cat-list { grid-template-columns: repeat(2, 1fr); } }

/* Dashboard variant — single-column row with wider bar */
.cat-bar-row {
    display: grid;
    grid-template-columns: 130px 1fr 56px;
    gap: 14px; align-items: center;
    padding: 4px 0;
}
.cat-bar-row .name { font-size: 13px; font-weight: 500; }
.cat-bar-row .track {
    height: 12px; background: var(--bg-sunk);
    border-radius: 3px; overflow: hidden;
}
.cat-bar-row .fill { height: 100%; border-radius: 3px; }
.cat-bar-row .v {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-weight: 600; font-variant-numeric: tabular-nums;
    font-size: 13px; text-align: right;
}

/* ── Insights card markdown narrative ──────────────────────────── */
.insights-narrative {
    padding: 22px 24px 24px;
}
.insights-narrative h2 {
    font-size: 18px; font-weight: 600; letter-spacing: -0.015em;
    margin: 12px 0 10px;
}
.insights-narrative h3 {
    font-size: 13px; font-weight: 600;
    margin: 18px 0 6px;
    color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.08em;
}
.insights-narrative p {
    margin: 0 0 10px; line-height: 1.6;
    max-width: 78ch; color: var(--text);
}
.insights-narrative p strong { font-weight: 600; }
.insights-narrative p code {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12.5px; padding: 1px 5px;
    background: var(--bg-sunk);
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--accent-strong);
}
.insights-narrative .quote {
    border-left: 2px solid var(--accent);
    padding-left: 14px; margin: 12px 0;
    color: var(--text-muted);
}
.collapse-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12.5px; color: var(--text-muted);
    padding: 6px 0;
    background: none; border: 0; cursor: pointer; font-family: inherit;
}
.collapse-toggle svg { transition: transform .18s; }
.collapse-toggle.open svg { transform: rotate(90deg); }

.eyebrow {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--text-faint); font-weight: 600;
}

/* ── Repo grid + tile (Dashboard) ──────────────────────────────── */
.repo-grid-design {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}
.repo-tile {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 18px 20px 16px;
    display: flex; flex-direction: column;
    gap: 12px;
    cursor: pointer;
    transition: border-color .12s, transform .08s, box-shadow .12s;
    min-height: 210px;
    box-shadow: var(--shadow-card);
}
.repo-tile:hover {
    border-color: var(--line-strong);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px -6px oklch(0.2 0.01 240 / 0.10);
}
.repo-tile .head { display: flex; align-items: flex-start; gap: 10px; }
.repo-tile .name {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-weight: 600; font-size: 15px;
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    letter-spacing: -0.015em;
}
.repo-tile .branch-row {
    display: flex; align-items: center; gap: 8px;
    font-size: 12.5px; color: var(--text-muted);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.repo-tile .counts-row {
    display: flex; gap: 16px; font-size: 12.5px;
}
.repo-tile .counts-row .lbl { color: var(--text-muted); margin-right: 5px; font-weight: 500; }
.repo-tile .counts-row .val {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-weight: 600; font-variant-numeric: tabular-nums;
}
.repo-tile hr { border: 0; border-top: 1px solid var(--line); margin: 0; }
.repo-tile .spark-area {
    flex: 1; min-height: 56px;
    display: flex; align-items: center;
}
.repo-tile .spark { width: 100%; height: 56px; }
.repo-tile .footer { font-size: 11.5px; color: var(--text-muted); }
@media (max-width: 720px) { .repo-grid-design { grid-template-columns: 1fr; } }

/* ── Files list table (Code) ───────────────────────────────────── */
.files-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.files-tbl thead th {
    text-align: left; padding: 14px 16px;
    font-size: 10.5px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-faint);
    border-bottom: 1px solid var(--line);
    background: var(--bg-sunk);
    position: sticky; top: 0;
}
.files-tbl tbody td {
    padding: 0 16px; height: 56px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.files-tbl tbody tr { cursor: pointer; transition: background-color .08s; }
.files-tbl tbody tr:hover { background: var(--bg-sunk); }
.files-tbl .col-rating { width: 58px; }
.files-tbl .col-cov    { width: 220px; }
.files-tbl .col-lines  {
    width: 110px; text-align: right;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}
.files-tbl .col-issues { width: 80px; text-align: right; }
.files-tbl .filepath {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 13px; font-weight: 500;
}
.files-tbl .filepath .dim { color: var(--text-faint); font-weight: 400; }
.cov-cell { display: flex; align-items: center; gap: 12px; }
.cov-track {
    flex: 1; height: 8px;
    background: var(--bg-sunk);
    border-radius: 2px; overflow: hidden;
    max-width: 130px;
}
.cov-fill { height: 100%; }
.cov-val {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-variant-numeric: tabular-nums;
    font-size: 12px; color: var(--text-muted);
    width: 48px; text-align: right;
}
.issue-pill {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 26px; height: 22px;
    padding: 0 8px; border-radius: 999px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-weight: 600; font-size: 11px;
    font-variant-numeric: tabular-nums;
}
.issue-pill.has  { background: var(--sev-error-soft); color: var(--sev-error); }
.issue-pill.zero { background: var(--bg-sunk); color: var(--text-faint); }

/* ── Code browser (file source) ────────────────────────────────── */
.cb {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 16px;
    height: calc(100vh - 180px);
    min-height: 600px;
}
.cb-tree {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    display: flex; flex-direction: column;
    gap: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-card);
}
.cb-tree .filter {
    width: 100%; padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--bg-sunk);
    font: inherit; font-size: 13px; color: var(--text);
}
.cb-tree .filter:focus {
    outline: 0; border-color: var(--accent);
    background: var(--bg-elev);
}
.cb-tree .scroll { flex: 1; overflow-y: auto; padding-right: 4px; }
.cb-tree .tree-row {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px; line-height: 1;
}
.cb-tree .tree-row:hover { background: var(--bg-sunk); }
.cb-tree .tree-row.active {
    background: var(--accent-soft);
    color: var(--accent-strong);
}
.cb-tree .tree-row .chev {
    width: 12px; color: var(--text-faint);
    transition: transform .12s;
    flex-shrink: 0;
}
.cb-tree .tree-row.open .chev { transform: rotate(90deg); }
.cb-tree .tree-row .nm {
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.cb-tree .tree-row .ct {
    background: var(--bg-sunk); color: var(--text-faint);
    padding: 1px 7px; border-radius: 999px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10.5px; font-weight: 600;
}
.cb-tree .tree-row.active .ct {
    background: oklch(var(--accent-l) var(--accent-c) var(--accent-h) / 0.2);
    color: var(--accent-strong);
}
.cb-tree .tree-row .folder-icon {
    width: 14px; height: 14px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.cb-tree .tree-children {
    padding-left: 18px;
    display: flex; flex-direction: column;
    gap: 1px;
}

.cb-source {
    background: oklch(0.20 0.025 195);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    display: flex; flex-direction: column;
    box-shadow: var(--shadow-card);
}
[data-theme="dark"] .cb-source { background: oklch(0.16 0.025 195); }
.cb-code {
    flex: 1; overflow: auto;
    font-family: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 12.5px; line-height: 1.55;
    color: oklch(0.95 0.005 200);
}
.cb-line {
    display: grid;
    grid-template-columns: 28px 48px 1fr;
    align-items: center;
    padding: 0 14px 0 0;
    min-height: 22px;
}
.cb-line .gut-dot {
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 999px;
    margin: 0 auto;
}
.gut-covered    { background: oklch(0.65 0.16 145); }
.gut-uncovered  { background: oklch(0.6 0.2 25); }
.gut-noexec     { background: oklch(0.42 0.025 200); }
.cb-line .lnum {
    text-align: right; padding-right: 14px;
    color: oklch(0.55 0.025 200);
    font-variant-numeric: tabular-nums;
    user-select: none;
    font-size: 11.5px;
}
.cb-line .cd { white-space: pre; overflow: visible; }
.cb-line.hl-warn { background: oklch(0.32 0.05 25 / 0.4); }
.cb-line.hl-info { background: oklch(0.32 0.05 240 / 0.3); }

/* python-ish syntax highlighting */
.tk-kw  { color: oklch(0.78 0.14 320); font-weight: 500; }
.tk-str { color: oklch(0.78 0.14 70); }
.tk-com { color: oklch(0.55 0.025 200); font-style: italic; }
.tk-fn  { color: oklch(0.82 0.12 200); }
.tk-num { color: oklch(0.78 0.14 70); }
.tk-cls { color: oklch(0.82 0.12 145); }
.tk-tag { color: oklch(0.85 0.025 200); }

.finding-row {
    background: oklch(0.32 0.06 25 / 0.35);
    border-top: 1px solid oklch(0.5 0.15 25 / 0.3);
    border-bottom: 1px solid oklch(0.5 0.15 25 / 0.3);
    padding: 10px 14px 12px 76px;
    display: grid;
    grid-template-columns: auto auto auto 1fr auto auto;
    gap: 10px; align-items: start;
    color: oklch(0.95 0.025 25);
    font-size: 12.5px; line-height: 1.55;
}
.finding-row.info  { background: oklch(0.32 0.06 240 / 0.32); border-color: oklch(0.5 0.15 240 / 0.3); color: oklch(0.93 0.02 240); }
.finding-row .sev-bubble {
    display: inline-flex; align-items: center;
    padding: 3px 9px; border-radius: 4px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10.5px; font-weight: 700;
    letter-spacing: 0.06em; text-transform: uppercase;
}
.finding-row.error .sev-bubble { background: oklch(0.55 0.2 25); color: white; }
.finding-row.info  .sev-bubble { background: oklch(0.55 0.18 240); color: white; }
.finding-row .rid {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-weight: 600; font-size: 12px;
    padding: 3px 9px; border-radius: 4px;
    background: oklch(0.4 0.05 200 / 0.3);
    color: oklch(0.92 0.02 200);
}
.finding-row .dot-sep { color: oklch(0.6 0.025 200); }
.finding-row .msg { color: inherit; max-width: 720px; }
.finding-row .ttag {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10.5px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em;
    padding: 3px 8px; border-radius: 4px;
    background: oklch(0.4 0.05 200 / 0.4);
    color: oklch(0.85 0.02 200);
}
.finding-row .fix-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px; border-radius: 6px;
    background: oklch(0.95 0.005 100);
    color: oklch(0.25 0.05 320);
    font-weight: 600; font-size: 12px;
    border: 0; cursor: pointer; font-family: inherit;
}
.finding-row .fix-btn:hover { background: white; }

.legend {
    display: flex; align-items: center; gap: 14px;
    font-size: 12px; color: var(--text-muted);
}
.legend .item { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 2px; }
.legend .sw.cov { background: oklch(0.65 0.16 145); }
.legend .sw.unc { background: oklch(0.6 0.2 25); }
.legend .sw.nox { background: oklch(0.78 0.005 100); border: 1px solid var(--line); }

/* ── Today's Plan ──────────────────────────────────────────────── */
.plan-meta-bar {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 18px;
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: 12px;
    flex-wrap: wrap;
    box-shadow: var(--shadow-card);
}
.plan-meta-bar .lbl {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-faint); font-weight: 600;
}
.plan-meta-bar .v {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 13px; font-weight: 500;
}
.plan-meta-bar .div { width: 1px; height: 20px; background: var(--line); }
.plan-meta-bar input[type="date"] {
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--bg-elev);
    font: inherit; font-size: 12.5px;
    color: var(--text);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}

.plan-tabs {
    display: flex; gap: 6px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    margin-bottom: 0;
}
.plan-tab {
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: transparent;
    font-size: 13px; font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex; gap: 8px; align-items: center;
    font-family: inherit;
}
.plan-tab .ct {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11px; padding: 1px 7px;
    border-radius: 999px;
    background: var(--bg-sunk);
    color: var(--text-faint);
    font-weight: 600;
}
.plan-tab.active {
    background: var(--bg-elev);
    border-color: var(--line);
    color: var(--text);
}
.plan-tab.active .ct { background: var(--accent-soft); color: var(--accent-strong); }

.plan-step {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0;
    margin-bottom: 8px;
    transition: border-color .12s;
    box-shadow: var(--shadow-card);
}
.plan-step:hover { border-color: var(--line-strong); }
.plan-step.expanded { border-color: var(--accent); }
.plan-step.pending  { border-left: 3px solid var(--sev-warning); }
.plan-step.done     { border-left: 3px solid var(--accent); }
.plan-step.offplan  { border-left: 3px solid oklch(0.55 0.14 290); }

.plan-step-head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 18px; align-items: center;
    padding: 14px 18px;
    cursor: pointer;
}
.plan-step-head:hover { background: var(--bg-sunk); }
.plan-step .id-col {
    display: flex; align-items: center; gap: 10px;
    flex-wrap: wrap;
}
.plan-step .step-id {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12.5px; font-weight: 600;
    padding: 3px 9px; border-radius: 5px;
    background: var(--bg-sunk);
    color: var(--text);
}
.plan-step .meta-col {
    font-size: 12.5px; color: var(--text-muted);
    display: flex; gap: 18px; flex-wrap: wrap; align-items: center;
}
.plan-step .meta-col .item {
    display: inline-flex; gap: 5px; align-items: center;
}
.plan-step .meta-col .lbl {
    font-size: 10.5px; text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-faint); font-weight: 600;
}
.plan-step .meta-col .v {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-weight: 500; color: var(--text);
}
.plan-step .actions-col { display: flex; gap: 8px; align-items: center; }
.plan-step .chev { color: var(--text-faint); transition: transform .15s; }
.plan-step.expanded .chev { transform: rotate(90deg); }

.plan-step-body {
    display: none;
    padding: 0 18px 18px 18px;
    border-top: 1px dashed var(--line);
    margin-top: 0;
}
.plan-step.expanded .plan-step-body { display: block; }
.plan-step-body .ratio {
    padding-top: 14px;
    font-size: 13px; line-height: 1.6;
    color: var(--text);
}
.plan-step-body .ratio h5 {
    font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-faint); font-weight: 600;
    margin: 0 0 8px;
}
.plan-step-body .ratio ul {
    margin: 8px 0; padding-left: 20px;
    color: var(--text-muted);
}
.plan-step-body .ratio ul li { margin-bottom: 6px; }
.plan-step-body .ratio code {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12px; padding: 1px 5px;
    background: var(--bg-sunk);
    border-radius: 3px;
    color: var(--accent-strong);
}
.plan-step-body .footer-row {
    display: flex; gap: 10px; align-items: center;
    padding-top: 12px; margin-top: 12px;
    border-top: 1px dashed var(--line);
}
.plan-step-body .footer-row input[type="text"] {
    flex: 1; max-width: 360px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--bg-sunk);
    font: inherit; font-size: 13px;
    color: var(--text);
}
.plan-step-body .artifact-tags {
    display: flex; gap: 8px; flex-wrap: wrap;
    padding-top: 12px; margin-top: 12px;
    border-top: 1px dashed var(--line);
}
.plan-step-body .art-tag {
    display: inline-flex; gap: 6px; align-items: center;
    padding: 4px 8px; border-radius: 5px;
    background: var(--bg-sunk);
    font-size: 11.5px;
}
.plan-step-body .art-tag .k {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em;
    color: var(--text-faint); font-weight: 600;
}
.plan-step-body .art-tag .v {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-weight: 500; color: var(--text);
}

/* ── Modal (design's variant — overlay + card) ─────────────────── */
.modal-back {
    position: fixed; inset: 0;
    background: oklch(0.1 0.005 240 / 0.32);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 80px 20px 40px;
    overflow-y: auto;
}
.modal-design {
    background: var(--bg-elev);
    border-radius: 14px;
    box-shadow: var(--shadow-pop);
    border: 1px solid var(--line);
    width: 560px; max-width: 100%;
    overflow: hidden;
}
.modal-design .modal-h {
    padding: 18px 22px 14px;
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 10px;
}
.modal-design .modal-h h2 {
    font-size: 16px; font-weight: 600;
    letter-spacing: -0.01em; flex: 1; margin: 0;
}
.modal-design .modal-b { padding: 18px 22px 8px; }
.modal-design .modal-f {
    padding: 14px 22px;
    border-top: 1px solid var(--line);
    background: var(--bg-sunk);
    display: flex; gap: 10px;
    justify-content: flex-end;
}
.field-design {
    display: flex; flex-direction: column;
    gap: 6px; margin-bottom: 14px;
}
.field-design label {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-faint); font-weight: 600;
}
.field-design input[type="text"],
.field-design input[type="url"],
.field-design select,
.field-design textarea {
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--bg-elev);
    font: inherit; font-size: 13px;
    color: var(--text);
}
.field-design input:focus,
.field-design select:focus,
.field-design textarea:focus {
    outline: 0;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-design .help { font-size: 11.5px; color: var(--text-muted); }
.field-design .row { display: flex; gap: 10px; }
.field-design .row > * { flex: 1; }

.choice-row { display: flex; gap: 10px; }
.choice {
    flex: 1; padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
    transition: all .1s;
    display: flex; flex-direction: column; gap: 4px;
}
.choice:hover { border-color: var(--line-strong); }
.choice.selected {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.choice .nm { font-size: 12.5px; font-weight: 600; }
.choice .ds { font-size: 11.5px; color: var(--text-muted); }

/* ── Repo Detail re-skin overrides ─────────────────────────────────
   Existing markup paired with new design's visual language: tighter
   tables, design-aligned filter bar, redesigned files-by-rating list,
   compact commit/PR tables.  No JS render changes needed. */

/* View header: borrow design's view-bar look (border, padding) but
   keep the inline structure of the existing render. */
.view-header {
    padding: 16px 0 14px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--line);
}
#view-repo .view-header,
#view-repo-settings .view-header,
#view-code .view-header,
#view-code-file .view-header,
#view-scans .view-header,
#view-scan .view-header,
#view-commit .view-header,
#view-plan .view-header { padding: 18px 0 14px; }
.view-header h1 { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; }
.view-header .repo-name,
.view-header h1 .mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* Files-by-rating list — re-skin existing <ol class="file-list">
   to use the design's `.fbr` row layout. */
.file-list {
    list-style: none;
    padding: 0; margin: 0;
    display: flex; flex-direction: column;
}
.file-list li {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px dashed var(--line);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.08s;
}
.file-list li:last-child { border-bottom: 0; }
.file-list li:hover { background: var(--bg-sunk); }
.file-list .file-name {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12.5px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-list .file-score {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12px;
    color: var(--text-muted);
    float: none;
    white-space: nowrap;
}

/* Filter toolbar → filter-bar look (sunk bg, eyebrow labels). */
.filter-toolbar {
    background: var(--bg-sunk);
    border-color: var(--line);
    padding: 12px 16px;
    border-radius: 10px 10px 0 0;
    margin-bottom: 0;
    gap: 10px;
}
.filter-toolbar label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-faint);
}
.filter-toolbar select,
.filter-toolbar input {
    height: 30px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: var(--bg-elev);
    font-size: 13px;
    min-width: 110px;
    padding: 0 10px;
}
.filter-toolbar input:focus,
.filter-toolbar select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.findings-count {
    color: var(--text-muted);
    font-size: 12px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}

/* Findings table: align with design's `.tbl` look (uppercase eyebrow
   headers, dashed row dividers, subtle hover). */
.findings-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.findings-table thead th {
    text-align: left;
    font-size: 10.5px; font-weight: 600;
    letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--text-faint);
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-sunk);
}
.findings-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    height: var(--row-h);
    vertical-align: middle;
}
.findings-table tbody tr:last-child td { border-bottom: 0; }
.findings-table tbody tr { cursor: pointer; transition: background 0.08s; }
.findings-table tbody tr:hover { background: var(--bg-sunk); }

/* Compact tables (PRs / commits / AI sessions / scans) */
.simple-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.simple-table thead th {
    text-align: left;
    font-size: 10.5px; font-weight: 600;
    letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--text-faint);
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-sunk);
}
.simple-table tbody td {
    padding: 7px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.simple-table tbody tr:last-child td { border-bottom: 0; }
.simple-table tbody tr:hover { background: var(--bg-sunk); }

/* PR / commit / AI sessions tables share the tight padding spec. */
.pr-table tbody td,
.commit-table tbody td,
.remediations-table tbody td,
.scans-table tbody td { padding: 7px 12px; }

/* Repo category card — bring the existing `#repo-category-card`
   in line with the design's `.cat-banner` layout (large total
   number on left, category list on right, slim bars). */
#repo-category-card {
    grid-template-columns: 160px 1fr;
    padding: 18px 22px;
    gap: 24px;
}
#repo-category-card .category-total .category-total-num {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 36px; font-weight: 600;
    letter-spacing: -0.04em;
    color: var(--accent-strong);
    line-height: 1;
}
#repo-category-card .category-total .category-total-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    margin-top: 4px;
}
#repo-category-card .category-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px 18px;
}

/* Insights card markdown narrative — adopt design's typography. */
#repo-narrative h2 {
    font-size: 18px; font-weight: 600; letter-spacing: -0.015em;
    margin: 12px 0 10px;
}
#repo-narrative h3 {
    font-size: 13px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-muted);
    margin: 18px 0 6px;
}
#repo-narrative p {
    margin: 0 0 10px;
    line-height: 1.6;
    max-width: 78ch;
    color: var(--text);
}
#repo-narrative p code {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12.5px;
    padding: 1px 5px;
    background: var(--bg-sunk);
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--accent-strong);
}
#repo-narrative blockquote,
#repo-narrative .quote {
    border-left: 2px solid var(--accent);
    padding: 0 0 0 14px; margin: 12px 0;
    color: var(--text-muted);
}

/* Pager — design uses sunk top-border strip, not centered. */
.pager {
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid var(--line);
    background: var(--bg-sunk);
    font-size: 12.5px;
    color: var(--text-muted);
    border-radius: 0 0 10px 10px;
}

/* Findings table sits inside .table-wrap which now gets the design's
   border + radius treatment.  Filter-toolbar above shares the top
   radius for a single visual bordered card. */
#view-repo .table-wrap {
    border: 1px solid var(--line);
    border-radius: 0 0 10px 10px;
    border-top: 0;
    background: var(--bg-elev);
    overflow: hidden;
}
#view-repo .filter-toolbar {
    border: 1px solid var(--line);
    border-radius: 10px 10px 0 0;
}

/* ── Accent picker (Settings) ──────────────────────────────────── */
.accent-swatches {
    display: inline-flex; gap: 8px; align-items: center;
}
.accent-swatch {
    width: 28px; height: 28px;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    outline: 1px solid var(--line);
    transition: outline-color 0.12s, transform 0.08s;
    padding: 0;
}
.accent-swatch:hover { transform: scale(1.05); }
.accent-swatch.active {
    border-color: var(--text);
    outline-color: transparent;
}

/* ============================================================
   Mobile pass — narrow viewports get layout simplifications
   ============================================================
   Targets ≤720px and ≤480px breakpoints.  Fixes:
   - Brand name + user pill no longer wrap inside the top bar
   - QE summary headline shrinks so it doesn't break each word
     onto its own line at ~360px width
   - PR/commit/AI-sessions split collapses to single column
   - File-source code-browser switches to single column with the
     tree above the source
   - Plan meta-bar entries wrap with explicit gap
   - Tables stay inside their card via overflow-x scroll on the
     surrounding wrap (cards stop pushing past the viewport edge)
*/
@media (max-width: 720px) {
    /* Top-bar text stays on one line so wrapping doesn't make the
       header double in height.  At very narrow widths the
       wordmark hides altogether — the brand-mark tile is enough. */
    .header { gap: 12px; padding: 0 12px; }
    .header-brand { gap: 8px; min-width: 0; }
    .header-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .user-menu-btn { padding: 4px 6px 4px 10px; }
    .user-menu-btn .user-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
    .user-menu-btn .badge-role { flex-shrink: 0; }
    .header-actions { gap: 6px; }
    .kbd { display: none; }

    /* Quality Evolution headline — drops from 28px to 20px so the
       text wraps as full lines instead of one word per line.  The
       `.qe-head` flex container also stacks the time-range tabs
       below the title at this width so each gets its own row. */
    .qe-summary { font-size: 20px; line-height: 1.35; word-spacing: normal; }
    .qe-hero { padding: 18px 16px 6px; }
    .qe-head { flex-direction: column; align-items: stretch; gap: 10px; }
    .qe-tabs { align-self: flex-start; }
    .qe-metrics { grid-template-columns: repeat(2, 1fr); margin: 14px -16px 0; }
    .qe-metric { padding: 12px 14px; }
    .qe-metric .val { font-size: 22px; }
    .qe-chart { margin: 0; padding: 12px 0 4px; }

    /* Cards stop trying to be wide enough for tables — the inner
       table-wrap takes overflow-x scroll and the card stays in
       the viewport.  `min-width: 0` on flex/grid items so the
       table can shrink past its content's intrinsic min-width. */
    #app-content { padding: 14px 12px; }
    .container { padding: 0; }
    .content-wide { padding: 14px 12px 60px; }
    .card { padding: 16px; }
    .card-h { padding: 12px 16px 0; }
    .card-b { padding: 12px 16px 16px; }
    .card,
    #view-repo .table-wrap,
    .repo-tile,
    .quality-evo-card { min-width: 0; }
    .table-wrap { overflow-x: auto; }
    .pr-table, .commit-table, .remediations-table, .scans-table,
    .files-tbl, .findings-table, .simple-table { min-width: 100%; }

    /* Repo Detail: split-grid (PRs + commits) and 2-col splits all
       collapse to single column. */
    .split-grid, .split-2, .split-1-1 { grid-template-columns: 1fr; gap: 14px; }

    /* Repo Detail action cluster: button-cluster + standalone btns
       stack below the title so they don't get clipped. */
    .view-header { flex-direction: column; align-items: stretch; gap: 10px; padding: 14px 0 12px; }
    .view-header-left { flex-wrap: wrap; }
    .view-actions { flex-wrap: wrap; }

    /* Repo category banner: hero number scales down so it doesn't
       eat the row.  Categories collapse to single column. */
    #repo-category-card { grid-template-columns: 1fr; gap: 14px; }
    #repo-category-card .category-list { grid-template-columns: 1fr; }
    .category-total-num { font-size: 36px; }
    .cat-list { grid-template-columns: 1fr; }

    /* Files List (Code) — coverage column shrinks to a label-only
       view so the table fits viewport width.  Rating chip narrower. */
    .files-tbl thead th, .files-tbl tbody td { padding: 10px 10px; }
    .files-tbl tbody td { height: 48px; }
    .files-tbl .col-cov   { width: 130px; }
    .files-tbl .col-lines { width: 80px; font-size: 11.5px; }
    .files-tbl .col-issues { width: 56px; }
    .cov-track { max-width: 70px; }

    /* File Source — collapses to single column: tree above source.
       The source panel also gets a sane height instead of full-vh
       so the page can scroll naturally. */
    .cb { grid-template-columns: 1fr; height: auto; min-height: 0; gap: 12px; }
    .code-file-layout { grid-template-columns: 1fr; min-height: 0; }
    .code-file-sidebar, .cb-tree { max-height: 320px; }
    #code-file-body { max-height: 70vh; }

    /* Plan view-header — h1 + run-id stack so neither gets cut off,
       date input + Refresh wrap onto their own row. */
    #view-plan .view-header { gap: 8px; }
    .plan-meta-bar { gap: 10px 14px; padding: 12px 14px; font-size: 12px; }
    .plan-meta-bar .div { display: none; }
    .plan-step-grid { grid-template-columns: 1fr; }
    .plan-step-head { grid-template-columns: 1fr; gap: 10px; }

    /* Drawer + chat take full viewport on phones */
    .drawer { width: 100vw; max-width: none; }
    .chat-panel { width: calc(100vw - 24px); right: 12px; bottom: 80px; height: calc(100vh - 100px); }

    /* Modals — full bleed margins */
    .modal-overlay { padding: 40px 12px 20px; }
    .modal { border-radius: 10px; }

    /* Findings table filter bar wraps onto multiple rows on narrow */
    .filter-toolbar { gap: 8px; }
    .filter-toolbar .field, .filter-bar .field { min-width: 110px; flex: 1 1 130px; }

    /* Repo grid (dashboard) — already 1-col via earlier rules, but
       confirm spacing tightens. */
    .repo-grid { gap: 12px; }
    .repo-tile { padding: 14px 16px; }
}

@media (max-width: 480px) {
    /* At phone width drop the wordmark — the accent tile is brand
       enough.  User name truncates more aggressively. */
    .header-title, .brand-name { display: none; }
    .user-menu-btn .user-name { max-width: 80px; }
    .qe-summary { font-size: 18px; }
    .qe-metrics { grid-template-columns: 1fr; }
    .qe-metric { border-right: 0; border-bottom: 1px solid var(--line); }
    .qe-metric:last-child { border-bottom: 0; }
    .category-total-num { font-size: 30px; }
    .commit-metrics-card { grid-template-columns: 1fr; }
}
