:root {
    --theme-background: #050a12;
    --theme-surface: #091321;
    --theme-surface-raised: #0d1928;
    --theme-surface-muted: #07111e;
    --theme-text: #f2f7fc;
    --theme-text-muted: #93a4b8;
    --theme-border: rgba(148, 163, 184, .18);
    --theme-border-strong: rgba(148, 163, 184, .3);
    --theme-input: #07111e;
    --theme-shadow: 0 20px 55px rgba(0, 0, 0, .25);
    --theme-header: rgba(5, 10, 18, .9);
    --theme-focus: #22d3ee;
    --atlas-page-title: clamp(28px, 2.2vw, 34px);
    --atlas-section-title: clamp(18px, 1.5vw, 22px);
    --atlas-panel-title: clamp(15px, 1.1vw, 18px);
    --atlas-body-text: 14px;
    --atlas-meta-text: 12px;
    --atlas-card-radius: 14px;
    --atlas-card-radius-sm: 10px;
    --theme-bg: var(--theme-background);
    --theme-raised: var(--theme-surface-raised);
    --theme-muted: var(--theme-text-muted);
    --theme-line: var(--theme-border);
    --theme-line-strong: var(--theme-border-strong);
}

.interscan-logo {
    display: block;
    width: auto;
    height: 38px;
    max-width: min(180px, 42vw);
    object-fit: contain;
    object-position: left center;
    flex: 0 0 auto;
}

.interscan-header-logo {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    color: inherit;
    text-decoration: none;
}

html[data-theme="light"] {
    --theme-background: #f4f7fb;
    --theme-surface: #ffffff;
    --theme-surface-raised: #f8fafc;
    --theme-surface-muted: #eef3f8;
    --theme-text: #142033;
    --theme-text-muted: #52647a;
    --theme-border: rgba(71, 85, 105, .18);
    --theme-border-strong: rgba(71, 85, 105, .3);
    --theme-input: #ffffff;
    --theme-shadow: 0 18px 45px rgba(15, 35, 60, .11);
    --theme-header: rgba(255, 255, 255, .92);
    --theme-focus: #087ea4;
}

html[data-theme] {
    --bg: var(--theme-background);
    --panel: var(--theme-surface);
    --panel2: var(--theme-surface-raised);
    --text: var(--theme-text);
    --muted: var(--theme-text-muted);
    --line: var(--theme-border);
    color-scheme: dark;
}
html[data-theme="light"] { color-scheme: light; }
html[data-theme="light"] body { color: var(--theme-text) !important; background-color: var(--theme-bg) !important; background-image: none !important; }
html[data-theme="light"] :is(.sidebar,.panel,.card,.topbar,.modal,.drawer,dialog,pre) { color: var(--theme-text); background-color: var(--theme-surface) !important; border-color: var(--theme-line) !important; }
html[data-theme="light"] :is(input,select,textarea,button:not(.primary):not(.top-action)) { color: var(--theme-text) !important; background-color: var(--theme-input) !important; border-color: var(--theme-line-strong) !important; }

body { color: var(--theme-text); }
.theme-control {
    position: fixed; right: 18px; bottom: 18px; z-index: 1000;
    display: flex; align-items: center; gap: 8px; padding: 7px 8px 7px 11px;
    border: 1px solid var(--theme-line-strong); border-radius: 10px;
    color: var(--theme-muted); background: var(--theme-header);
    box-shadow: var(--theme-shadow); backdrop-filter: blur(14px);
    font: 700 10px/1 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.theme-control select {
    width: auto; min-width: 76px; min-height: 31px; padding: 5px 24px 5px 8px;
    border: 1px solid var(--theme-line); border-radius: 7px;
    color: var(--theme-text); background: var(--theme-input); font: inherit;
}
.theme-control select:focus-visible,
html[data-theme] :is(a,button,input,select,textarea):focus-visible { outline: 3px solid color-mix(in srgb, var(--theme-focus) 35%, transparent); outline-offset: 2px; }

html[data-theme="light"] body {
    background-color: var(--theme-bg) !important;
    background-image: none !important;
    color: var(--theme-text) !important;
}
html[data-theme="light"] body::before { opacity: .16; }
html[data-theme="light"] :is(.platform-header,.topbar,.modal-header,.modal-footer) { background-color: var(--theme-header) !important; }
html[data-theme="light"] :is(.sidebar,.modal,.confirm-dialog,.panel,.card,.customer-card,.summary-grid article,.locked-card,.asset-hero,.asset-panel,.integration-card,.settings-card,.user-card,.kpi,.mini,.detail-card,.fleet-card,.metric-tile,.headline-item,.assessment-card,.scorecard-card,.impact-card,.trend-card,.risk-card,.schedule-card,.confidence-score,.readiness-panel,.drawer,dialog,.toast,pre) {
    color: var(--theme-text); background-color: var(--theme-surface) !important;
    background-image: none !important; border-color: var(--theme-line) !important;
    box-shadow: var(--theme-shadow);
}
html[data-theme="light"] :is(input,select,textarea,.filter-tabs,.capability,.brand-preview,.empty-state,.workspace-switcher,button:not(.primary):not(.btn-primary):not(.top-action),.filter-btn,.iconbtn,.secondary,.tab,.bar) {
    color: var(--theme-text) !important; background-color: var(--theme-input) !important;
    border-color: var(--theme-line-strong) !important;
}
html[data-theme="light"] :is(th,.nav-label,.eyebrow,.subtitle,.muted,.field-help,.section-note,.brand-details span,.dashboard-title,.customer-heading span,.summary-grid span,.summary-grid small) { color: var(--theme-muted) !important; }
html[data-theme="light"] :is(td,th,.brand-details > div,.panel,.modal-header,.modal-footer,.platform-header,.topbar) { border-color: var(--theme-line) !important; }
html[data-theme="light"] :is(.secondary-button,.icon-button,.refresh-button,.customer-button,.btn.secondary) { color: var(--theme-text) !important; background: var(--theme-raised) !important; }
html[data-theme="light"] :is(.modal-backdrop,.confirm-backdrop) { background: var(--theme-overlay) !important; }
html[data-theme="light"] .sidebar a:not(.active):not(:hover) { color: var(--theme-muted); }
html[data-theme="light"] .sidebar { background: #ffffff !important; }
html[data-theme="light"] .workspace-main { background: var(--theme-bg) !important; }
html[data-theme="light"] .customer-card.inactive-card { opacity: .82; }
html[data-theme="light"] .status-pill.active { color: #08783f; background: #dcfce7; }
html[data-theme="light"] .status-pill.inactive { color: #b4233d; background: #ffe4e9; }
html[data-theme="dark"] :is(.panel,.kpi,.trend,.mini,.detail-table,.locked-card) {
    color: var(--theme-text); background: var(--theme-surface) !important;
    border-color: var(--theme-line) !important;
}
html[data-theme="dark"] :is(.kpi .value,.trend-current,.mini strong) { color: var(--theme-text) !important; }
html[data-theme="dark"] :is(td,th,.recommendation,.part) { border-color: var(--theme-line) !important; }

html[data-theme="light"] :is(.nav a,.tabs .tab,.brand p,.ticker-track,.pager) { color: var(--theme-text-muted) !important; }
html[data-theme="light"] :is(.nav a:hover,.nav a.active,.tab.active) { color: var(--theme-text) !important; background: var(--theme-surface-muted) !important; }
html[data-theme="light"] :is(table,th,td,.table-wrap,.panel-head,.mini-row,.insight,.rank,.part-row,.action-row) { border-color: var(--theme-border) !important; }
html[data-theme="light"] th { color: #38536f !important; }
html[data-theme="light"] td { color: var(--theme-text) !important; }
html[data-theme="light"] .bar { background: #dbe5ef !important; }
html[data-theme="light"] :is(.modal-backdrop,.mobile-overlay.show) { background: var(--theme-overlay) !important; }
html[data-theme="light"] :is(.login-error,.error,.FailedValidation) { color: #9f1239 !important; }
html[data-theme="light"] :is(.schedule-warning,.warn,.PendingValidation,.NeedsValidation) { color: #854d0e !important; }
html[data-theme="light"] :is(.Completed,.Closed,.Validated,.Resolved,.driver) { color: #166534 !important; }

@media print { .theme-control { display: none !important; } }

@media (max-width: 700px) {
    .theme-control { right: 10px; bottom: 10px; }
    .theme-control > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ==========================================================================
   InterScan Mission Control
   Shared operating-system layer for every authenticated product surface.
   ========================================================================== */
:root {
    --mc-canvas: #030810;
    --mc-sidebar: #06101b;
    --mc-panel: #0a1725;
    --mc-panel-raised: #0e1d2e;
    --mc-line: #20344a;
    --mc-line-bright: #31506b;
    --mc-cyan: #30c8e8;
    --mc-blue: #3b82f6;
    --mc-green: #35d07f;
    --mc-amber: #f3bd45;
    --mc-red: #ff6077;
    --mc-radius: 10px;
    --mc-control-height: 34px;
    --mc-type: Inter, "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --mc-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

html:not([data-theme="light"]) body {
    color: #edf5fc;
    background-color: var(--mc-canvas);
    background-image:
        linear-gradient(rgba(63, 101, 139, .025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(63, 101, 139, .025) 1px, transparent 1px),
        radial-gradient(circle at 78% -12%, rgba(29, 104, 168, .15), transparent 33%) !important;
    background-size: 32px 32px, 32px 32px, auto !important;
    font-family: var(--mc-type);
    font-feature-settings: "tnum" 1, "ss01" 1, "cv11" 1;
    text-rendering: geometricPrecision;
}

html:not([data-theme="light"]) :is(
    .platform-header, .platform-bar, .page-header, .topbar,
    .operations-topbar, .workspace-header, .executive-topbar
) {
    border-bottom-color: var(--mc-line) !important;
    background: rgba(4, 12, 21, .94) !important;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .025), 0 12px 30px rgba(0, 0, 0, .22);
    backdrop-filter: blur(20px) saturate(130%);
}

html:not([data-theme="light"]) :is(
    .sidebar, .operations-sidebar, .workspace-sidebar, .executive-rail, .admin-nav
) {
    border-color: var(--mc-line) !important;
    background: linear-gradient(180deg, #071421 0%, #050d17 68%, #040a11 100%) !important;
    box-shadow: inset -1px 0 rgba(255, 255, 255, .018);
}

html:not([data-theme="light"]) :is(
    .panel, .widget, .workspace-card, .customer-card, .executive-panel,
    .integration-card, .settings-card, .table-shell, .asset-panel,
    .locked-card, .service-plan-banner, .command-strip, dialog, .modal
) {
    border-color: var(--mc-line) !important;
    border-radius: var(--mc-radius) !important;
    background: linear-gradient(145deg, rgba(14, 29, 46, .97), rgba(8, 20, 33, .98)) !important;
    box-shadow: 0 14px 34px rgba(0, 0, 0, .2), inset 0 1px rgba(255, 255, 255, .025) !important;
}

html:not([data-theme="light"]) :is(
    .kpi, .kpi-card, .hero-card, .metric-grid article, .mini-metrics article,
    .summary-grid article, .status-grid > div, .fleet-metric, .detail-card
) {
    border-color: var(--mc-line) !important;
    border-radius: 8px !important;
    background: linear-gradient(155deg, #102237, #0a1725) !important;
    box-shadow: inset 0 1px rgba(255, 255, 255, .025), 0 8px 20px rgba(0, 0, 0, .14) !important;
}

html:not([data-theme="light"]) :is(
    .panel, .widget, .workspace-card, .customer-card, .executive-panel,
    .kpi, .kpi-card, .hero-card, .metric-grid article, .summary-grid article
):hover {
    border-color: var(--mc-line-bright) !important;
}

:is(h1, h2, h3, strong, .value) {
    font-variant-numeric: tabular-nums;
}

:is(.eyebrow, .nav-label, .panel-kicker, .widget-kicker, .workspace-eyebrow) {
    color: var(--mc-cyan) !important;
    font-size: 9px !important;
    font-weight: 820 !important;
    letter-spacing: .145em !important;
    text-transform: uppercase;
}

html:not([data-theme="light"]) :is(.muted, .subtitle, small, .panel-meta) {
    color: #91a7bc;
}

html:not([data-theme="light"]) :is(th, .table-wrap thead td) {
    color: #9fb5ca !important;
    background: #091522 !important;
    border-color: var(--mc-line) !important;
    font-size: 9px;
    font-weight: 780;
    letter-spacing: .075em;
    text-transform: uppercase;
}

html:not([data-theme="light"]) :is(td, th) {
    border-color: rgba(45, 72, 98, .72) !important;
}

html:not([data-theme="light"]) tbody tr {
    transition: background-color 140ms ease;
}

html:not([data-theme="light"]) tbody tr:hover {
    background: rgba(48, 200, 232, .045);
}

html:not([data-theme="light"]) :is(input, select, textarea) {
    min-height: var(--mc-control-height);
    color: #edf5fc !important;
    border-color: var(--mc-line-bright) !important;
    border-radius: 7px !important;
    background: #071321 !important;
}

html:not([data-theme="light"]) :is(
    button, .button, .primary-button, .secondary-button, .refresh-button,
    .customer-button, .hero-link, .iconbtn
) {
    min-height: var(--mc-control-height);
    border-radius: 7px !important;
    font-weight: 760;
    letter-spacing: .01em;
}

html:not([data-theme="light"]) :is(
    button.primary, .button:not(.secondary):not(.danger), .primary-button,
    .customer-button, .hero-link.primary
) {
    border-color: rgba(48, 200, 232, .35) !important;
    color: #fff !important;
    background: linear-gradient(135deg, #1768ad, #147f9b) !important;
    box-shadow: 0 7px 20px rgba(9, 91, 135, .22);
}

html:not([data-theme="light"]) :is(
    .nav a, .workspace-nav button, .operations-sidebar nav a,
    .executive-rail nav a, .admin-nav a
) {
    border-radius: 6px !important;
    font-weight: 680;
    transition: color 130ms ease, background-color 130ms ease, box-shadow 130ms ease !important;
}

html:not([data-theme="light"]) :is(
    .nav a.active, .workspace-nav button.active, .operations-sidebar nav a.active,
    .executive-rail nav a.active, .admin-nav a.active
) {
    color: #f4fbff !important;
    background: linear-gradient(90deg, rgba(28, 122, 179, .25), rgba(23, 70, 105, .1)) !important;
    box-shadow: inset 2px 0 var(--mc-cyan);
}

html:not([data-theme="light"]) :is(.status-dot, .mission-dot, .enterprise-live)::before,
html:not([data-theme="light"]) .data-freshness i {
    box-shadow: 0 0 12px rgba(53, 208, 127, .7);
}

.theme-control {
    right: 12px;
    bottom: 12px;
    padding: 5px 6px 5px 9px;
    border-radius: 7px;
    opacity: .58;
    transition: opacity 140ms ease;
}
.theme-control:hover, .theme-control:focus-within { opacity: 1; }

* {
    scrollbar-width: thin;
    scrollbar-color: #29425b #07101a;
}
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: #07101a; }
*::-webkit-scrollbar-thumb { border: 2px solid #07101a; border-radius: 10px; background: #29425b; }

@media (max-width: 760px) {
    html:not([data-theme="light"]) body {
        background-size: 24px 24px, 24px 24px, auto !important;
    }
}

/* CEO demo readability freeze: contrast only. */
html:not([data-theme="light"]) {
    --theme-text: #f8fafc;
    --theme-text-muted: #bcc9d8;
    --theme-muted: #bcc9d8;
    --chart-text: #d6e0ea;
    --chart-muted: #a7b7c9;
    --text: #f8fafc;
    --muted: #bcc9d8;
    --ink: #f8fafc;
}

html:not([data-theme="light"]) body {
    color: #d6e0ea !important;
}

html:not([data-theme="light"]) :is(h1, h2, h3, h4, h5, h6) {
    color: #f8fafc !important;
}

html:not([data-theme="light"]) :is(
    p:not(.eyebrow):not(.error):not(.warning):not(.success),
    td
) {
    color: #d6e0ea !important;
}

html:not([data-theme="light"]) small:not([aria-disabled="true"]) {
    color: #bcc9d8 !important;
}

html:not([data-theme="light"]) :is(
    .kpi-card > strong,
    .hero-card > strong,
    .summary-metric > strong,
    .metric-grid article > strong,
    .mini-metrics article > strong,
    .fleet-metric > strong,
    .detail-card > strong,
    .account-summary-metrics strong,
    .customer-card-details strong,
    .hero-score > strong,
    .trend-current,
    .value
) {
    color: #fff !important;
}

html:not([data-theme="light"]) :is(
    .welcome > div > p:last-child,
    .hero-copy p:last-of-type,
    .hero-narrative > p:not(.eyebrow),
    .record-card p,
    .report-card p,
    .locked p,
    .empty-state p,
    .panel-heading p,
    .section-heading p:not(.eyebrow),
    .branding-heading p,
    .entitlement-heading > div > p:last-child,
    .plan-control p,
    .service-plan-summary p,
    .card-heading p,
    .form-heading p,
    .environment-banner p,
    .guardrail-card li
) {
    color: #d6e0ea !important;
}

html:not([data-theme="light"]) :is(
    .hero-card small,
    .summary-metric small,
    .attention-item small,
    .work-item small,
    .activity-item span,
    .summary-item span,
    .compact-item span,
    .record-card > span,
    .metric-grid small,
    .kpi-card > small,
    .brief-action small,
    .fleet-table-card td > small,
    .fleet-health-cell small,
    .service-term small,
    .support-commitments small,
    .feature-row small,
    .tenant-cell small,
    .platform-brand small,
    .login-brand small,
    .login-live-metrics span,
    .trust-row span,
    .executive-brand small,
    .executive-customer small,
    .executive-rail nav a,
    .operations-sidebar nav a,
    .workspace-nav button,
    .workspace-nav > a,
    .tenant-identity a,
    .breadcrumb,
    .workspace-context span,
    .workspace-context small,
    .widget > header a,
    .widget-loading p,
    .fleet-heading > div > span,
    .fleet-toolbar > span,
    .dashboard-title,
    .customer-heading > span,
    .customer-card-details span,
    .brand-details span,
    .field-help,
    .section-note,
    .plan-description,
    .configuration-form small,
    .status-grid span
) {
    color: #bcc9d8 !important;
}

html:not([data-theme="light"]) :is(
    time,
    .timestamp,
    .metadata,
    .panel-meta,
    .action-meta,
    .hero-meta > span:last-child,
    .attention-item em,
    .fleet-customer em,
    .data-freshness small,
    .executive-rail footer small,
    .operations-sidebar footer small,
    .account-identity small,
    .service-history-entry span,
    .service-history-entry time,
    .file-name
) {
    color: #a7b7c9 !important;
}

html:not([data-theme="light"]) :is(
    th,
    .metric-grid article > span,
    .mini-metrics article > span,
    .summary-metric > span,
    .hero-card > span,
    .fleet-metric > span,
    .detail-card > span,
    .account-summary-metrics span,
    .customer-card-details span,
    .tenant-identity small,
    .customer-identity small,
    .fleet-customer small,
    .operations-sidebar nav p,
    .workspace-nav p
) {
    color: #a7b7c9 !important;
}

html:not([data-theme="light"]) :is(
    button:disabled,
    [aria-disabled="true"],
    .disabled,
    [disabled]
) {
    color: #8fa1b6 !important;
}
