/* ===== 4SAFEDRIVERS DESIGN SYSTEM v2 ===== */
/* Visual refresh — clean, efficient, readable from arm's length.
   Three themes share the same token NAMES, each with its own values,
   so component CSS stays theme-agnostic. Backward-compat aliases
   preserved at the bottom of each theme block so older class names
   keep binding without a sweep. */

/* ===== DARK THEME (default) ===== */
:root, body.theme-dark {
    /* Surface */
    --bg-page:        #0a0e17;
    --bg-surface:     #131927;
    --bg-sunken:      #0c1119;
    --bg-hover:       rgba(255,255,255,0.05);

    /* Text — two tiers */
    --text-primary:   #f1f4fb;
    --text-muted:     #94a0b8;
    --text-inverse:   #0a0e17;

    /* Borders */
    --border:         #1f2a3f;
    --border-strong:  #2d3b56;
    --border-subtle:  rgba(255,255,255,0.04);

    /* Accent — brand navy (decision color). The parent-site brand is navy
       #223a66; on this dark surface we use a lightened steel-navy so
       interactive elements stay legible. */
    --accent:         #6487d1;
    --accent-soft:    rgba(100,135,209,0.16);
    --accent-strong:  #7d9cdd;

    /* Success — the good-result color (clear reports, released, OK states).
       Deliberately NOT the brand accent: green stays the universal
       "nothing found / done" signal. */
    --success:        #10b981;
    --success-soft:   rgba(16,185,129,0.14);
    --success-strong: #0e9b6e;

    /* Structural — slate (orientation color, never a decision) */
    --structural:        #94a3b8;
    --structural-soft:   rgba(148,163,184,0.14);
    --structural-strong: #cbd5e1;

    /* Semantic */
    --danger:         #ef4444;
    --danger-soft:    rgba(239,68,68,0.14);
    --warning:        #f59e0b;
    --warning-soft:   rgba(245,158,11,0.14);
    --info:           #6b8afd;
    --info-soft:      rgba(107,138,253,0.14);
    --focus-ring:     rgba(100,135,209,0.45);

    /* Sidebar icon tints — meaning-coded families (see app-shell.js
       ICON_FAMILY). Muted so the nav reads as one calm column with a
       hint of colour per row, not a rainbow. */
    --nav-work-fg:       #8fb0ee;  --nav-work-bg:       rgba(100,135,209,0.16);
    --nav-people-fg:     #5fc7ba;  --nav-people-bg:     rgba(45,166,152,0.16);
    --nav-money-fg:      #9bc37a;  --nav-money-bg:      rgba(120,160,80,0.16);
    --nav-compliance-fg: #e39a9a;  --nav-compliance-bg: rgba(200,110,110,0.16);
    --nav-setup-fg:      #a3aec2;  --nav-setup-bg:      rgba(148,163,184,0.14);

    /* Type */
    --font-body:    'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-display: 'DM Sans', system-ui, -apple-system, sans-serif;
    --font-mono:    'DM Mono', 'JetBrains Mono', ui-monospace, monospace;

    --type-12: 12px;
    --type-14: 14px;
    --type-15: 15px;
    --type-16: 16px;
    --type-18: 18px;
    --type-22: 22px;
    --type-28: 28px;
    --type-36: 36px;
    --type-48: 48px;

    --leading-tight:  1.15;
    --leading-snug:   1.35;
    --leading-normal: 1.55;

    --tracking-tight: -0.02em;
    --tracking-normal: 0;
    --tracking-wide:   0.06em;

    /* Spacing */
    --space-1:  4px;
    --space-2:  8px;
    --space-3:  12px;
    --space-4:  16px;
    --space-5:  20px;
    --space-6:  24px;
    --space-8:  32px;
    --space-10: 40px;
    --space-12: 48px;

    /* Shared content frame — the consistent max-width every full-view page
       caps to (centered, with the standard gutter). Lists/tables/dashboards
       fill it; forms + text keep their own readable measures inside it. */
    --content-max: 1320px;

    /* Radii — squarer */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;

    /* Shadow */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.25);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.35);

    --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);

    /* — Backward-compat aliases (older component CSS reads these) — */
    --bg-primary:     var(--bg-page);
    --bg-secondary:   var(--bg-surface);
    --bg-card:        var(--bg-surface);
    --bg-card-hover:  var(--bg-hover);
    --bg-elevated:    var(--bg-surface);
    --text-secondary: var(--text-muted);
    --accent-dim:     var(--accent-soft);
    --accent-glow:    var(--accent-soft);
    --danger-dim:     var(--danger-soft);
    --warning-dim:    var(--warning-soft);
    --clear:          var(--success);
    --clear-dim:      var(--success-soft);
    --hit:            var(--danger);
    --hit-dim:        var(--danger-soft);
    --pending:        var(--info);
    --pending-dim:    var(--info-soft);
    --processing:     #a882ff;
    --processing-dim: rgba(168,130,255,0.14);
    --hover-overlay:       var(--bg-hover);
    --hover-overlay-table: rgba(255,255,255,0.025);
    --table-header-bg:     var(--bg-sunken);
    --topbar-bg:           rgba(10,14,23,0.85);
    --select-arrow:        %2394a0b8;
    --shadow-card:     var(--shadow-sm);
    --shadow-elevated: var(--shadow-lg);
}

/* ===== MIDNIGHT THEME — saturated navy ===== */
body.theme-midnight {
    --bg-page:        #14223e;
    --bg-surface:     #1c2d52;
    --bg-sunken:      #0f1a31;
    --bg-hover:       rgba(255,255,255,0.06);

    --text-primary:   #f1f5fc;
    --text-muted:     #9fb1d2;
    --text-inverse:   #14223e;

    --border:         #2d4068;
    --border-strong:  #3d5589;
    --border-subtle:  rgba(255,255,255,0.06);

    --accent:         #7ca2e8;
    --accent-soft:    rgba(124,162,232,0.18);
    --accent-strong:  #93b3ee;

    --success:        #1cc790;
    --success-soft:   rgba(28,199,144,0.16);
    --success-strong: #19b182;

    --structural:        #8aa0bf;
    --structural-soft:   rgba(138,160,191,0.16);
    --structural-strong: #b8c8e0;

    --danger:         #ff6b6b;
    --danger-soft:    rgba(255,107,107,0.16);
    --warning:        #ffc233;
    --warning-soft:   rgba(255,194,51,0.16);
    --info:           #6e9bff;
    --info-soft:      rgba(110,155,255,0.16);
    --focus-ring:     rgba(124,162,232,0.45);

    --nav-work-fg:       #a4c0f2;  --nav-work-bg:       rgba(124,162,232,0.18);
    --nav-people-fg:     #6fd0c4;  --nav-people-bg:     rgba(60,180,165,0.18);
    --nav-money-fg:      #a9cd8a;  --nav-money-bg:      rgba(130,175,90,0.18);
    --nav-compliance-fg: #eaa6a6;  --nav-compliance-bg: rgba(210,120,120,0.18);
    --nav-setup-fg:      #b3bdd0;  --nav-setup-bg:      rgba(160,175,200,0.16);

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.25);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.20);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.30);

    /* Backward-compat */
    --bg-primary:     var(--bg-page);
    --bg-secondary:   var(--bg-surface);
    --bg-card:        var(--bg-surface);
    --bg-card-hover:  var(--bg-hover);
    --bg-elevated:    var(--bg-surface);
    --text-secondary: var(--text-muted);
    --accent-dim:     var(--accent-soft);
    --accent-glow:    var(--accent-soft);
    --danger-dim:     var(--danger-soft);
    --warning-dim:    var(--warning-soft);
    --clear:          var(--success);
    --clear-dim:      var(--success-soft);
    --hit:            var(--danger);
    --hit-dim:        var(--danger-soft);
    --pending:        var(--info);
    --pending-dim:    var(--info-soft);
    --processing:     #a88aef;
    --processing-dim: rgba(168,138,239,0.16);
    --hover-overlay:       var(--bg-hover);
    --hover-overlay-table: rgba(255,255,255,0.04);
    --table-header-bg:     var(--bg-sunken);
    --topbar-bg:           rgba(20,34,62,0.88);
    --select-arrow:        %239fb1d2;
    --shadow-card:     var(--shadow-sm);
    --shadow-elevated: var(--shadow-lg);
}

/* ===== LIGHT THEME — the buyer's default ===== */
body.theme-light {
    --bg-page:        #fafaf7;       /* warm off-white, not paper-blue */
    --bg-surface:     #ffffff;
    --bg-sunken:      #f1f0eb;
    --bg-hover:       rgba(11,15,23,0.04);

    --text-primary:   #0b0f17;       /* near-black */
    --text-muted:     #2e3640;       /* deep-charcoal "secondary" — NOT a
                                        light grey. Hierarchy comes from
                                        size + weight, not from washing
                                        text out. (Old value #5a6271 read
                                        as light grey on warm cream.)    */
    --text-inverse:   #fafaf7;

    --border:         #e2dfd6;       /* warm grey-tan */
    --border-strong:  #c8c3b7;
    --border-subtle:  rgba(11,15,23,0.06);

    --accent:         #223a66;       /* brand navy — matches 4safedrivers.com */
    --accent-soft:    #eef2f7;
    --accent-strong:  #1a2c50;

    /* Success — clear reports / released / OK states keep the old green so
       "good news" stays instantly readable; brand navy owns everything
       interactive. */
    --success:        #047857;
    --success-soft:   #ecfdf5;
    --success-strong: #065f46;

    /* Structural slate — used where green USED to be (subhead rules,
       'Most Ordered' pill, eyebrows, structural chrome). Green is now
       reserved for DECISION moments only (selected card, primary CTA). */
    --structural:        #334155;
    --structural-soft:   #eef2f7;
    --structural-strong: #1e293b;

    --danger:         #b91c1c;
    --danger-soft:    #fef2f2;
    --warning:        #b45309;
    --warning-soft:   #fffbeb;
    --info:           #1d4ed8;
    --info-soft:      #eff6ff;
    --focus-ring:     rgba(34,58,102,0.45);

    /* Sidebar icon tints — meaning-coded families (see app-shell.js
       ICON_FAMILY). Ink-on-tint pairs tuned for the warm cream surface;
       maroon is the logo shield's colour, softened. */
    --nav-work-fg:       #223a66;  --nav-work-bg:       #e6ecf5;
    --nav-people-fg:     #0f6e66;  --nav-people-bg:     #e2f1ee;
    --nav-money-fg:      #4a6b2a;  --nav-money-bg:      #ebf1e2;
    --nav-compliance-fg: #8a2f38;  --nav-compliance-bg: #f6e7e6;
    --nav-setup-fg:      #4b5563;  --nav-setup-bg:      #eaecef;

    --shadow-sm: 0 1px 2px rgba(11,15,23,0.06);
    --shadow-md: 0 4px 12px rgba(11,15,23,0.08);
    --shadow-lg: 0 12px 32px rgba(11,15,23,0.12);

    /* Backward-compat */
    --bg-primary:     var(--bg-page);
    --bg-secondary:   var(--bg-surface);
    --bg-card:        var(--bg-surface);
    --bg-card-hover:  var(--bg-hover);
    --bg-elevated:    var(--bg-surface);
    --text-secondary: var(--text-muted);
    --accent-dim:     var(--accent-soft);
    --accent-glow:    var(--accent-soft);
    --danger-dim:     var(--danger-soft);
    --warning-dim:    var(--warning-soft);
    --clear:          var(--success);
    --clear-dim:      var(--success-soft);
    --hit:            var(--danger);
    --hit-dim:        var(--danger-soft);
    --pending:        var(--info);
    --pending-dim:    var(--info-soft);
    --processing:     #6d28d9;
    --processing-dim: rgba(109,40,217,0.10);
    --hover-overlay:       var(--bg-hover);
    --hover-overlay-table: rgba(11,15,23,0.025);
    --table-header-bg:     var(--bg-sunken);
    --topbar-bg:           rgba(250,250,247,0.88);
    --select-arrow:        %235a6271;
    --shadow-card:     var(--shadow-sm);
    --shadow-elevated: var(--shadow-lg);
}

/* ===== THEME SWITCHER ===== */
.theme-switcher {
    display: flex;
    gap: 4px;
    padding: 3px;
    background: var(--bg-page);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.theme-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: all var(--transition);
}

.theme-btn:hover { transform: scale(1.08); }
.theme-btn.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.theme-btn.dark-swatch     { background: #0a0e17; }
.theme-btn.midnight-swatch { background: #14223e; }
.theme-btn.light-swatch    { background: #fafaf7; }

/* ===== BASE ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-body);
    font-size: var(--type-16);
    line-height: var(--leading-normal);
    background: var(--bg-page);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    /* Smarter line-breaking: the browser avoids orphans/widows and picks
       nicer break points. Kills most of the awkward wrapping a contained
       (narrower) column produces. Progressive enhancement — unsupported
       browsers just fall back to normal wrapping. */
    text-wrap: pretty;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Headings balance their lines instead of leaving a lone word stranded on
   the last line — the most common awkward wrap in a contained column. */
h1, h2, h3, h4, h5, h6 { text-wrap: balance; }

/* body::before gradient removed — was templatey ambient glow */

/* ===== LAYOUT ===== */
.app { display: flex; min-height: 100vh; position: relative; z-index: 1; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: 252px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: var(--space-6) var(--space-5);
    border-bottom: 1px solid var(--border);
}

.sidebar-brand h1 {
    font-family: var(--font-display);
    font-size: var(--type-22);
    font-weight: 700;
    letter-spacing: var(--tracking-tight);
    color: var(--text-primary);
    line-height: var(--leading-tight);
}

.sidebar-brand h1 span { color: var(--accent); }

.sidebar-brand p {
    font-size: var(--type-12);
    color: var(--text-muted);
    margin-top: var(--space-1);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    font-weight: 600;
}

.sidebar-nav { padding: var(--space-4) var(--space-3); flex: 1; }

.nav-section { margin-bottom: var(--space-6); }

.nav-section-label {
    font-size: var(--type-12);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    color: var(--text-muted);
    padding: 0 var(--space-2);
    margin-bottom: var(--space-2);
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 7px var(--space-3);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--type-15);
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    position: relative;
    text-decoration: none;
}

.nav-item:hover { background: var(--bg-hover); }
.nav-item.active { color: var(--accent); background: var(--accent-soft); }

/* Primary CTA row — used for "New Order" on the client nav. Quiet
   button look: accent-tinted bg, accent text, heavier weight. Sits in
   the nav rhythm so it doesn't shout, but the buyer's most common
   action is always pre-highlighted. When ALSO active (buyer is on
   /order.html), the existing .active rules add the left rail on top
   without changing the fill, so there's no visual conflict. */
.nav-item.nav-item-primary {
    color: var(--accent);
    background: var(--accent-soft);
    font-weight: 600;
}
.nav-item.nav-item-primary:hover {
    background: var(--accent-soft);
    filter: brightness(0.97);
}
.nav-item.nav-item-primary .nav-icon { opacity: 1; }
/* Disabled (account not yet active) — drop the primary fill so a
   pending-approval buyer doesn't see a confusingly-bright row. */
.nav-item.nav-item-primary.disabled {
    background: transparent;
    color: var(--text-muted);
    font-weight: 500;
}

/* Sub-items under Triage: filter links inside the inbox */
.nav-item.nav-item-sub {
    margin-left: var(--space-3);
    padding-left: var(--space-4);
    font-size: var(--type-14);
    border-left: 1px solid var(--border);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.nav-item.nav-item-sub.active { border-left-color: var(--accent); }

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}

.nav-icon { width: 16px; height: 16px; }
/* Icon tile: 28px square, family tint. Colour lives on the tile so the
   label stays ink-on-cream and the row still reads as text-first. */
.nav-ico {
    width: 28px; height: 28px; flex: 0 0 28px;
    display: inline-grid; place-items: center;
    border-radius: var(--radius-sm);
    background: var(--nav-setup-bg); color: var(--nav-setup-fg);
    transition: background var(--transition), color var(--transition);
}
.nav-ico-work       { background: var(--nav-work-bg);       color: var(--nav-work-fg); }
.nav-ico-people     { background: var(--nav-people-bg);     color: var(--nav-people-fg); }
.nav-ico-money      { background: var(--nav-money-bg);      color: var(--nav-money-fg); }
.nav-ico-compliance { background: var(--nav-compliance-bg); color: var(--nav-compliance-fg); }
.nav-ico-setup      { background: var(--nav-setup-bg);      color: var(--nav-setup-fg); }
/* Active + primary rows: tile goes solid in its own family colour so the
   current page reads at a glance without changing the row fill. */
.nav-item.active .nav-ico,
.nav-item.nav-item-primary:not(.disabled) .nav-ico { background: currentColor; }
.nav-item.active .nav-ico .nav-icon,
.nav-item.nav-item-primary:not(.disabled) .nav-ico .nav-icon { color: var(--bg-surface); }
.nav-item.disabled .nav-ico { background: var(--bg-hover); color: var(--text-muted); }
.nav-item.nav-item-sub .nav-ico { width: 24px; height: 24px; flex-basis: 24px; }
.nav-item.nav-item-sub .nav-icon { width: 14px; height: 14px; }

.nav-badge {
    margin-left: auto;
    font-size: var(--type-12);
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-variant-numeric: tabular-nums;
}

.nav-badge.danger  { background: var(--danger-soft);  color: var(--danger); }
.nav-badge.pending { background: var(--info-soft);    color: var(--info); }
.nav-badge.warning { background: var(--warning-soft); color: var(--warning); }

/* Profile + Sign out moved from the sidebar footer (fell below the fold on
   short windows) into the topbar right — always visible. */
.topbar-user {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding-left: var(--space-4);
    border-left: 1px solid var(--border);
}
.topbar-user .user-avatar { width: 30px; height: 30px; font-size: var(--type-12); }
.topbar-user-text { line-height: 1.25; }
.topbar-user .user-name { font-size: var(--type-13, 13px); }
.topbar-user .user-role {
    font-size: 11px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.topbar-user .signout-link {
    margin-left: var(--space-3);
    font-size: var(--type-12);
    color: var(--text-muted);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 5px 10px;
    white-space: nowrap;
    transition: color 140ms ease, border-color 140ms ease;
}
.topbar-user .signout-link:hover { color: var(--text-primary); border-color: var(--border-strong); }
@media (max-width: 760px) {
    .topbar-user-text { display: none; }
}

.user-info { display: flex; align-items: center; gap: var(--space-3); }

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--type-14);
    font-weight: 600;
    color: var(--text-inverse);
    letter-spacing: var(--tracking-tight);
}

.user-name { font-size: var(--type-14); font-weight: 500; }
.user-role { font-size: var(--type-12); color: var(--text-muted); }

/* ===== MAIN ===== */
.main { margin-left: 252px; flex: 1; padding: 0; }
/* Column so the shell footer sits at the bottom of short pages. Direct
   children keep full width (auto side-margins on .content still centre it
   because width is explicit). */
.main { display: flex; flex-direction: column; }
.main > * { width: 100%; flex-shrink: 0; }

/* ===== HELP MARKERS (app-shell.js HelpMarks) =====
   A quiet circled "?" next to a heading, label, or the page title. Click-
   only; the popover is plain text edited by staff in the Help Text editor.
   Deliberately subtle so experienced users can ignore them. */
.help-mark {
    display: inline-grid; place-items: center;
    /* 14px fits INSIDE a small label's existing line box, so adding a
       marker never changes a label's height — sibling fields stay
       aligned and the fill-style inputs below don't shift. Quiet by
       default (thin ring, low opacity); full colour only on hover/open. */
    width: 14px; height: 14px;
    padding: 0; margin: 0 0 0 5px;
    vertical-align: middle;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 9px; font-weight: 700; line-height: 1;
    opacity: 0.75;
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition), opacity var(--transition);
}
/* The class's display beats the UA's [hidden] rule — restore it so a
   marker can be gated with the control it explains (mvr-report). */
.help-mark[hidden] { display: none; }
.help-mark:hover,
.help-mark[aria-expanded="true"] {
    color: var(--accent);
    border-color: var(--accent);
    opacity: 1;
}
.help-pop {
    position: fixed; z-index: 240;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 14px 16px;
    font-size: 14px; line-height: 1.55;
    color: var(--text-primary);
}
.help-pop-title {
    font-weight: 700; font-size: 14px;
    margin-bottom: 6px;
}
.help-pop p { margin: 0 0 8px; }
.help-pop p:last-of-type { margin-bottom: 0; }
.help-pop-more {
    display: inline-block; margin-top: 8px;
    font-size: 13.5px; font-weight: 600;
    color: var(--accent); text-decoration: none;
}

/* ===== FOOTER (rendered by app-shell.js renderFooter) ===== */
.app-footer {
    margin-top: auto;
    padding: var(--space-5) var(--space-8) var(--space-6);
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-muted);
}
.app-footer a { color: var(--text-muted); text-decoration: none; }
.app-footer a:hover { color: var(--accent); }
.app-footer-row {
    display: flex; align-items: center; gap: var(--space-6); flex-wrap: wrap;
}
.app-footer-brand { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.app-footer-brand img { display: block; opacity: 0.85; }
.app-footer-links { display: inline-flex; gap: var(--space-5); }
.app-footer-links a { color: var(--text-primary); font-weight: 500; }
.app-footer-support { margin-left: auto; font-family: var(--font-mono); font-size: 12.5px; }
.app-footer-legal {
    margin-top: var(--space-3);
    display: flex; flex-wrap: wrap; gap: 0 10px; align-items: center;
    font-size: 12.5px;
}
@media (max-width: 600px) {
    .app-footer { padding: var(--space-5) var(--space-4); }
    .app-footer-support { margin-left: 0; }
}

/* ===== TOPBAR ===== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-8);
    border-bottom: 1px solid var(--border);
    background: var(--topbar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left  { display: flex; align-items: center; gap: var(--space-4); }
.topbar-right { display: flex; align-items: center; gap: var(--space-3); }

.page-title {
    font-size: var(--type-22);
    font-weight: 600;
    letter-spacing: var(--tracking-tight);
    line-height: var(--leading-snug);
}

.page-subtitle {
    font-size: var(--type-14);
    color: var(--text-muted);
    margin-left: var(--space-3);
}

/* ===== MOBILE MENU (hamburger + drawer) =====
   The sidebar is fixed and always-on at desktop widths. On narrow screens
   it would permanently eat the viewport, so below the breakpoint it becomes
   an off-canvas drawer toggled by the topbar hamburger, dimmed by a scrim. */
.menu-toggle {
    display: none;               /* desktop: no hamburger */
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    margin-right: var(--space-1);
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 140ms ease, background 140ms ease;
}
.menu-toggle:hover { border-color: var(--text-muted); background: var(--bg-surface); }
.menu-toggle svg { width: 20px; height: 20px; display: block; }

/* Dim layer behind the open drawer. Lives in .app, below the sidebar
   (z-index 100) and above content. Inert until the menu is open. */
.sidebar-scrim {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}

@media (max-width: 900px) {
    .menu-toggle { display: inline-flex; }
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        box-shadow: none;
    }
    .app.menu-open .sidebar {
        transform: none;
        box-shadow: 0 0 48px rgba(0, 0, 0, 0.45);
    }
    .app.menu-open .sidebar-scrim { opacity: 1; pointer-events: auto; }
    .main { margin-left: 0; }     /* content reclaims the full width */
    body.menu-open { overflow: hidden; }   /* lock scroll behind the drawer */
}

/* ===== SEARCH ===== */
.search-box {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px 14px;
    min-width: 280px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.search-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.search-box input {
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: var(--type-15);
    outline: none;
    width: 100%;
}

.search-box input::placeholder { color: var(--text-muted); }
.search-icon { color: var(--text-muted); width: 16px; height: 16px; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: 40px;
    padding: 0 var(--space-5);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: var(--type-15);
    font-weight: 500;
    line-height: 1;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.btn:disabled, .btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: var(--accent);
    color: var(--text-inverse);
    border-color: var(--accent);
}
.btn-primary:hover {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-strong);
}
.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.btn-ghost {
    background: transparent;
    color: var(--text-primary);
    border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-hover); }

.btn-danger {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: transparent;
}
.btn-danger:hover { background: var(--danger); color: var(--text-inverse); }

.btn-warning {
    background: var(--warning-soft);
    color: var(--warning);
    border-color: transparent;
}
.btn-warning:hover { background: var(--warning); color: var(--text-inverse); }

.btn-sm { height: 32px; padding: 0 14px; font-size: var(--type-14); }
.btn-lg { height: 48px; padding: 0 var(--space-6); font-size: var(--type-16); }

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}

.btn-icon:hover { background: var(--bg-hover); border-color: var(--border-strong); }

/* ===== CONTENT ===== */
/* Consistent page frame for plain content pages (lists, tables): capped at
   --content-max, centered, with the standard gutter. Data tables and grids
   fill it; this is what makes drivers/orders/etc. line up instead of running
   edge-to-edge. Pages with a bespoke wrapper (.dash-page, .mvr-page, …) set
   the same frame on their own wrapper. */
.content { max-width: var(--content-max); margin-inline: auto; padding: var(--space-8) var(--space-8); }
@media (max-width: 600px) { .content { padding: var(--space-5) var(--space-4); } }

/* ===== STATS ===== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-8);
}

.stats-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.stats-row.cols-5 { grid-template-columns: repeat(5, 1fr); }

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    position: relative;
    transition: border-color var(--transition);
}

.stat-card:hover { border-color: var(--border-strong); }

/* Glow ::after blur removed — was templatey */

.stat-label {
    font-size: var(--type-12);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    font-weight: 600;
    margin-bottom: var(--space-2);
}

.stat-value {
    font-family: var(--font-display);
    font-size: var(--type-36);
    font-weight: 700;
    letter-spacing: var(--tracking-tight);
    line-height: var(--leading-tight);
    margin-bottom: var(--space-1);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.stat-value.green  { color: var(--success); }
.stat-value.blue   { color: var(--info); }
.stat-value.red    { color: var(--danger); }
.stat-value.amber  { color: var(--warning); }
.stat-value.purple { color: var(--processing); }

.stat-change { font-size: var(--type-14); color: var(--text-muted); }
.stat-change span { color: var(--success); font-weight: 500; }

/* ===== PANELS ===== */
.panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border);
}

.panel-title { font-size: var(--type-16); font-weight: 600; letter-spacing: var(--tracking-tight); }

.panel-tabs {
    display: flex;
    gap: 2px;
    background: var(--bg-page);
    border-radius: var(--radius-md);
    padding: 3px;
}

.panel-tab {
    padding: 6px 14px;
    font-size: var(--type-14);
    font-weight: 500;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    border: none;
    background: none;
    font-family: var(--font-body);
}

.panel-tab:hover { color: var(--text-primary); }
.panel-tab.active { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-sm); }

.panel-body { padding: var(--space-5); }

/* ===== TABLES ===== */
.data-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }

.data-table th {
    text-align: left;
    padding: 12px var(--space-6);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    background: var(--bg-sunken);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 15px var(--space-6);
    font-size: var(--type-15);
    color: var(--text-primary);
    /* Lighter hairline between rows so the eye scans the data, not the grid. */
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

/* Generous first/last gutters so content breathes to the panel edge. */
.data-table th:first-child, .data-table td:first-child { padding-left: var(--space-6); }
.data-table th:last-child,  .data-table td:last-child  { padding-right: var(--space-6); }

/* Numeric columns: opt-in right alignment + tabular figures so counts/money
   line up on the decimal. Mark the <th>/<td> (or the column) with .num. */
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

.data-table tbody tr {
    transition: background var(--transition), box-shadow var(--transition);
    cursor: pointer;
}
/* Hover: a quiet neutral wash — no coloured rail. Restraint over decoration. */
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* Selected rows — checkbox-driven, no JS needed (:has). A subtle wash so a
   multi-select reads at a glance without shouting. */
.data-table tbody tr:has(.row-select:checked) { background: var(--accent-soft); }

/* Wrap a wide table in .table-scroll so it scrolls horizontally on narrow
   screens instead of breaking the page layout. */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ===== ROSTER — editorial list ==================================
   The list-page alternative to a boxed data-table: each entity is an
   anchored, two-line row with right-aligned figures and a quiet status.
   Built for scanning with hierarchy + air, not grid lines. Monochrome;
   the only colour is a single small status dot. */
.roster { display: flex; flex-direction: column; }

/* Slim head — holds a select-all control; no column labels (it's not a grid). */
.roster-head {
    display: flex; align-items: center; gap: 10px;
    padding: 10px var(--space-2) 12px;
    margin-bottom: 2px;
    border-bottom: 1px solid var(--border);
}
.roster-head label {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 12px; color: var(--text-muted); cursor: pointer;
    letter-spacing: 0.02em;
}
.roster-head input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

.roster-row {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: 15px var(--space-2);
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: background var(--transition);
}
.roster-row:hover { background: var(--bg-hover); }
.roster-row:last-child { border-bottom: none; }

/* Optional leading checkbox (multi-select pages). Quiet until hovered/checked. */
.roster-check {
    flex-shrink: 0; display: inline-flex; align-items: center;
    width: 18px;
}
.roster-check input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* Leading anchor — square monogram / count. Neutral, restrained, no colour. */
.roster-mono {
    flex-shrink: 0;
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

/* Identity — strong primary line over a muted sub-line. */
.roster-identity { min-width: 0; flex: 1; }
.roster-id {
    font-size: var(--type-15);
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.roster-sub {
    margin-top: 3px;
    font-size: 12.5px;
    color: var(--text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.roster .mono { font-family: var(--font-mono); }

/* Right metadata — figures over a quiet status, right-aligned. */
.roster-meta {
    flex-shrink: 0;
    display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
    text-align: right;
}
.roster-figures {
    font-size: 13px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}
.roster-status {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 9px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-secondary);
    background: var(--bg-sunken);
}
.roster-status::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%;
    background: var(--text-muted); flex-shrink: 0;
}
/* Tone = tinted fill + matching text/dot. Semantic colors only (success /
   warning / error) — not competing brand accents — so the one-accent rule
   holds. Default (untoned, e.g. cancelled) stays neutral grey. */
.roster-status.ok   { color: var(--success);  background: var(--success-soft); }
.roster-status.warn { color: var(--warning); background: var(--warning-soft); }
.roster-status.bad  { color: var(--danger);  background: var(--danger-soft); }
.roster-status.ok::before   { background: var(--success); }
.roster-status.warn::before { background: var(--warning); }
.roster-status.bad::before  { background: var(--danger); }

.roster-empty {
    padding: 64px var(--space-4);
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

@media (max-width: 600px) {
    .roster-row { gap: var(--space-3); padding: 14px var(--space-1); }
    .roster-mono { width: 34px; height: 34px; font-size: 12px; }
}

/* ===== STATUS BADGES ===== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--type-12);
    font-weight: 500;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    letter-spacing: 0.02em;
    line-height: 1;
    min-height: 22px;
    /* Hairline in the badge's own colour so it reads as a defined tag, not a
       faint floating tint. currentColor = the variant's text colour, so it
       adapts to every status + theme automatically. */
    border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
}

.status-badge.clear      { background: var(--success-soft);  color: var(--success); }
.status-badge.hit        { background: var(--danger-soft);  color: var(--danger); }
.status-badge.pending    { background: var(--info-soft);    color: var(--info); }
.status-badge.processing { background: var(--processing-dim); color: var(--processing); }
.status-badge.warning    { background: var(--warning-soft); color: var(--warning); }
.status-badge.neutral    { background: var(--bg-sunken);    color: var(--text-muted); }

/* Shape varies by status so colorblind users still read them */
.status-dot {
    width: 7px;
    height: 7px;
    background: currentColor;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-badge.pending .status-dot {
    background: transparent;
    border: 1.5px solid currentColor;
}
.status-badge.warning .status-dot {
    border-radius: 0;
    width: 0;
    height: 0;
    background: transparent;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 7px solid currentColor;
}
.status-badge.hit .status-dot {
    border-radius: 1px;
    width: 7px;
    height: 7px;
}
.status-badge.processing .status-dot {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

/* ===== SCREENING TAGS ===== */
.screening-tags { display: flex; gap: 4px; flex-wrap: wrap; }

.screening-tag {
    font-size: var(--type-12);
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    line-height: 1.2;
}

.screening-tag.county   { background: var(--info-soft);    color: var(--info); }
.screening-tag.state    { background: var(--processing-dim); color: var(--processing); }
.screening-tag.national { background: var(--accent-soft);  color: var(--accent); }
.screening-tag.civil    { background: var(--warning-soft); color: var(--warning); }
.screening-tag.ssn      { background: var(--bg-sunken);    color: var(--text-muted); }
.screening-tag.sexoff   { background: var(--danger-soft);  color: var(--danger); }
.screening-tag.mvr      { background: var(--accent-soft);  color: var(--accent); }

/* Product-type pill — Background Check vs Driving Record */
.product-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    padding: 3px 9px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    white-space: nowrap;
    line-height: 1.2;
}
.product-pill::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.product-pill.bgc { background: var(--accent-soft); color: var(--accent); }
.product-pill.dr  { background: var(--processing-dim); color: var(--processing); }

/* ===== COMMON ELEMENTS ===== */
.order-id    { font-family: var(--font-mono); font-size: var(--type-14); color: var(--text-muted); }
.subject-name{ font-weight: 500; color: var(--text-primary); font-size: var(--type-15); }
.subject-dob { font-size: var(--type-12); color: var(--text-muted); margin-top: 2px; }
.time-ago    { font-size: var(--type-14); color: var(--text-muted); }

/* ===== BANNERS — semantic notice strip ===== */
.banner {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: 14px 18px;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--border-strong);
    background: var(--bg-sunken);
    font-size: var(--type-15);
    line-height: var(--leading-normal);
    color: var(--text-primary);
}
.banner-title {
    font-size: var(--type-15);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.banner-body { color: var(--text-primary); }
.banner-info    { border-left-color: var(--info);    background: var(--info-soft); }
.banner-warn    { border-left-color: var(--warning); background: var(--warning-soft); }
.banner-error   { border-left-color: var(--danger);  background: var(--danger-soft); }
.banner-success { border-left-color: var(--success);  background: var(--success-soft); }

/* ===== FORMS ===== */
.form-section { margin-bottom: var(--space-6); }

.form-section-title {
    font-size: var(--type-12);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--border);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin-bottom: var(--space-3); }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

.form-label { font-size: var(--type-14); font-weight: 500; color: var(--text-primary); }
.form-label .required { color: var(--danger); margin-left: 2px; }

.form-input,
.form-select {
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    height: 44px;
    padding: 0 14px;
    font-family: var(--font-body);
    font-size: var(--type-16);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.form-input::placeholder { color: var(--text-muted); }
.form-input.error { border-color: var(--danger); }
.form-input.error:focus { box-shadow: 0 0 0 3px var(--danger-soft); }

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a6271' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

.form-hint  { font-size: var(--type-14); color: var(--text-muted); margin-top: 2px; }
.form-error { font-size: var(--type-14); color: var(--danger); margin-top: 2px; }

textarea.form-input { resize: vertical; min-height: 96px; height: auto; padding: 12px 14px; line-height: var(--leading-normal); }

/* ===== MODALS ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11,15,23,0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.modal-overlay.active { display: flex; opacity: 1; }

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 620px;
    max-width: calc(100vw - 32px);
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(8px);
    transition: transform 0.25s ease;
}

.modal-overlay.active .modal { transform: translateY(0); }
.modal.wide { width: 820px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-6) var(--space-6) 0;
}

.modal-title { font-size: var(--type-22); font-weight: 600; letter-spacing: var(--tracking-tight); }

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-body { padding: var(--space-5) var(--space-6) var(--space-6); }

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: 0 var(--space-6) var(--space-6);
}

/* ===== SLIDE PANEL ===== */
.slide-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11,15,23,0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.slide-overlay.active { display: block; opacity: 1; }

.slide-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 700px;
    max-width: calc(100vw - 32px);
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateX(16px);
    transition: transform 0.25s ease;
}

.slide-overlay.active .slide-panel { transform: translateX(0); }

/* ===== CARDS ===== */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    margin-bottom: var(--space-3);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}

.card-title { font-size: var(--type-18); font-weight: 600; letter-spacing: var(--tracking-tight); color: var(--text-primary); }

/* ===== RECORD DETAILS ===== */
.record-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: var(--space-3);
    padding: 6px 0;
    font-size: var(--type-15);
}

.record-label { color: var(--text-muted); font-weight: 500; }
.record-value { color: var(--text-primary); }

/* ===== PROGRESS BAR ===== */
.progress-bar {
    height: 4px;
    background: var(--bg-sunken);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}

.progress-fill.green { background: var(--success); }
.progress-fill.blue  { background: var(--info); }
.progress-fill.red   { background: var(--danger); }
.progress-fill.amber { background: var(--warning); }

/* ===== EMPTY STATE ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 72px var(--space-5);
    text-align: center;
}

.empty-state-icon {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
    margin-bottom: var(--space-4);
    opacity: 0.6;
}

.empty-state-title {
    font-size: var(--type-18);
    font-weight: 600;
    margin-bottom: var(--space-2);
    color: var(--text-primary);
}

.empty-state-text {
    font-size: var(--type-15);
    color: var(--text-muted);
    max-width: 360px;
    line-height: var(--leading-normal);
}

/* ===== TABS ===== */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-6);
}

.tab {
    padding: 12px var(--space-5);
    font-size: var(--type-15);
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color var(--transition), border-color var(--transition);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: var(--font-body);
    margin-bottom: -1px;
}

.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ===== TIMELINE ===== */
.timeline { position: relative; padding-left: var(--space-6); }

.timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: var(--space-5);
}

.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot {
    position: absolute;
    left: calc(-1 * var(--space-6) + 1px);
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg-page);
}

.timeline-dot.green { border-color: var(--success);  background: var(--success); }
.timeline-dot.blue  { border-color: var(--info);    background: var(--info); }
.timeline-dot.red   { border-color: var(--danger);  background: var(--danger); }
.timeline-dot.amber { border-color: var(--warning); background: var(--warning); }

.timeline-time { font-size: var(--type-12); color: var(--text-muted); margin-bottom: 2px; font-weight: 500; }
.timeline-text { font-size: var(--type-15); color: var(--text-primary); line-height: var(--leading-normal); }
.timeline-text strong { color: var(--text-primary); font-weight: 600; }

/* ===== KANBAN ===== */
.kanban { display: flex; gap: var(--space-4); overflow-x: auto; padding-bottom: var(--space-2); }

.kanban-column {
    min-width: 300px;
    flex: 1;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 200px);
}

.kanban-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    border-bottom: 1px solid var(--border);
}

.kanban-column-title {
    font-size: var(--type-12);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    color: var(--text-muted);
}

.kanban-count {
    font-size: var(--type-12);
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background: var(--bg-sunken);
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.kanban-cards {
    padding: var(--space-3);
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.kanban-card {
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.kanban-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
}

/* ===== CONFIDENCE METER ===== */
.confidence {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.confidence-bar {
    display: flex;
    gap: 2px;
}

.confidence-segment {
    width: 16px;
    height: 6px;
    border-radius: 1px;
    background: var(--border);
}

.confidence-segment.filled.high   { background: var(--success); }
.confidence-segment.filled.medium { background: var(--warning); }
.confidence-segment.filled.low    { background: var(--danger); }

.confidence-label { font-size: var(--type-12); font-weight: 600; letter-spacing: var(--tracking-wide); text-transform: uppercase; }
.confidence-label.high   { color: var(--success); }
.confidence-label.medium { color: var(--warning); }
.confidence-label.low    { color: var(--danger); }

/* ===== ANIMATIONS ===== */
.fade-in { animation: fadeIn 0.4s ease forwards; }

.fade-in-up {
    opacity: 0;
    transform: translateY(8px);
    animation: fadeInUp 0.5s ease forwards;
}

.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.10s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.20s; }
.stagger-5 { animation-delay: 0.25s; }

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

/* prefers-reduced-motion: force final state so opacity:0 doesn't stick */
@media (prefers-reduced-motion: reduce) {
    .fade-in-up { opacity: 1 !important; transform: none !important; animation: none !important; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1400px) { .stats-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 1200px) { .kanban { flex-wrap: wrap; } .kanban-column { min-width: 100%; } }

/* ===== APP SHELL ADDITIONS (BGC) ===== */
.nav-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.nav-item.disabled:hover {
    background: transparent;
    color: var(--text-muted);
}
.nav-lock {
    margin-left: auto;
    font-size: var(--type-12);
    opacity: 0.7;
}
.signout-link:hover { color: var(--accent) !important; }

.error-card {
    margin: 40px auto;
    max-width: 520px;
    padding: var(--space-6);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--danger);
    font-size: var(--type-15);
}

/* ===== STATUS PILLS (BGC) ===== */
.status-pill {
    display: inline-block;
    padding: 4px 10px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-sunken);
    color: var(--text-muted);
}
.status-pill.status-received,
.status-pill.status-pending,
.status-pill.status-consent_pending {
    background: var(--info-soft); color: var(--info); border-color: transparent;
}
.status-pill.status-processing  { background: var(--processing-dim); color: var(--processing); border-color: transparent; }
.status-pill.status-adjudication,
.status-pill.status-report_review { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.status-pill.status-ready,
.status-pill.status-delivered,
.status-pill.status-active     { background: var(--success-soft); color: var(--success); border-color: transparent; }
.status-pill.status-adverse_action { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.status-pill.status-closed,
.status-pill.status-suspended,
.status-pill.status-denied     { background: var(--bg-sunken); color: var(--text-muted); }
/* MVR re-run flags on the operator pipeline */
.status-pill.rerun-issue       { background: var(--danger-soft);  color: var(--danger);  border-color: transparent; }
.status-pill.rerun-attn        { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
