:root {
    --bg: #f8fafc;
    --surface-light: #f8fafc;
    --surface: #f1f5f9;
    --surface-alt: #ffffff;
    --surface-strong: #0f172a;
    --text: #111827;
    --text-muted: #475569;
    --text-soft: #64748b;
    --accent: #2563eb;
    --accent2: #1d4ed8;
    --accent-soft: rgba(37, 99, 235, 0.1);
    --success: #15803d;
    --warning: #b45309;
    --danger: #dc2626;
    --border: rgba(15, 23, 42, 0.08);
    --border-strong: rgba(15, 23, 42, 0.14);
    --border-width: 1px;
    --glass: rgba(255, 255, 255, 0.34);
    --glass-border: rgba(255, 255, 255, 0.46);
    --shadow: rgba(15, 23, 42, 0.06);
    --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.06);
    --shadow-card: 0 12px 32px rgba(15, 23, 42, 0.07);
    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 24px;
}

/* Full-width profile saved-report card layout adjustments */
.report-history-row { width: 100%; padding: 0 40px; margin-bottom: 24px; }
.report-history-item {
    padding: 20px;
    border-radius: 12px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(15,23,42,0.06);
}
.report-history-header { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:8px; }
.report-history-company { font-size:1.225rem; font-weight:700; color:var(--surface-strong); }
.report-history-actions { display:flex; gap:8px; align-items:center; }
.remove-report-btn { background: transparent; border: none; font-size:1.175rem; cursor:pointer; color:#a00; }
.report-history-subheader { display:flex; gap:16px; align-items:center; margin-bottom:8px; color:var(--text-muted); }
.report-active-status, .report-docket-number { font-size:1.075rem; }
.report-history-meta-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
    align-items: stretch;
    margin-top: 20px;
}
.report-stat-card {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    min-height: 56px;
}
.report-stat-title {
    font-size: 0.975rem;
    color: var(--text-muted);
}
.report-stat-value {
    font-size: 1.125rem;
    color: var(--surface-strong);
    font-weight: 700;
}
.report-history-iss { font-weight:700; font-size:1.125rem; }

@media (max-width: 860px) {
    .report-history-meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
    .report-history-meta-grid { grid-template-columns: 1fr; }
}


/* Search results container */
#carrierSearchResults {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    min-width: 300px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 10000;
    max-height: 350px;
    overflow-y: auto;
    margin-top: 4px;
}

/* Individual result item */
.carrier-search-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s;
    gap: 12px;
}

.carrier-search-result:hover {
    background-color: #f5f5f5;
}

/* Carrier name */
.carrier-search-name {
    font-weight: 600;
    font-size: 16px;
    color: #333;
    flex: 2;
}

/* USDOT number */
.carrier-search-dot {
    font-size: 14px;
    color: #666;
    font-family: monospace;
    flex: 1;
}

/* State */
.carrier-search-state {
    font-size: 14px;
    color: #888;
    width: 40px;
    text-align: right;
    font-weight: 500;
}

/* Empty state */
.carrier-search-empty {
    padding: 16px;
    text-align: center;
    color: #999;
    font-size: 16px;
}

.snapshot-iss-block .info-value {
    font-size: 1.825rem !important;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.07), transparent 24%),
        linear-gradient(180deg, #ffffff 0%, var(--bg) 42%, #f8fafc 100%);
    color: var(--text);
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-weight: 400;
    overflow-x: hidden;
    min-height: 100vh;
    line-height: 1.5;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.06) 0%, rgba(248,250,252,0.14) 40%, rgba(244,247,251,0.2) 100%),
        radial-gradient(circle at 15% 20%, rgba(37, 99, 235, 0.025), transparent 30%),
        radial-gradient(circle at 85% 18%, rgba(15, 23, 42, 0.015), transparent 28%);
    z-index: -4;
    pointer-events: none;
}

.truck-background {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: -3;
}

.truck-sprite {
    position: absolute;
    width: clamp(220px, 18vw, 360px);
    aspect-ratio: 2.8 / 1;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    opacity: 0.1;
    filter: none;
    will-change: transform;
    /* `top` (the lane / "road" position) is managed by JS and adjusts as trucks
       resize each pass — glide it so the roads re-fill smoothly. The horizontal
       drift uses `transform`, which is intentionally NOT transitioned. */
    transition: top 0.8s linear;
}

.truck-left {
    background-image: var(--truck-left-image);
    animation: truck-drift-left var(--truck-duration, 30s) linear infinite;
}

.truck-right {
    background-image: var(--truck-right-image);
    animation: truck-drift-right var(--truck-duration, 34s) linear infinite;
}

.truck-left-1 {
    --truck-left-image: url('/truck-assets/left1.png?v=3');
    --truck-duration: 34s;
    top: 8%;
    animation-delay: -10s;
}

.truck-left-2 {
    --truck-left-image: url('/truck-assets/left2.png?v=3');
    --truck-duration: 28s;
    top: 32%;
    animation-delay: -18s;
}

.truck-left-3 {
    --truck-left-image: url('/truck-assets/left1.png?v=3');
    --truck-duration: 38s;
    top: 58%;
    animation-delay: -6s;
}

.truck-left-4 {
    --truck-left-image: url('/truck-assets/left2.png?v=3');
    --truck-duration: 31s;
    top: 80%;
    animation-delay: -22s;
}

.truck-right-1 {
    --truck-right-image: url('/truck-assets/right1.png?v=3');
    --truck-duration: 36s;
    top: 16%;
    animation-delay: -15s;
}

.truck-right-2 {
    --truck-right-image: url('/truck-assets/right2.png?v=3');
    --truck-duration: 27s;
    top: 44%;
    animation-delay: -5s;
}

.truck-right-3 {
    --truck-right-image: url('/truck-assets/right1.png?v=3');
    --truck-duration: 40s;
    top: 68%;
    animation-delay: -20s;
}

.truck-right-4 {
    --truck-right-image: url('/truck-assets/right2.png?v=3');
    --truck-duration: 33s;
    top: 88%;
    animation-delay: -12s;
}

@keyframes truck-drift-left {
    from {
        transform: translate3d(115vw, 0, 0);
    }
    to {
        transform: translate3d(-32vw, 0, 0);
    }
}

@keyframes truck-drift-right {
    from {
        transform: translate3d(-35vw, 0, 0);
    }
    to {
        transform: translate3d(118vw, 0, 0);
    }
}

/* Collapsible sections */
.collapsible-section {
    margin-bottom: 1.5rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    background-color: #f1f5f9;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    transition: background-color 0.2s;
    margin-bottom: 0.5rem;
}

    .section-header:hover {
        background-color: #e2e8f0;
    }

    .section-header .section-title {
        font-size: 1.325rem;
        font-weight: 600;
        color: var(--text);
        margin: 0;
        border-bottom: none;
        padding: 0;
    }

.toggle-arrow {
    font-size: 1.325rem;
    transition: transform 0.2s;
}

.section-content {
    padding: 0;
    background: transparent;
    border: none;
}

.collapsible-section.collapsed .section-content {
    display: none;
}

.collapsible-section.collapsed .toggle-arrow {
    transform: rotate(-90deg);
}

/* Report sections � remove borders and extra padding */
.report-section,
.collapsible-section {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    margin-bottom: 0;
}

/* Two-column grid � stretch edge-to-edge */
.two-column-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1.5rem;
    width: 100vw;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    padding-left: 2rem;
    padding-right: 2rem;
}

.subpanel-card {
    background: var(--glass);
    border: var(--border-width) solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 2px 10px var(--shadow);
}

.subpanel-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.subpanel-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.subpanel-title-row .subpanel-title {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.card-refresh-btn {
    min-width: 112px;
    border: 1px solid rgba(40, 92, 243, 0.18);
    border-radius: 999px;
    background: #eef2ff;
    color: #285cf3;
    font-size: 0.905rem;
    font-weight: 700;
    padding: 0.45rem 0.8rem;
    white-space: nowrap;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
}

.card-refresh-btn:hover:not(:disabled) {
    background: #dbe7ff;
}

.card-refresh-btn:disabled {
    cursor: default;
    opacity: 0.7;
}

.card-refresh-btn-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.card-refresh-btn-spinner {
    width: 16px;
    height: 16px;
    border-radius: 999px;
    border: 2px solid rgba(37, 99, 235, 0.22);
    border-top-color: #2563eb;
    animation: report-update-spin 0.8s linear infinite;
}

.deferred-top-action.hidden,
.deferred-card-empty-action.hidden {
    display: none !important;
}

/* Admin users table styling */
.admin-users-table-wrap {
    max-height: 420px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-alt);
}
.admin-users-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 480px;
}
.admin-users-table th,
.admin-users-table td {
    padding: 0.6rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 1.075rem;
}
.admin-users-table thead th {
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 2;
}
.admin-users-empty {
    text-align: center;
    padding: 1.2rem;
    color: var(--text-soft);
}
.admin-panel-notice {
    padding: 0.6rem 0.8rem;
    margin-bottom: 0.8rem;
    border-radius: 8px;
    background: #fff8e1;
    border: 1px solid rgba(180,83,9,0.08);
    color: var(--text-muted);
}

.deferred-card-empty-action {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 140px;
    padding: 0.5rem 0 0.75rem;
}

.deferred-center-action {
    min-width: 132px;
    justify-content: center;
}

/* ?? Deferred section "Load" wrapper (Revocations & OOS Orders) ???????? */
.deferred-section-load-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 1.5rem 1rem;
    text-align: center;
    width: 100%;
}

.deferred-section-load-wrap.hidden {
    display: none !important;
}

.deferred-section-load-btn {
    min-width: 132px;
    border: 1px solid rgba(40, 92, 243, 0.18);
    border-radius: 999px;
    background: #eef2ff;
    color: #285cf3;
    font-weight: 600;
    font-size: 1.025rem;
    padding: 0.55rem 1.4rem;
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease, box-shadow 120ms ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.deferred-section-load-btn:hover {
    background: #dbeafe;
    box-shadow: 0 2px 8px rgba(40, 92, 243, 0.18);
}

.deferred-section-load-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.deferred-section-load-hint {
    color: #64748b;
    font-size: 0.945rem;
}

/* ?? Revocations & OOS card (fixed height, scrollable inner area) ??? */
.revocations-oos-card {
    /* Keep the card a predictable size so the inner table is the scrollable
       region instead of pushing the page height. */
    max-height: 420px;
    display: flex;
    flex-direction: column;
}

.revocations-oos-content {
    flex: 1 1 auto;
    min-height: 0;          /* allow the flex child to actually shrink */
    overflow-y: auto;
    padding-right: 0.25rem; /* breathing room for the scrollbar */
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.revocations-oos-banner:empty {
    display: none !important;
}

/* Initial loading overlay & spinner */
.initial-loading {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    z-index: 9999;
}
.initial-loading-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 22px;
    border-radius: 12px;
    box-shadow: 0 6px 22px rgba(15,23,42,0.12);
    background: linear-gradient(180deg, #fff, #fbfbfd);
}
.initial-spinner {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    border: 4px solid rgba(37,99,235,0.18);
    border-top-color: #2563eb;
    animation: initial-spin 0.9s linear infinite;
}
.initial-loading-brand {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--text);
}
@keyframes initial-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Ensure auth and tool containers remain hidden until JS reveals them */
#authContainer { display: none; }
#toolContainer { display: none; }

/* Hide the injected app content until we explicitly reveal it after session check */
#appContent { visibility: hidden; }

/* Authority history table lives inside the Revocations & OOS card. The
   parent already provides the scroll context, so the table wrap just needs
   to allow horizontal overflow for narrow viewports. */
.revocations-oos-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.revocations-oos-table-wrap:empty {
    display: none !important;
}

.revocations-oos-table-wrap .authority-history-table {
    margin-bottom: 0;
}

/* Tighten the nested cards rendered by renderRevocationBanner so they
   don't double-pad inside the parent card. */
.revocations-oos-content .revocation-card,
.revocations-oos-content .subpanel-card {
    margin: 0;
    padding: 0.85rem 1rem !important;
    box-shadow: none;
}

.tool-intro-card {
    margin-top: 1rem;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
}

.admin-panel-section {
    margin-top: 1rem;
}

.admin-panel-section-spaced {
    padding: 1.5rem !important;
}

.admin-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.9rem;
}

.admin-summary-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    padding: 0.85rem 1rem;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.admin-summary-label {
    color: var(--text-muted);
    font-size: 0.945rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.admin-summary-value {
    margin-top: 0.2rem;
    font-size: 1.475rem;
    font-weight: 700;
    color: var(--text);
}

.admin-panel-title {
    margin-bottom: 0.75rem;
}

.admin-panel-notice {
    margin-bottom: 0.7rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid rgba(37, 99, 235, 0.22);
    border-radius: 8px;
    background: rgba(37, 99, 235, 0.08);
    color: #1d4ed8;
    font-size: 0.985rem;
    font-weight: 500;
}

.admin-users-table-wrap {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: auto;
}

.admin-users-table {
    margin-bottom: 0;
}

.admin-users-table thead th {
    background: #f8fafc;
    font-size: 0.905rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.admin-users-empty {
    text-align: center;
    color: var(--text-soft);
    font-style: italic;
    padding: 1rem 0.75rem !important;
}

.admin-status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 82px;
    border-radius: 999px;
    padding: 0.2rem 0.5rem;
    font-size: 0.875rem;
    font-weight: 700;
}

.admin-status-active {
    background: rgba(22, 163, 74, 0.14);
    color: #15803d;
}

.admin-status-disabled {
    background: rgba(220, 38, 38, 0.12);
    color: #b91c1c;
}

.admin-create-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
}

.admin-create-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.admin-create-field label {
    font-size: 0.925rem;
    font-weight: 600;
    color: var(--text-muted);
}

.admin-create-field input,
.admin-create-field select {
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 0.5rem 0.6rem;
    font-size: 0.985rem;
    background: #fff;
}

.admin-create-actions {
    margin-top: 0.9rem;
    display: flex;
    justify-content: flex-end;
}

@media (max-width: 1080px) {
    .admin-create-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .admin-summary-grid,
    .admin-create-grid {
        grid-template-columns: 1fr;
    }

    .admin-create-actions {
        justify-content: flex-start;
    }
}

.page-content-surface {
    display: grid;
    /* minmax(0, 1fr) (not the implicit `auto`) so a wide/non-wrapping descendant
       can't blow the single column out past the viewport — the classic CSS grid
       overflow fix. Keeps every page's content within its gutters. */
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
    /* Space above the first card matches the inter-card gap. */
    padding-top: 1.25rem;
    animation: page-fade-in 0.32s ease;
}

@keyframes page-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tool-intro-points {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 1rem;
    max-width: 920px;
}

.tool-intro-point {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 1rem 1.05rem;
    background-color: rgba(255,255,255,0.1);
    background-image: linear-gradient(135deg, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0.04) 100%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
}

.tool-intro-point strong {
    color: var(--text);
}

.tool-intro-point span {
    color: var(--text-muted);
    font-size: 1.025rem;
}

.tool-intro-note {
    margin-top: 1rem;
    color: var(--accent);
    font-weight: 600;
}

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

    .tool-intro-card {
        min-height: auto;
        display: block;
    }
}

.map-shell {
    background: #fff;
    border: var(--border-width) solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 2px 10px var(--shadow);
}

.map-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.85rem;
    flex-wrap: wrap;
}

.map-toolbar-title {
    font-size: 1.105rem;
    font-weight: 600;
    color: var(--text);
}

.map-legend {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.legend-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.6rem;
    border-radius: 999px;
    font-size: 0.905rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--surface-light);
    cursor: pointer;
}

button.legend-chip {
    font-family: inherit;
}

.legend-chip.active {
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.35);
}

.legend-chip.inactive {
    opacity: 0.45;
}

.legend-inspection::before,
.legend-crash::before {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.legend-inspection::before {
    background: #2563eb;
}

.legend-crash::before {
    background: #dc2626;
}

.incident-map-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(320px, 0.95fr);
    gap: 1rem;
    align-items: start;
}

.incident-state-marker-wrap {
    background: transparent;
    border: none;
}

.incident-state-marker {
    position: relative;
    width: 34px;
    height: 42px;
    border-radius: 18px 18px 18px 4px;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.92);
}

.incident-state-marker span {
    transform: rotate(45deg);
    color: #fff;
    font-size: 0.945rem;
    font-weight: 800;
    line-height: 1;
}

.incident-state-marker.crash {
    background: #dc2626;
}

.incident-state-marker.inspection {
    background: #2563eb;
}

.incident-state-panel {
    min-height: 620px;
    height: 620px;
    display: flex;
    flex-direction: column;
}

.incident-section-title {
    font-size: 1.475rem;
    font-weight: 800;
    padding: 1.35rem 1.4rem 0.85rem;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.incident-title-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.1rem;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    background: #eef2ff;
    color: #285cf3;
    font-size: 1.025rem;
    font-weight: 800;
}

.fixed-scroll-card {
    height: 620px;
    display: flex;
    flex-direction: column;
    padding: 1.1rem !important;
}

.fixed-scroll-card .section-content {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
    padding: 0.35rem;
}

#inspectionHistory,
#crashHistory {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.incident-history-table-wrap {
    height: 100%;
    flex: 1;
    overflow: auto;
    min-height: 0;
    width: 100%;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.incident-history-table-wrap::-webkit-scrollbar {
    display: none;
}

.incident-history-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.incident-history-table th,
.incident-history-table td {
    border: 1px solid rgba(121, 135, 161, 0.3);
    padding: 0.85rem 0.95rem;
    text-align: left;
    vertical-align: top;
}

.incident-history-table thead th {
    position: sticky;
    top: 0;
    background: #eef2ff;
    z-index: 1;
}

.incident-empty-state {
    padding: 0.85rem 0;
    color: var(--text-muted);
}

/* Crash not-preventable styling */
.crash-np-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 8px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    font-size: 0.875rem;
}

.crash-np-badge {
    flex-shrink: 0;
    font-weight: 700;
    color: #16a34a;
    background: #dcfce7;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.785rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.crash-np-note {
    color: #334155;
}

.crash-row-np {
    opacity: 0.55;
    background: #f0fdf4;
}

.crash-np-cell-badge {
    display: inline-block;
    font-size: 0.705rem;
    font-weight: 700;
    color: #16a34a;
    background: #dcfce7;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.state-incident-item {
    margin-bottom: 0.75rem;
}

.incident-state-content {
    font-size: 1.045rem;
    color: var(--text-muted);
    flex: 1;
    min-height: 0;
    overflow: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.incident-state-content::-webkit-scrollbar {
    display: none;
}

.state-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.9rem;
}

.state-count-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.state-count-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.32rem 0.65rem;
    border-radius: 999px;
    font-size: 0.905rem;
    font-weight: 700;
}

.state-count-badge.inspection {
    background: rgba(37, 99, 235, 0.12);
    color: #1d4ed8;
}

.state-count-badge.crash {
    background: rgba(220, 38, 38, 0.12);
    color: #b91c1c;
}

.incident-group-title {
    margin: 0.85rem 0 0.5rem;
    font-size: 1.025rem;
    font-weight: 700;
    color: var(--text);
}

.incident-report-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 0.6rem;
    overflow: hidden;
    background: var(--surface-light);
}

.incident-report-header {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: center;
    padding: 0.75rem 0.9rem;
}

.incident-report-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.85rem;
    align-items: center;
    font-size: 0.945rem;
    color: var(--text-muted);
}

.incident-report-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
}

.incident-report-link:hover {
    text-decoration: underline;
}

.incident-detail-panel {
    display: none;
    padding: 0.85rem 0.9rem 1rem;
    background: #fff;
    border-top: 1px solid var(--border);
}

.incident-report-item.open .incident-detail-panel {
    display: block;
}

.map-canvas-placeholder,
#incidentMap {
    min-height: 620px;
    width: 100%;
    border-radius: 14px;
}

.floating-notice {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 2100;
    max-width: 360px;
    padding: 0.95rem 1.1rem;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.96);
    color: #fff;
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.22);
    transform: translateY(120%);
    opacity: 0;
    transition: transform 0.35s ease, opacity 0.35s ease;
}

.floating-notice.visible {
    transform: translateY(0);
    opacity: 1;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(15, 23, 42, 0.62);
    padding: 2rem;
    /* The header is fixed on top (z-index 9999) and would clip the modal's top.
       Start the dialog below the header with a fair margin. */
    padding-top: calc(var(--app-header-height, 80px) + 1.5rem);
    overflow-y: auto;
}

.modal-content {
    position: relative;
    width: min(1200px, 96vw);
    min-height: min(780px, calc(100vh - 4rem));
    margin: 0 auto;
    background: #fff;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 25px 80px rgba(15, 23, 42, 0.25);
}

#modalContent {
    max-height: calc(100vh - 10rem) !important;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.close {
    position: sticky;
    top: 0;
    float: right;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-left: auto;
    border-radius: 999px;
    background: #f1f5f9;
    color: #0f172a;
    font-size: 1.725rem;
    cursor: pointer;
    z-index: 2;
}

.report-card {
    display: grid;
    gap: 1rem;
}

.report-card .report-section {
    background: #f8fafc;
    border: 1px solid rgba(121, 135, 161, 0.18);
    border-radius: 14px;
    padding: 1rem 1.1rem;
}

@media (max-width: 1100px) {
    .incident-map-layout {
        grid-template-columns: 1fr;
    }

    .fixed-scroll-card {
        height: auto;
    }

    .incident-history-table-wrap {
        max-height: 480px;
    }
}

    .two-column-grid > * {
        min-width: 0; /* prevent overflow */
    }

/* Company snapshot card remains visible with border */
#companyInfoSection {
    background-color: rgba(255,255,255,0.08);
    background-image: linear-gradient(135deg, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0.04) 100%);
    border: var(--border-width) solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    width: 100vw;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    padding-left: 2rem;
    padding-right: 2rem;
}

/* ISS + Crash Summary inline header row inside Company Snapshot */
.snapshot-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    background: var(--surface-light);
    border-radius: 8px;
    border-left: 4px solid var(--accent);
}

.snapshot-header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    flex: 1;
}

.snapshot-header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.snapshot-header-item {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.snapshot-header-item .info-label {
    margin-bottom: 0.15rem;
}

.snapshot-header-item .info-value {
    font-size: 1.225rem;
}

.snapshot-header-alerts {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

/* Full-width cards (break out of max-width container) */
.full-width-card {
    width: 100vw;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    padding-left: 2rem;
    padding-right: 2rem;
    border-radius: 12px;
}

/* Snapshot summary: plain ISS text, no blue card treatment */
.snapshot-header-row {
    align-items: flex-start;
    background: transparent;
    border: none;
    padding: 0;
    margin-bottom: 0;
}

.snapshot-iss-plain {
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

.snapshot-iss-plain .info-label {
    font-size: 0.905rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.snapshot-iss-plain .info-value {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    font-size: 2.025rem !important;
    line-height: 1.05;
    font-weight: 800;
}

.iss-score-value {
    font-size: 2.025rem;
    font-weight: 800;
}

.iss-score-recommendation {
    font-size: 1.025rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.snapshot-alerts-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 68px;
    flex: 1;
    text-align: center;
}

.snapshot-alerts-text {
    font-size: 1.205rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.snapshot-alerts-text strong {
    color: var(--text);
    margin-right: 0.35rem;
}

.snapshot-risk-card {
    min-height: auto !important;
}

.snapshot-risk-row {
    align-items: stretch;
}

.snapshot-risk-left,
.snapshot-risk-right {
    align-items: stretch;
}

.snapshot-risk-score-block .info-value {
    font-size: 1.975rem !important;
    font-weight: 800;
    color: #1c273c;
}

.snapshot-risk-tier {
    font-size: 1.275rem !important;
    font-weight: 800;
}

.snapshot-risk-tier.tier-low {
    color: #15803d;
}

.snapshot-risk-tier.tier-medium {
    color: #b45309;
}

.snapshot-risk-tier.tier-high {
    color: #dc2626;
}

.snapshot-risk-reasons-block {
    min-width: min(100%, 540px);
}

.snapshot-risk-reasons {
    font-size: 1.105rem !important;
    line-height: 1.45;
    color: var(--text-muted);
    white-space: normal;
}

.score-info-label-row {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.score-info-button {
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 999px;
    background: #2563eb;
    color: #fff;
    font-size: 0.945rem;
    font-weight: 800;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.18);
}

.score-info-bubble {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    width: min(280px, 72vw);
    padding: 0.75rem 0.85rem;
    border-radius: 12px;
    background: #fff;
    border: 1px solid rgba(121, 135, 161, 0.18);
    box-shadow: 0 14px 28px rgba(28, 39, 60, 0.12);
    color: #596882;
    font-size: 0.955rem;
    font-weight: 500;
    line-height: 1.45;
    z-index: 20;
}

.score-info-bubble.hidden {
    display: none !important;
}

.score-info-bubble-close {
    position: absolute;
    top: 0.35rem;
    right: 0.45rem;
    border: none;
    background: transparent;
    color: #7987a1;
    font-size: 1.125rem;
    line-height: 1;
    cursor: pointer;
}

/* Elevate the side-item card when its info bubble is open so
   the bubble renders above sibling cards */
.ov-side-item.score-info-elevated {
    position: relative;
    z-index: 30;
    overflow: visible !important;
}

.snapshot-risk-trends {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.85rem;
    margin-top: 1rem;
}

.snapshot-risk-trend-item {
    padding: 0.95rem 1rem;
    border: 1px solid rgba(121, 135, 161, 0.18);
    border-radius: 14px;
    background: #f8fafc;
}

.snapshot-risk-trend-item .info-value {
    font-size: 1.045rem !important;
    line-height: 1.45;
    color: #1c273c;
}

.carrier-timeline-card {
    padding: 1rem !important;
}

.carrier-timeline-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

.carrier-timeline-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.carrier-timeline-filter {
    border: 1px solid rgba(121, 135, 161, 0.22);
    border-radius: 999px;
    background: #eef2ff;
    padding: 0.5rem 0.85rem;
    font-weight: 700;
    cursor: pointer;
}

#timelineFilterCrash {
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.22);
    background: rgba(220, 38, 38, 0.1);
}

#timelineFilterInspection {
    color: #2563eb;
    border-color: rgba(37, 99, 235, 0.22);
    background: rgba(37, 99, 235, 0.1);
}

.carrier-timeline-filter.inactive {
    background: #f8fafc;
    color: #7987a1;
}

.carrier-timeline-shell {
    position: relative;
    display: flex;
    overflow-x: auto;
    flex: 1;
    min-height: 0;
    padding: 0.75rem;
}

.carrier-timeline-track {
    flex: 1;
    min-width: 980px;
}

.carrier-timeline-histogram {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 1rem;
    min-height: 100%;
}

.carrier-timeline-y-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    color: #7987a1;
    font-size: 0.905rem;
    padding: 0.25rem 0;
}

.carrier-timeline-bars-wrap {
    position: relative;
    height: 100%;
    min-height: 100%;
}

.carrier-timeline-grid-lines {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
}

.carrier-timeline-grid-lines span {
    display: block;
    height: 1px;
    background: rgba(121, 135, 161, 0.18);
}

.carrier-timeline-bars {
    position: relative;
    z-index: 1;
    height: 100%;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(90px, 1fr);
    gap: 1rem;
    align-items: end;
    padding-top: 0.5rem;
}

.carrier-timeline-bucket {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 0.6rem;
    min-height: 100%;
}

.carrier-timeline-bar-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
    align-items: end;
    align-self: stretch;
    height: 100%;
    min-height: 0;
}

.carrier-timeline-bar-wrap {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    height: 100%;
    min-height: 0;
    gap: 0.3rem;
}

.carrier-timeline-bar {
    border-radius: 10px 10px 0 0;
    min-height: 4px;
    width: 100%;
    align-self: end;
}

.carrier-timeline-bar.crash {
    background: #dc2626;
}

.carrier-timeline-bar.inspection {
    background: #2563eb;
}

.carrier-timeline-bucket-label {
    color: #596882;
    font-size: 0.925rem;
    text-align: center;
}

.carrier-timeline-bar-value {
    color: #1c273c;
    font-size: 0.905rem;
    font-weight: 700;
    line-height: 1;
    text-align: center;
}

.carrier-timeline-empty {
    padding: 1rem 0;
}

.report-update-changes-card {
    margin-bottom: 1.25rem;
    padding: 1.25rem 1.4rem !important;
}

.report-update-changes-list {
    margin: 0;
    padding-left: 1.2rem;
    color: #1c273c;
}

.report-update-changes-list li {
    margin: 0.35rem 0;
    color: #596882;
}

/* ===== Restore styled layout while keeping latest content changes ===== */
.dashboard-shell {
    position: relative;
}

.dashboard-sidebar {
    position: fixed !important;
    top: 1.25rem !important;
    left: 1.25rem !important;
    width: 280px !important;
    height: calc(100vh - 2.5rem) !important;
    z-index: 120 !important;
    display: flex !important;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem !important;
    overflow-y: auto;
    background: #ffffff !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-card) !important;
}

.dashboard-main {
    position: relative;
    margin-left: calc(280px + 2.5rem) !important;
    margin-right: 1.25rem !important;
    width: auto !important;
    max-width: none !important;
    min-width: 0;
}

/* Styled sidebar sections */
.sidebar-nav {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.55rem !important;
}

.sidebar-nav-link,
.sidebar-anchor-link {
    display: block !important;
    width: 100% !important;
    background: #fff !important;
    border: 1px solid var(--border-strong) !important;
    border-radius: 12px !important;
    padding: 0.72rem 0.8rem !important;
}

.sidebar-nav-link.active,
.sidebar-anchor-link.active {
    background: linear-gradient(135deg, #eff6ff 0%, #eef2ff 100%) !important;
    color: var(--surface-strong) !important;
    border-color: rgba(37, 99, 235, 0.16) !important;
}

/* Search + signed in styling */
.sidebar-search-card {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 0.65rem !important;
    align-items: center;
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    position: relative;
}

.sidebar-search-card input {
    width: 100%;
    border: 1px solid var(--border) !important;
    border-radius: 999px !important;
    padding: 0.8rem 1rem !important;
    background: #fff !important;
}

.sidebar-search-card button {
    width: auto;
    min-width: 112px;
    border: 1px solid var(--surface-strong) !important;
    border-radius: 999px !important;
    padding: 0.8rem 1rem !important;
    background: var(--surface-strong) !important;
    color: #fff !important;
}

/* Restore cards */
.card,
.info-panel,
.subpanel-card,
.violation-card,
.basics-chart-container,
.map-shell {
    background: var(--glass) !important;
    border-radius: 16px !important;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1) !important;
    backdrop-filter: blur(9.3px) !important;
    -webkit-backdrop-filter: blur(9.3px) !important;
    border: 1px solid var(--glass-border) !important;
}

/* Snapshot wrapper stays borderless; individual cards keep styling */
#companyInfoSection.company-snapshot-grid-wrap {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
}

.dashboard-main .company-snapshot-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 1.25rem !important;
    width: 100% !important;
}

.dashboard-main .company-snapshot-grid > .card,
.dashboard-main .company-snapshot-grid > .info-panel {
    width: 100%;
    min-width: 0;
    margin: 0;
    min-height: auto;
    padding: 0.85rem 1rem !important;
}

/* BASIC cards remain separate and styled */
.basics-two-column {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 1.25rem !important;
    align-items: stretch;
}

.basics-table-container,
.basics-chart-container {
    min-height: 520px;
    display: flex;
    flex-direction: column;
}

@media (max-width: 1200px) {
    .dashboard-sidebar {
        position: static !important;
        width: 100% !important;
        height: auto !important;
    }

    .dashboard-main {
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
    }

    .dashboard-main .company-snapshot-grid,
    .basics-two-column {
        grid-template-columns: 1fr !important;
    }
}

