/* ============================================================================
   DJI Cloud API Dashboard – UAVIA Cockpit theme
   ----------------------------------------------------------------------------
   Pulls heavily from `webapp-front`:
     - Lato typography (300/400/700)
     - Cockpit chrome: `$light-black: #1E2029` deep, `$dark-blue: #2B3E50`
       panels (matches `start-cockpit.component.scss` and
       `cockpit-header.component.scss`)
     - Brand palette: $green #18BC9C, $blue #428BCA, $orange #FFA500,
       $red #D64F4F, $yellow #FFD700
     - Sync-flash keyframes ported from
       `webapp-front/src/sass/_ui-sync-animations.scss`
     - Notification banner gradient ported from
       `cockpit-notifications.component.scss` (`.popup-ERROR`)
     - Pill chips ported from `cockpit-mission-control` (`.name-robot`,
       `.mission-time`) and `cockpit-flight-authorization` (`.flight-auth-*`)
     - Ripple animation ported from `global-map.scss`

   Sized for landscape DJI controllers — DJI Smart Controller (5.5" 1920×1080,
   DPR≈2.6 → ≈720×405 CSS) and DJI RC Pro 2 (7.02" 1920×1200, DPR≈2 → ≈960×600
   CSS). Cockpit-dark by default for outdoor flight sessions; high-contrast,
   glowing connection rings, and ≥56px touch targets keep it readable in 1000
   cd/m² sunlight.
   ============================================================================ */

/* ----------------------------------------------------------------------------
   Lato @font-face — same source files as webapp-front
   ---------------------------------------------------------------------------- */
@font-face {
    font-family: Lato;
    font-style: italic;
    font-weight: 300;
    font-display: swap;
    src: local('Lato Light Italic'), local('Lato-LightItalic'),
         url('/public/assets/fonts/Lato/Lato-LightItalic.woff2') format('woff2');
}
@font-face {
    font-family: Lato;
    font-style: normal;
    font-weight: 300;
    font-display: swap;
    src: local('Lato Light'), local('Lato-Light'),
         url('/public/assets/fonts/Lato/Lato-Light.woff2') format('woff2');
}
@font-face {
    font-family: Lato;
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: local('Lato Italic'), local('Lato-Italic'),
         url('/public/assets/fonts/Lato/Lato-Italic.woff2') format('woff2');
}
@font-face {
    font-family: Lato;
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: local('Lato Regular'), local('Lato-Regular'),
         url('/public/assets/fonts/Lato/Lato-Regular.woff2') format('woff2');
}
@font-face {
    font-family: Lato;
    font-style: italic;
    font-weight: 700;
    font-display: swap;
    src: local('Lato Bold Italic'), local('Lato-BoldItalic'),
         url('/public/assets/fonts/Lato/Lato-BoldItalic.woff2') format('woff2');
}
@font-face {
    font-family: Lato;
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: local('Lato Bold'), local('Lato-Bold'),
         url('/public/assets/fonts/Lato/Lato-Bold.woff2') format('woff2');
}

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

/* ----------------------------------------------------------------------------
   Theme tokens — cockpit-dark by default
   ---------------------------------------------------------------------------- */
:root {
    color-scheme: dark;

    /* Brand palette mirrors webapp-front/src/sass/_variables.scss */
    --white: #ffffff;
    --black: #4a4a4a;
    --dark-grey: #585858;
    --grey: #707070;
    --light-grey: #9b9b9b;
    /* Secondary labels — must stay ≥4.5:1 vs --panel / --panel-deep */
    --lighter-grey: #dce3ec;

    --green: #18bc9c;
    --green-soft: #18c8a8; /* webapp-front popup-SUCCESS gradient stop */
    --green-active: #18bc80;
    --blue: #428bca;
    --blue-soft: #52afff; /* webapp-front btn-notifications-gradient stop */
    --dark-blue: #2b3e50;
    /* Dividers / chrome on dark-blue surfaces (not primary body text) */
    --grey-blue: #97a8b8;
    --red: #d64f4f;
    --red-soft: #ef5454; /* webapp-front popup-ERROR gradient stop */
    --orange: #ffa500;
    --orange-soft: #ffc605;
    --yellow: #ffd700;
    --light-black: #1e2029;

    /* Cockpit surface elevations (dark mode) */
    --bg: var(--light-black);
    --bg-elev-1: #232733;          /* between light-black and dark-blue */
    --panel: var(--dark-blue);     /* card / tile / chip background */
    --panel-elev: #34465a;         /* hover */
    --panel-deep: #1b2733;         /* logs, nested surfaces */

    --text: var(--white);
    --text-soft: var(--lighter-grey);
    /* Helper / detail lines on cards — AA vs #2b3e50 and #1b2733 */
    --muted: #cdd5df;

    --line: rgba(255, 255, 255, 0.12);
    --line-strong: rgba(255, 255, 255, 0.24);
    --line-divider: rgba(255, 255, 255, 0.22);

    --good: var(--green);
    --good-strong: var(--green-active);
    --bad: var(--red);
    --working: var(--blue);
    --working-soft: var(--blue-soft);
    --warn: var(--orange);

    /* Typography */
    --font-stack: Lato, "Helvetica Neue", Helvetica, Arial, sans-serif;
    --font-mono: "Roboto Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

    /* Layout — DJI controller landscape */
    --shell-max-w: 1100px;
    --header-h: 56px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-pill: 999px;

    --shadow-card: 0 2px 6px rgba(0, 0, 0, 0.45);
    --shadow-card-hover: 0 4px 12px rgba(0, 0, 0, 0.55);
    --shadow-glow-good: 0 0 0 4px rgba(24, 188, 156, 0.18), 0 0 18px rgba(24, 188, 156, 0.35);
    --shadow-glow-bad: 0 0 0 4px rgba(214, 79, 79, 0.18);
    --shadow-glow-work: 0 0 0 4px rgba(66, 139, 202, 0.22), 0 0 22px rgba(82, 175, 255, 0.3);

    /* Surface tokens that diverge between themes (dark default values). */
    --modal-backdrop: rgba(7, 12, 20, 0.72);
    --header-btn-border: rgba(255, 255, 255, 0.18);
    --header-btn-border-hover: rgba(255, 255, 255, 0.32);
    --header-btn-bg-hover: rgba(255, 255, 255, 0.08);
    --header-btn-bg-active: rgba(255, 255, 255, 0.14);

    --tap-min: 56px;
}

/* ----------------------------------------------------------------------------
   Light theme — same brand palette, inverted surface + text tokens. We keep
   the historic variable names (`--white`, `--lighter-grey`, `--dark-blue`,
   `--light-black`) so the rest of the stylesheet doesn't need to change;
   they're treated semantically (foreground / soft-foreground / panel / page
   background) rather than literally. The theme is selected by the
   inline bootstrap script in dashboard.html based on a localStorage
   preference, falling back to `prefers-color-scheme`.
   ---------------------------------------------------------------------------- */
[data-theme="light"] {
    color-scheme: light;

    --white: #1e2029;            /* primary foreground (was literal white) */
    --lighter-grey: #3d4756;     /* secondary foreground — AA on white panels */
    --light-grey: #5c6570;
    --grey-blue: #5f6c7a;
    --dark-blue: #ffffff;        /* primary panel / tile background */
    --light-black: #f5f7fa;      /* page background */

    --bg: var(--light-black);
    --bg-elev-1: #ffffff;
    --panel: var(--dark-blue);
    --panel-elev: #eef2f6;
    --panel-deep: #f7f9fc;

    --text: var(--white);
    --text-soft: var(--lighter-grey);
    --muted: #5a6572;

    --line: rgba(15, 23, 42, 0.12);
    --line-strong: #cbd5e0;
    --line-divider: #768396;

    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-card-hover: 0 4px 8px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-glow-good: 0 0 0 4px rgba(24, 188, 156, 0.20);
    --shadow-glow-bad: 0 0 0 4px rgba(214, 79, 79, 0.18);
    --shadow-glow-work: 0 0 0 4px rgba(66, 139, 202, 0.22);

    --modal-backdrop: rgba(15, 23, 42, 0.40);
    --header-btn-border: rgba(15, 23, 42, 0.18);
    --header-btn-border-hover: rgba(15, 23, 42, 0.32);
    --header-btn-bg-hover: rgba(15, 23, 42, 0.06);
    --header-btn-bg-active: rgba(15, 23, 42, 0.10);
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.22);
}
[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(15, 23, 42, 0.34);
}

/* ----------------------------------------------------------------------------
   Base
   ---------------------------------------------------------------------------- */
html,
body {
    height: 100%;
}

body {
    min-height: 100vh;
    background: var(--bg);
    /* Subtle radial vignette — adds HUD depth without distraction */
    background-image:
        radial-gradient(ellipse at 50% -10%, rgba(43, 62, 80, 0.55) 0%, transparent 55%),
        radial-gradient(ellipse at 50% 110%, rgba(43, 62, 80, 0.35) 0%, transparent 60%);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font-stack);
    font-weight: 400;
    font-size: 16px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior: contain;
}

button,
select,
input,
textarea {
    font: inherit;
    color: inherit;
}

a {
    color: var(--green);
    text-decoration: none;
    cursor: pointer;
}
a:hover {
    color: var(--green-active);
    text-decoration: underline;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.30);
}

/* ----------------------------------------------------------------------------
   Cockpit header (mirrors cockpit-header.component.scss)
   ---------------------------------------------------------------------------- */
.app-shell {
    width: 100%;
    max-width: var(--shell-max-w);
    margin: 0 auto;
    padding: 0 16px 24px;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    margin: 0 -16px 18px;
    padding: 0 20px;
    height: var(--header-h);
    background: var(--dark-blue);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    /* HUD accent strip under the header (blue gradient like
       cockpit-mission-control .btn-lang-border) */
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.app-header::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--blue) 25%,
        var(--blue-soft) 50%,
        var(--blue) 75%,
        transparent 100%
    );
    opacity: 0.55;
    pointer-events: none;
}

.brand-block {
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-logo {
    width: 132px;
    max-width: 32vw;
    height: auto;
    object-fit: contain;
    cursor: pointer;
    user-select: none;
    /* Two PNGs (white wordmark + dark wordmark) shipped from
       webapp-front's UAVIA brand pack. The HTML <img src> defaults to
       the white version (matches the default `data-theme="dark"` set
       by the bootstrap script in <head>). The `[data-theme="light"]`
       override below swaps in the dark-text logo on light backgrounds
       via `content: url(...)`, which the spec lets us use to override
       the rendered image without touching the DOM. */
    transition: opacity 0.15s ease, transform 0.15s ease;
}
[data-theme="light"] .brand-logo {
    content: url("/public/assets/uavia-logo.png");
}
.brand-logo:active {
    opacity: 0.7;
    transform: scale(0.97);
}

/* Always-visible reset-cache control in the header. Compact icon-only
   button anchored to the right; clears WebView storage and reloads. Sits
   on top of the centered brand logo without disturbing its layout. */
.header-icon-btn {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--header-btn-border);
    background: transparent;
    color: var(--white);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.15s ease,
        border-color 0.15s ease;
}
.header-icon-btn:hover:not(:disabled) {
    background: var(--header-btn-bg-hover);
    border-color: var(--header-btn-border-hover);
}
.header-icon-btn:active:not(:disabled) {
    transform: translateY(calc(-50% + 1px));
    background: var(--header-btn-bg-active);
}

/* The theme toggle is anchored to the LEFT edge of the header (the
   reset-cache button stays anchored right). This deliberately mirrors
   the layout — actions live on opposite sides so they never overlap or
   visually compete. The brand logo is centered between them. */
.header-icon-btn--theme {
    right: auto;
    left: 16px;
}
@media (max-width: 480px) {
    .header-icon-btn--theme {
        left: 10px;
    }
}

/* Site switcher — left-anchored pill (next to the theme toggle) showing
   the active site; tapping it opens the OTP / site-picker page where the
   operator can switch, pair a new site, or unpair one. Text truncates so
   it never collides with the centered brand logo. */
.site-switcher {
    position: absolute;
    left: 60px;
    top: 50%;
    transform: translateY(-50%);
    height: 36px;
    max-width: 160px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--header-btn-border);
    background: transparent;
    color: var(--white);
    font-family: var(--font-stack);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.site-switcher:hover {
    background: var(--header-btn-bg-hover);
    border-color: var(--header-btn-border-hover);
}
.site-switcher svg {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
}
.site-switcher-label {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Expired / re-pair-required state — the cookie is gone or expired, so the
   switcher turns into a clear call to action (tap to re-pair). */
.site-switcher--expired {
    border-color: var(--bad);
    color: var(--bad);
    background: color-mix(in srgb, var(--bad) 14%, transparent);
    animation: site-switcher-pulse 1.8s ease-in-out infinite;
}
.site-switcher--expired:hover {
    background: color-mix(in srgb, var(--bad) 22%, transparent);
    border-color: var(--bad);
}
@keyframes site-switcher-pulse {
    0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 45%, transparent); }
    50% { box-shadow: 0 0 0 4px transparent; }
}
@media (prefers-reduced-motion: reduce) {
    .site-switcher--expired { animation: none; }
}
@media (max-width: 480px) {
    .site-switcher {
        left: 46px;
        max-width: 110px;
        padding: 0 10px;
    }
}

/* Show the icon that represents the *target* theme — i.e. on dark we
   show a sun (click to go light), on light we show a moon (click to
   go dark). */
[data-theme="dark"] .theme-icon-moon { display: none; }
[data-theme="light"] .theme-icon-sun { display: none; }
.header-icon-btn:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}
.header-icon-btn svg {
    width: 18px;
    height: 18px;
}
.header-icon-btn.is-resetting svg {
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Language switcher (EN | FR) — header pill anchored just left of the
   right-side icon button, matching the OTP/site page banner. */
.header-actions {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: calc(50% - 80px);
}
.header-actions .header-icon-btn {
    position: static;
    transform: none;
    flex: 0 0 auto;
}
.header-actions .header-icon-btn:active:not(:disabled) {
    transform: translateY(1px);
}
.header-actions .lang-switcher {
    position: static;
    transform: none;
    flex: 0 0 auto;
}
.lang-switcher {
    position: absolute;
    right: 60px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    gap: 2px;
    padding: 2px;
    border: 1px solid var(--header-btn-border);
    border-radius: var(--radius-pill);
    background: transparent;
}
.lang-btn {
    min-width: 30px;
    padding: 4px 9px;
    border: none;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--white);
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.lang-btn:hover:not(.is-active) { background: var(--header-btn-bg-hover); }
.lang-btn.is-active {
    background: var(--blue);
    color: #fff;
}

.dashboard-main {
    display: grid;
    gap: 16px;
}

/* ----------------------------------------------------------------------------
   Build-identity footer — populated from /api/version. Stays a single
   muted line so it doesn't compete with the operational tiles for
   attention; on the cockpit (RC Pro / Smart Controller) breakpoint we
   shrink it further so the four tiles + identity strip + collapsed
   device IDs still fit on the 720x405 CSS-pixel viewport.
   ---------------------------------------------------------------------------- */
.app-footer {
    margin: 12px auto 0;
    padding: 6px 12px 10px;
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: 1280px;
}
.app-version {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-soft);
    opacity: 0.75;
    letter-spacing: 0.02em;
    text-align: center;
    user-select: text;
    /* Pre-format the dot separators with surrounding hair-spaces so a
       narrow footer wraps on the dot rather than mid-token. */
    word-break: break-word;
}
.app-version:empty {
    /* Hide the empty span before /api/version resolves so the
       footer doesn't reserve a blank line on first paint. */
    display: none;
}
.app-version a {
    /* Allow the commit hash to act as a GitHub link when the
       backend stamps the URL on it. */
    color: inherit;
    text-decoration: underline;
    text-decoration-color: rgba(150, 200, 255, 0.45);
    text-underline-offset: 2px;
}
.app-version a:hover {
    opacity: 1;
}
@media (max-width: 820px) {
    .app-footer {
        margin-top: 4px;
        padding: 2px 8px 6px;
    }
    .app-version {
        font-size: 0.6rem;
        opacity: 0.7;
    }
}

/* ----------------------------------------------------------------------------
   Sync-flash keyframes
   Ported from `webapp-front/src/sass/_ui-sync-animations.scss`.
   Adapted for dark cockpit baseline (white border instead of fading-from-white).
   ---------------------------------------------------------------------------- */
@keyframes flash-success-border {
    0%,
    100% {
        border-color: var(--good);
        box-shadow: var(--shadow-glow-good);
    }
    50% {
        border-color: var(--green-soft);
        box-shadow: 0 0 0 8px rgba(24, 188, 156, 0.25), 0 0 28px rgba(24, 188, 156, 0.55);
    }
}

@keyframes flash-error-border {
    0%,
    100% {
        border-color: var(--bad);
        box-shadow: var(--shadow-glow-bad);
    }
    50% {
        border-color: var(--red-soft);
        box-shadow: 0 0 0 8px rgba(214, 79, 79, 0.30);
    }
}

@keyframes flash-success-text {
    0%,
    100% {
        color: var(--white);
    }
    50% {
        color: var(--good);
    }
}

/* Radar sweep — used on the working ring (mirrors
   cockpit-mission-control gradient stops on $blue/$blue-soft). */
@keyframes radar-sweep {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Ripple — ported from `webapp-front/src/sass/global-map.scss` */
@keyframes ripple {
    0% {
        box-shadow: 0 0 0 0 rgba(82, 175, 255, 0.55);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(82, 175, 255, 0.15);
    }
    100% {
        box-shadow: 0 0 0 18px rgba(82, 175, 255, 0);
    }
}

/* ----------------------------------------------------------------------------
   Status panel + tiles
   ---------------------------------------------------------------------------- */
.status-panel {
    background: transparent;
    padding: 0;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    padding: 4px;
}

/* LiveShare diagnostics — visible only with debug panel (10× header tap or ?debug=1). */
.liveshare-diagnostics.liveshare-diagnostics--debug-only {
    display: none;
}
body.debug-mode .liveshare-diagnostics.liveshare-diagnostics--debug-only {
    display: block;
}

/* LiveShare diagnostics — red / green / gray checklist (DJI Pilot troubleshooting) */
.liveshare-diagnostics {
    margin-top: 14px;
    padding: 14px 16px 16px;
    background: var(--panel);
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    box-shadow: var(--shadow-card);
}

.liveshare-diagnostics-title {
    font-family: Lato, system-ui, sans-serif;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--grey-blue);
    margin: 0 0 12px;
}

.liveshare-diagnostics-intro {
    font-family: Lato, system-ui, sans-serif;
    font-size: 12px;
    font-weight: 400;
    color: var(--lighter-grey);
    line-height: 1.45;
    margin: 0 0 14px;
    opacity: 0.95;
}

.liveshare-diag-table {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.liveshare-diag-row {
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
}

.liveshare-diag-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 5px;
    flex-shrink: 0;
}

.liveshare-diag-dot--ok {
    background: var(--good);
    box-shadow: 0 0 8px rgba(24, 188, 156, 0.42);
}

.liveshare-diag-dot--bad {
    background: var(--bad);
    box-shadow: 0 0 8px rgba(214, 79, 79, 0.45);
}

.liveshare-diag-dot--unknown {
    background: var(--grey);
    opacity: 0.85;
}

.liveshare-diag-label-wrap {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.liveshare-diag-label {
    font-family: Lato, system-ui, sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.25;
}

.liveshare-diag-hint {
    font-family: Lato, system-ui, sans-serif;
    font-size: 11px;
    font-weight: 400;
    color: var(--lighter-grey);
    line-height: 1.35;
    opacity: 0.92;
}

.status-tile {
    position: relative;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--line-strong);
    border-radius: 10px; /* mirrors cockpit `name-robot` / `flight-auth-container` */
    padding: 22px 16px 18px;
    min-height: 248px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
    cursor: default;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition:
        background-color 0.18s ease,
        border-color 0.25s ease,
        transform 0.12s ease,
        box-shadow 0.25s ease;
}

/* Only <button> tiles (Video) are interactive. Cloud + Telemetry are
   pure status indicators rendered as <div role="status"> and must not
   look pressable. */
button.status-tile {
    cursor: pointer;
}

/* HUD corner brackets — purely decorative cockpit detail */
.status-tile::before,
.status-tile::after {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    border-color: rgba(255, 255, 255, 0.18);
    border-style: solid;
    pointer-events: none;
    transition: border-color 0.25s ease;
}
.status-tile::before {
    top: 8px;
    left: 8px;
    border-width: 1px 0 0 1px;
}
.status-tile::after {
    bottom: 8px;
    right: 8px;
    border-width: 0 1px 1px 0;
}

button.status-tile:hover {
    background: var(--panel-elev);
    box-shadow: var(--shadow-card-hover);
}
button.status-tile:active {
    transform: scale(0.985);
}
button.status-tile:focus-visible {
    outline: 2px solid var(--blue-soft);
    outline-offset: 2px;
}

/* ---- Connected state — green glow + sync-flash on entry ---- */
.status-tile.status-connected {
    border-color: var(--good);
    box-shadow: var(--shadow-glow-good);
    animation: flash-success-border 1s ease-in-out 1;
}
.status-tile.status-connected::before,
.status-tile.status-connected::after {
    border-color: var(--good);
}

/* ---- Disconnected state — red ring (no flash on initial load) ---- */
.status-tile.status-disconnected {
    border-color: var(--bad);
    box-shadow: var(--shadow-glow-bad);
}
.status-tile.status-disconnected::before,
.status-tile.status-disconnected::after {
    border-color: rgba(214, 79, 79, 0.55);
}

/* ---- Loading state — blue working glow ---- */
.status-tile.status-loading {
    border-color: var(--working);
    box-shadow: var(--shadow-glow-work);
}
.status-tile.status-loading::before,
.status-tile.status-loading::after {
    border-color: var(--working-soft);
}

/* Connection ring */
.status-ring {
    position: relative;
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--bad);
    border: 4px solid var(--bad);
    transition:
        border-color 0.25s ease,
        color 0.25s ease,
        background-color 0.25s ease,
        box-shadow 0.25s ease;
}

.status-ring svg {
    width: 42px;
    height: 42px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 6px currentColor);
    opacity: 0.9;
}

.status-connected .status-ring {
    border-color: var(--good);
    color: var(--good);
    background: rgba(24, 188, 156, 0.10);
    box-shadow: 0 0 0 3px rgba(24, 188, 156, 0.18), 0 0 16px rgba(24, 188, 156, 0.45);
}

.status-disconnected .status-ring {
    border-color: var(--bad);
    color: var(--bad);
    background: rgba(214, 79, 79, 0.06);
}

.status-loading .status-ring {
    border-color: var(--working);
    color: var(--working);
    background: rgba(66, 139, 202, 0.10);
    animation: ripple 1.6s ease-out infinite;
}

/* Loading radar-sweep — conic gradient overlay on the ring */
.status-loading .status-ring::after {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: conic-gradient(
        from 0deg,
        transparent 0deg,
        rgba(82, 175, 255, 0.0) 200deg,
        rgba(82, 175, 255, 0.55) 320deg,
        transparent 360deg
    );
    -webkit-mask: radial-gradient(circle, transparent 30px, #000 31px, #000 calc(50% - 1px), transparent calc(50% + 1px));
            mask: radial-gradient(circle, transparent 30px, #000 31px, #000 calc(50% - 1px), transparent calc(50% + 1px));
    animation: radar-sweep 2.2s linear infinite;
    pointer-events: none;
}

/* Crisp spinner overlay — sits just outside the ring border and rotates a
   bright top-arc, so the user immediately reads the tile as "working".
   Hidden in connected/disconnected states. */
.status-spinner {
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: var(--working);
    border-right-color: rgba(82, 175, 255, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}
.status-loading .status-spinner {
    opacity: 1;
    animation: spin 0.85s linear infinite;
}

/* Block re-clicks (and the hover lift) while the Video tile is mid-action.
   Cloud + Telemetry are non-interactive divs anyway, so this only affects
   the Video <button> tile. */
.status-tile.status-loading {
    pointer-events: none;
}

.status-name {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--white);
}

.status-text {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-soft);
}

.status-connected .status-text {
    color: var(--good);
}
.status-loading .status-text {
    color: var(--working-soft);
}
.status-disconnected .status-text {
    color: var(--bad);
}

.status-detail {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.35;
    font-weight: 300;
    letter-spacing: 0.02em;
}

/* SSL pill — mirrors cockpit `btn-notifications-SUCCESS` chip */
.ssl-connection-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--white);
    background: linear-gradient(180deg, var(--green-soft) 0%, var(--green-active) 100%);
    padding: 2px 7px;
    border-radius: var(--radius-pill);
    line-height: 1.2;
    box-shadow: 0 0 8px rgba(24, 188, 156, 0.45);
    z-index: 1;
}

/* ----------------------------------------------------------------------------
   Identity strip — populated from /api/auth's `operation` block
   (organization → site → robot). Only visible once Entities returns the
   names; older Entities builds keep the strip hidden via `[hidden]`.
   ---------------------------------------------------------------------------- */
.identity-strip {
    display: flex;
    align-items: stretch;
    flex-wrap: wrap;
    gap: 4px 12px;
    padding: 10px 14px;
    margin-bottom: 12px;
    background: var(--panel);
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    box-shadow: var(--shadow-card);
}
.identity-strip[hidden] {
    display: none;
}
.identity-segment {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 0;
}
.identity-label {
    font-size: 0.65rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--lighter-grey);
    font-weight: 700;
}
.identity-value {
    color: var(--white);
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.identity-divider {
    color: var(--grey-blue);
    font-weight: 700;
    align-self: center;
    user-select: none;
}
@media (max-width: 480px) {
    .identity-divider { display: none; }
    .identity-strip { gap: 6px 0; }
}

/* ----------------------------------------------------------------------------
   Device details — chip rows (mirrors cockpit `name-robot` / `mission-time`
   pill styles in cockpit-mission-control.component.scss)
   ---------------------------------------------------------------------------- */
.device-details {
    margin-top: 16px;
    padding: 14px 16px;
    background: var(--panel);
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    box-shadow: var(--shadow-card);
}

.device-details summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--white);
    font-size: 0.85rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    padding: 2px 0;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
}
.device-details summary::-webkit-details-marker {
    display: none;
}
.device-details summary::before {
    content: "";
    width: 0;
    height: 0;
    border-left: 6px solid var(--blue-soft);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    transition: transform 0.18s ease;
}
.device-details[open] summary::before {
    transform: rotate(90deg);
}

.detail-grid {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    font-size: 0.85rem;
}

/* DRC mode toggle — paired RC (drc_mode_enter / exit via POST /api/drc/mode) */
.drc-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 10px 0 0;
    padding: 12px 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--panel-deep);
}
.drc-control--header {
    margin: 0;
    padding: 0 10px;
    height: 36px;
    gap: 8px;
    border: 1px solid var(--header-btn-border);
    border-radius: var(--radius-pill);
    background: transparent;
    flex: 0 1 auto;
    min-width: 0;
}
.drc-control--header:hover {
    background: var(--header-btn-bg-hover);
    border-color: var(--header-btn-border-hover);
}
.drc-control--header .drc-control-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--white);
    white-space: nowrap;
}
.drc-control--header .toggle-switch {
    width: 44px;
    height: 24px;
}
.drc-control--header .toggle-switch-track::after {
    width: 18px;
    height: 18px;
    top: 3px;
    left: 3px;
}
.drc-control--header .toggle-switch input:checked + .toggle-switch-track::after {
    transform: translateX(20px);
}
.drc-control[hidden] { display: none; }
.drc-control-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
}
.drc-control-label {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text);
}
.drc-control-hint {
    font-size: 0.76rem;
    line-height: 1.35;
    color: var(--text-soft);
}
.toggle-switch {
    position: relative;
    flex: 0 0 auto;
    width: 52px;
    height: 32px;
    cursor: pointer;
}
.toggle-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-switch-track {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: var(--radius-pill);
    background: var(--line-strong);
    transition: background 0.2s ease;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.18);
}
.toggle-switch-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--white);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
    transition: transform 0.2s ease;
}
.toggle-switch input:checked + .toggle-switch-track {
    background: var(--good);
}
.toggle-switch input:checked + .toggle-switch-track::after {
    transform: translateX(20px);
}
.toggle-switch input:disabled + .toggle-switch-track {
    opacity: 0.45;
    cursor: not-allowed;
}
.toggle-switch input:focus-visible + .toggle-switch-track {
    box-shadow: var(--shadow-glow-work);
}

.detail-label {
    font-weight: 700;
    color: var(--lighter-grey);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.72rem;
}

.detail-value {
    color: var(--white);
    word-break: break-all;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.82rem;
}

.detail-value.error {
    color: var(--bad);
}
.detail-value.loading {
    color: var(--warn);
    /* Loading shimmer */
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 0%,
        rgba(255, 165, 0, 0.18) 50%,
        rgba(255, 255, 255, 0.05) 100%
    );
    background-size: 200% 100%;
    animation: detail-shimmer 1.6s ease-in-out infinite;
    padding: 0 6px;
    border-radius: var(--radius-sm);
}

@keyframes detail-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Pairing pill — sits in the device-details summary row and reflects the
   aircraft↔RC link state without having to expand the panel. */
.device-summary-label {
    flex: 1;
}
.pairing-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--line-strong);
    background: rgba(0, 0, 0, 0.25);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-soft);
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.pairing-pill-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--muted);
    box-shadow: 0 0 0 0 transparent;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}
.pairing-pill--linked {
    color: var(--good);
    border-color: rgba(24, 188, 156, 0.55);
    background: rgba(24, 188, 156, 0.10);
}
.pairing-pill--linked .pairing-pill-dot {
    background: var(--good);
    box-shadow: 0 0 6px rgba(24, 188, 156, 0.8);
}
.pairing-pill--unpaired {
    color: var(--bad);
    border-color: rgba(214, 79, 79, 0.55);
    background: rgba(214, 79, 79, 0.10);
}
.pairing-pill--unpaired .pairing-pill-dot {
    background: var(--bad);
    box-shadow: 0 0 6px rgba(214, 79, 79, 0.7);
}
.pairing-pill--unknown {
    color: var(--muted);
}

/* ----------------------------------------------------------------------------
   Drone-state strip — live OSD pills (battery, GPS, mode, altitude, link).
   Fed by GET /api/telemetry/stream (SSE). Hidden until the first OSD frame
   arrives so we don't show a row of "—" placeholders to a pilot whose drone
   is powered off.
   ---------------------------------------------------------------------------- */
.drone-state-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin-top: 12px;
}
.drone-state-strip[hidden] {
    display: none !important;
}

.drone-state-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--panel);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-card);
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease, transform 0.1s ease;
    min-width: 0;
    /* Pills are <button>s now (clickable to open the telemetry detail
       modal); reset the platform default button chrome and font to keep
       parity with the previous <div> styling. */
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}
.drone-state-pill:hover {
    background: var(--panel-elev);
    border-color: var(--blue-soft);
}
.drone-state-pill:active {
    transform: scale(0.985);
}
.drone-state-pill:focus-visible {
    outline: 2px solid var(--blue-soft);
    outline-offset: 2px;
}

.drone-state-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    color: var(--text-soft);
    flex: 0 0 auto;
}
.drone-state-icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.drone-state-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--lighter-grey);
    flex: 0 0 auto;
}
.drone-state-value {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--white);
    margin-left: auto;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Battery: SVG fill width set inline by JS (0–100 → 0–13). Color-code via
   modifier classes set on the parent pill. */
.drone-state-pill--battery .drone-state-battery-fill {
    fill: currentColor;
    transform-origin: left center;
    transition: width 0.4s ease;
}
.drone-state-pill--battery .drone-state-icon {
    color: var(--good);
}
.drone-state-pill--battery.is-warn .drone-state-icon {
    color: var(--warn);
}
.drone-state-pill--battery.is-warn {
    border-color: rgba(255, 165, 0, 0.55);
}
.drone-state-pill--battery.is-bad .drone-state-icon {
    color: var(--bad);
}
.drone-state-pill--battery.is-bad {
    border-color: rgba(214, 79, 79, 0.55);
    background: rgba(214, 79, 79, 0.08);
}

/* GPS: green when RTK fixed, blue when GNSS-only with enough sats, red <5 sats. */
.drone-state-pill--gps.is-fixed .drone-state-icon {
    color: var(--good);
}
.drone-state-pill--gps.is-fixed {
    border-color: rgba(24, 188, 156, 0.55);
}
.drone-state-pill--gps.is-poor .drone-state-icon {
    color: var(--bad);
}
.drone-state-pill--gps.is-poor {
    border-color: rgba(214, 79, 79, 0.55);
}

/* Link: bars are decorative (icon stays the same); colour reflects worst
   of dl/up quality. DJI link quality is 0..5 in newer firmware. */
.drone-state-pill--link.is-warn .drone-state-icon { color: var(--warn); }
.drone-state-pill--link.is-warn { border-color: rgba(255, 165, 0, 0.55); }
.drone-state-pill--link.is-bad .drone-state-icon { color: var(--bad); }
.drone-state-pill--link.is-bad { border-color: rgba(214, 79, 79, 0.55); }

/* ----------------------------------------------------------------------------
   Debug panel + console (10×-tap anywhere on the app header unhides — the
   tap counter is wired in ui.js and persists the resulting on/off bit in
   localStorage so reloads keep the chosen mode)
   ---------------------------------------------------------------------------- */
.debug-panel {
    display: grid;
    gap: 12px;
}
.debug-panel[hidden] {
    display: none !important;
}

/* Thing + OSD livestream pills — below Device IDs; visible only in debug mode. */
.osd-bridge-strip.osd-bridge-strip--debug-only {
    display: none;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
}
body.debug-mode .osd-bridge-strip.osd-bridge-strip--debug-only {
    display: flex;
}

.debug-connection-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.debug-conn-pill {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border: 1px solid var(--line);
    background: var(--panel-deep);
    color: var(--muted);
}

.debug-conn-pill--on {
    border-color: rgba(74, 222, 128, 0.45);
    background: rgba(74, 222, 128, 0.12);
    color: #b6f7c8;
}

.debug-conn-pill--off {
    border-color: rgba(248, 113, 113, 0.4);
    background: rgba(248, 113, 113, 0.1);
    color: #fecaca;
}

.debug-conn-pill--na {
    border-color: var(--line);
    color: var(--muted);
}

.debug-card {
    background: var(--panel-deep);
    color: var(--white);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow-card);
    padding: 16px;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.section-heading h2 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--white);
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

/* ----------------------------------------------------------------------------
   Buttons — Material-ish, cockpit-flavoured
   Mirrors webapp-front .mat-mdc-raised-button.btn-* helpers.
   ---------------------------------------------------------------------------- */
.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.btn {
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, 0.04);
    color: var(--white);
    padding: 10px 16px;
    min-height: 40px;
    min-width: 100px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-size: 0.78rem;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.12s ease;
}
.btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.10);
    border-color: var(--white);
}
.btn:active:not(:disabled) {
    transform: scale(0.97);
}
.btn:focus-visible {
    outline: 2px solid var(--blue-soft);
    outline-offset: 2px;
}
.btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

/* Primary — green gradient (mirrors btn-notifications-gradient pattern) */
.btn-primary {
    background: linear-gradient(180deg, var(--green-soft) 0%, var(--green-active) 100%);
    border-color: var(--green-active);
    color: var(--white);
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(24, 188, 156, 0.35);
}
.btn-primary:hover:not(:disabled) {
    background: linear-gradient(180deg, var(--green) 0%, var(--green-active) 100%);
    border-color: var(--green);
    box-shadow: 0 2px 14px rgba(24, 188, 156, 0.55);
}

.btn-secondary {
    background: transparent;
    border-color: var(--grey-blue);
    color: var(--white);
}
.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--white);
    color: var(--white);
}

.btn-danger {
    background: transparent;
    border-color: var(--bad);
    color: var(--bad);
    font-weight: 700;
}
.btn-danger:hover:not(:disabled) {
    background: linear-gradient(180deg, var(--red-soft) 0%, var(--bad) 100%);
    color: var(--white);
}

/* ----------------------------------------------------------------------------
   Logs
   ---------------------------------------------------------------------------- */
.logs {
    min-height: 200px;
    max-height: 380px;
    overflow: auto;
    background: #050608;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.55;
    color: #ecf0f1;
}

.log-entry {
    margin-bottom: 6px;
    padding: 4px 8px 4px 10px;
    border-left: 3px solid var(--grey);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.log-timestamp {
    color: var(--lighter-grey);
    font-weight: 700;
}

.log-message {
    margin-left: 8px;
}

.log-success {
    border-left-color: var(--good);
}
.log-error {
    border-left-color: var(--bad);
}
.log-info,
.log-debug {
    border-left-color: var(--working);
}
.log-warning {
    border-left-color: var(--warn);
}

/* ----------------------------------------------------------------------------
   Live Events panel — one expandable row per upstream channel (MQTT OSD,
   MQTT livestream control, Kafka stream.video.live.event,
   Kafka mission.live.event). Only renders inside #debug-panel which is
   itself gated behind the 10-tap header gesture, so the JSON contents are
   never exposed in normal operator mode.
   ---------------------------------------------------------------------------- */
.debug-events {
    display: grid;
    gap: 8px;
}
.debug-events-empty {
    font-size: 0.85rem;
    color: var(--muted);
    font-style: italic;
    padding: 10px 4px;
    text-align: center;
}
.debug-event {
    background: #050608;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.debug-event[open] {
    border-color: var(--blue-soft);
}
.debug-event > summary {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--white);
    list-style: none;
    user-select: none;
    background: rgba(255, 255, 255, 0.02);
    transition: background 0.15s ease;
}
.debug-event > summary:hover {
    background: rgba(255, 255, 255, 0.05);
}
.debug-event > summary::-webkit-details-marker {
    display: none;
}
.debug-event > summary::before {
    content: "";
    width: 0;
    height: 0;
    border-left: 5px solid var(--blue-soft);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    transition: transform 0.18s ease;
    flex: 0 0 auto;
}
.debug-event[open] > summary::before {
    transform: rotate(90deg);
}
.debug-event-source {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    color: var(--white);
    flex: 0 0 auto;
}
.debug-event-source--kafka {
    background: linear-gradient(180deg, var(--blue-soft) 0%, var(--blue) 100%);
}
.debug-event-source--mqtt {
    background: linear-gradient(180deg, var(--green-soft) 0%, var(--green-active) 100%);
}
.debug-event-channel {
    font-size: 0.82rem;
    color: var(--white);
    font-weight: 600;
    letter-spacing: 0.01em;
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.debug-event-topic {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-soft);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line);
    padding: 1px 8px;
    border-radius: var(--radius-pill);
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    user-select: text;
    cursor: text;
}
.debug-event-meta {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--muted);
    flex: 0 0 auto;
    /* Push the timestamp to the right edge of the summary row so it
       reads as a separate metadata column rather than getting jammed
       against the topic chip. */
    margin-left: auto;
}
.debug-event-status {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-soft);
    flex: 0 0 auto;
    letter-spacing: 0.04em;
}
.debug-event-json {
    margin: 0;
    padding: 10px 12px;
    background: #050608;
    border-top: 1px solid var(--line);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1.5;
    color: #ecf0f1;
    overflow-x: auto;
    max-height: 320px;
    overflow-y: auto;
    white-space: pre;
}

/* ----------------------------------------------------------------------------
   Alerts — cockpit notification banner gradient
   (mirrors `.popup-ERROR` in cockpit-notifications.component.scss)
   ---------------------------------------------------------------------------- */
.alert {
    border-radius: var(--radius-sm);
    border: 0;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--white);
    display: flex;
    gap: 8px;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.alert-error {
    background: linear-gradient(90deg, var(--red-soft), var(--bad));
}
.alert-error strong {
    color: var(--white);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    margin-right: 4px;
}

.alert-warning {
    background: linear-gradient(90deg, var(--orange-soft), var(--orange));
}

/* ----------------------------------------------------------------------------
   Responsive — DJI controllers
   ---------------------------------------------------------------------------- */

/* Smart Controller and DJI RC Pro Enterprise (5.5" 1920×1080,
   DPR ≈ 2.6 → ≈ 720×405 CSS px).
   The cockpit controllers have very little vertical real estate
   (~405 CSS px in landscape) so the centered, square-tile layout used
   on desktop won't fit the header + 4 tiles + device-IDs summary on
   one screen. We switch the tiles to a horizontal layout — ring on
   the left, name/status/detail stacked on the right — and tighten
   header / strip / details paddings so the full cold-start chrome
   (header → tiles → device-IDs collapsed) sits inside one viewport
   without scrolling. */
@media (max-width: 820px) {
    .app-shell {
        padding: 0 10px 8px;
    }
    .app-header {
        margin: 0 -10px 8px;
        padding: 0 14px;
        height: 40px;
    }
    .brand-logo {
        width: 92px;
    }
    .header-icon-btn {
        right: 8px;
        width: 28px;
        height: 28px;
    }
    .header-icon-btn--theme {
        left: 8px;
    }
    .header-icon-btn svg {
        width: 14px;
        height: 14px;
    }
    .header-actions {
        right: 8px;
        gap: 4px;
        max-width: calc(50% - 56px);
    }
    .drc-control--header {
        padding: 0 6px;
        height: 28px;
        gap: 4px;
    }
    .drc-control--header .drc-control-label {
        font-size: 0.62rem;
    }
    .drc-control--header .toggle-switch {
        width: 36px;
        height: 20px;
    }
    .drc-control--header .toggle-switch-track::after {
        width: 14px;
        height: 14px;
        top: 3px;
        left: 3px;
    }
    .drc-control--header .toggle-switch input:checked + .toggle-switch-track::after {
        transform: translateX(16px);
    }
    .lang-btn {
        min-width: 26px;
        padding: 3px 7px;
    }
    .dashboard-main {
        /* Default desktop gap of 16px adds 32px between identity
           strip / tiles / drone-pills — way too much when only
           405 CSS px tall. */
        gap: 6px;
    }

    /* Identity strip: drop to a single compact line. The labels are
       already redundant with the values most of the time, so we
       hide them on narrow screens and let just the org / site /
       robot names breathe horizontally. */
    .identity-strip {
        padding: 4px 10px;
        margin-bottom: 0;
        gap: 2px 10px;
    }
    .identity-label {
        font-size: 0.55rem;
    }
    .identity-value {
        font-size: 0.78rem;
    }

    .status-grid {
        /* 2×2 on narrow controllers; tiles slightly taller than before for readability. */
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        padding: 6px;
    }
    .status-tile {
        /* Override desktop's centered flex column with a 2-column grid:
           ring on the left, name / status / detail stacked on the
           right. */
        display: grid;
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto auto;
        column-gap: 12px;
        row-gap: 1px;
        align-items: center;
        justify-items: start;
        text-align: left;
        min-height: 102px;
        padding: 10px 12px 10px 14px;
    }
    .status-tile::before {
        top: 4px;
        left: 4px;
    }
    .status-tile::after {
        bottom: 4px;
        right: 4px;
    }
    .status-ring {
        grid-row: 1 / span 3;
        align-self: center;
        width: 58px;
        height: 58px;
        border-width: 3px;
    }
    .status-ring svg {
        width: 26px;
        height: 26px;
    }
    .status-name {
        font-size: 0.7rem;
        letter-spacing: 0.10em;
    }
    .status-text {
        font-size: 0.78rem;
    }
    .status-detail {
        font-size: 0.65rem;
        line-height: 1.25;
        /* Long detail lines (e.g. "Manual mission · last event ended ·
           5da82504…") would otherwise wrap to 3+ lines and force the
           tile to grow taller than ~102px. Cap at one line with an
           ellipsis — the full detail is still visible in the
           telemetry / debug panels. */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    .ssl-connection-indicator {
        top: 4px;
        right: 4px;
        font-size: 0.55rem;
        padding: 1px 5px;
    }

    /* Drone-state strip: fewer pills per row would wrap and balloon
       vertically, so tighten the pill itself and let the auto-fit
       grid keep all five visible on one row. */
    .drone-state-strip {
        grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
        gap: 4px;
        margin-top: 4px;
    }
    .drone-state-pill {
        padding: 4px 8px;
        gap: 6px;
    }
    .drone-state-icon {
        width: 16px;
        height: 16px;
    }
    .drone-state-icon svg {
        width: 14px;
        height: 14px;
    }
    .drone-state-label {
        font-size: 0.55rem;
        letter-spacing: 0.10em;
    }
    .drone-state-value {
        font-size: 0.72rem;
    }

    .device-details {
        /* Keep the bottom gap (grid → device-IDs strip) equal to the top
           gap (identity strip → grid): both are just the `.dashboard-main`
           grid gap plus `.status-grid` padding. No extra margin here, or
           the bottom reads heavier than the top. */
        margin-top: 0;
        padding: 6px 12px;
    }
    .device-details summary {
        font-size: 0.7rem;
        letter-spacing: 0.12em;
    }
    .device-details[open] {
        /* Once expanded, the detail rows still need breathing room.
           The collapsed summary is intentionally tiny but expanding
           is an opt-in operator action so it's OK to overflow into
           the page-level scroll then. */
        padding: 8px 12px;
    }
    .detail-grid {
        gap: 4px;
        margin-top: 8px;
    }
    .detail-row {
        padding: 4px 10px;
        font-size: 0.78rem;
    }
    .detail-label {
        font-size: 0.65rem;
    }
    .detail-value {
        font-size: 0.75rem;
    }
    .pairing-pill {
        padding: 2px 8px;
        font-size: 0.6rem;
    }
}

/* Portrait fallback (uncommon on the controller). Inherits the
   ring-on-left grid layout from the 820px rule above; just stacks
   the four tiles vertically and gives the text rows a touch more
   breathing room since vertical space is no longer scarce. */
@media (max-width: 600px) and (orientation: portrait) {
    .status-grid {
        grid-template-columns: 1fr;
    }
    .status-tile {
        min-height: 118px;
        column-gap: 14px;
        row-gap: 2px;
        padding: 14px 16px;
    }
    .btn {
        width: 100%;
    }
    .detail-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        border-radius: var(--radius-sm);
    }
    .detail-value {
        text-align: left;
    }
}

/* RC Pro 2 (7.02" 1920×1200, DPR ≈ 2 → ≈ 960×600 CSS px) */
@media (min-width: 821px) and (max-width: 1100px) {
    .status-tile {
        min-height: 268px;
    }
    .status-ring {
        width: 96px;
        height: 96px;
    }
    .status-ring svg {
        width: 46px;
        height: 46px;
    }
}

/* Larger monitors (debug / service laptop) */
@media (min-width: 1101px) {
    .app-shell {
        padding: 0 24px 32px;
    }
    .status-tile {
        min-height: 288px;
        padding: 26px 20px 22px;
    }
    .status-ring {
        width: 108px;
        height: 108px;
        border-width: 5px;
    }
    .status-ring svg {
        width: 50px;
        height: 50px;
    }
    .status-name {
        font-size: 1.05rem;
    }
}

/* Reduced motion preference — strip the radar/ripple/flash */
@media (prefers-reduced-motion: reduce) {
    .status-loading .status-ring,
    .status-loading .status-ring::after,
    .status-loading .status-spinner,
    .status-tile.status-connected,
    .detail-value.loading {
        animation: none !important;
    }
    .status-tile,
    .status-ring,
    .status-spinner,
    .btn,
    .brand-logo {
        transition: none !important;
    }
}

/* ----------------------------------------------------------------------------
   Video tile — playable state. The Video tile is a <button> rendered as
   `disabled` until `_handleVideoLiveEvent` sees STARTED + WHEP path + at
   least one bearer (Kafka `token` or dashboard JWT from /api/auth); ui.js
   toggles `.is-playable` so the play badge fades in. Clicking opens WHEP.
   ---------------------------------------------------------------------------- */
.status-play-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(180deg, var(--green-soft) 0%, var(--green-active) 100%);
    color: var(--white);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 10px rgba(24, 188, 156, 0.55);
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.18s ease, transform 0.18s ease;
    pointer-events: none;
}
.status-play-badge svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
    /* Optical centring — the play-triangle glyph reads slightly
       left-of-center otherwise. */
    transform: translateX(1px);
}
button.status-tile.is-playable .status-play-badge {
    opacity: 1;
    transform: scale(1);
}
button.status-tile:disabled {
    /* Pilot might pass a stream with a still-empty token while
       STARTING — leave the tile reading "Live" / "Idle" naturally
       and just grey out the cursor. */
    cursor: default;
    opacity: 1; /* don't dim the headline status text */
}
button.status-tile:disabled:hover {
    /* Override `button.status-tile:hover` lift so a non-playable
       tile doesn't react to hover. */
    background: var(--panel);
    box-shadow: var(--shadow-card);
    transform: none;
}
@media (max-width: 820px) {
    /* Tighter geometry to match the compact tile layout. */
    .status-play-badge {
        bottom: 4px;
        right: 4px;
        width: 22px;
        height: 22px;
    }
    .status-play-badge svg {
        width: 12px;
        height: 12px;
    }
}

/* ----------------------------------------------------------------------------
   Live video modal — WHEP player surface. Opens on Video-tile tap and
   negotiates a WebRTC session against the URP platform's media server
   (mediamtx) using the credentials forwarded over SSE.
   ---------------------------------------------------------------------------- */
.video-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.video-modal[hidden] {
    display: none !important;
}
.video-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.video-modal-card {
    position: relative;
    width: min(960px, 100%);
    max-height: min(90vh, 720px);
    display: flex;
    flex-direction: column;
    background: #000;
    border: 1px solid var(--line-strong, rgba(255, 255, 255, 0.10));
    border-radius: 12px;
    box-shadow: 0 24px 56px rgba(0, 0, 0, 0.55);
    overflow: hidden;
    color: var(--white, #f5f7fa);
}
.video-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid var(--line, rgba(255, 255, 255, 0.06));
    flex: 0 0 auto;
}
.video-modal-header h2 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}
.video-modal-meta {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-soft, #cbd5e1);
}
.video-modal-close {
    appearance: none;
    background: transparent;
    color: inherit;
    border: 0;
    font-size: 1.5rem;
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    flex: 0 0 auto;
    transition: background 0.15s ease;
}
.video-modal-close:hover {
    background: rgba(255, 255, 255, 0.06);
}
.video-modal-close:focus-visible {
    outline: 2px solid var(--blue-soft);
    outline-offset: 2px;
}
.video-modal-body {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    background: #000;
}
.video-modal-stream {
    width: 100%;
    height: 100%;
    /* `cover` would crop the picture; the operator generally prefers
       `contain` so they can see the whole frame even on the tiny
       cockpit screen. Switching mode is just a CSS tweak away. */
    object-fit: contain;
    background: #000;
    display: block;
    /* Aspect ratio guard so the modal body isn't 0-height when no
       track has arrived yet. 16:9 matches the M30T / Mavic 3E
       sensors at default zoom. */
    aspect-ratio: 16 / 9;
}
.video-modal-status {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.55);
    color: var(--white, #f5f7fa);
    font-size: 0.85rem;
    text-align: center;
    padding: 16px;
    transition: opacity 0.18s ease;
}
.video-modal-status[hidden] {
    display: none !important;
}
.video-modal-status.is-error {
    background: rgba(20, 0, 0, 0.85);
    color: var(--bad);
}
.video-modal-status-text {
    max-width: 80%;
}
.video-modal-spinner {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.18);
    border-top-color: var(--blue-soft, #52afff);
    animation: spin 0.85s linear infinite;
}
.video-modal-status.is-error .video-modal-spinner {
    display: none;
}
.video-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.03);
    border-top: 1px solid var(--line, rgba(255, 255, 255, 0.06));
    flex: 0 0 auto;
}
.video-modal-source {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-soft, #cbd5e1);
}
.video-modal-mute {
    /* Smaller, tighter button — fits the cockpit footer better than
       the default `.btn` 40-px touch target. */
    min-width: 0;
    min-height: 32px;
    padding: 6px 12px;
    font-size: 0.7rem;
    flex: 0 0 auto;
}

@media (max-width: 820px) {
    .video-modal {
        padding: 0;
    }
    .video-modal-card {
        width: 100%;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
        border: 0;
    }
    .video-modal-header {
        padding: 6px 10px;
    }
    .video-modal-header h2 {
        font-size: 0.82rem;
    }
    .video-modal-meta {
        font-size: 0.65rem;
    }
    .video-modal-close {
        width: 28px;
        height: 28px;
        font-size: 1.3rem;
    }
    .video-modal-stream {
        aspect-ratio: auto;
        height: 100%;
    }
    .video-modal-footer {
        padding: 6px 10px;
    }
    .video-modal-source {
        font-size: 0.62rem;
    }
}
@media (prefers-reduced-motion: reduce) {
    .video-modal-spinner {
        animation: none !important;
    }
    .video-modal-backdrop {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

/* ----------------------------------------------------------------------------
   Telemetry detail modal — opened by tapping any drone-state pill. The body
   (#telemetry-modal-body) is rendered dynamically by ui.js from the latest
   OSD envelope; the focus section is highlighted so a tap on the Battery
   pill, for example, anchors the user at the Battery section.
   ---------------------------------------------------------------------------- */
.telemetry-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.telemetry-modal[hidden] {
    display: none !important;
}
.telemetry-modal-backdrop {
    position: absolute;
    inset: 0;
    background: var(--modal-backdrop);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.telemetry-modal-card {
    position: relative;
    width: min(640px, 100%);
    max-height: min(82vh, 720px);
    display: flex;
    flex-direction: column;
    background: var(--panel-elev, #11161e);
    border: 1px solid var(--line-strong, rgba(255,255,255,0.08));
    border-radius: 14px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
    overflow: hidden;
    color: var(--white, #f5f7fa);
}
.telemetry-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line, rgba(255,255,255,0.06));
}
.telemetry-modal-header h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.telemetry-modal-close {
    appearance: none;
    background: transparent;
    color: inherit;
    border: 0;
    font-size: 1.5rem;
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
}
.telemetry-modal-close:hover {
    background: rgba(255, 255, 255, 0.06);
}
.telemetry-modal-close:focus-visible {
    outline: 2px solid var(--blue-soft);
    outline-offset: 2px;
}
.telemetry-modal-body {
    overflow-y: auto;
    padding: 8px 18px 18px;
}
.telemetry-modal-empty {
    padding: 20px 4px;
    color: var(--lighter-grey, #9aa3b2);
    text-align: center;
    font-style: italic;
}
.telemetry-modal-footer {
    padding: 10px 18px;
    border-top: 1px solid var(--line, rgba(255,255,255,0.06));
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--lighter-grey, #9aa3b2);
    text-align: right;
}

/* Sections inside the modal body. Each section header is sticky so when
   the user scrolls, they always know which group they're inspecting. */
.tm-section {
    margin: 4px 0;
    padding: 12px;
    border: 1px solid var(--line, rgba(255,255,255,0.06));
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
}
.tm-section h3 {
    margin: 0 0 8px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--lighter-grey, #9aa3b2);
}
.tm-section h3 .tm-section-status {
    color: var(--text-soft, #cbd5e1);
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: none;
    margin-left: 6px;
}
.tm-grid {
    margin: 0;
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 16px;
    row-gap: 4px;
    align-items: baseline;
}
.tm-grid dt {
    color: var(--lighter-grey, #9aa3b2);
    font-size: 0.78rem;
}
.tm-grid dd {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--white, #f5f7fa);
    text-align: right;
    word-break: break-all;
}
.tm-grid dd.is-muted {
    color: var(--lighter-grey, #9aa3b2);
    font-style: italic;
}
.tm-note {
    margin: 8px 0 0;
    font-size: 0.78rem;
    color: var(--lighter-grey, #9aa3b2);
}

@media (prefers-reduced-motion: reduce) {
    .telemetry-modal-backdrop {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}
@media (max-width: 480px) {
    .telemetry-modal {
        padding: 0;
    }
    .telemetry-modal-card {
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    .tm-grid {
        grid-template-columns: 1fr;
    }
    .tm-grid dt {
        margin-top: 6px;
    }
    .tm-grid dd {
        text-align: left;
    }
}

/* ----------------------------------------------------------------------------
   Light-theme touch-ups for hardcoded dark-mode overlays. The token swap in
   `[data-theme="light"]` covers the main surfaces; these rules patch the
   handful of places that hardcoded `rgba(255,255,255,...)` for borders,
   backgrounds or scrollbars (invisible on white).
   ---------------------------------------------------------------------------- */
[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.20);
}
[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(15, 23, 42, 0.32);
}
[data-theme="light"] .app-header {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border-bottom-color: rgba(15, 23, 42, 0.08);
}
[data-theme="light"] .tm-section {
    background: rgba(15, 23, 42, 0.03);
}

/* Connection pills — dark theme uses pale mint/coral text on tinted fills; on
   light panels that yields ~2:1 contrast. Switch to saturated foreground hues. */
[data-theme="light"] .debug-conn-pill--on {
    border-color: rgba(21, 128, 61, 0.55);
    background: rgba(34, 197, 94, 0.16);
    color: #14532d;
}

[data-theme="light"] .debug-conn-pill--off {
    border-color: rgba(185, 28, 28, 0.45);
    background: rgba(248, 113, 113, 0.14);
    color: #991b1b;
}
