:root {
    --bg: #f1f4f8;
    --surface: #ffffff;
    --border: #e2e8f0;
    --border-subtle: #edf0f5;
    --text: #111827;
    --muted: #64748b;
    --muted-light: #94a3b8;

    /* Patriot Fleet Group brand colors */
    --primary: #1a3494;          /* Patriot navy blue */
    --primary-hover: #142a7a;
    --pfg-red: #c8102e;          /* Patriot red (logo swoosh) */
    --pfg-dark: #1a1a1e;         /* Header charcoal */
    --pfg-dark-2: #2c2c2c;       /* Slightly lighter header depth */

    --complete: #15803d;
    --complete-bg: #f0fdf4;
    --complete-border: #bbf7d0;

    --incomplete: #64748b;
    --incomplete-bg: #f8fafc;
    --incomplete-border: #e2e8f0;

    --at-risk: #b45309;
    --at-risk-bg: #fffbeb;
    --at-risk-border: #fde68a;

    --overdue: #b91c1c;
    --overdue-bg: #fef2f2;
    --overdue-border: #fecaca;

    --radius: 8px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.05);
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Skip navigation link (WCAG 2.4.1) ────────────────────────────────────── */
.skip-link {
    position: absolute;
    top: -48px;
    left: 8px;
    background: var(--primary);
    color: #fff;
    padding: 10px 18px;
    border-radius: 0 0 var(--radius) var(--radius);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    z-index: 99999;
    transition: top 0.1s;
}
.skip-link:focus { top: 0; outline: 3px solid #fff; outline-offset: 2px; }

/* ── Global focus-visible baseline (WCAG 2.4.7) ────────────────────────────── */
:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* ── Screen-reader only utility (visually hidden but accessible) ─────────── */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.65;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
    font-family: var(--mono);
    font-size: 12px;
    background: #f1f3f5;
    padding: 1px 5px;
    border-radius: 3px;
    border: 1px solid var(--border);
}

.muted { color: var(--muted); }

/* Header — Patriot Fleet Group dark charcoal bar */
.site-header {
    background: var(--pfg-dark);
    border-bottom: 2px solid var(--pfg-red);
    padding: 10px 24px;
    display: flex;
    align-items: center;
}

.header-inner {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Brand block: logo + subtitle */
.site-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
}

.site-brand:hover { text-decoration: none; opacity: 0.9; }

.site-logo {
    height: 46px;
    width: auto;
    flex-shrink: 0;
    display: block;
}

.brand-sub {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255,255,255,0.5);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    white-space: nowrap;
}

nav { display: flex; gap: 1px; }

.nav-link {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.01em;
    transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
    background: rgba(255,255,255,0.09);
    color: rgba(255,255,255,0.92);
    text-decoration: none;
}

.nav-link.active {
    background: rgba(255,255,255,0.13);
    color: #ffffff;
    font-weight: 600;
    box-shadow: inset 0 -2px 0 var(--pfg-red);
}

.nav-divider {
    display: inline-block;
    width: 1px;
    height: 18px;
    background: rgba(255,255,255,0.18);
    margin: 0 4px;
    vertical-align: middle;
}

.nav-link-le { color: rgba(255,255,255,0.75); }
.nav-link-le:hover { color: #fff; }
.nav-link-le.active { box-shadow: inset 0 -2px 0 #60a5fa; }

/* Main */
.main-content {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 28px 24px;
}

/* Footer — matches dark header */
.site-footer {
    border-top: 1px solid rgba(255,255,255,0.06);
    padding: 12px 24px;
    text-align: center;
    color: rgba(255,255,255,0.6);
    font-size: 11px;
    background: var(--pfg-dark);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* ── Shared page top bar (Ordered / Delivered / Unclassified) ── */
.dashboard-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}
.dashboard-heading h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.4px;
    color: var(--text);
    margin: 0 0 2px;
}

/* ── Dashboard header: title row + action row ── */
.dash-header {
    margin-bottom: 16px;
}
.dash-title-row h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.4px;
    color: var(--text);
    margin: 0 0 1px;
    line-height: 1.2;
}
.dash-title-row .dashboard-subtitle {
    font-size: 12.5px;
    color: var(--muted);
    margin: 0 0 10px;
    font-weight: 400;
}
.dash-action-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}
.dash-cta-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    flex-shrink: 0;
}
.last-checked {
    font-size: 12px;
    color: var(--muted);
    letter-spacing: 0.01em;
}
.last-scan-time {
    font-size: 10px;
    color: #b0bac8;
    letter-spacing: 0.01em;
    text-align: center;
    white-space: nowrap;
    align-self: center;
}

/* Run Check button */
.btn-run {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    padding: 9px 20px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s, opacity 0.15s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    box-shadow: 0 1px 3px rgba(26,52,148,.25);
}

.btn-run:hover { background: var(--primary-hover); box-shadow: 0 2px 6px rgba(26,52,148,.35); }

.btn-run.running {
    opacity: 0.75;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-run.btn-run-locked {
    background: #6b7280;
    cursor: not-allowed;
    opacity: 0.55;
    pointer-events: none;
    box-shadow: none;
}

.btn-run.btn-run-locked:hover {
    background: #6b7280;
    box-shadow: none;
}

/* Tooltip wrapper for locked Run Check button */
.run-lock-wrap {
    position: relative;
    display: inline-block;
}

.run-lock-wrap::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: #1e2a4a;
    color: #fff;
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.4;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.15s, transform 0.15s;
    z-index: 500;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.run-lock-wrap::before {
    content: "";
    position: absolute;
    bottom: calc(100% + 2px);
    right: 14px;
    border: 5px solid transparent;
    border-top-color: #1e2a4a;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 501;
}

.run-lock-wrap:hover::after,
.run-lock-wrap:hover::before {
    opacity: 1;
    transform: translateY(0);
}

.btn-link-subtle {
    background: none;
    border: none;
    padding: 0;
    font-size: 11px;
    color: #9ca3af;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    vertical-align: middle;
    line-height: 1;
}
.btn-link-subtle:hover {
    color: #4b5563;
}

.btn-run .btn-spinner {
    display: none;
    width: 13px;
    height: 13px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.btn-run.running .btn-spinner { display: inline-block; }

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

/* ── Run-check firetruck modal ─────────────────────────────────────────────── */
#rcm {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    align-items: center;
    justify-content: center;
}
#rcm.active { display: flex; }

.rcm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(3px);
    animation: rcm-fade-in 0.2s ease;
}

@keyframes rcm-fade-in { from { opacity: 0; } to { opacity: 1; } }

.rcm-card {
    position: relative;
    background: #fff;
    border-radius: 20px;
    padding: 28px 36px 24px;
    text-align: center;
    width: 360px;
    max-width: 92vw;
    box-shadow: 0 24px 64px rgba(0,0,0,0.28);
    animation: rcm-pop-in 0.25s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes rcm-pop-in {
    from { transform: scale(0.85); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

/* Scene — sky + road */
.rcm-scene {
    position: relative;
    height: 90px;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 18px;
    background: linear-gradient(180deg, #bfdbfe 0%, #dbeafe 55%, #6b7280 55%, #4b5563 100%);
}

/* Scrolling road dashes */
.rcm-road { position: absolute; bottom: 0; left: 0; right: 0; height: 40px; }

.rcm-dashes {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 4px;
    background: repeating-linear-gradient(
        90deg,
        #fbbf24 0, #fbbf24 22px,
        transparent 22px, transparent 44px
    );
    transform: translateY(-50%);
    animation: rcm-road-scroll 0.5s linear infinite;
}

@keyframes rcm-road-scroll { to { background-position: -44px 0; } }

/* Firetruck — flipped to face right, bouncing */
.rcm-truck {
    position: absolute;
    bottom: 38px;
    left: 14%;
    font-size: 44px;
    line-height: 1;
    transform: scaleX(-1);
    animation: rcm-drive 2.8s ease-in-out infinite, rcm-bounce 0.35s ease-in-out infinite alternate;
    transform-origin: center bottom;
    filter: drop-shadow(2px 2px 3px rgba(0,0,0,0.2));
}

@keyframes rcm-drive {
    0%   { left: 10%; }
    45%  { left: 52%; }
    55%  { left: 52%; }
    100% { left: 10%; }
}

@keyframes rcm-bounce {
    from { transform: scaleX(-1) translateY(0); }
    to   { transform: scaleX(-1) translateY(-5px); }
}

/* Money bag — pulses, truck stops short of it */
.rcm-money {
    position: absolute;
    bottom: 40px;
    right: 14%;
    font-size: 38px;
    line-height: 1;
    animation: rcm-money-pulse 1.2s ease-in-out infinite alternate;
    filter: drop-shadow(1px 2px 4px rgba(0,0,0,0.15));
}

@keyframes rcm-money-pulse {
    from { transform: scale(1) rotate(-4deg); }
    to   { transform: scale(1.12) rotate(4deg); }
}

/* Smoke — drifts left behind the truck */
.rcm-smoke {
    position: absolute;
    bottom: 46px;
    left: 7%;
    font-size: 18px;
    opacity: 0.7;
    animation: rcm-smoke-drift 1.4s ease-out infinite;
}

@keyframes rcm-smoke-drift {
    0%   { opacity: 0.7; transform: translateX(0) scale(1); }
    100% { opacity: 0;   transform: translateX(-28px) scale(1.6); }
}

/* Done state — truck reaches money */
#rcm.done .rcm-truck {
    animation: rcm-arrive 0.5s ease-out forwards, rcm-bounce 0.35s ease-in-out infinite alternate;
}
@keyframes rcm-arrive { to { left: 44%; } }

#rcm.done .rcm-money { animation: rcm-celebrate 0.4s ease-in-out infinite alternate; }
@keyframes rcm-celebrate {
    from { transform: scale(1.1) rotate(-6deg); }
    to   { transform: scale(1.25) rotate(6deg); }
}

/* Labels */
.rcm-label {
    font-size: 15px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 4px;
}

.rcm-sub {
    font-size: 12px;
    color: #6b7280;
    margin: 0;
}

/* Fetch Photos button */
.action-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.btn-photos {
    background: #ffffff;
    color: var(--primary);
    border: 1.5px solid var(--primary);
    border-radius: var(--radius);
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.btn-photos:hover {
    background: var(--primary);
    color: #ffffff;
}

/* Info banner */
.info-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    color: #1e40af;
    font-size: 13px;
    padding: 10px 16px;
    margin-bottom: 20px;
    gap: 12px;
}

.banner-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #1e40af;
    line-height: 1;
    padding: 0 4px;
    flex-shrink: 0;
}

/* Status cards */
.status-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 20px;
    border-left: 4px solid transparent;
}

.card-count {
    font-size: 48px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -1px;
    margin-bottom: 3px;
}

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

.card-sub {
    font-size: 10px;
    color: #b0b8c4;
    margin-top: 1px;
    font-weight: 400;
}

.card-complete { border-left-color: var(--complete); }
.card-complete .card-count { color: var(--complete); }

.card-incomplete { border-left-color: var(--incomplete); }
.card-incomplete .card-count { color: var(--incomplete); }

.card-at-risk { border-left-color: var(--at-risk); }
.card-at-risk .card-count { color: var(--at-risk); }

.card-overdue { border-left-color: var(--overdue); }
.card-overdue .card-count { color: var(--overdue); }

/* Filter bar */
.drilldown-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f0f4ff;
    border: 1px solid #c7d4f8;
    border-left: 4px solid #2563eb;
    border-radius: var(--radius);
    padding: 10px 16px;
    margin-bottom: 12px;
    font-size: .875rem;
    color: #1e3a8a;
}
.drilldown-icon { font-size: .95rem; line-height: 1; }
.drilldown-clear {
    margin-left: auto;
    font-size: .8rem;
    color: #2563eb;
    text-decoration: none;
    white-space: nowrap;
}
.drilldown-clear:hover { text-decoration: underline; }

.filter-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 13px 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.filter-form {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.filter-form label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.02em;
}

.filter-form select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
}
.filter-form select:focus {
    outline: none;
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}

.clear-link {
    font-size: 12px;
    color: var(--muted);
    margin-left: 4px;
}

/* Table */
.table-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: auto;
    box-shadow: var(--shadow-sm);
}

.vehicles-table {
    width: 100%;
    border-collapse: collapse;
}

.vehicles-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--muted);
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    white-space: nowrap;
}

.vehicles-table td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

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

.row-overdue { background: #fef9f9; }
.row-at-risk { background: #fefdf6; }

.row-overdue:hover { background: #fef2f2; }
.row-at-risk:hover { background: #fffbeb; }
.vehicles-table tbody tr:hover { background: #f7f9fb; }
.row-overdue:hover, .row-at-risk:hover { }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.badge-complete, .badge-delivered { background: var(--complete-bg); color: var(--complete); border: 1px solid var(--complete-border); }
.badge-incomplete { background: var(--incomplete-bg); color: var(--incomplete); border: 1px solid var(--incomplete-border); }
.badge-at_risk, .badge-at-risk, .badge-approaching { background: var(--at-risk-bg); color: var(--at-risk); border: 1px solid var(--at-risk-border); }
.badge-overdue, .badge-expired { background: var(--overdue-bg); color: var(--overdue); border: 1px solid var(--overdue-border); }

.badge-lg { font-size: 13px; padding: 4px 12px; }

/* Source tags */
.source-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    background: #f1f5f9;
    color: #475569;
    text-decoration: none;
    border: 1px solid #e2e8f0;
}
a.source-tag {
    cursor: pointer;
    transition: filter .15s;
}
a.source-tag:hover { filter: brightness(0.93); text-decoration: none; }

.source-press_release { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.source-website { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.source-rss { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.source-social { background: #faf5ff; color: #7e22ce; border-color: #e9d5ff; }

/* Triage signal source badges */
.source-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: #e9ecef;
    color: #495057;
}
/* Northeast Firenews */
.source-badge[class*="firenews"]    { background: #dbeafe; color: #1e40af; }
/* MassFireTrucks */
.source-badge[class*="massfiretrucks"] { background: #fef3c7; color: #78350f; }
/* Greenwood EV */
.source-badge[class*="greenwood"]   { background: #d1fae5; color: #065f46; }
/* Marion Body Works */
.source-badge[class*="marionbody"]  { background: #ede9fe; color: #5b21b6; }
/* E-One */
.source-badge[class*="e-one"]       { background: #fee2e2; color: #991b1b; }
/* KME */
.source-badge[class*="kme"]         { background: #fce7f3; color: #9d174d; }

/* Cell specifics */
.cell-title { max-width: 240px; font-weight: 500; }

/* Two-tier title: bold department + muted subtitle */
.title-dept {
    display: block;
    font-weight: 700;
    line-height: 1.35;
}

/* ── Click-to-copy on department name ────────────────────────── */
.vehicles-table .title-dept {
    cursor: pointer;
    position: relative;
}
.vehicles-table .title-dept:hover {
    text-decoration: underline;
    text-decoration-style: dotted;
    text-decoration-color: #9ca3af;
}
.vehicles-table .title-dept::after {
    content: 'copy to clipboard';
    position: absolute;
    left: 0;
    top: calc(100% + 3px);
    background: #1a1a2e;
    color: #fff;
    font-size: 11px;
    font-weight: 400;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: opacity .12s;
}
.vehicles-table .title-dept:hover::after {
    opacity: 1;
}
/* Toast notification */
.copy-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: #1a1a2e;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    padding: 7px 16px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
    pointer-events: none;
    opacity: 0;
    transition: opacity .18s, transform .18s;
    z-index: 9999;
    white-space: nowrap;
}
.copy-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.title-sub {
    display: block;
    font-weight: 400;
    font-size: 11px;
    color: var(--muted);
    line-height: 1.4;
    margin-top: 2px;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cell-key { font-size: 12px; }
.cell-ts { font-size: 12px; white-space: nowrap; color: var(--muted); }
.ts-overdue { color: var(--overdue) !important; font-weight: 600; }
.ts-at-risk { color: var(--at-risk) !important; font-weight: 600; }
.cell-missing { font-size: 12px; }
.missing-fields { color: var(--overdue); }

/* Dashboard — "0 submitted" context */
.card-count-muted { color: var(--muted); }
.card-pending-note {
    margin-top: 6px;
    font-size: 11px;
    color: var(--muted);
    font-style: italic;
}

/* Settings — removal reason breakdown */
.removal-summary-table {
    width: 100%;
    max-width: 540px;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 12px;
}
.removal-summary-table th {
    text-align: left;
    padding: 6px 10px;
    background: #f1f5f9;
    border-bottom: 2px solid #e2e8f0;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}
.removal-summary-table td {
    padding: 7px 10px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
.removal-summary-table tfoot td {
    border-top: 2px solid #e2e8f0;
    border-bottom: none;
    padding-top: 8px;
}
.removal-bar-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
    min-width: 120px;
}
.removal-bar {
    height: 8px;
    border-radius: 4px;
    background: #1a3494;
    min-width: 4px;
    max-width: 80px;
}
.removal-pct {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    min-width: 32px;
    text-align: right;
}
.badge-neutral {
    background: #e2e8f0;
    color: #334155;
}

.badge-blue {
    background: #dbeafe;
    color: #1e40af;
}

.badge-green {
    background: #d1fae5;
    color: #065f46;
}

.badge-yellow {
    background: #fef3c7;
    color: #78350f;
}

.detail-link {
    font-size: 12px;
    font-weight: 500;
}

/* Empty state */
.empty-state {
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    color: var(--muted);
}
.no-tab-results {
    padding: 40px 24px;
    text-align: center;
    background: var(--surface);
    border-top: 1px solid var(--border);
}
.no-tab-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; border-radius: 50%;
    background: #d1fae5; color: #065f46;
    font-size: 22px; font-weight: 700;
    margin: 0 auto 12px;
}
.no-tab-msg {
    font-size: 14px; font-weight: 600;
    color: var(--color-text, #111827);
    margin-bottom: 4px;
}
.no-tab-hint {
    font-size: 12px; color: var(--muted, #9ca3af);
}

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.4px;
    color: var(--text);
}

/* Detail page */
.detail-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 28px;
}
.detail-header .back-link {
    width: 100%;
    margin-bottom: 0;
}
.detail-header .detail-title {
    margin: 0;
    flex: 1;
}

.back-link {
    display: inline-block;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 12px;
}

.back-link:hover { color: var(--text); }

.detail-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.detail-grid + .detail-grid { margin-top: 24px; }

.detail-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.detail-section-full { grid-column: 1 / -1; }

.detail-section h2 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.detail-table { width: 100%; border-collapse: collapse; }
.detail-table th {
    text-align: left;
    font-weight: 500;
    color: var(--muted);
    font-size: 12px;
    padding: 6px 12px 6px 0;
    vertical-align: middle;
    width: 160px;
    white-space: nowrap;
}
.detail-table td {
    padding: 6px 0;
    font-size: 13px;
    vertical-align: middle;
    word-break: break-word;
}

.notes-text {
    font-size: 13px;
    color: var(--text);
    line-height: 1.7;
}

/* Photo thumbnails in dashboard table */
.cell-thumb {
    width: 80px;
    text-align: center;
    padding: 4px 6px;
}

.thumb {
    width: 72px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
    display: block;
    transition: opacity 0.15s;
}

.thumb:hover { opacity: 0.85; }

.no-photo {
    font-size: 16px;
    color: var(--muted);
}

/* Detail page photo */
.detail-photo {
    margin-bottom: 28px;
    text-align: center;
}

.detail-photo img {
    max-width: 640px;
    max-height: 380px;
    width: 100%;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.photo-caption {
    font-size: 11px;
    color: var(--muted);
    margin-top: 6px;
    font-style: italic;
}

/* ── Lightbox (native dialog) ────────────────────────────── */
dialog.lb-dialog {
    border: none;
    padding: 0;
    background: transparent;
    max-width: 95vw;
    max-height: 95vh;
    overflow: visible;
    outline: none;
}

dialog.lb-dialog::backdrop {
    background: rgba(0,0,0,0.88);
}

.lb-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.lb-img-wrap {
    position: relative;
    min-width: 60px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#lb-img {
    max-width: 88vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
    display: block;
    transition: opacity 0.2s;
}

.lb-spinner {
    display: none;
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: lb-spin 0.7s linear infinite;
    position: absolute;
}

@keyframes lb-spin { to { transform: rotate(360deg); } }

.lb-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 16px;
    min-height: 20px;
}

#lb-caption {
    color: #e2e8f0;
    font-size: 13px;
    font-style: italic;
    flex: 1;
}

.lb-counter-text {
    color: #94a3b8;
    font-size: 12px;
    white-space: nowrap;
}

.lb-close {
    position: fixed;
    top: 14px;
    right: 18px;
    background: rgba(0,0,0,0.4);
    border: none;
    color: #fff;
    font-size: 30px;
    line-height: 1;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.15s, background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lb-close:hover { opacity: 1; background: rgba(0,0,0,0.65); }

.lb-arrow {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    font-size: 52px;
    line-height: 1;
    padding: 10px 16px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s;
    user-select: none;
}

.lb-arrow:hover { background: rgba(255,255,255,0.28); }
.lb-prev { left: 10px; }
.lb-next { right: 10px; }

/* Photo open link (fills the img-wrap, opens viewer page) */
.photo-open-btn {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: none;
    background: none;
    cursor: zoom-in;
    position: relative;
    text-decoration: none;
}

.photo-open-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.lb-hint-icon {
    position: absolute;
    bottom: 6px;
    right: 8px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6));
}

.photo-open-btn:hover .lb-hint-icon { opacity: 1; }

/* ── Photo gallery (detail page) ──────────────────────────── */
.gallery-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 28px;
}

.gallery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.gallery-header h2 {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
}

.photo-count {
    font-weight: 400;
    color: var(--muted);
    font-size: 13px;
}

.no-photos-msg {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 20px;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.photo-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: #f8f9fb;
    display: flex;
    flex-direction: column;
}

.photo-card.photo-primary {
    border-color: var(--primary);
    border-width: 2px;
}

.photo-card.photo-broken .photo-img-wrap img { display: none; }
.photo-card.photo-broken .photo-img-wrap::after {
    content: 'Image unavailable';
    display: flex;
    align-items: center;
    justify-content: center;
    height: 140px;
    font-size: 12px;
    color: var(--muted);
}

.photo-img-wrap {
    position: relative;
    width: 100%;
    height: 160px;
    background: #e5e7eb;
    overflow: hidden;
}

.photo-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.primary-badge, .upload-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

.primary-badge {
    background: var(--primary);
    color: #fff;
}

.upload-badge {
    background: #16a34a;
    color: #fff;
    top: 6px;
    left: auto;
    right: 6px;
}

.search-badge {
    position: absolute;
    bottom: 6px;
    left: 6px;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    letter-spacing: 0.3px;
    background: #92400e;
    color: #fef3c7;
    pointer-events: none;
}

.photo-unverified .photo-img-wrap {
    outline: 2px solid #d97706;
    outline-offset: -2px;
    border-radius: var(--radius);
}

.photo-label-warn {
    color: #92400e;
    font-style: italic;
}

.photo-label {
    font-size: 12px;
    color: var(--muted);
    padding: 6px 10px 2px;
    margin: 0;
    line-height: 1.4;
    flex: 1;
}

.photo-actions {
    display: flex;
    gap: 6px;
    padding: 8px 10px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.btn-photo-action {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 9px;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    transition: background 0.12s;
    white-space: nowrap;
}

.btn-photo-action:hover { background: #f1f3f5; }

.btn-primary-set { color: var(--primary); border-color: #bfdbfe; }
.btn-primary-set:hover { background: #eff6ff; }

.btn-delete { color: var(--overdue); border-color: #fca5a5; }
.btn-delete:hover { background: #fff1f2; }

/* Upload area */
.upload-area {
    border-top: 1px solid var(--border);
    padding-top: 20px;
}

.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 28px 20px;
    color: var(--muted);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.drop-zone:hover, .drop-zone.dz-over {
    border-color: var(--primary);
    background: #f0f7ff;
    color: var(--primary);
}

.drop-label { font-size: 13px; font-weight: 500; margin: 0; }
.drop-hint  { font-size: 11px; color: var(--muted); margin: 0; }

.browse-link {
    color: var(--primary);
    cursor: pointer;
    text-decoration: underline;
}

#preview-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 0;
}

#preview-img {
    height: 80px;
    width: 120px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.upload-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 12px;
    flex-wrap: wrap;
}

.caption-input {
    flex: 1;
    min-width: 180px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: var(--font);
    color: var(--text);
    background: var(--surface);
}

.caption-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.btn-upload {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.btn-upload:hover:not(:disabled) { background: var(--primary-hover); }

.btn-upload:disabled {
    background: #93c5fd;
    cursor: not-allowed;
}

/* Alert */
.alert {
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-error {
    background: var(--overdue-bg);
    border: 1px solid var(--overdue-border);
    color: var(--overdue);
}

/* ── Flash messages ───────────────────────────────────────────────────────── */
.flash-container {
    margin-bottom: 16px;
}
.flash {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}
.flash-icon {
    font-size: 16px;
    flex-shrink: 0;
}
.flash-success {
    background: var(--complete-bg);
    border-color: var(--complete-border);
    color: var(--complete);
}
.flash-error {
    background: var(--overdue-bg);
    border-color: var(--overdue-border);
    color: var(--overdue);
}

/* ── Salesforce section (detail page) ────────────────────────────────────── */
.sf-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 24px;
}
.sf-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}
.sf-header h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}
.sf-logo {
    flex-shrink: 0;
}
.sf-mock-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.sf-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.sf-status-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 28px;
}
.sf-status-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid;
    white-space: nowrap;
}
.sf-synced {
    background: var(--complete-bg);
    border-color: var(--complete-border);
    color: var(--complete);
}
.sf-error {
    background: var(--overdue-bg);
    border-color: var(--overdue-border);
    color: var(--overdue);
}
.sf-never {
    background: var(--incomplete-bg);
    border-color: var(--incomplete-border);
    color: var(--muted);
}
.sf-record-id {
    font-size: 12px;
    color: var(--muted);
}
.sf-ts {
    font-size: 12px;
}
.sf-error-msg {
    font-size: 12px;
    color: var(--overdue);
    font-family: var(--mono);
    background: var(--overdue-bg);
    padding: 2px 6px;
    border-radius: 3px;
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sf-form {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.btn-sf {
    font-size: 13px;
    font-weight: 600;
    padding: 8px 18px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: opacity 0.15s;
    white-space: nowrap;
}
.btn-sf:hover { opacity: 0.85; }
.btn-sf-send {
    background: #00a1e0;
    color: #fff;
}
.btn-sf-update {
    background: var(--complete);
    color: #fff;
}
.sf-mock-note {
    font-size: 12px;
    color: var(--muted);
    font-style: italic;
}

/* ── Salesforce column (dashboard) ───────────────────────────────────────── */
.cell-sf {
    text-align: center;
    width: 42px;
}
.sf-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    cursor: default;
}
.sf-dot-synced {
    background: var(--complete-bg);
    color: var(--complete);
    border: 1px solid var(--complete-border);
}
.sf-dot-error {
    background: var(--overdue-bg);
    color: var(--overdue);
    border: 1px solid var(--overdue-border);
}
.sf-dot-none {
    color: var(--muted);
}

/* ── Triage page ──────────────────────────────────────────────────────────── */
.triage-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.triage-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 4px;
}
.triage-subtitle {
    font-size: 13px;
    color: var(--muted);
    margin: 0;
}
.triage-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
.btn-secondary {
    font-size: 13px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: background 0.12s;
}
.btn-secondary:hover { background: var(--bg); }

.triage-empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--muted);
}
.triage-empty-icon { font-size: 48px; margin-bottom: 12px; }
.triage-empty-state h2 { font-size: 18px; color: var(--text); margin-bottom: 8px; }
.triage-empty-state p  { font-size: 14px; max-width: 440px; margin: 0 auto; }

/* ── Summary cards ─────────────────────────────────────────────────────────── */
.triage-cards {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}
.triage-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    text-align: center;
}
.tc-num   { font-size: 28px; font-weight: 700; line-height: 1; }
.tc-label { font-size: 12px; font-weight: 600; margin: 4px 0 2px; text-transform: uppercase; letter-spacing: .04em; }
.tc-sub   { font-size: 11px; color: var(--muted); }
.triage-card-overdue  { border-color: var(--overdue-border); }
.triage-card-overdue  .tc-num { color: var(--overdue); }
.triage-card-critical { border-color: #f97316; }
.triage-card-critical .tc-num { color: #ea580c; }
.triage-card-urgent   { border-color: var(--at-risk-border); }
.triage-card-urgent   .tc-num { color: var(--at-risk); }
.triage-card-new      { border-color: var(--complete-border); }
.triage-card-new      .tc-num { color: var(--complete); }
.triage-card-confirmed .tc-num { color: #6366f1; }

/* ── Tabs ──────────────────────────────────────────────────────────────────── */
.triage-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}
.triage-tab {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.12s;
}
.triage-tab:hover { color: var(--text); }
.triage-tab.active { color: var(--text); border-bottom-color: var(--primary); }
.tab-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 20px;
    background: #ef4444;
    color: #fff;
}
.tab-badge-warn { background: #f97316; }
.tab-badge-neutral { background: var(--muted); }

/* ── Filter bar ────────────────────────────────────────────────────────────── */
.triage-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
    align-items: center;
}
.filter-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.filter-label { font-size: 12px; color: var(--muted); font-weight: 600; margin-right: 2px; }
.filter-pill {
    font-size: 12px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    transition: background 0.1s;
}
.filter-pill:hover { background: var(--bg); }
.filter-pill.active { background: var(--text); color: var(--surface); border-color: var(--text); }
.pill-overdue.active  { background: var(--overdue); border-color: var(--overdue); }
.pill-critical.active { background: #ea580c; border-color: #ea580c; }
.pill-urgent.active   { background: var(--at-risk); border-color: var(--at-risk); }

/* ── Match cards ────────────────────────────────────────────────────────────── */
.match-list { display: flex; flex-direction: column; gap: 10px; }

.match-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    overflow: hidden;
    transition: box-shadow 0.12s;
}
.match-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.07); }
.match-card.match-overdue  { border-color: var(--overdue-border); }
.match-card.match-critical { border-color: #fed7aa; }
.match-card.match-urgent   { border-color: var(--at-risk-border); }
.match-card.match-confirmed { opacity: 0.9; }
.match-card.match-dismissed { opacity: 0.45; }

.match-urgency-stripe {
    width: 5px;
    flex-shrink: 0;
    border-radius: var(--radius) 0 0 var(--radius);
}
.urgency-overdue  { background: var(--overdue); }
.urgency-critical { background: #ea580c; }
.urgency-urgent   { background: var(--at-risk); }
.urgency-new      { background: var(--complete); }
.urgency-unknown  { background: var(--border); }

.match-body {
    display: grid;
    grid-template-columns: 1fr 90px 1fr auto;
    gap: 16px;
    padding: 14px 16px;
    flex: 1;
    align-items: start;
}
.match-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    margin-bottom: 6px;
}
.match-vehicle-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.match-thumb-wrap {
    position: relative;
    flex-shrink: 0;
    width: 52px;
    height: 40px;
}
.match-thumb {
    width: 52px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
    background: var(--bg);
}
.thumb-unverified-badge {
    position: absolute;
    bottom: -4px;
    right: -4px;
    background: #92400e;
    color: #fef3c7;
    font-size: 10px;
    font-weight: 700;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    cursor: help;
    border: 1.5px solid #fff;
}
.match-thumb-placeholder {
    width: 52px;
    height: 40px;
    background: var(--bg);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.match-vehicle-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    line-height: 1.3;
    display: block;
    margin-bottom: 4px;
}
.match-vehicle-title:hover { color: var(--primary); text-decoration: underline; }
.match-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* Confidence column */
.match-score-col { text-align: center; }
.match-confidence {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    width: 60px;
    padding: 6px 0;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 6px;
}
.match-conf-high   { border-color: var(--complete-border); background: var(--complete-bg); }
.match-conf-medium { border-color: var(--at-risk-border); background: var(--at-risk-bg, #fff7ed); }
.match-conf-low    { border-color: var(--incomplete-border); background: var(--incomplete-bg); }
.conf-score { font-size: 18px; font-weight: 800; line-height: 1; }
.conf-tier  { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.match-conf-high   .conf-score { color: var(--complete); }
.match-conf-medium .conf-score { color: var(--at-risk); }
.match-conf-low    .conf-score { color: var(--muted); }
.match-fields { display: flex; flex-direction: column; gap: 3px; align-items: center; }
.match-field-tag {
    font-size: 10px;
    font-weight: 500;
    padding: 1px 5px;
    border-radius: 3px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--muted);
    white-space: nowrap;
}

/* Claim side */
.match-claim-name { font-size: 14px; font-weight: 600; margin-bottom: 5px; }
.match-claim-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.match-deadline-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Deadline badges */
.deadline-badge {
    font-size: 12px; font-weight: 700;
    padding: 2px 9px; border-radius: 20px; border: 1px solid; white-space: nowrap;
}
.deadline-overdue  { background: var(--overdue-bg); border-color: var(--overdue-border); color: var(--overdue); }
.deadline-critical { background: #fff7ed; border-color: #fed7aa; color: #ea580c; }
.deadline-urgent   { background: var(--at-risk-bg, #fefce8); border-color: var(--at-risk-border); color: var(--at-risk); }
.deadline-new      { background: var(--complete-bg); border-color: var(--complete-border); color: var(--complete); }

/* Apparatus / state badges */
.appt-badge {
    font-size: 12px; font-weight: 600; padding: 2px 8px;
    border-radius: 4px; background: var(--incomplete-bg); border: 1px solid var(--incomplete-border);
    color: var(--text);
}
.state-badge {
    font-size: 11px; font-weight: 700; padding: 1px 6px;
    border-radius: 3px; background: var(--bg); border: 1px solid var(--border);
    color: var(--muted); letter-spacing: .04em;
}

/* Action buttons */
.match-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
    justify-content: center;
    min-width: 90px;
}
.btn-confirm {
    font-size: 12px; font-weight: 700;
    padding: 7px 12px; border-radius: var(--radius);
    border: none; cursor: pointer;
    background: var(--complete); color: #fff;
    transition: opacity .12s;
}
.btn-confirm:hover { opacity: .85; }
.btn-dismiss {
    font-size: 11px; font-weight: 700;
    padding: 4px 8px; border-radius: var(--radius);
    border: 1px solid var(--border); cursor: pointer;
    background: var(--surface); color: var(--muted);
    transition: background .12s, color .12s, border-color .12s;
    line-height: 1;
}
.btn-dismiss:hover { background: #fff1f2; color: var(--overdue); border-color: #fca5a5; }

/* Inline delete form sits next to View link in table rows */
.cell-actions { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.inline-delete-form { margin: 0; padding: 0; }

/* Delete button on detail page */
.detail-delete-form { margin-left: auto; }
.btn-delete {
    font-size: 12px; font-weight: 600;
    padding: 6px 14px; border-radius: var(--radius);
    border: 1px solid #fca5a5; cursor: pointer;
    background: #fff1f2; color: var(--overdue);
    transition: background .12s;
}
.btn-undo {
    font-size: 11px; font-weight: 600;
    padding: 5px 10px; border-radius: var(--radius);
    border: 1px solid var(--border); cursor: pointer;
    background: var(--surface); color: var(--muted);
}
.btn-view-link {
    font-size: 12px; font-weight: 600;
    color: #3b82f6; text-decoration: none;
    text-align: center;
}
.match-status-badge {
    font-size: 11px; font-weight: 700; padding: 3px 8px;
    border-radius: 20px; border: 1px solid; text-align: center;
}
.status-confirmed { background: var(--complete-bg); border-color: var(--complete-border); color: var(--complete); }
.status-dismissed { background: var(--incomplete-bg); border-color: var(--incomplete-border); color: var(--muted); }

/* ── Watch list & unmatched signals tables ─────────────────────────────────── */
.triage-section-note {
    font-size: 13px;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
}
.triage-watch-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.triage-watch-table th {
    text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .05em; color: var(--muted); padding: 8px 12px;
    border-bottom: 2px solid var(--border); background: var(--surface);
}
.triage-watch-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.triage-watch-table tr:hover td { background: var(--surface); }
.row-overdue td    { background: var(--overdue-bg) !important; }
.row-at-risk td    { background: #fff7ed !important; }
.row-urgent-watch td { background: var(--at-risk-bg, #fefce8) !important; }
.watch-thumb {
    width: 44px; height: 34px; object-fit: cover;
    border-radius: 3px; display: block;
}
.cell-photo-sm { width: 56px; }
.thumb-placeholder-sm { font-size: 22px; }
.triage-empty { text-align: center; padding: 32px; color: var(--muted); font-size: 14px; }

/* ── Operational delay status (triage match cards) ─────────────────────────── */
.op-status-row { margin-top: 5px; }
.op-status {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .3px;
    padding: 2px 7px;
    border-radius: 20px;
    display: inline-block;
}
.op-build_in_progress  { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.op-in_delivery_window { background: #f0fdf4; color: #16a34a; border: 1px solid #86efac; }
.op-build_delayed      { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }

/* ── Evidence summary card on triage ────────────────────────────────────────── */
.triage-card-evidence {
    border-color: #e0e7ff;
    background: #f5f7ff;
    cursor: pointer;
    transition: background .15s;
}
.triage-card-evidence:hover { background: #e0e7ff; }
.triage-card-evidence .tc-num { color: #4f46e5; }

/* ── Evidence queue page ─────────────────────────────────────────────────────── */
.ev-summary-row {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.ev-summary-card {
    flex: 1;
    min-width: 100px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    text-align: center;
}
.ev-summary-num { display: block; font-size: 28px; font-weight: 700; line-height: 1; }
.ev-summary-label { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .5px; }
.ev-summary-pending .ev-summary-num { color: #b45309; }
.ev-summary-linked  .ev-summary-num { color: #2563eb; }
.ev-summary-approved .ev-summary-num { color: #16a34a; }
.ev-summary-rejected .ev-summary-num { color: var(--overdue); }

.ev-filter-bar { display: flex; gap: 6px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }

.ev-list { display: flex; flex-direction: column; gap: 12px; }

.ev-card {
    display: flex;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    transition: box-shadow .15s;
}
.ev-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.ev-card-linked  { border-left: 3px solid #2563eb; }
.ev-card-rejected { opacity: .6; }

.ev-card-image {
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
}
.ev-card-image img { width: 100%; height: 100%; object-fit: cover; }
.ev-no-image { font-size: 11px; color: var(--muted); text-align: center; }

.ev-card-body  { flex: 1; min-width: 0; }
.ev-card-headline { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.ev-vehicle-link { font-size: 14px; font-weight: 600; color: var(--primary); text-decoration: none; }
.ev-vehicle-link:hover { text-decoration: underline; }
.ev-badges { display: flex; gap: 4px; flex-wrap: wrap; }
.ev-source-badge { font-size: 11px; background: #e0e7ff; color: #4338ca; border-radius: 20px; padding: 1px 7px; }
.ev-type-badge   { font-size: 11px; background: #f0fdf4; color: #16a34a; border: 1px solid #86efac; border-radius: 20px; padding: 1px 7px; }
.ev-score-badge  { font-size: 11px; background: #f0f9ff; color: #0284c7; border: 1px solid #bae6fd; border-radius: 20px; padding: 1px 7px; font-weight: 700; }

.ev-summary { font-size: 13px; color: var(--text); margin: 4px 0 6px; }
.ev-meta-row { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.ev-meta-item { }
.ev-source-link { color: var(--primary); text-decoration: none; font-size: 12px; }
.ev-source-link:hover { text-decoration: underline; }

.ev-claim-link-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.ev-claim-linked-badge { font-size: 11px; color: #2563eb; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 20px; padding: 1px 7px; font-weight: 600; }
.ev-claim-name  { font-size: 13px; font-weight: 600; }
.ev-claim-state { font-size: 11px; background: #f3f4f6; color: #374151; border-radius: 20px; padding: 1px 7px; }
.ev-claim-type  { font-size: 11px; background: #f0fdf4; color: #16a34a; border: 1px solid #86efac; border-radius: 20px; padding: 1px 7px; }
.ev-claim-deadline { font-size: 11px; border-radius: 20px; padding: 1px 7px; background: #f0fdf4; color: #16a34a; }
.ev-claim-deadline.deadline-overdue  { background: var(--overdue-bg);  color: var(--overdue); }
.ev-claim-deadline.deadline-critical { background: #fff7ed; color: #c2410c; }

.ev-card-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; justify-content: flex-start; min-width: 110px; }
.ev-status-badge { font-size: 11px; font-weight: 700; border-radius: 20px; padding: 2px 8px; }
.ev-status-pending  { background: #fef3c7; color: #b45309; }
.ev-status-approved { background: #dcfce7; color: #16a34a; }
.ev-status-rejected { background: var(--overdue-bg); color: var(--overdue); }
.ev-reviewed-by { font-size: 11px; color: var(--muted); text-align: right; }

.btn-ev-approve {
    background: #16a34a; color: #fff; border: none; border-radius: 4px;
    padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
    transition: background .15s;
}
.btn-ev-approve:hover { background: #15803d; }
.btn-ev-reject {
    background: transparent; color: var(--overdue); border: 1px solid #fca5a5;
    border-radius: 4px; padding: 4px 12px; font-size: 12px; font-weight: 600;
    cursor: pointer; transition: all .15s;
}
.btn-ev-reject:hover { background: var(--overdue-bg); }

/* ── Settings page ────────────────────────────────────────────────────────────── */
.settings-section { max-width: 860px; }
.settings-section-header { margin-bottom: 20px; }
.settings-section-header h2 { font-size: 17px; font-weight: 700; margin: 0 0 6px; }
.settings-section-desc { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.5; }

.rule-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
}
.rule-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f8f9fb;
    border-bottom: 1px solid var(--border);
}
.rule-type-badge {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    background: #e0e7ff;
    border-radius: 20px;
    padding: 2px 10px;
}
.rule-updated { font-size: 11px; color: var(--muted); }

.rule-fields {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 2fr;
    gap: 16px;
    padding: 16px;
    align-items: start;
}
.rule-field-group { display: flex; flex-direction: column; gap: 4px; }
.rule-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.rule-range-inputs { display: flex; align-items: center; gap: 4px; }
.rule-input-wrap { display: flex; align-items: center; gap: 4px; }
.rule-input {
    width: 64px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    background: var(--bg);
    color: var(--text);
    transition: border-color .15s;
}
.rule-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,52,148,.15); }
.rule-input-wide { width: 100%; min-width: 160px; }
.rule-input-suffix { font-size: 11px; color: var(--muted); white-space: nowrap; }
.rule-dash { color: var(--muted); padding: 0 2px; }
.rule-hint { font-size: 11px; color: var(--muted); margin: 0; line-height: 1.4; }
.rule-field-notes .rule-input-wrap { width: 100%; }

.rule-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: #f8f9fb;
    border-top: 1px solid var(--border);
}
.rule-urgency-preview { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.rule-preview-label { font-size: 11px; color: var(--muted); }
.urgency-badge {
    font-size: 11px;
    font-weight: 600;
    border-radius: 20px;
    padding: 2px 8px;
}
.urgency-critical { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.urgency-urgent   { background: #fefce8; color: #b45309; border: 1px solid #fde68a; }
.urgency-new      { background: #f0fdf4; color: #16a34a; border: 1px solid #86efac; }

.btn-save-rule {
    background: var(--primary); color: #fff; border: none; border-radius: 4px;
    padding: 6px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
    transition: background .15s;
}
.btn-save-rule:hover { background: var(--primary-hover); }

/* ── Evidence section on vehicle detail ──────────────────────────────────────── */
.evidence-section { margin-top: 28px; }
.evidence-section-title { font-size: 17px; font-weight: 700; margin: 0 0 4px; }
.evidence-count { font-size: 13px; font-weight: 400; color: var(--muted); }
.evidence-section-desc { font-size: 13px; color: var(--muted); margin: 0 0 16px; }
.ev-detail-list { display: flex; flex-direction: column; gap: 10px; }
.ev-detail-card {
    display: flex;
    gap: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
}
.ev-review-approved { border-left: 3px solid #16a34a; }
.ev-review-rejected { border-left: 3px solid var(--overdue); opacity: .65; }
.ev-review-pending  { border-left: 3px solid #b45309; }
.ev-detail-left { flex-shrink: 0; }
.ev-detail-img { width: 64px; height: 64px; object-fit: cover; border-radius: 4px; }
.ev-detail-body { flex: 1; min-width: 0; }
.ev-detail-top  { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.ev-linked-badge {
    font-size: 11px; background: #eff6ff; color: #1d4ed8;
    border: 1px solid #bfdbfe; border-radius: 20px; padding: 1px 7px; font-weight: 600;
}
.ev-unlinked-badge {
    font-size: 11px; background: #f3f4f6; color: var(--muted);
    border: 1px solid var(--border); border-radius: 20px; padding: 1px 7px;
}
.ev-detail-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }
.ev-notes { font-size: 12px; color: var(--text); font-style: italic; margin: 4px 0 0; }
.ev-detail-actions { display: flex; flex-direction: column; gap: 6px; }

/* ── Lifecycle tabs ───────────────────────────────────────────────────────────── */
.lifecycle-tabs-bar { display: flex; gap: 4px; margin: 12px 0 16px; flex-wrap: wrap; }
.lc-tab {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 500;
    text-decoration: none; color: var(--text); background: var(--surface);
    border: 1px solid var(--border); transition: background 0.15s;
}
.lc-tab:hover { background: #e8edf3; }
.lc-tab-active { background: #1a3e6e; color: #fff; border-color: #1a3e6e; }
.lc-tab-active:hover { background: #1a3e6e; }
.lc-tab-delivered.lc-tab-active { background: #1a7a4a; border-color: #1a7a4a; }
.lc-tab-ordered.lc-tab-active   { background: #1565c0; border-color: #1565c0; }
.lc-tab-count {
    background: rgba(0,0,0,0.12); border-radius: 10px;
    padding: 1px 7px; font-size: 11px; font-weight: 700;
}
.lc-tab-active .lc-tab-count { background: rgba(255,255,255,0.25); }

/* ── Lifecycle badges (table + detail) ────────────────────────────────────────── */
.lc-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600;
    letter-spacing: 0.02em; white-space: nowrap;
}
.lc-badge-lg { font-size: 14px; padding: 4px 14px; border-radius: 16px; }
.lc-ordered   { background: #dbeafe; color: #1e40af; }
.lc-delivered { background: #d1fae5; color: #065f46; }
.lc-unknown   { background: #f1f5f9; color: #64748b; }
.lc-pct  { font-weight: 400; opacity: 0.75; font-size: 10px; }
.lc-manual { font-size: 11px; }

/* ── Lifecycle detail block ───────────────────────────────────────────────────── */
.lifecycle-detail-block { display: flex; flex-direction: column; gap: 14px; }
.lifecycle-current { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lc-confidence { font-size: 12px; color: var(--muted); }
.lc-override-tag { font-size: 12px; color: #b45309; font-weight: 500; }
.lifecycle-evidence { font-size: 13px; }
.lifecycle-evidence .evidence-list { margin: 4px 0 0 18px; line-height: 1.7; color: var(--text); }
.lifecycle-override-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lifecycle-override-form label { font-size: 13px; font-weight: 500; }
.lc-select { font-size: 13px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }

/* ── Responsive ────────────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
    .status-cards { grid-template-columns: repeat(2, 1fr); }
    .detail-grid { grid-template-columns: 1fr; }
    .detail-section-full { grid-column: 1; }
    .rule-fields { grid-template-columns: 1fr 1fr; }
    .ev-card { flex-wrap: wrap; }
}

@media (max-width: 540px) {
    .status-cards { grid-template-columns: 1fr 1fr; }
    .main-content { padding: 16px; }
    .rule-fields { grid-template-columns: 1fr; }
}

/* ── Department & Dealer Contacts ────────────────────────────────────────────── */
.contacts-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.contacts-header h2 { margin: 0; }
.btn-contacts-edit {
    background: var(--surface); border: 1px solid var(--border); color: var(--primary);
    border-radius: 6px; padding: 5px 14px; font-size: 13px; font-weight: 600;
    cursor: pointer; transition: background 0.15s, color 0.15s;
}
.btn-contacts-edit:hover { background: var(--primary); color: #fff; }
.btn-contacts-edit.btn-contacts-editing { background: #f3f4f6; color: #555; border-color: #ccc; }

.contacts-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 860px) { .contacts-two-col { grid-template-columns: 1fr; } }

.contacts-subhead { font-size: 13px; font-weight: 700; color: var(--muted);
    text-transform: uppercase; letter-spacing: .05em; margin: 0 0 8px; }

.contacts-empty { color: var(--muted); font-style: italic; }

.contacts-input {
    width: 100%; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 13px; font-family: inherit; background: #fff; color: var(--text);
    box-sizing: border-box;
}
.contacts-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(26,52,148,.1); }

.contacts-form-actions { display: flex; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.btn-small {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 7px 16px; border-radius: 6px;
    font-size: 13px; font-weight: 600;
    cursor: pointer; font-family: inherit;
    transition: background .12s, opacity .12s;
    white-space: nowrap;
}
.btn-contacts-save { background: var(--primary); color: #fff; border: none; }
.btn-contacts-save:hover { background: #122680; }
.btn-contacts-cancel { background: #f3f4f6; color: #555; border: 1px solid #ccc; }
.btn-contacts-cancel:hover { background: #e5e7eb; }

/* ══════════════════════════════════════════════════════════════════
   Mobile / Responsive  (≤ 768 px)
   ══════════════════════════════════════════════════════════════════ */

/* Hamburger button — invisible on desktop */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 4px;
    margin-left: auto;
    flex-shrink: 0;
}
.nav-toggle-bar {
    display: block;
    width: 22px;
    height: 2px;
    background: rgba(255,255,255,0.85);
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}

/* ══════════════════════════════════════════════════════════════
   TABLET / SMALL-DESKTOP  (≤ 768 px)
   Nav collapses, content padding tightens, cards go 2-col.
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* ── Header ─────────────────────────────────────────────────── */
    .site-header {
        height: auto;
        padding: 10px 14px;
    }
    .header-inner {
        flex-wrap: wrap;
        align-items: center;
        gap: 0;
    }
    .site-brand { flex: 1; }
    .brand-sub  { display: none; }
    .site-logo  { height: 36px; }

    /* Show hamburger */
    .nav-toggle { display: flex; }

    /* Nav collapses; opens with .nav-open */
    #main-nav {
        display: none;
        flex-direction: column;
        width: 100%;
        order: 10;
        border-top: 1px solid rgba(255,255,255,0.12);
        padding: 8px 0 4px;
        margin-top: 8px;
        gap: 2px;
    }
    #main-nav.nav-open { display: flex; }
    .nav-link {
        padding: 10px 10px;
        border-radius: 6px;
        font-size: 14px;
    }

    /* ── Main content ───────────────────────────────────────────── */
    .main-content { padding: 14px 12px; }

    /* ── Dashboard top bar ─────────────────────────────────────── */
    .dashboard-top {
        flex-direction: row;
        align-items: flex-start;
        justify-content: space-between;
        gap: 10px;
        flex-wrap: nowrap;
    }
    .dashboard-heading { flex: 1; min-width: 0; }
    .dashboard-heading h1 { font-size: 18px; }
    .action-buttons,
    .btn-run-wrap { flex-shrink: 0; }
    .btn-run, .btn-photos {
        width: auto;
        white-space: nowrap;
    }

    /* ── Lifecycle tabs ────────────────────────────────────────── */
    .lc-tabs { flex-wrap: wrap; gap: 6px; }
    .lc-tab  { font-size: 12px; padding: 5px 11px; }

    /* ── Status cards ──────────────────────────────────────────── */
    .status-cards {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    .status-card-value { font-size: 28px; }

    /* ── Vehicle detail ────────────────────────────────────────── */
    .detail-header  { padding: 16px 0 12px; }
    .detail-title   { font-size: 17px; line-height: 1.3; }
    .back-link      { font-size: 12px; }
    .workflow-flags-bar { flex-wrap: wrap; gap: 6px; }

    /* ── Photo gallery ─────────────────────────────────────────── */
    .photo-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    /* ── Settings ──────────────────────────────────────────────── */
    .settings-section { max-width: 100%; }

    /* ── Map ───────────────────────────────────────────────────── */
    #map { height: 50vh; }

    /* ── Ordered / Delivered header ────────────────────────────── */
    .ordered-header, .delivered-header { flex-wrap: wrap; gap: 10px; }

    /* ── Pagination ────────────────────────────────────────────── */
    .pagination-bar { flex-wrap: wrap; gap: 8px; font-size: 12px; }
    .pagination-controls { flex-wrap: wrap; gap: 4px; }

    /* ── Badges ────────────────────────────────────────────────── */
    .badge, .lc-badge { font-size: 11px; padding: 2px 7px; }
}

/* ══════════════════════════════════════════════════════════════
   MOBILE CARD TABLE LAYOUT  (≤ 640 px)
   Each table row becomes a white card.  Title is full-width at
   top; action buttons flow below it.  No horizontal scrolling.
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {

    /* ── Filter bar: source + search on same row via grid ───────── */
    .filter-bar {
        display: grid;
        grid-template-columns: auto 1fr;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        margin-bottom: 12px;
    }
    .filter-form {
        display: flex;
        flex-wrap: nowrap;
        gap: 6px;
        align-items: center;
        width: auto;
    }
    .filter-form label { font-size: 12px; flex-shrink: 0; }
    .filter-form select { width: 90px; flex: none; }

    /* Search box fills grid column 2 */
    .search-wrap {
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
        margin-left: 0 !important;
    }
    #table-search {
        flex: 1;
        width: 100% !important;
        min-width: 0;
        box-sizing: border-box;
    }

    /* ── Table wrapper: shed the bordered box ───────────────────── */
    .table-wrapper {
        background: transparent;
        border: none;
        overflow: visible;
        padding: 0;
    }

    /* Make table / tbody block containers */
    .vehicles-table,
    .vehicles-table tbody { display: block; width: 100%; }

    /* Hide header row */
    .vehicles-table thead { display: none; }

    /* ── Each row → card ─────────────────────────────────────────── */
    .vehicles-table tbody tr {
        display: flex;
        flex-wrap: wrap;
        align-items: flex-start;
        background: var(--surface);
        border: 1px solid var(--border);
        border-left: 4px solid var(--border);
        border-radius: 8px;
        margin-bottom: 10px;
        padding: 12px 14px;
        gap: 8px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }

    /* Status accent stripes */
    .vehicles-table tbody .row-expired    { border-left-color: var(--overdue); background: #fff8f8; }
    .vehicles-table tbody .row-approaching { border-left-color: var(--at-risk); background: #fffdf5; }
    .vehicles-table tbody .row-action-needed { border-left-color: var(--pfg-red); }
    .vehicles-table tbody .row-soft-submitted { opacity: 0.55; }

    /* All td: reset box model so flex drives layout */
    .vehicles-table tbody td {
        display: flex;
        align-items: center;
        padding: 0;
        border: none;
        font-size: 13px;
    }

    /* ── Hide columns not needed on mobile ──────────────────────── */
    .vehicles-table td.hide-mob,
    .vehicles-table .cell-thumb { display: none !important; }

    /* ── View button: right side of the title row ───────────────── */
    .vehicles-table .cell-view {
        flex: 0 0 auto;
        order: 2;
        align-self: flex-start;
    }

    /* ── Title: full-width, first line ──────────────────────────── */
    .vehicles-table .cell-title {
        flex: 1 1 calc(100% - 60px);
        order: 1;
        max-width: none !important;
        font-size: 14px;
        font-weight: 600;
        line-height: 1.45;
        word-break: break-word;
        white-space: normal;
        flex-direction: column;
        align-items: flex-start;
    }
    .vehicles-table .cell-title .title-sub {
        font-size: 12px;
    }

    /* ── Separator line between title row and action row ─────────── */
    .vehicles-table tbody tr::after {
        content: '';
        flex: 1 1 100%;
        order: 3;
        height: 0;
        border-top: 1px solid #f0f1f3;
        margin: 2px 0;
    }

    /* ── Delivered: merged actions row (order 4 = below separator) ─ */
    .vehicles-table .cell-actions-merged {
        flex: 1 1 100%;
        order: 4;
        padding-top: 4px;
    }
    .vehicles-table .actions-wrap {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        width: 100%;
    }

    /* ── Ordered: all three action cells inline on one row ──────── */
    .vehicles-table .cell-action-needed,
    .vehicles-table .cell-flag,
    .vehicles-table .cell-remove {
        flex: 0 0 auto;
        order: 4;
        align-self: center;
        border-top: none;
        padding-top: 4px;
        margin-top: 0;
    }

    /* ── Ordered: outcome cell (Claim Needed / Entered in SF) below title ─ */
    .vehicles-table .cell-outcome {
        flex: 1 1 100%;
        order: 5;
        padding-top: 8px;
        border-top: 1px solid #f0f1f3;
    }
    .outcome-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        width: 100%;
    }
    .outcome-display {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
    }
    .btn-outcome {
        flex: 1 1 auto;
        min-width: 0;
        text-align: center;
        justify-content: center;
        font-size: 12px;
        padding: 7px 10px;
    }

    /* ── Button sizing on mobile ────────────────────────────────── */
    .flag-btn,
    .btn-dismiss,
    .btn-remove,
    .btn-undo-submitted,
    .btn-undo-ineligible {
        font-size: 12px;
        padding: 6px 12px;
        white-space: nowrap;
    }

    /* ── Pagination card ─────────────────────────────────────────── */
    .pagination-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 12px 14px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 8px;
        font-size: 12px;
    }
    .pagination-controls {
        flex-wrap: wrap;
        gap: 6px;
        width: 100%;
    }
    .page-size-wrap { font-size: 12px; }

    /* ── Global page padding reduction ──────────────────────────── */
    .main-content { padding: 20px 14px; }

    /* ── Dashboard top: stack heading + button on tiny screens ──── */
    .dashboard-top { flex-wrap: wrap; }
    .dashboard-top .btn-run { width: 100%; }
    .btn-run-wrap { width: 100%; }
    .last-scan-time { text-align: center; }
}

/* ── Ready to Submit — Delivered page banner variant ────────── */
.drilldown-banner-ready {
    background: #f0fdf4;
    border-color: #86efac;
    border-left-color: #16a34a;
    color: #14532d;
}

/* ── Ready to Submit pill in filter bar ─────────────────────── */
.ready-submit-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 13px;
    border-radius: 20px;
    background: #dcfce7;
    border: 1px solid #86efac;
    color: #15803d;
    font-size: .8rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s, border-color .15s;
    flex-shrink: 0;
}
.ready-submit-pill:hover {
    background: #bbf7d0;
    border-color: #4ade80;
    color: #166534;
}

/* ── Action sections row (Ready to Submit + Approaching Deadlines) ── */
.action-sections-row {
    display: flex;
    gap: 16px;
    margin: 0 0 24px;
    align-items: stretch;
}
.action-sections-row > .ready-section,
.action-sections-row > .deadline-section {
    flex: 1;
    min-width: 0;
    margin: 0;
}

/* ── Approaching Deadlines section ── */
.deadline-section {
    background: #fff;
    border: 1px solid #fde8c8;
    border-left: 3px solid #fb923c;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.deadline-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 22px;
    background: #fffcf8;
    border-bottom: 1px solid #fde8c8;
}
.deadline-section-count-wrap {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.deadline-section-count {
    font-size: 2.6rem;
    font-weight: 900;
    line-height: 1;
    color: #c2410c;
    letter-spacing: -.04em;
}
.deadline-section-label {
    font-size: .65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: #f4a25e;
}
.deadline-section-viewall {
    font-size: .8rem;
    font-weight: 600;
    color: #c2410c;
    text-decoration: none;
    padding: 5px 13px;
    border: 1px solid #fde8c8;
    border-radius: var(--radius-sm);
    background: #fff;
    transition: background .15s, border-color .15s;
    white-space: nowrap;
}
.deadline-section-viewall:hover { background: #fff7ed; border-color: #fdba74; }
.deadline-section-body { padding: 4px 0; }
.deadline-preview-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 22px;
    text-decoration: none;
    color: #1f2937;
    border-bottom: 1px solid #f3f4f6;
    transition: background .12s;
    font-size: .875rem;
    gap: 8px;
}
.deadline-preview-row:last-child { border-bottom: none; }
.deadline-preview-row:hover { background: #fff7ed; }
.deadline-preview-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.deadline-preview-date {
    font-size: .8rem;
    font-weight: 600;
    color: #ea580c;
    flex-shrink: 0;
    white-space: nowrap;
}
.deadline-preview-empty {
    padding: 16px 22px;
    font-size: .875rem;
    color: var(--muted);
    line-height: 1.5;
}

@media (max-width: 700px) {
    .action-sections-row { flex-direction: column; }
    .deadline-section-header { flex-wrap: wrap; gap: 10px; }
    .deadline-section-viewall { width: 100%; text-align: center; }
}

.ready-section {
    background: #fff;
    border: 1px solid #d1fae5;
    border-left: 4px solid #22c55e;
    border-radius: var(--radius);
    margin: 0 0 24px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.ready-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 22px;
    background: #f6fef9;
    border-bottom: 1px solid #d1fae5;
}
.ready-section-count-wrap {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.ready-section-count {
    font-size: 2.6rem;
    font-weight: 900;
    line-height: 1;
    color: #15803d;
    letter-spacing: -.04em;
}
.ready-section-label {
    font-size: .62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: #166534;
}
.ready-section-viewall {
    font-size: .8rem;
    font-weight: 600;
    color: #15803d;
    text-decoration: none;
    padding: 5px 13px;
    border: 1px solid #86efac;
    border-radius: var(--radius-sm);
    background: #fff;
    transition: background .15s, border-color .15s;
    white-space: nowrap;
}
.ready-section-viewall:hover { background: #f0fdf4; border-color: #4ade80; }
.ready-section-body { padding: 4px 0; }
.ready-preview-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 22px;
    text-decoration: none;
    color: #1f2937;
    border-bottom: 1px solid #f3f4f6;
    transition: background .12s;
    font-size: .875rem;
}
.ready-preview-row:last-child { border-bottom: none; }
.ready-preview-row:hover { background: #f6fef9; }
.ready-preview-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ready-preview-arrow { color: #94a3b8; font-size: .8rem; flex-shrink: 0; margin-left: 8px; }
.ready-preview-more {
    padding: 8px 22px;
    font-size: .8rem;
    color: var(--muted);
}
.ready-preview-more a { color: #15803d; text-decoration: underline; }
.ready-preview-empty {
    padding: 16px 22px;
    font-size: .875rem;
    color: var(--muted);
    line-height: 1.5;
}
@media (max-width: 600px) {
    .ready-section-header { flex-wrap: wrap; gap: 10px; }
    .ready-section-viewall { width: 100%; text-align: center; }
}

/* ── Unclassified action buttons — no red, ever ───────────────── */
button.btn-outcome.btn-mark-ordered,
button.btn-outcome.btn-mark-delivered {
    border: 1.5px solid #9ca3af !important;
    background: #f3f4f6 !important;
    color: #4b5563 !important;
    box-shadow: none !important;
}
button.btn-outcome.btn-mark-ordered:hover,
button.btn-outcome.btn-mark-delivered:hover {
    background: #e5e7eb !important;
    border-color: #6b7280 !important;
    color: #374151 !important;
    box-shadow: 0 2px 6px rgba(0,0,0,.1) !important;
}

/* ── Dashboard department search ──────────────────────────────── */
.dash-search-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
    max-width: 520px;
}
.dash-search-form {
    display: flex;
    position: relative;
}
.dash-search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
    display: flex;
    align-items: center;
}
.dash-search-input {
    flex: 1;
    min-width: 0;
    padding: 9px 14px 9px 34px;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    font-size: 13.5px;
    color: var(--text);
    background: #fff;
    outline: none;
    transition: border-color .15s;
    width: 100%;
}
.dash-search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,52,148,.08); }
.dash-search-btn-hidden {
    position: absolute;
    width: 0; height: 0;
    opacity: 0; border: none; padding: 0;
    pointer-events: none;
}
/* Dropdown */
.dash-search-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1.5px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,.12);
    list-style: none;
    margin: 0;
    padding: 4px 0;
    z-index: 200;
    max-height: 260px;
    overflow-y: auto;
}
/* Dept group header */
.dsd-dept-header {
    padding: 8px 14px 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #6b7280;
    border-top: 1px solid #f3f4f6;
    margin-top: 2px;
}
.dsd-dept-header:first-child { border-top: none; margin-top: 0; }
/* Vehicle row */
.dsd-vehicle {
    display: flex;
    align-items: center;
    padding: 7px 14px 7px 22px;
    font-size: 13px;
    color: #1f2937;
    cursor: pointer;
    transition: background .1s;
    gap: 4px;
}
.dsd-vehicle:hover,
.dsd-vehicle-active { background: #eff6ff; }
.dsd-vehicle-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dsd-vehicle-removed { opacity: .45; }
