/* ═══════════════════════════════════════════════════════════════════════════
   Predator — Mission-Control Theme System
   All colours live here as custom properties.  No hex/rgb literal may appear
   outside this token block — every downstream rule MUST use var().
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Dark theme (default) ────────────────────────────────────────────────── */
:root {
    /* ── Base backgrounds */
    --bg:              #070b14;
    --panel:           #0d1322;
    --panel-elev:      #111a2e;
    --panel-border:    #1c2740;
    --panel-highlight: rgba(255,255,255,.03);   /* subtle inner top highlight  */

    /* ── Borders / dividers */
    --border:          #1c2740;
    --border-subtle:   rgba(28,39,64,.5);

    /* ── Text */
    --text:            #dbe4f3;
    --muted:           #5b6b85;
    --grey:            #7a8fa8;

    /* ── Accents */
    --accent:          #22d3ee;   /* cyan                                      */
    --accent-dim:      rgba(34,211,238,.15);
    --accent-wash:     rgba(34,211,238,.06);
    --accent-active:   rgba(34,211,238,.10);
    --accent-orange:   #f97316;   /* alerts / drone                            */

    /* ── Status */
    --ok:              #34d399;
    --warn:            #fbbf24;
    --bad:              #fb7185;
    --info:            #60a5fa;

    /* ── Status tints (badge / row backgrounds) */
    --ok-tint:         rgba(52,211,153,.15);
    --warn-tint:       rgba(251,191,36,.15);
    --bad-tint:        rgba(251,113,133,.15);
    --info-tint:       rgba(96,165,250,.15);
    --grey-tint:       rgba(122,143,168,.15);

    /* ── Glow / shadow tokens */
    --glow:            0 0 12px rgba(34,211,238,.25);
    --glow-sm:         0 0 6px  rgba(34,211,238,.20);
    --glow-ok:         0 0 8px  rgba(52,211,153,.30);
    --glow-bad:        0 0 12px rgba(251,113,133,.30);
    --pulse-ring:      rgba(52,211,153,.25);
    --accent-border:   rgba(34,211,238,.25);
    --shadow-card:     0 2px 8px rgba(0,0,0,.40);
    --shadow-elev:     0 4px 16px rgba(0,0,0,.55);

    /* ── Header accent strip */
    --header-accent-strip: linear-gradient(90deg, var(--accent) 0%, var(--accent-orange) 100%);

    /* ── Mono font stack (data values) */
    --font-mono: "JetBrains Mono", ui-monospace, Consolas, "Cascadia Code", monospace;
    --font-ui:   -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    /* ── Transition speed */
    --t-fast:  120ms ease-out;
    --t-base:  150ms ease-out;
}

/* ── Light theme ─────────────────────────────────────────────────────────── */
[data-theme="light"] {
    /* ── Base backgrounds */
    --bg:              #eef2f8;
    --panel:           #ffffff;
    --panel-elev:      #f4f7fc;
    --panel-border:    #d7e0ee;
    --panel-highlight: rgba(255,255,255,.60);

    /* ── Borders */
    --border:          #d7e0ee;
    --border-subtle:   rgba(215,224,238,.6);

    /* ── Text */
    --text:            #16203a;
    --muted:           #64748f;
    --grey:            #8896aa;

    /* ── Accents — one step darker for contrast on light */
    --accent:          #0891b2;
    --accent-dim:      rgba(8,145,178,.15);
    --accent-wash:     rgba(8,145,178,.07);
    --accent-active:   rgba(8,145,178,.12);
    --accent-orange:   #ea580c;

    /* ── Status */
    --ok:              #059669;
    --warn:            #d97706;
    --bad:              #e11d48;
    --info:            #2563eb;

    /* ── Status tints */
    --ok-tint:         rgba(5,150,105,.12);
    --warn-tint:       rgba(217,119,6,.12);
    --bad-tint:        rgba(225,29,72,.10);
    --info-tint:       rgba(37,99,235,.10);
    --grey-tint:       rgba(136,150,170,.12);

    /* ── Glows → soft shadows in light mode */
    --glow:            0 2px 10px rgba(8,145,178,.20);
    --glow-sm:         0 1px 5px  rgba(8,145,178,.15);
    --glow-ok:         0 2px 6px  rgba(5,150,105,.20);
    --glow-bad:        0 2px 8px  rgba(225,29,72,.25);
    --pulse-ring:      rgba(5,150,105,.25);
    --accent-border:   rgba(8,145,178,.30);
    --shadow-card:     0 1px 4px  rgba(22,32,58,.10);
    --shadow-elev:     0 3px 12px rgba(22,32,58,.15);

    /* ── Header accent strip */
    --header-accent-strip: linear-gradient(90deg, var(--accent) 0%, var(--accent-orange) 100%);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Base reset
   ═══════════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.5;
}

/* ── Themed thin scrollbars ──────────────────────────────────────────────── */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
*::-webkit-scrollbar          { width: 5px; height: 5px; }
*::-webkit-scrollbar-track    { background: transparent; }
*::-webkit-scrollbar-thumb    { background: var(--border); border-radius: 99px; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ═══════════════════════════════════════════════════════════════════════════
   Layout
   ═══════════════════════════════════════════════════════════════════════════ */

.app-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    grid-template-rows: 48px 1fr;
    grid-template-areas:
        "header header"
        "sidebar main";
    height: 100vh;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Header
   ═══════════════════════════════════════════════════════════════════════════ */

.app-header {
    grid-area: header;
    background: var(--panel);
    /* 2 px accent gradient strip along bottom */
    border-bottom: none;
    box-shadow: inset 0 -2px 0 0 transparent; /* reserve space */
    position: relative;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 0.75rem;
}

/* Accent strip pseudo-element */
.app-header::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    background: var(--header-accent-strip);
}

.app-brand {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--accent);
    text-transform: uppercase;
    transition: color var(--t-base);
}

/* ── Health dot ──────────────────────────────────────────────────────────── */
.health-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background var(--t-base);
}

.health-dot.ok   { background: var(--ok);   animation: pulse-ok 2.5s ease-in-out infinite; }
.health-dot.warn { background: var(--warn); }
.health-dot.bad  { background: var(--bad);  }
.health-dot.grey { background: var(--grey); }

@keyframes pulse-ok {
    0%, 100% { transform: scale(1);    opacity: 1;    box-shadow: 0 0 0   0   transparent; }
    50%       { transform: scale(1.25); opacity: 0.85; box-shadow: 0 0 0 4px var(--pulse-ring); }
}

/* ── Theme toggle button (in header) ──────────────────────────────────────── */
.theme-toggle {
    margin-left: auto;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 4px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    cursor: pointer;
    transition: color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}
.theme-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: var(--glow-sm);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Sidebar + Nav
   ═══════════════════════════════════════════════════════════════════════════ */

.app-sidebar {
    grid-area: sidebar;
    background: var(--panel);
    border-right: 1px solid var(--border);
    padding: 1rem 0;
    overflow-y: auto;
    transition: background var(--t-base), border-color var(--t-base);
}

.nav-section {
    padding: 0.25rem 0.75rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.nav-link {
    display: block;
    padding: 0.45rem 1rem;
    color: var(--text);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}

.nav-link:hover {
    background: var(--accent-wash);
    color: var(--accent);
}

/* Active state: accent glow rail */
.nav-link.active {
    border-left-color: var(--accent);
    color: var(--accent);
    background: var(--accent-active);
    box-shadow: inset 3px 0 8px var(--accent-active);
}

.nav-disabled {
    display: block;
    padding: 0.45rem 1rem;
    color: var(--muted);
    font-size: 0.85rem;
    cursor: default;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Main content area
   ═══════════════════════════════════════════════════════════════════════════ */

.app-main {
    grid-area: main;
    padding: 1.5rem;
    overflow-y: auto;
}

/* ── Page headings — h1 with accent dash ──────────────────────────────────── */

h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 1.25rem;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

h1::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 3px;
    border-radius: 2px;
    background: var(--accent);
    flex-shrink: 0;
    transition: background var(--t-base);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Cards
   ═══════════════════════════════════════════════════════════════════════════ */

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    /* subtle inner top highlight */
    box-shadow: inset 0 1px 0 var(--panel-highlight), var(--shadow-card);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: background var(--t-base), border-color var(--t-base), box-shadow var(--t-base);
}

/* Card hover elevation — 2px accent top-border appears */
.card:hover {
    background: var(--panel-elev);
    border-color: var(--accent-dim);
    box-shadow: inset 0 1px 0 var(--panel-highlight), var(--shadow-elev);
    border-top-color: var(--accent);
}

.card h2 {
    margin: 0 0 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Tables
   ═══════════════════════════════════════════════════════════════════════════ */

.tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.tbl th {
    text-align: left;
    padding: 0.4rem 0.75rem;          /* slightly denser */
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.tbl td {
    padding: 0.4rem 0.75rem;          /* denser rows */
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
    transition: background var(--t-fast);
}

/* Numeric / mono data cells */
.tbl td.num,
.tbl td.mono {
    font-family: var(--font-mono);
    font-size: 0.82rem;
}

.tbl tr:last-child td { border-bottom: none; }

/* Row hover: accent wash + left bar */
.tbl tbody tr {
    position: relative;
    transition: background var(--t-fast);
}

.tbl tbody tr:hover td {
    background: var(--accent-wash);
}

.tbl tbody tr:hover td:first-child {
    box-shadow: inset 3px 0 0 var(--accent);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: 4px;               /* sharp 4px radius per design language */
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: box-shadow var(--t-fast), opacity var(--t-fast), transform var(--t-fast);
    white-space: nowrap;
    text-decoration: none;
}

.btn:hover:not(:disabled) {
    box-shadow: var(--glow);
    opacity: 0.92;
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
    box-shadow: var(--glow-sm);
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-danger {
    background: var(--bad);
    color: var(--panel);
}

.btn-danger:hover:not(:disabled) {
    box-shadow: var(--glow-bad);
}

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--panel-elev);
    box-shadow: var(--shadow-card);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Forms
   ═══════════════════════════════════════════════════════════════════════════ */

label {
    display: block;
    margin-bottom: 0.75rem;
    color: var(--text);
    font-size: 0.875rem;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="url"],
input[type="email"],
select,
textarea {
    display: block;
    width: 100%;
    margin-top: 0.2rem;
    padding: 0.4rem 0.65rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
input[type="url"]:focus,
input[type="email"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--glow-sm);
}

input[type="checkbox"] {
    width: auto;
    margin-right: 0.4rem;
    accent-color: var(--accent);
}

input[type="radio"] {
    accent-color: var(--accent);
    margin-right: 0.4rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Badges — dot prefix + per-status tints
   ═══════════════════════════════════════════════════════════════════════════ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Dot prefix via ::before */
.badge::before {
    content: '';
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.badge-ok       { background: var(--ok-tint);   color: var(--ok); }
.badge-degraded { background: var(--warn-tint);  color: var(--warn); }
.badge-bad      { background: var(--bad-tint);   color: var(--bad); }
.badge-disabled { background: var(--grey-tint);  color: var(--grey); }
.badge-accent   { background: var(--accent-dim); color: var(--accent); }

/* ═══════════════════════════════════════════════════════════════════════════
   Wizard steps
   ═══════════════════════════════════════════════════════════════════════════ */

.wizard-steps {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.wizard-step {
    padding: 0.3rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--border);
    color: var(--muted);
    transition: background var(--t-fast), color var(--t-fast);
}

.wizard-step.active {
    background: var(--accent);
    color: var(--bg);
}

.wizard-step.done {
    background: var(--ok-tint);
    color: var(--ok);
}

.wizard-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
    justify-content: flex-end;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Drone map marker
   ═══════════════════════════════════════════════════════════════════════════ */

.drone-marker {
    background: transparent;
    border: none;
}

.drone-icon {
    width: 48px;
    height: 48px;
    will-change: transform;          /* heading rotation set inline from JS */
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.55));
}

.drone-icon .rotor {
    transform-box: fill-box;
    transform-origin: center;
}

.drone-icon.flying .rotor {
    animation: rotor-spin 0.18s linear infinite;
}

@keyframes rotor-spin {
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Form fields (label above input, uniform width)
   ═══════════════════════════════════════════════════════════════════════════ */

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 0.9rem;
    max-width: 420px;
}

.form-field .lbl {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
}

.form-field .lbl .hint {
    font-weight: 400;
    opacity: 0.7;
}

.form-field input[type="text"],
.form-field input[type="number"],
.form-field input[type="password"],
.form-field select {
    width: 100%;
    box-sizing: border-box;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Grid layout helpers
   ═══════════════════════════════════════════════════════════════════════════ */

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Dashboard layout
   ═══════════════════════════════════════════════════════════════════════════ */

.dashboard-layout {
    display: flex;
    flex-direction: row;
    gap: 1rem;
    height: calc(100vh - 120px);
}

.dashboard-map {
    flex: 3;
    min-width: 0;
}

.dashboard-right {
    flex: 2;
    min-width: 280px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.device-card .device-status-row {
    margin-bottom: 0.75rem;
}

.feed-time {
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--muted);
}

/* ═══════════════════════════════════════════════════════════════════════════
   3D map panel
   ═══════════════════════════════════════════════════════════════════════════ */

/* Thin header bar that sits above the 2D/3D maps, holding the toggle + toolbar */
.map-panel-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 2.2rem;
    padding: 0 0.6rem;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: wrap;
    z-index: 900;
    position: relative;
}

.map-hud {
    position: absolute;
    left: 1rem;
    bottom: 1rem;
    z-index: 800;
    min-width: 250px;
    padding: 0.9rem 1rem;
    border: 1px solid var(--accent-border);
    border-radius: 10px;
    background: color-mix(in srgb, var(--panel) 88%, transparent);
    box-shadow: var(--shadow-elev);
    backdrop-filter: blur(12px);
    pointer-events: none;
    font-family: var(--font-mono);
}
.map-hud-title { display: flex; align-items: center; gap: 0.5rem; color: var(--text); font-size: 0.78rem; }
.map-hud-title span:last-child { margin-left: auto; color: var(--accent); text-transform: uppercase; }
.map-hud-live { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: var(--glow-ok); }
.map-hud-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.7rem 1.3rem; margin-top: 0.8rem; }
.map-hud-grid span { display: flex; flex-direction: column; gap: 0.15rem; }
.map-hud-grid small { color: var(--muted); font-size: 0.64rem; letter-spacing: 0.1em; }
.map-hud-grid strong { color: var(--text); font-size: 1.05rem; font-weight: 600; }

.mission-map-toggle { margin-bottom: 0.5rem; width: fit-content; }
.mission-coordinate { width: 8rem; max-width: 100%; font-family: var(--font-mono); }
.mission-row-actions { display: flex; gap: 0.2rem; }
.mission-route-summary { color: var(--accent); font-family: var(--font-mono); font-size: 0.82rem; margin: 0.6rem 0 0; }

/* Segmented 2D | 3D toggle */
.map-mode-toggle {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}

.map-mode-btn {
    padding: 0.18rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 600;
    background: transparent;
    color: var(--muted);
    border: none;
    cursor: pointer;
    letter-spacing: 0.04em;
    transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}

.map-mode-btn:hover:not(.active) {
    background: var(--accent-wash);
    color: var(--text);
}

.map-mode-btn.active {
    background: var(--accent);
    color: var(--bg);
}

/* The Cesium viewer fills the same space as the Leaflet div */
#map3d {
    position: relative;
}

/* Make Cesium's credit / attribution unobtrusive */
.cesium-credit-container,
.cesium-widget-credits {
    font-size: 9px !important;
    opacity: 0.45 !important;
    bottom: 2px !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Blazor wiring
   ═══════════════════════════════════════════════════════════════════════════ */

#blazor-error-ui {
    background: var(--bad);
    color: var(--panel);
    padding: 0.75rem 1rem;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    display: none;
}

#blazor-error-ui.blazor-error-boundary { display: block; }

.blazor-error-boundary {
    background: var(--bad);
    color: var(--panel);
    padding: 1rem;
    border-radius: 6px;
}

.blazor-error-boundary::after { content: "An error has occurred." }

/* ═══════════════════════════════════════════════════════════════════════════
   Utility
   ═══════════════════════════════════════════════════════════════════════════ */

.text-muted   { color: var(--muted); }
.text-ok      { color: var(--ok); }
.text-warn    { color: var(--warn); }
.text-bad     { color: var(--bad); }
.text-accent  { color: var(--accent); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* ── Mono / data utility ──────────────────────────────────────────────────── */
/* Apply to telemetry numbers, SNs, coordinates, timestamps, ids, log rows.   */
.mono,
.data {
    font-family: var(--font-mono);
    font-size: 0.85em;
    font-variant-numeric: tabular-nums;
}

/* ── Three-dot loading utility ────────────────────────────────────────────── */
.loading-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.loading-dots span {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
    animation: dot-pulse 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-pulse {
    0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
    40%           { opacity: 1;   transform: scale(1.2); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Battery bar (dashboard + fleet device readouts)
   ─────────────────────────────────────────────────────────────────────────
   <div class="bar"><div class="bar-fill ok|warn|bad" style="width:X%"></div></div>
   ═══════════════════════════════════════════════════════════════════════════ */

.bar {
    width: 100%;
    height: 5px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.5s ease-out, background var(--t-base);
    background: var(--ok);         /* default = ok colour */
}

.bar-fill.warn { background: var(--warn); }
.bar-fill.bad  { background: var(--bad);  }

/* ── Big mono battery percent label ──────────────────────────────────────── */
.battery-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    color: var(--ok);
    transition: color var(--t-base);
}

.battery-value.warn { color: var(--warn); }
.battery-value.bad  { color: var(--bad);  }

/* ═══════════════════════════════════════════════════════════════════════════
   Readout grid (AGL / speed / status in a labelled mini-grid)
   ─────────────────────────────────────────────────────────────────────────
   <div class="readout-grid">
     <div class="readout-cell">
       <span class="readout-label">AGL</span>
       <span class="readout-value mono">12.4 m</span>
     </div>
     …
   </div>
   ═══════════════════════════════════════════════════════════════════════════ */

.readout-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin: 0.6rem 0;
}

.readout-cell {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.readout-label {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--muted);
}

.readout-value {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Map frame — corner accent ticks via CSS pseudo-elements
   ─────────────────────────────────────────────────────────────────────────
   Wrap any map container: <div class="map-frame">…</div>
   ═══════════════════════════════════════════════════════════════════════════ */

.map-frame {
    position: relative;
}

/* All four corner ticks share a common pseudo-element size */
.map-frame::before,
.map-frame::after,
.map-frame > .map-frame-inner::before,
.map-frame > .map-frame-inner::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border-color: var(--accent);
    border-style: solid;
    pointer-events: none;
    z-index: 10;
    opacity: 0.7;
    transition: opacity var(--t-base);
}

.map-frame:hover::before,
.map-frame:hover::after,
.map-frame:hover > .map-frame-inner::before,
.map-frame:hover > .map-frame-inner::after { opacity: 1; }

/* Top-left */
.map-frame::before {
    top: 0; left: 0;
    border-width: 2px 0 0 2px;
}

/* Top-right */
.map-frame::after {
    top: 0; right: 0;
    border-width: 2px 2px 0 0;
}

/* We use a thin shim div inside .map-frame for the bottom ticks
   without needing a second child wrapper — use a data attribute hook */
.map-frame[data-ticks]::before,
.map-frame[data-ticks]::after { /* already handled above */ }

/* Bottom ticks via .map-frame-br pseudo-class hack:
   We abuse the card's own ::before/::after by applying map-frame
   to the CARD wrapper; the card already has a hover::before (top border)
   which we don't want to break.  Instead we use a CSS-only approach:
   apply the bottom corners via a contained child pseudo. */

/* Simpler: add .map-frame-tl .map-frame-tr .map-frame-bl .map-frame-br classes */
.map-frame .map-corner-tl,
.map-frame .map-corner-tr,
.map-frame .map-corner-bl,
.map-frame .map-corner-br {
    position: absolute;
    width: 14px;
    height: 14px;
    border-color: var(--accent);
    border-style: solid;
    pointer-events: none;
    z-index: 10;
    opacity: 0.65;
    transition: opacity var(--t-base);
}

.map-frame:hover .map-corner-tl,
.map-frame:hover .map-corner-tr,
.map-frame:hover .map-corner-bl,
.map-frame:hover .map-corner-br { opacity: 1; }

.map-frame .map-corner-tl { top: 6px; left: 6px;   border-width: 2px 0 0 2px; }
.map-frame .map-corner-tr { top: 6px; right: 6px;  border-width: 2px 2px 0 0; }
.map-frame .map-corner-bl { bottom: 6px; left: 6px;  border-width: 0 0 2px 2px; }
.map-frame .map-corner-br { bottom: 6px; right: 6px; border-width: 0 2px 2px 0; }

/* ═══════════════════════════════════════════════════════════════════════════
   Segmented control
   ─────────────────────────────────────────────────────────────────────────
   <div class="segmented">
     <button class="seg-btn active">2D</button>
     <button class="seg-btn">3D</button>
   </div>
   ═══════════════════════════════════════════════════════════════════════════ */

.segmented {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}

.seg-btn {
    padding: 0.22rem 0.7rem;
    font-size: 0.78rem;
    font-weight: 600;
    background: transparent;
    color: var(--muted);
    border: none;
    border-right: 1px solid var(--border);
    cursor: pointer;
    letter-spacing: 0.04em;
    transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
    white-space: nowrap;
}

.seg-btn:last-child { border-right: none; }

.seg-btn:hover:not(.active):not(:disabled) {
    background: var(--accent-wash);
    color: var(--text);
}

.seg-btn.active {
    background: var(--accent);
    color: var(--bg);
    box-shadow: var(--glow-sm);
}

.seg-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ═══════════════════════════════════════════════════════════════════════════
   Terminal feed log (.feed-log)
   ─────────────────────────────────────────────────────────────────────────
   <div class="feed-log">
     <div class="feed-row [feed-alert-high|feed-alert-low|feed-alert-info]">
       <span class="feed-ts mono">14:22:01</span>
       <span class="feed-event">…</span>
       <span class="feed-device">…</span>
     </div>
   </div>
   ═══════════════════════════════════════════════════════════════════════════ */

.feed-log {
    display: flex;
    flex-direction: column;
    gap: 1px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    overflow-y: auto;
    max-height: 260px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
}

.feed-row {
    display: grid;
    grid-template-columns: 60px 1fr auto;
    gap: 0.5rem;
    align-items: center;
    padding: 0.2rem 0.5rem;
    border-left: 2px solid transparent;
    transition: background var(--t-fast);
}

.feed-row:hover { background: var(--accent-wash); }

.feed-ts {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--muted);
    white-space: nowrap;
}

.feed-event { color: var(--text); }
.feed-device { color: var(--muted); font-size: 0.72rem; white-space: nowrap; }

/* Severity-coloured rows */
.feed-alert-high {
    border-left-color: var(--bad);
    background: var(--bad-tint);
}

.feed-alert-low {
    border-left-color: var(--warn);
    background: var(--warn-tint);
}

.feed-alert-info {
    border-left-color: var(--info);
    background: var(--info-tint);
}

/* Thumbnail inline in feed */
.feed-thumb {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 2px;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Fleet card polish (.fleet-card)
   ─────────────────────────────────────────────────────────────────────────
   Extends .card — adds a thin status-coloured top bar and a chip row for
   active streams.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Status top bar: override the top border with a solid accent colour */
.fleet-card { position: relative; padding-top: 1.5rem; }

.fleet-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: 8px 8px 0 0;
    background: var(--muted);          /* default = grey */
    transition: background var(--t-base);
}

.fleet-card.status-ok::before     { background: var(--ok); }
.fleet-card.status-warn::before   { background: var(--warn); }
.fleet-card.status-bad::before    { background: var(--bad); }
.fleet-card.status-active::before { background: var(--accent); }

/* Stream chips — glowing accent pills */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid var(--accent-border);
    transition: box-shadow var(--t-fast);
}

.chip:hover { box-shadow: var(--glow-sm); }

/* ═══════════════════════════════════════════════════════════════════════════
   Mission progress ticker (.ticker)
   ─────────────────────────────────────────────────────────────────────────
   <div class="ticker">
     <span class="ticker-label mono">in_progress</span>
     <div class="bar"><div class="bar-fill ok" style="width:42%"></div></div>
     <span class="ticker-pct mono">42%</span>
   </div>
   ═══════════════════════════════════════════════════════════════════════════ */

.ticker {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.ticker-label { color: var(--text); font-weight: 600; }
.ticker .bar  { flex: 1; }
.ticker-pct   { color: var(--muted); min-width: 3ch; text-align: right; }

/* ═══════════════════════════════════════════════════════════════════════════
   Alerts page polish
   ─────────────────────────────────────────────────────────────────────────
   Severity left-border on table rows, media frames, detail grid.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Severity row classes */
.sev-high td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.sev-low  td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.sev-info td:first-child { box-shadow: inset 3px 0 0 var(--info); }

.sev-high { background: var(--bad-tint);  }
.sev-low  { background: var(--warn-tint); }
.sev-info { background: var(--info-tint); }

/* Media frame — bordered snapshot container with caption bar */
.media-frame {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    background: var(--bg);
    max-width: 480px;
}

.media-frame img,
.media-frame video {
    display: block;
    max-width: 100%;
    max-height: 270px;
    object-fit: contain;
}

.media-caption {
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
    color: var(--muted);
    background: var(--panel);
    border-top: 1px solid var(--border);
    font-family: var(--font-mono);
}

/* Detail grid for expanded alert rows (dt/dd or label/value) */
.detail-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 1rem;
    font-size: 0.85rem;
    align-items: baseline;
}

.detail-grid dt,
.detail-grid .dg-label {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.detail-grid dd,
.detail-grid .dg-value {
    font-family: var(--font-mono);
    color: var(--text);
    margin: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Wizard steps — accent connector line between steps
   ═══════════════════════════════════════════════════════════════════════════ */

/* Override the gap-based list to add a connecting line */
.wizard-steps {
    position: relative;
    align-items: center;
}

/* Horizontal rule behind the pills */
.wizard-steps::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0.75rem;
    right: 0.75rem;
    height: 1px;
    background: var(--border);
    transform: translateY(-50%);
    z-index: 0;
}

.wizard-step {
    position: relative;
    z-index: 1;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Health page — mono detail column + pulse dot alignment
   ═══════════════════════════════════════════════════════════════════════════ */

/* Already have .tbl td.mono — just ensure health detail is mono */
.health-detail {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--muted);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Tab bar — segmented tab row used in Media, Deliveries
   ─────────────────────────────────────────────────────────────────────────
   Use the .segmented class + .seg-btn on the tab buttons;
   a dedicated class for the bar wrapper:
   ═══════════════════════════════════════════════════════════════════════════ */

.tab-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   M11 — Login / access-denied centred card + identity bits
   ═══════════════════════════════════════════════════════════════════════════ */

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: var(--bg);
}

.login-card {
    width: 100%;
    max-width: 360px;
    text-align: center;
}

.login-brand {
    font-family: var(--mono, "JetBrains Mono", monospace);
    font-weight: 600;
    font-size: 1.6rem;
    letter-spacing: 0.04em;
    background: var(--header-accent-strip);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.login-sub { margin: 0.25rem 0 1.25rem; }
.login-error { margin-bottom: 1rem; }

.login-card .form-field { text-align: left; }
.login-btn { width: 100%; margin-top: 0.5rem; }

/* Header user identity + logout */
.app-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.82rem;
    color: var(--muted);
}
.app-user .app-user-name { color: var(--text); font-weight: 600; }
.app-user .app-user-role {
    font-family: var(--mono, monospace);
    font-size: 0.72rem;
    padding: 0.05rem 0.4rem;
    border-radius: 4px;
    background: var(--accent-dim);
    color: var(--accent);
}
.logout-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 6px;
    padding: 0.2rem 0.6rem;
    font: inherit;
    font-size: 0.78rem;
    cursor: pointer;
}
.logout-btn:hover { color: var(--text); border-color: var(--accent-border); }

/* ═══════════════════════════════════════════════════════════════════════════
   M12 — Control-room UI
   ─────────────────────────────────────────────────────────────────────────
   Status strip, unacknowledged-alert pill, ack/clear table, live-feed pulse.
   All colours come from the existing token blocks — no raw hex here.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Ops status strip (dashboard rail) ── */
.status-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    gap: 0.5rem;
}

.status-cell {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
}

.status-cell .status-num {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text);
}

.status-cell .status-cap {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

/* Accent the cells that matter at a glance */
.status-cell.is-online .status-num   { color: var(--accent); }
.status-cell.is-charging .status-num { color: var(--ok); }
.status-cell.is-offline .status-num  { color: var(--bad); }
.status-cell.is-alerts.has-unack     { border-color: var(--bad); background: var(--bad-tint); }
.status-cell.is-alerts.has-unack .status-num { color: var(--bad); }

/* System-health pill */
.health-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--border);
}
.health-pill .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.health-pill.ok   { background: var(--ok-tint);  color: var(--ok);  border-color: transparent; }
.health-pill.ok   .dot { background: var(--ok); animation: pulse-ok 2.5s ease-in-out infinite; }
.health-pill.warn { background: var(--warn-tint); color: var(--warn); border-color: transparent; }
.health-pill.warn .dot { background: var(--warn); }
.health-pill.bad  { background: var(--bad-tint);  color: var(--bad);  border-color: transparent; }
.health-pill.bad  .dot { background: var(--bad); }

/* ── Prominent unacknowledged-alert badge (Alert Log header) ── */
.unack-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.8rem;
    border-radius: 9999px;
    font-weight: 700;
    font-size: 0.95rem;
    background: var(--bad-tint);
    color: var(--bad);
    border: 1px solid var(--bad);
}
.unack-badge.is-zero {
    background: var(--ok-tint);
    color: var(--ok);
    border-color: transparent;
    font-weight: 600;
}
.unack-badge .unack-num { font-family: var(--font-mono); }

/* ── Ack-state badges on the Alert Log ── */
.ack-new     { background: var(--bad-tint);  color: var(--bad); }
.ack-acked   { background: var(--warn-tint); color: var(--warn); }
.ack-cleared { background: var(--ok-tint);   color: var(--ok); }

/* ── High-severity live-feed pulse ── */
.feed-alert-pulse { animation: feed-flash 1.4s ease-out 2; }
@keyframes feed-flash {
    0%   { background: var(--bad); }
    100% { background: var(--bad-tint); }
}

/* Acked/cleared rows fade back so unacked alerts dominate the eye */
.alert-row-acked   { opacity: 0.72; }
.alert-row-cleared { opacity: 0.5; }

/* Snapshot thumbnail in the alert log table */
.alert-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 3px;
    border: 1px solid var(--border);
    display: block;
}
.simcam-panel { margin-top: .75rem; padding: .75rem; }
.simcam-header, .simcam-controls { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.simcam-header { justify-content: space-between; margin-bottom: .65rem; }
.simcam-viewport { width: 100%; height: 320px; background: radial-gradient(circle at 50% 50%, #25394a, #07111b); overflow: hidden; }
.simcam-controls { margin-top: .65rem; font-size: .82rem; }
