/* ═══════════════════════════════════════════════════════════════════
   RouteTracker — Modern Obsidian Theme
   ═══════════════════════════════════════════════════════════════════ */

:root {
    /* Backgrounds — midnight navy, not pure black */
    --bg-primary: #0d1117;
    --bg-secondary: #151f2e;
    --bg-card: #1c2535;
    --bg-panel: rgba(13, 17, 23, 0.97);
    --bg-glass: rgba(129, 140, 248, 0.07);

    /* Borders */
    --border: rgba(255, 255, 255, 0.09);
    --border-active: rgba(129, 140, 248, 0.42);
    --border-subtle: rgba(255, 255, 255, 0.04);

    /* Accent palette */
    --accent-blue: #818cf8;
    /* indigo-400  — primary  */
    --accent-cyan: #22d3ee;
    /* cyan-400    — marine   */
    --accent-green: #34d399;
    /* emerald-400 — success  */
    --accent-orange: #fb923c;
    /* orange-400  — warning  */
    --accent-red: #f87171;
    /* red-400     — alert    */
    --accent-violet: #c084fc;
    /* purple-400  — extra    */
    --accent-dim: #3d4d65;
    /* dark slate  — muted    */

    /* Text */
    --text-primary: #e4ecf7;
    /* warm off-white */
    --text-secondary: #8795af;
    /* muted slate-blue */
    --text-dim: #3d4d65;
    /* dark muted */

    /* Typography */
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    --font-ui: 'Inter', 'Segoe UI', system-ui, sans-serif;

    --panel-w: 300px;
    --header-h: 54px;
    --radius: 8px;
    --radius-lg: 12px;

    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html,
body {
    height: 100%;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-ui);
    overflow: hidden;
}

/* ─── Scrollbar ─────────────────────────────── */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

/* ─── Subtle ambient glow ──────────────── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(129, 140, 248, 0.09) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(192, 132, 252, 0.07) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ═══════════════════════════════════════════════════════════════════
   TOP BAR
   ═══════════════════════════════════════════════════════════════════ */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: rgba(13, 17, 23, 0.92);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    box-shadow: 0 1px 0 var(--border-subtle), 0 4px 32px rgba(0, 0, 0, 0.4);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: .04em;
    font-size: 15px;
    font-weight: 700;
    color: var(--accent-blue);
}

.logo-icon {
    display: flex;
    align-items: center;
    color: var(--accent-blue);
    filter: drop-shadow(0 0 6px var(--accent-blue));
    animation: float 4s ease-in-out infinite;
}

.logo-dim {
    color: var(--text-secondary);
    font-weight: 400;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-3px);
    }
}

.provider-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-blue);
    letter-spacing: .04em;
    background: var(--bg-glass);
    backdrop-filter: blur(8px);
}

.provider-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-blue);
    box-shadow: 0 0 6px var(--accent-blue);
    animation: pulse-blue 2s infinite;
}

@keyframes pulse-blue {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .3;
    }
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    letter-spacing: .05em;
}

.conn-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-dim);
    transition: background var(--transition), box-shadow var(--transition);
}

.conn-dot.connected {
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
}

.conn-dot.connecting {
    background: var(--accent-orange);
    box-shadow: 0 0 8px var(--accent-orange);
    animation: blink .8s infinite;
}

.conn-dot.error {
    background: var(--accent-red);
    box-shadow: 0 0 8px var(--accent-red);
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .2;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════════════ */
.layout {
    display: flex;
    height: 100vh;
    padding-top: var(--header-h);
}

/* ═══════════════════════════════════════════════════════════════════
   LEFT PANEL
   ═══════════════════════════════════════════════════════════════════ */
.left-panel {
    width: var(--panel-w);
    min-width: 180px;
    max-width: 520px;
    flex-shrink: 0;
    position: relative;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
    backdrop-filter: blur(24px) saturate(140%);
    -webkit-backdrop-filter: blur(24px) saturate(140%);
    transition: none;
}

/* Drag-resize handle */
.panel-resize-handle {
    position: absolute;
    top: 0;
    right: -3px;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 50;
    background: transparent;
    transition: background 0.15s;
}

.panel-resize-handle:hover,
.panel-resize-handle.dragging {
    background: var(--accent-blue);
    opacity: 0.35;
}

.section {
    padding: 18px 16px;
    border-bottom: 1px solid var(--border);
}

.section:last-child {
    border-bottom: none;
}

.section-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .16em;
    color: var(--accent-blue);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::before {
    content: '';
    flex: 1;
    max-width: 20px;
    height: 1px;
    background: var(--accent-blue);
    opacity: .5;
}

.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ─── Inputs ─────────────────────────────── */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 12px;
}

.input-group label {
    font-size: 10px;
    color: var(--text-secondary);
    letter-spacing: .08em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ─── Info tooltip ─────────────────────────── */
.info-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    color: var(--accent-blue);
    font-size: 11px;
    opacity: 0.6;
    position: relative;
    flex-shrink: 0;
    transition: opacity var(--transition);
}

.info-tip:hover {
    opacity: 1;
}

.info-tip::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-active);
    border-radius: var(--radius);
    padding: 9px 12px;
    font-size: 10px;
    line-height: 1.55;
    width: 210px;
    white-space: normal;
    text-transform: none;
    letter-spacing: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 9500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.info-tip:hover::after {
    opacity: 1;
}

.input-group input {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    font-family: var(--font-mono);
    outline: none;
    transition: border var(--transition), box-shadow var(--transition), background var(--transition);
    text-transform: uppercase;
    width: 100%;
}

.input-group input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.12);
    background: var(--bg-secondary);
}

.input-group input::placeholder {
    color: var(--text-dim);
    opacity: 0.7;
}

/* ─── Buttons ─────────────────────────────── */
.btn {
    width: 100%;
    padding: 10px 0;
    border: none;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .06em;
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 8px;
    font-family: var(--font-ui);
}

.btn:last-child {
    margin-bottom: 0;
}

.btn-primary {
    background: linear-gradient(135deg, #3730a3 0%, #6366f1 60%, var(--accent-blue) 100%);
    color: #fff;
    box-shadow: 0 2px 12px rgba(129, 140, 248, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(129, 140, 248, 0.22);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 4px 22px rgba(129, 140, 248, 0.50), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
    background: linear-gradient(135deg, #4338ca 0%, #818cf8 80%, var(--accent-violet) 100%);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--accent-red);
    color: var(--accent-red);
    background: rgba(248, 113, 113, 0.06);
}

.btn-danger {
    background: linear-gradient(135deg, #991b1b, var(--accent-red));
    color: #fff;
    box-shadow: 0 2px 12px rgba(248, 113, 113, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.2);
    width: auto;
    padding: 10px 32px;
}

.btn:disabled {
    opacity: .30;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ─── Mode Tabs ──────────────────────────── */
.mode-tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    flex-shrink: 0;
}

.mode-tab {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .1em;
    padding: 13px 0;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-ui);
}

.mode-tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
    background: var(--bg-glass);
}

.mode-tab:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(255, 255, 255, .025);
}

/* ─── Marine TRACK button (cyan accent) ─── */
.btn-marine {
    background: linear-gradient(135deg, #0e7490, var(--accent-cyan));
    color: #fff;
    box-shadow: 0 2px 12px rgba(34, 211, 238, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(34, 211, 238, 0.2);
}

.btn-marine:hover:not(:disabled) {
    box-shadow: 0 4px 20px rgba(34, 211, 238, 0.40);
    transform: translateY(-1px);
    background: linear-gradient(135deg, #155e75, #06b6d4);
}

/* ─── Flight Info Grid ─────────────────────── */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.info-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 12px;
    transition: border-color var(--transition);
}

.info-item:hover {
    border-color: var(--border-active);
}

.info-item.wide {
    grid-column: 1 / -1;
}

.info-label {
    display: block;
    font-size: 9px;
    color: var(--text-secondary);
    letter-spacing: .08em;
    margin-bottom: 3px;
}

.info-value {
    display: block;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--accent-blue);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── Deviation Gauge ─────────────────────── */
.deviation-gauge {
    margin-bottom: 12px;
}

.gauge-svg {
    width: 100%;
    max-width: 200px;
    display: block;
    margin: 0 auto;
}

/* Override SVG presentation attributes so gauge adapts to themes */
.gauge-svg path:first-child {
    stroke: var(--bg-card);
}

#gaugeNeedle {
    stroke: var(--text-primary);
}

.gauge-svg circle {
    fill: var(--text-primary);
}

.gauge-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: -8px;
    padding: 0 14px;
}

.gauge-center-label {
    font-family: var(--font-mono);
    font-size: 18px;
    color: var(--text-primary);
    font-weight: 700;
}

.deviation-status {
    text-align: center;
    margin-bottom: 14px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 24px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .07em;
    margin-top: 5px;
    border: 1px solid transparent;
    transition: all var(--transition);
}

.status-ok {
    background: rgba(74, 222, 128, 0.07);
    border-color: var(--accent-green);
    color: var(--accent-green);
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.12);
}

.status-deviation {
    background: rgba(248, 113, 113, 0.10);
    border-color: var(--accent-red);
    color: var(--accent-red);
    box-shadow: 0 0 16px rgba(248, 113, 113, 0.25);
    animation: deviation-pulse 1s infinite;
}

.status-nodata {
    background: rgba(51, 65, 85, 0.20);
    border-color: var(--accent-dim);
    color: var(--text-secondary);
}

.status-anchored {
    background: rgba(100, 116, 139, 0.12);
    border-color: #475569;
    color: #94a3b8;
    box-shadow: 0 0 8px rgba(100, 116, 139, 0.15);
}

@keyframes deviation-pulse {

    0%,
    100% {
        box-shadow: 0 0 16px rgba(248, 113, 113, 0.25);
    }

    50% {
        box-shadow: 0 0 28px rgba(248, 113, 113, 0.55);
    }
}

.xtd-detail {
    font-size: 11px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

/* ─── Legend ─────────────────────────────── */
.legend-section {
    padding: 12px 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════
   MAP
   ═══════════════════════════════════════════════════════════════════ */
.map-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
    background: #090d18;
}

/* Make Leaflet tiles refined dark */
.leaflet-tile {
    filter: brightness(0.84) saturate(0.72) hue-rotate(5deg);
}

.leaflet-control-zoom {
    border: 1px solid var(--border) !important;
}

.leaflet-control-zoom a {
    background: var(--bg-panel) !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border) !important;
}

.leaflet-control-zoom a:hover {
    color: var(--accent-blue) !important;
}

.leaflet-control-attribution {
    background: rgba(7, 9, 15, 0.82) !important;
    color: var(--text-secondary) !important;
    font-size: 9px !important;
}

.leaflet-control-attribution a {
    color: var(--text-secondary) !important;
}

/* ─── Aircraft marker ─────────────────────── */
.aircraft-icon {
    font-size: 24px;
    text-align: center;
    line-height: 1;
    filter: drop-shadow(0 0 6px var(--accent-green));
    transition: transform .4s ease;
}

/* ─── Vessel marker ───────────────────── */
.vessel-icon {
    font-size: 22px;
    text-align: center;
    line-height: 1;
    filter: drop-shadow(0 0 6px var(--accent-blue));
    transition: transform .4s ease;
}

/* ─── Map Overlay ─────────────────────────── */
.map-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(7, 9, 15, 0.60);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 500;
    transition: opacity .4s;
}

.map-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    text-align: center;
    max-width: 360px;
}

.overlay-icon {
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 18px;
    color: var(--accent-blue);
    filter: drop-shadow(0 0 20px var(--accent-blue));
    animation: float 3s ease-in-out infinite;
}

.overlay-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: .08em;
    color: var(--accent-blue);
    margin-bottom: 10px;
}

.overlay-sub {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.overlay-sub strong {
    color: var(--text-primary);
}

/* ─── Map Footer ──────────────────────────── */
.map-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 400;
    background: rgba(7, 9, 15, 0.82);
    border-top: 1px solid var(--border);
    padding: 5px 16px;
    font-size: 10.5px;
    color: var(--text-secondary);
    display: flex;
    gap: 8px;
    font-family: var(--font-mono);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.separator {
    color: var(--border);
}

/* ═══════════════════════════════════════════════════════════════════
   DEVIATION ALERT MODAL
   ═══════════════════════════════════════════════════════════════════ */
.alert-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .6);
    backdrop-filter: blur(6px);
    animation: fadeIn .3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.alert-modal-inner {
    background: var(--bg-secondary);
    border: 1px solid var(--accent-red);
    box-shadow: 0 0 0 1px var(--border-subtle), 0 0 40px rgba(248, 113, 113, 0.30), inset 0 0 40px rgba(248, 113, 113, 0.02);
    border-radius: var(--radius-lg);
    padding: 40px 48px;
    text-align: center;
    max-width: 440px;
    animation: slideUp .35s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.alert-icon {
    font-size: 52px;
    color: var(--accent-red);
    margin-bottom: 16px;
    filter: drop-shadow(0 0 16px var(--accent-red));
    animation: shake 0.5s ease infinite alternate;
}

@keyframes shake {
    from {
        transform: rotate(-6deg);
    }

    to {
        transform: rotate(6deg);
    }
}

.alert-title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: .12em;
    color: var(--accent-red);
    margin-bottom: 12px;
}

.alert-body {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 28px;
    line-height: 1.7;
    font-family: var(--font-mono);
}

/* ═══════════════════════════════════════════════════════════════════
   LEAFLET POPUP OVERRIDE
   ═══════════════════════════════════════════════════════════════════ */
.leaflet-popup-content-wrapper {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
    border-radius: 8px !important;
    font-family: var(--font-mono) !important;
    font-size: 12px !important;
    box-shadow: 0 4px 24px rgba(0, 0, 0, .5) !important;
}

.leaflet-popup-tip {
    background: var(--bg-secondary) !important;
}

.leaflet-popup-close-button {
    color: var(--text-secondary) !important;
}

/* ─── Leaflet tooltip (hover labels on route/trail) ─── */
.leaflet-tooltip {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-active) !important;
    color: var(--text-primary) !important;
    border-radius: var(--radius) !important;
    font-family: var(--font-ui) !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    padding: 5px 10px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4) !important;
    white-space: nowrap !important;
}

.leaflet-tooltip::before {
    border-top-color: var(--border-active) !important;
}

[data-theme="light"] .leaflet-tooltip {
    background: #ffffff !important;
    border-color: rgba(79, 70, 229, 0.3) !important;
    color: var(--text-primary) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12) !important;
}

[data-theme="light"] .leaflet-tooltip::before {
    border-top-color: rgba(79, 70, 229, 0.3) !important;
}

/* ─── Responsive ─────────────────────────── */
@media (max-width: 720px) {
    .left-panel {
        width: 260px;
        min-width: 260px;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   TOP BAR — extended for v2
   ═══════════════════════════════════════════════════════════════════ */
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    padding: 6px 10px;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    position: relative;
    font-family: var(--font-ui);
    line-height: 1;
}

.icon-btn svg {
    display: block;
    flex-shrink: 0;
    pointer-events: none;
}

.icon-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background: rgba(129, 140, 248, 0.09);
}

.bell-btn {
    padding: 6px 10px;
}

.bell-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--accent-red);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 5px;
    min-width: 16px;
    text-align: center;
    line-height: 14px;
}

/* ═══════════════════════════════════════════════════════════════════
   LEFT PANEL v2 — voyage list
   ═══════════════════════════════════════════════════════════════════ */
.panel-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 12px 12px 0;
    flex-shrink: 0;
}

.btn-new-voyage {
    flex: 1;
    margin-bottom: 0;
    padding: 9px 0;
    font-size: 11px;
}

.fit-btn {
    padding: 6px 10px;
    border-radius: var(--radius);
}

.voyage-section {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.voyage-section:last-child {
    border-bottom: none;
}

.section-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .16em;
    color: var(--text-dim);
    padding: 6px 12px 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.collapsible-label {
    cursor: pointer;
}

.collapsible-label:hover {
    color: var(--text-secondary);
}

.collapse-arrow {
    font-size: 10px;
}

.voyage-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.voyage-empty {
    font-size: 11px;
    color: var(--text-dim);
    padding: 10px 12px;
    line-height: 1.6;
}

.voyage-empty strong {
    color: var(--text-secondary);
}

/* ─── Voyage Card ────────────────────────────────────────────────── */
.voyage-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px 9px 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition);
    position: relative;
}

.voyage-card:last-child {
    border-bottom: none;
}

.voyage-card:hover {
    background: rgba(129, 140, 248, 0.05);
}

.voyage-card.selected {
    background: rgba(129, 140, 248, 0.08);
    box-shadow: inset 3px 0 0 var(--accent-blue);
}

.voyage-card.deviating {
    background: rgba(248, 113, 113, 0.06);
    box-shadow: inset 3px 0 0 var(--accent-red);
}

.card-ring {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: box-shadow var(--transition);
}

.card-type-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.card-type-icon svg {
    width: 15px;
    height: 15px;
    display: block;
}

.voyage-card:hover .card-ring {
    box-shadow: 0 0 10px currentColor;
}

@keyframes ring-pulse {

    0%,
    100% {
        box-shadow: 0 0 8px rgba(248, 113, 113, 0.6);
    }

    50% {
        box-shadow: 0 0 20px rgba(248, 113, 113, 0.9);
    }
}

.card-body {
    flex: 1;
    min-width: 0;
    outline: none;
}

.card-identifier {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .06em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-label {
    font-size: 10px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.card-xtd {
    font-size: 10px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    margin-top: 2px;
}

.card-xtd b {
    color: var(--accent-green);
}

.card-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.card-badge {
    background: var(--accent-red);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 6px;
    line-height: 14px;
    min-width: 16px;
    text-align: center;
}

.card-pause-btn,
.card-stop-btn,
.card-delete-btn {
    font-size: 11px;
    padding: 3px 6px;
    opacity: 0;
    transition: opacity var(--transition);
}

.card-eye-btn {
    font-size: 13px;
    padding: 3px 5px;
    opacity: 0;
    transition: opacity var(--transition), border-color var(--transition), color var(--transition);
}

.voyage-card:hover .card-pause-btn,
.voyage-card:hover .card-stop-btn,
.voyage-card:hover .card-delete-btn,
.voyage-card:hover .card-eye-btn {
    opacity: 1;
}

/* Eye button stays fully opaque when the voyage is currently shown on map */
.card-eye-btn.eye-on {
    opacity: 1;
    border-color: var(--accent-blue) !important;
    color: var(--accent-blue) !important;
}

.card-eye-btn:hover {
    border-color: var(--accent-blue) !important;
    color: var(--accent-blue) !important;
}

.card-stop-btn:hover {
    border-color: var(--accent-red) !important;
    color: var(--accent-red) !important;
}

.card-delete-btn {
    font-size: 13px;
}

.card-delete-btn:hover {
    border-color: var(--accent-red) !important;
    color: var(--accent-red) !important;
}

/* ─── Deviation History Tab ──────────────────────────────────────── */
.history-header-row {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
}

.history-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    color: var(--text-secondary);
}

.history-sub {
    font-size: 11px;
    color: var(--accent-blue);
}

.history-table-wrap {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 420px;
    border-radius: 6px;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.history-table thead th {
    position: sticky;
    top: 0;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 10px;
    letter-spacing: .08em;
    font-weight: 700;
    padding: 6px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.history-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

.history-table tbody tr:hover {
    background: var(--bg-panel);
}

.history-table tbody td {
    padding: 7px 12px;
    color: var(--text-primary);
    white-space: nowrap;
}

.history-table .hist-xtd {
    color: var(--accent-blue);
    font-weight: 600;
}

.history-table .hist-pct {
    color: var(--accent-orange);
    font-weight: 600;
}

/* ─── Map button marker ──────────────────────────────────────────── */
.marker-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: transform .4s ease;
}

.marker-icon svg {
    display: block;
}

/* ═══════════════════════════════════════════════════════════════════
   MODALS (shared)
   ═══════════════════════════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .65);
    backdrop-filter: blur(6px);
    animation: fadeIn .25s ease;
    padding: 20px;
}

.modal-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-active);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    box-shadow: 0 0 0 1px var(--border-subtle), 0 8px 48px rgba(0, 0, 0, 0.65), 0 0 40px rgba(129, 140, 248, 0.08);
    animation: slideUp .3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.modal-box-lg {
    max-width: 680px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 10px;
}

.modal-title {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .1em;
    color: var(--accent-blue);
}

.modal-type-icon {
    font-size: 18px;
    margin-right: 6px;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

.modal-type-icon svg {
    width: 18px;
    height: 18px;
}

.detail-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: 4px;
}

.detail-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    flex-shrink: 0;
}

.modal-tab {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .1em;
    padding: 11px 0;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-ui);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.modal-tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
    background: var(--bg-glass);
}

.modal-tab:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(255, 255, 255, .025);
}

.tab-badge {
    background: var(--accent-red);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    border-radius: 8px;
    padding: 1px 5px;
    min-width: 16px;
    text-align: center;
    line-height: 14px;
}

/* ─── New Voyage Modal specifics ─────────────────────────────────── */
.type-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.type-btn {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    padding: 10px 0;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-ui);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.type-btn.active {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background: rgba(129, 140, 248, 0.09);
    box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.type-btn:hover:not(.active) {
    border-color: var(--border-active);
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

/* ── Mode selector (Region Scan / Individual) ───────────────────────── */
.mode-selector {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
}

.mode-btn {
    flex: 1;
    padding: 9px 12px;
    border-radius: var(--radius);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-ui);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.mode-btn:hover:not(.active) {
    border-color: var(--border-active);
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.mode-btn.active {
    background: rgba(129, 140, 248, 0.12);
    color: var(--accent-blue);
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* 3-column scan-type selector */
.type-selector.three-col {
    gap: 5px;
}

.type-selector.three-col .type-btn {
    font-size: 10px;
    padding: 8px 4px;
    letter-spacing: 0.03em;
}

/* Form sub-label */
.section-sublabel {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin: 14px 0 6px;
}

/* Native select styled to match text inputs */
.select-input {
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--radius);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font-ui);
    cursor: pointer;
    appearance: auto;
    transition: border-color var(--transition);
}

.select-input:focus {
    outline: none;
    border-color: var(--border-active);
}

.select-input option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Region scan card — dashed ring instead of solid */
.region-ring {
    border-style: dashed !important;
    border-width: 2px !important;
}

/* Compact entity count pills on region scan cards */
.scan-entity {
    font-size: 12px !important;
    opacity: 0.88;
}

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.optional {
    font-size: 9px;
    color: var(--text-dim);
    font-weight: 400;
    font-style: italic;
}

.modal-error {
    background: rgba(248, 113, 113, 0.08);
    border: 1px solid var(--accent-red);
    border-radius: var(--radius);
    color: var(--accent-red);
    font-size: 12px;
    padding: 8px 12px;
    margin-bottom: 12px;
}

/* ─── Status badge (in detail header) ───────────────────────────── */
.status-badge {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid transparent;
}

.status-badge-active {
    background: rgba(74, 222, 128, 0.08);
    border-color: var(--accent-green);
    color: var(--accent-green);
}

.status-badge-paused {
    background: rgba(255, 153, 0, .08);
    border-color: var(--accent-orange);
    color: var(--accent-orange);
}

.status-badge-stopped {
    background: rgba(51, 65, 85, 0.15);
    border-color: var(--accent-dim);
    color: var(--text-secondary);
}

.status-badge-completed {
    background: rgba(129, 140, 248, 0.09);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

/* ─── Button sizes ────────────────────────────────────────────────── */
.btn-sm {
    padding: 5px 12px;
    font-size: 10px;
    letter-spacing: .08em;
    width: auto;
    margin-bottom: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-pause {
    background: rgba(255, 153, 0, .1);
    border: 1px solid var(--accent-orange);
    color: var(--accent-orange);
}

.btn-pause:hover {
    background: rgba(255, 153, 0, .2);
}

.btn-stop {
    background: rgba(248, 113, 113, 0.10);
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
}

.btn-stop:hover {
    background: rgba(248, 113, 113, 0.20);
}

.btn-ack {
    background: rgba(74, 222, 128, 0.08);
    border: 1px solid var(--accent-green);
    color: var(--accent-green);
}

.btn-ack:hover {
    background: rgba(74, 222, 128, 0.16);
}

.btn-ack-all {
    background: rgba(74, 222, 128, 0.08);
    border: 1px solid var(--accent-green);
    color: var(--accent-green);
}

.btn-ack-all:hover {
    background: rgba(74, 222, 128, 0.16);
}

/* ─── Detail modal body specifics ────────────────────────────────── */
.detail-gauge {
    margin-bottom: 20px;
}

.detail-meta {
    margin-top: 14px;
    font-size: 10px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    text-align: center;
}

/* ─── Alerts list in detail modal ────────────────────────────────── */
.alerts-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .1em;
    color: var(--accent-blue);
}

.alerts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Severity-left-border accent */
.alert-row {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent-red);
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: opacity var(--transition);
}

.alert-sev-critical {
    border-left-color: #f87171;
}

.alert-sev-high {
    border-left-color: #fb923c;
}

.alert-sev-warning {
    border-left-color: #fbbf24;
}

.alert-sev-info {
    border-left-color: #60a5fa;
}

.alert-sev-legacy {
    border-left-color: var(--border);
}

.alert-row.acked {
    border-color: var(--border);
    opacity: 0.45;
}

.alert-row-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.alert-sev-pill {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .08em;
    padding: 2px 7px;
    border-radius: 4px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.alert-sev-pill.sev-critical {
    background: rgba(248, 113, 113, .18);
    color: #f87171;
}

.alert-sev-pill.sev-high {
    background: rgba(251, 146, 60, .18);
    color: #fb923c;
}

.alert-sev-pill.sev-warning {
    background: rgba(251, 191, 36, .18);
    color: #fbbf24;
}

.alert-sev-pill.sev-info {
    background: rgba(96, 165, 250, .18);
    color: #60a5fa;
}

.alert-row-time {
    font-size: 10px;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.alert-row-msg {
    font-size: 12px;
    color: var(--text-primary);
}

.alert-row-xtd {
    font-size: 10px;
    color: var(--accent-orange);
    font-family: var(--font-mono);
}

.alert-score-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.alert-score-bar-wrap {
    flex: 1;
}

.alert-score-num {
    font-size: 18px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
    min-width: 30px;
    text-align: right;
    line-height: 1;
}

.alert-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2px;
}

.alert-legacy-note {
    font-size: 10px;
    color: var(--text-dim);
    font-style: italic;
    margin-top: 2px;
}

.alert-row-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 2px;
}

.ack-badge {
    font-size: 10px;
    color: var(--accent-green);
    font-weight: 700;
    letter-spacing: .06em;
}


/* ═══════════════════════════════════════════════════════════════════
   ENTITY DETAIL PANEL (flight / vessel drill-down in region scan)
   ═══════════════════════════════════════════════════════════════════ */
.entity-panel {
    position: fixed;
    top: var(--header-h);
    right: 0;
    bottom: 0;
    width: 360px;
    background: var(--bg-panel);
    border-left: 1px solid var(--border-active);
    z-index: 1400;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.4, 0, .2, 1);
    backdrop-filter: blur(20px);
    box-shadow: -8px 0 32px rgba(0, 0, 0, .35);
}

.entity-panel.open {
    transform: translateX(0);
}

.entity-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 10px;
}

.entity-panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.entity-panel-icon {
    font-size: 22px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.entity-panel-icon svg {
    width: 20px;
    height: 20px;
}

.entity-panel-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: .02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.entity-panel-sub {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.entity-panel-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.entity-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Section title within entity panel */
.ep-section-title {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .12em;
    color: var(--text-dim);
    text-transform: uppercase;
    padding: 14px 0 6px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

.ep-section-title:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

/* Info grid inside entity panel */
.ep-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 0;
}

.ep-grid .info-item.wide {
    grid-column: span 2;
}

/* Deviation callout box */
.ep-dev-box {
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-top: 6px;
    font-size: 12px;
    font-weight: 600;
}

.ep-dev-box.ep-dev-alert {
    background: rgba(248, 113, 113, .1);
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
}

.ep-dev-box.ep-dev-ok {
    background: rgba(34, 197, 94, .08);
    border: 1px solid #22c55e55;
    color: #22c55e;
}

.ep-dev-box .ep-dev-main {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 4px;
}

.ep-dev-box .ep-dev-sub {
    font-size: 11px;
    opacity: .8;
}

/* Map legend inside entity panel */
.entity-panel-legend {
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 16px;
    flex-shrink: 0;
}

.ep-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: var(--text-secondary);
}

.ep-legend-line {
    display: inline-block;
    width: 24px;
    height: 3px;
    border-radius: 2px;
}

.ep-legend-route {
    background: #818cf8;
    opacity: .8;
}

.ep-legend-track {
    background: #22c55e;
}

.ep-route-toggle {
    opacity: 0.35;
    transition: opacity .15s;
}

.ep-route-toggle.route-on {
    opacity: 1;
    color: #818cf8;
    text-shadow: 0 0 8px #818cf888;
}

.ep-route-toggle:disabled {
    opacity: 0.15;
    cursor: default;
}

.ep-track-toggle {
    opacity: 0.45;
    transition: opacity .15s;
}

.ep-track-toggle.track-on {
    opacity: 1;
    color: #22c55e;
    text-shadow: 0 0 8px #22c55e88;
}

.ep-legend-track-vessel {
    background: #34d399;
}

/* ═══════════════════════════════════════════════════════════════════
   ALERT BELL DRAWER
   ═══════════════════════════════════════════════════════════════════ */
.bell-drawer {
    position: fixed;
    top: var(--header-h);
    right: 0;
    bottom: 0;
    width: 320px;
    background: var(--bg-panel);
    border-left: 1px solid var(--border-active);
    z-index: 1500;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform .3s ease;
    backdrop-filter: blur(16px);
}

.bell-drawer.open {
    transform: translateX(0);
}

.bell-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1499;
    background: rgba(0, 0, 0, .3);
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s;
}

.bell-drawer-backdrop.open {
    opacity: 1;
    pointer-events: all;
}

.bell-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .1em;
    color: var(--accent-blue);
    flex-shrink: 0;
}

.bell-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.drawer-empty {
    font-size: 12px;
    color: var(--text-dim);
    text-align: center;
    padding: 20px;
}

.drawer-alert-row {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent-red);
    border-radius: 6px;
    padding: 10px 10px 8px;
}

.drawer-alert-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-blue);
    margin-bottom: 3px;
}

.drawer-alert-time {
    font-size: 10px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    margin-bottom: 4px;
}

.drawer-alert-msg {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.drawer-alert-xtd {
    font-size: 10px;
    color: var(--accent-orange);
    font-family: var(--font-mono);
    margin-bottom: 8px;
}

.drawer-ack-btn {
    width: 100%;
}

/* ─── Map Legend ─────────────────────────────── */
.map-legend {
    position: absolute;
    bottom: 32px;
    left: 12px;
    z-index: 600;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
    pointer-events: all;
}

.legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    border-radius: 4px;
    padding: 2px 4px;
    margin: -2px -4px;
    transition: background 0.15s;
    user-select: none;
}

.legend-row:hover {
    background: rgba(255, 255, 255, 0.06);
}

.legend-row.legend-off .legend-line {
    opacity: 0.2;
}

.legend-row.legend-off .legend-label {
    opacity: 0.4;
    text-decoration: line-through;
}

.legend-line {
    display: inline-block;
    width: 26px;
    height: 2px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-line-route {
    background: #3b82f6;
    box-shadow: 0 0 5px rgba(59, 130, 246, 0.6);
}

.legend-line-trail {
    background: #34d399;
    box-shadow: 0 0 5px rgba(52, 211, 153, 0.6);
}

.legend-label {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.03em;
    white-space: nowrap;
}

[data-theme="light"] .map-legend {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(148, 163, 184, 0.3);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.10);
}

/* ─── Confirm Dialog ──────────────────────────────────────────────── */
.confirm-box {
    max-width: 360px;
    text-align: center;
    padding: 0;
    gap: 0;
}

/* ═══════════════════════════════════════════════════════════════════
   INFO MODAL
   ═══════════════════════════════════════════════════════════════════ */
.info-modal-box {
    max-width: 720px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.info-modal-body {
    overflow-y: auto;
    padding: 24px 28px 28px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.info-section {
    margin-bottom: 8px;
}

.info-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--accent-blue);
    margin-bottom: 12px;
}

.info-section-header svg {
    flex-shrink: 0;
    color: var(--accent-blue);
}

.info-subsection-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin: 18px 0 8px;
}

.info-p {
    font-size: 0.825rem;
    line-height: 1.65;
    color: var(--text-secondary);
    margin: 0 0 10px;
}

.info-rule-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 14px 0;
}

@media (max-width: 600px) {
    .info-rule-grid {
        grid-template-columns: 1fr;
    }
}

.info-subsection-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin: 18px 0 8px;
}

.info-rule-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 13px 15px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.info-rule-card--suppressor {
    border-color: var(--accent-blue);
    opacity: 0.85;
}

.info-rule-tag {
    display: inline-block;
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    background: color-mix(in srgb, var(--accent-blue) 15%, transparent);
    color: var(--accent-blue);
    border: 1px solid color-mix(in srgb, var(--accent-blue) 35%, transparent);
    border-radius: 4px;
    padding: 1px 5px;
    vertical-align: middle;
    margin-left: 6px;
}

.info-rule-name {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: .02em;
}

.info-rule-desc {
    font-size: 0.77rem;
    line-height: 1.55;
    color: var(--text-secondary);
}

.info-rule-meta {
    font-size: 0.71rem;
    color: var(--text-dim);
    border-top: 1px solid var(--border);
    padding-top: 6px;
    margin-top: 2px;
}

.info-source-list,
.info-bullet-list {
    margin: 0 0 10px 0;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.info-source-list li,
.info-bullet-list li {
    font-size: 0.815rem;
    line-height: 1.55;
    color: var(--text-secondary);
}

.info-source-list li strong,
.info-bullet-list li strong {
    color: var(--text-primary);
}

.info-note {
    font-size: 0.76rem;
    line-height: 1.6;
    color: var(--text-dim);
    background: var(--bg-card);
    border-left: 3px solid var(--accent-blue);
    border-radius: 0 6px 6px 0;
    padding: 9px 13px;
    margin: 8px 0 0;
}

.info-divider {
    height: 1px;
    background: var(--border);
    margin: 22px 0;
}



.confirm-icon-wrap {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 28px auto 18px;
}

.confirm-icon-wrap.is-warning {
    background: rgba(251, 146, 60, 0.14);
    box-shadow: 0 0 0 8px rgba(251, 146, 60, 0.06);
}

.confirm-icon-wrap.is-warning svg {
    color: var(--accent-orange);
}

.confirm-icon-wrap.is-danger {
    background: rgba(248, 113, 113, 0.14);
    box-shadow: 0 0 0 8px rgba(248, 113, 113, 0.06);
}

.confirm-icon-wrap.is-danger svg {
    color: var(--accent-red);
}

.confirm-title-text {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: .01em;
    margin-bottom: 10px;
    padding: 0 24px;
}

.confirm-message {
    font-size: 13.5px;
    color: var(--text-secondary);
    line-height: 1.6;
    padding: 0 28px;
    margin-bottom: 6px;
}

.confirm-message strong {
    color: var(--text-primary);
    font-weight: 600;
}

.confirm-sub {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-dim);
    opacity: 0.85;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    gap: 10px;
    padding: 24px;
    justify-content: center;
}

.confirm-actions .btn {
    flex: 1;
    max-width: 140px;
    padding: 10px 20px;
    font-size: 13px;
}

.btn-warning {
    background: linear-gradient(135deg, #92400e, var(--accent-orange));
    color: #fff;
    box-shadow: 0 2px 12px rgba(251, 146, 60, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(251, 146, 60, 0.2);
}

.btn-warning:hover:not(:disabled) {
    box-shadow: 0 4px 22px rgba(251, 146, 60, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

[data-theme="light"] .confirm-sub {
    opacity: 0.65;
}

/* ═══════════════════════════════════════════════════════════════════
   MAP TOASTS (deviation in-page notification)
   ═══════════════════════════════════════════════════════════════════ */
.toast-container {
    position: absolute;
    bottom: 40px;
    right: 16px;
    z-index: 600;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    pointer-events: none;
    max-width: 320px;
}

.map-toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent-red);
    border-radius: 8px;
    padding: 10px 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, .5);
    pointer-events: all;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity .35s, transform .35s;
}

.map-toast.visible {
    opacity: 1;
    transform: translateX(0);
}

.toast-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 700;
}

.toast-body {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.5;
}

.toast-actions {
    display: flex;
    gap: 6px;
}

/* ═══════════════════════════════════════════════════════════════════
   LIGHT THEME — Clean Modern Cloud
   ═══════════════════════════════════════════════════════════════════ */
[data-theme="light"] {
    /* Backgrounds — cool slate-blue, visually distinct */
    --bg-primary: #dce4f3;
    --bg-secondary: #e8f0fa;
    --bg-card: #f3f7ff;
    --bg-panel: rgba(221, 232, 247, 0.98);
    --bg-glass: rgba(79, 70, 229, 0.07);

    /* Borders */
    --border: rgba(90, 115, 165, 0.22);
    --border-active: rgba(79, 70, 229, 0.40);
    --border-subtle: rgba(0, 0, 0, 0.05);

    /* Accents — deeper for light backgrounds */
    --accent-blue: #4f46e5;
    /* indigo-600  */
    --accent-cyan: #0891b2;
    /* cyan-600    */
    --accent-green: #167050;
    /* muted forest emerald */
    --accent-orange: #a85c00;
    /* muted dark amber     */
    --accent-red: #dc2626;
    /* red-600     */
    --accent-violet: #7c3aed;
    /* violet-600  */
    --accent-dim: #94a3b8;
    /* slate-400   */

    /* Text */
    --text-primary: #0d1b35;
    /* deep navy */
    --text-secondary: #3e5070;
    /* medium navy-gray */
    --text-dim: #7b93b5;
    /* muted blue */
}

[data-theme="light"] body::before {
    background:
        radial-gradient(ellipse at 25% 0%, rgba(79, 70, 229, 0.07) 0%, transparent 55%),
        radial-gradient(ellipse at 75% 100%, rgba(124, 58, 237, 0.05) 0%, transparent 55%);
}

[data-theme="light"] .top-bar {
    background: rgba(214, 228, 246, 0.94);
    border-bottom-color: rgba(90, 120, 170, 0.25);
    box-shadow: 0 1px 0 rgba(90, 120, 170, 0.15), 0 4px 20px rgba(15, 30, 70, 0.08);
}

[data-theme="light"] .left-panel {
    background: rgba(219, 231, 248, 0.97);
    border-right-color: rgba(90, 120, 170, 0.22);
    box-shadow: 2px 0 24px rgba(15, 30, 70, 0.06);
}

[data-theme="light"] .leaflet-tile {
    filter: none;
}

[data-theme="light"] #map {
    background: #cdd8ee;
}

[data-theme="light"] .map-overlay {
    background: rgba(218, 230, 248, 0.85);
}

[data-theme="light"] .map-footer {
    background: rgba(214, 228, 246, 0.93);
    border-top-color: rgba(90, 120, 170, 0.28);
    color: var(--text-secondary);
}

[data-theme="light"] .modal-box {
    box-shadow: 0 0 0 1px rgba(90, 115, 165, 0.15), 0 16px 60px rgba(15, 30, 70, 0.16), 0 4px 16px rgba(15, 30, 70, 0.08);
}

[data-theme="light"] .info-item {
    background: #e8f0fb;
    border-color: rgba(90, 115, 165, 0.20);
}

[data-theme="light"] .voyage-section {
    border-bottom-color: rgba(90, 115, 165, 0.18);
}

[data-theme="light"] .voyage-card {
    border-bottom-color: rgba(90, 115, 165, 0.16);
}

[data-theme="light"] .voyage-card:hover {
    background: rgba(79, 70, 229, 0.04);
}

[data-theme="light"] .voyage-card.selected {
    background: rgba(79, 70, 229, 0.06);
    box-shadow: inset 3px 0 0 var(--accent-blue);
}

[data-theme="light"] .voyage-card.deviating {
    background: rgba(220, 38, 38, 0.05);
    box-shadow: inset 3px 0 0 var(--accent-red);
}

[data-theme="light"] .btn-primary {
    background: linear-gradient(135deg, #3730a3 0%, #4f46e5 100%);
    box-shadow: 0 2px 10px rgba(79, 70, 229, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

[data-theme="light"] .btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #312e81 0%, #6366f1 100%);
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.42);
}

[data-theme="light"] .input-group input {
    background: #ecf2fc;
    border-color: rgba(90, 120, 165, 0.35);
    color: var(--text-primary);
}

[data-theme="light"] .input-group input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.10);
    background: #f3f7ff;
}

[data-theme="light"] .icon-btn {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(90, 115, 165, 0.32);
    color: var(--text-secondary);
}

[data-theme="light"] .icon-btn:hover {
    background: rgba(79, 70, 229, 0.07);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

[data-theme="light"] .type-btn {
    background: #e8f0fb;
    border-color: rgba(90, 115, 165, 0.28);
    color: var(--text-secondary);
}

[data-theme="light"] .type-btn.active {
    background: rgba(79, 70, 229, 0.10);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.14);
}

[data-theme="light"] .type-btn:hover:not(.active) {
    background: rgba(79, 70, 229, 0.05);
    border-color: rgba(90, 115, 165, 0.50);
}

[data-theme="light"] .leaflet-control-zoom a {
    background: rgba(240, 247, 255, 0.97) !important;
    color: var(--text-primary) !important;
    border-bottom-color: rgba(90, 115, 165, 0.28) !important;
}

[data-theme="light"] .leaflet-control-attribution {
    background: rgba(214, 228, 246, 0.92) !important;
    color: var(--text-secondary) !important;
}

[data-theme="light"] .leaflet-popup-content-wrapper {
    background: #f3f7ff !important;
    border-color: rgba(90, 115, 165, 0.25) !important;
    color: var(--text-primary) !important;
    box-shadow: 0 4px 20px rgba(15, 30, 70, 0.14) !important;
}

[data-theme="light"] .leaflet-popup-tip {
    background: #f3f7ff !important;
}

[data-theme="light"] .bell-drawer {
    background: rgba(221, 232, 247, 0.98);
    border-left-color: rgba(90, 115, 165, 0.28);
    box-shadow: -4px 0 24px rgba(15, 30, 70, 0.10);
}

[data-theme="light"] .modal-overlay {
    background: rgba(15, 23, 42, 0.45);
}

/* MAP FOOTER v2 — duplicate removed; primary definition above */

/* ═══════════════════════════════════════════════════════════════════
   REGION ENTITY LIST  (flights / vessels list inside region scan modal)
   ═══════════════════════════════════════════════════════════════════ */

/* ── Filter bar ─────────────────────────────────────────────────── */
#regionFilterBar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 0 4px;
    align-items: center;
}

.rf-toggle-group {
    display: flex;
    gap: 3px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2px;
}

.rf-toggle {
    padding: 4px 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .06em;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    font-family: var(--font-ui);
}

.rf-toggle.active {
    background: var(--accent-blue);
    color: #fff;
}

.rf-toggle.active-dev {
    background: #f87171;
    color: #fff;
}

.rf-input {
    padding: 4px 9px;
    font-size: 11px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-mono);
    width: 100px;
    transition: border-color var(--transition);
}

.rf-input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.rf-input::placeholder {
    color: var(--text-dim);
}

.rf-count {
    margin-left: auto;
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: .04em;
}

/* ── Entity list ────────────────────────────────────────────────── */
#regionEntityList {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
}

.region-entity-section-hd {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .12em;
    color: var(--text-dim);
    text-transform: uppercase;
    padding: 9px 12px 7px;
    background: rgba(0, 0, 0, .18);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1;
}

.region-entity-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

.region-entity-row:last-child {
    border-bottom: none;
}

.region-entity-row:hover {
    background: rgba(255, 255, 255, .04);
}

.region-entity-row.region-entity-row-dev {
    background: rgba(248, 113, 113, .05);
}

.region-entity-row.region-entity-row-anchored {
    background: rgba(100, 116, 139, 0.05);
    opacity: 0.8;
}

.region-entity-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 26px;
    color: var(--text-secondary);
}

.region-entity-icon svg {
    width: 16px;
    height: 16px;
}

.region-entity-info {
    flex: 1;
    min-width: 0;
}

.region-entity-name {
    font-size: 13px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.region-entity-dev-tag {
    font-size: 10px;
    color: #f87171;
    font-family: var(--font-sans, sans-serif);
    font-weight: 800;
    letter-spacing: .06em;
    margin-left: 4px;
}

.region-entity-meta {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.region-entity-show-btn {
    flex-shrink: 0;
    padding: 4px 10px;
    font-size: 10px;
    background: rgba(129, 140, 248, .10);
    border: 1px solid var(--accent-blue);
    color: var(--accent-blue);
    border-radius: var(--radius);
    cursor: pointer;
    white-space: nowrap;
    letter-spacing: .05em;
    transition: background var(--transition);
}

.region-entity-show-btn:hover {
    background: rgba(129, 140, 248, .22);
}

.region-entity-row.region-entity-row-sel {
    background: rgba(129, 140, 248, .13);
    border-left: 3px solid var(--accent-blue);
}

/* ── Map highlight ring (pulsing ring around selected entity on map) ── */
@keyframes entity-pulse {
    0% {
        transform: scale(1);
        opacity: .9;
    }

    60% {
        transform: scale(1.55);
        opacity: .45;
    }

    100% {
        transform: scale(1);
        opacity: .9;
    }
}

.entity-highlight-ring {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 0 0 2px rgba(129, 140, 248, .7), 0 0 14px 4px rgba(129, 140, 248, .55);
    animation: entity-pulse 1.4s ease-in-out infinite;
    pointer-events: none;
}

.entity-highlight-ring.ring-dev {
    border-color: #f87171;
    box-shadow: 0 0 0 2px rgba(248, 113, 113, .7), 0 0 14px 4px rgba(248, 113, 113, .55);
}

/* ═══════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 720px) {
    :root {
        --panel-w: 100%;
        --header-h: 48px;
    }

    .layout {
        flex-direction: column;
    }

    .left-panel {
        width: 100%;
        min-width: unset;
        max-height: 38vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
        order: 2;
        flex-direction: column;
    }

    .map-container {
        flex: 1;
        order: 1;
        min-height: 0;
    }

    .bell-drawer {
        width: 100%;
    }

    .modal-box {
        max-width: 100%;
        margin: 0;
        border-radius: 12px 12px 0 0;
        align-self: flex-end;
    }

    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .toast-container {
        right: 8px;
        left: 8px;
        max-width: unset;
    }

    .detail-header-actions {
        gap: 6px;
    }
}


/* ═══════════════════════════════════════════════════════════════════
   SHIELD BUTTON (top-bar governance)
   ═══════════════════════════════════════════════════════════════════ */
.shield-btn {
    position: relative;
}

.shield-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--accent-orange);
    color: #000;
    font-size: 9px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 0 6px var(--accent-orange);
}

/* ═══════════════════════════════════════════════════════════════════
   REGION BUILDER OVERLAY
   ═══════════════════════════════════════════════════════════════════ */
.rb-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

/* ── Header ─────────────────────────────── */
.rb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 52px;
    flex-shrink: 0;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px);
    gap: 16px;
}

.rb-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .1em;
    color: var(--accent-blue);
    filter: drop-shadow(0 0 8px var(--accent-blue));
    flex-shrink: 0;
}

.rb-header-center {
    flex: 1;
    text-align: center;
}

.rb-shape-count-indicator {
    font-size: 12px;
    color: var(--text-secondary);
    letter-spacing: .04em;
}

.rb-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.rb-gov-save-btn {
    font-size: 11px;
    padding: 6px 14px;
    letter-spacing: .06em;
}

/* ── Body ───────────────────────────────── */
.rb-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ── Sidebar ────────────────────────────── */
.rb-sidebar {
    width: 270px;
    min-width: 270px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding-bottom: 20px;
}

.rb-sidebar-section {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.rb-section-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .14em;
    color: var(--accent-blue);
    margin-bottom: 10px;
    text-transform: uppercase;
}

.rb-section-sublabel {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .1em;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
}

.rb-section-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.rb-section-label-row .rb-section-label {
    margin-bottom: 0;
}

.rb-separator {
    height: 1px;
    background: var(--border);
    margin: 0;
    flex-shrink: 0;
}

/* ── Mode tabs ──────────────────────────── */
.rb-mode-tabs {
    display: flex;
    gap: 4px;
}

.rb-mode-tab {
    flex: 1;
    padding: 7px 6px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .06em;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.rb-mode-tab:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.rb-mode-tab.active {
    background: rgba(129, 140, 248, 0.12);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    box-shadow: 0 0 10px rgba(129, 140, 248, 0.15);
}

/* ── Draw tool buttons ──────────────────── */
.rb-tool-btns {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 10px;
}

.rb-tool-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.rb-tool-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background: rgba(129, 140, 248, 0.06);
}

.rb-tool-btn.active {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background: rgba(129, 140, 248, 0.13);
}

/* ── Tip text ───────────────────────────── */
.rb-tip {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.55;
    padding: 6px 0;
}

.rb-tip-warn {
    color: var(--accent-orange);
}

/* ── Shapes list ────────────────────────── */
.rb-shapes-section {
    flex: 1;
    min-height: 60px;
}

.rb-shapes-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-height: 36px;
    margin-bottom: 8px;
}

.rb-empty-shapes {
    font-size: 11px;
    color: var(--text-dim);
    padding: 8px 0;
    text-align: center;
}

.rb-shape-chip {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    font-size: 11px;
    color: var(--text-secondary);
    animation: fadeInUp .15s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.rb-chip-icon {
    font-size: 13px;
    flex-shrink: 0;
}

.rb-chip-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.rb-chip-remove {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 0 2px;
    font-size: 11px;
    transition: color var(--transition);
}

.rb-chip-remove:hover {
    color: var(--accent-red);
}

.rb-clear-btn {
    font-size: 10px;
    color: var(--accent-red);
    background: none;
    border: 1px solid rgba(248, 113, 113, 0.3);
    border-radius: var(--radius);
    padding: 5px 10px;
    cursor: pointer;
    width: 100%;
    letter-spacing: .06em;
    font-weight: 600;
    transition: all var(--transition);
}

.rb-clear-btn:hover {
    background: rgba(248, 113, 113, 0.1);
    border-color: var(--accent-red);
}

/* ── Countries search ───────────────────── */
.rb-countries-search {
    margin-top: 8px;
}

.search-input {
    width: 100%;
    padding: 7px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 12px;
    font-family: var(--font-ui);
    outline: none;
    transition: border-color var(--transition);
}

.search-input:focus {
    border-color: var(--accent-blue);
}

/* ── Criticality selector ───────────────── */
.rb-crit-selector {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rb-crit-btn {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-align: left;
    transition: all var(--transition);
}

.rb-crit-btn:hover {
    border-color: var(--crit-color, var(--accent-blue));
    color: var(--crit-color, var(--accent-blue));
}

.rb-crit-btn.active {
    border-color: var(--crit-color, var(--accent-blue));
    color: var(--crit-color, var(--accent-blue));
    background: color-mix(in srgb, var(--crit-color, var(--accent-blue)) 12%, transparent);
}

.rb-crit-btn[data-crit="1"] {
    --crit-color: #34d399;
}

.rb-crit-btn[data-crit="2"] {
    --crit-color: #fbbf24;
}

.rb-crit-btn[data-crit="3"] {
    --crit-color: #fb923c;
}

.rb-crit-btn[data-crit="4"] {
    --crit-color: #f87171;
}

/* ── Error + Start btn ──────────────────── */
.rb-modal-error {
    font-size: 12px;
    color: var(--accent-red);
    padding: 8px 12px;
    background: rgba(248, 113, 113, 0.08);
    border: 1px solid rgba(248, 113, 113, 0.25);
    border-radius: var(--radius);
    margin: 8px 0;
}

.rb-start-btn {
    width: 100%;
    margin-top: 12px;
    letter-spacing: .08em;
}

.rb-start-btn:disabled {
    opacity: 0.38;
    cursor: not-allowed;
    filter: none;
    box-shadow: none;
}

/* ── Map area ───────────────────────────── */
.rb-map-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#rbMap {
    width: 100%;
    height: 100%;
}

/* ── Governance regions overlay on builder map ── */
.rb-gov-overlay {
    position: absolute;
    bottom: 24px;
    right: 16px;
    z-index: 1000;
    background: rgba(10, 10, 10, 0.85);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    backdrop-filter: blur(12px);
    max-width: 240px;
}

.rb-gov-overlay-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .12em;
    color: var(--accent-blue);
    margin-bottom: 8px;
    text-transform: uppercase;
}

.rb-gov-legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    color: var(--text-secondary);
    padding: 3px 0;
}

.rb-gov-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.rb-gov-crit-tag {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .08em;
    margin-left: auto;
    flex-shrink: 0;
}

/* ── Country tooltip ────────────────────── */
.rb-country-tip {
    background: rgba(10, 10, 10, 0.9) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
    font-size: 12px !important;
    font-family: var(--font-ui) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5) !important;
    border-radius: 6px !important;
    padding: 5px 10px !important;
}

/* ── "Open Region Builder" button in session modal ── */
.rb-open-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    font-size: 13px;
    padding: 12px 20px;
    letter-spacing: .06em;
    box-shadow: 0 0 20px rgba(129, 140, 248, 0.25);
}

.rb-or-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-dim);
    font-size: 10px;
    letter-spacing: .08em;
    font-weight: 600;
    margin-bottom: 10px;
}

.rb-or-divider::before,
.rb-or-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}


/* ═══════════════════════════════════════════════════════════════════
   GOVERNANCE DRAWER
   ═══════════════════════════════════════════════════════════════════ */
.gov-drawer {
    position: fixed;
    top: var(--header-h);
    right: 0;
    bottom: 0;
    width: 380px;
    z-index: 1600;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    backdrop-filter: blur(24px) saturate(140%);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(0.4, 0, 0.2, 1);
}

.gov-drawer.open {
    transform: translateX(0);
}

.gov-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.gov-drawer-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .1em;
    color: var(--accent-blue);
}

.gov-drawer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.gov-drawer-subtitle {
    font-size: 11px;
    color: var(--text-secondary);
    padding: 10px 20px;
    border-bottom: 1px solid var(--border-subtle);
    line-height: 1.55;
}

.gov-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ── Governance region card ─────────────── */
.gov-region-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color var(--transition);
}

.gov-region-card:hover {
    border-color: var(--border-active);
}

.gov-region-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
}

.gov-region-indicator {
    width: 4px;
    min-height: 36px;
    border-radius: 2px;
    flex-shrink: 0;
    margin-top: 1px;
    box-shadow: 0 0 8px currentColor;
}

.gov-region-info {
    flex: 1;
    min-width: 0;
}

.gov-region-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
}

.gov-region-desc {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.45;
}

.gov-region-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.gov-crit-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 20px;
    border: 1px solid var(--crit-col, var(--accent-blue));
    color: var(--crit-col, var(--accent-blue));
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .1em;
    background: color-mix(in srgb, var(--crit-col, var(--accent-blue)) 10%, transparent);
}

.gov-del-btn {
    opacity: 0.5;
    transition: opacity var(--transition);
    font-size: 13px;
}

.gov-del-btn:hover {
    opacity: 1;
}

.gov-region-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    border-top: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.02);
}

.gov-meta-item {
    font-size: 10px;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

/* Light theme overrides */
[data-theme="light"] .rb-overlay,
[data-theme="light"] .rb-sidebar,
[data-theme="light"] .rb-header {
    background: #f8f9fa;
    border-color: #e5e7eb;
}

[data-theme="light"] .rb-shape-chip {
    background: #fff;
    border-color: #e5e7eb;
}

[data-theme="light"] .rb-gov-overlay {
    background: rgba(255, 255, 255, 0.92);
    border-color: #e5e7eb;
    color: #111;
}

[data-theme="light"] .gov-drawer {
    background: rgba(248, 249, 250, 0.97);
    border-color: #e5e7eb;
}

[data-theme="light"] .gov-region-card {
    background: #fff;
    border-color: #e5e7eb;
}

/* ═══════════════════ ANOMALY SCORE SECTION ═══════════════════════════════ */

#anomalySection {
    margin: 10px 0 6px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 8px;
}

.anomaly-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.anomaly-label {
    font-size: 10px;
    letter-spacing: 0.08em;
    color: #aaa;
    font-weight: 600;
}

.anomaly-score-val {
    font-size: 22px;
    font-weight: 700;
    color: #e5e7eb;
    line-height: 1;
}

.anomaly-severity {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 2px 7px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    color: #aaa;
}

.anomaly-severity.sev-critical {
    background: rgba(239, 68, 68, 0.20);
    color: #ef4444;
}

.anomaly-severity.sev-high {
    background: rgba(249, 115, 22, 0.20);
    color: #f97316;
}

.anomaly-severity.sev-warning {
    background: rgba(234, 179, 8, 0.20);
    color: #eab308;
}

.anomaly-severity.sev-info {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

/* Risk score bar */
.risk-bar-wrap {
    margin-bottom: 10px;
}

.risk-bar {
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.10);
    overflow: hidden;
}

.risk-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease, background 0.5s ease;
}

.risk-bar-fill.fill-info {
    background: #60a5fa;
}

.risk-bar-fill.fill-warning {
    background: #eab308;
}

.risk-bar-fill.fill-high {
    background: #f97316;
}

.risk-bar-fill.fill-critical {
    background: #ef4444;
}

/* Component chips */
.component-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 6px;
}

.comp-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    border: 1px solid transparent;
    transition: opacity 0.15s, transform 0.1s;
    line-height: 1.4;
    background: transparent;
}

.comp-chip:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.chip-off {
    background: rgba(255, 255, 255, 0.05);
    color: #666;
    border-color: rgba(255, 255, 255, 0.08);
}

.chip-info {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.3);
}

.chip-warning {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
    border-color: rgba(234, 179, 8, 0.3);
}

.chip-high {
    background: rgba(249, 115, 22, 0.15);
    color: #f97316;
    border-color: rgba(249, 115, 22, 0.3);
}

.chip-critical {
    background: rgba(239, 68, 68, 0.18);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.35);
}

/* Inline chips in alert rows */
.inline-chip {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 4px;
    vertical-align: middle;
}

/* Drilldown panel */
.comp-drilldown {
    margin-top: 8px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 6px;
    animation: fadeIn 0.15s ease;
}

.drilldown-title {
    font-size: 12px;
    font-weight: 700;
    color: #e5e7eb;
    margin-bottom: 4px;
}

.drilldown-rationale {
    font-size: 12px;
    color: #9ca3af;
    margin-bottom: 8px;
    line-height: 1.5;
}

/* Raw values table */
.raw-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.raw-table td {
    padding: 3px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.raw-table .raw-key {
    color: #6b7280;
    width: 45%;
}

.raw-table .raw-val {
    color: #d1d5db;
    font-family: monospace;
}

/* Light-theme overrides */
[data-theme="light"] #anomalySection {
    background: rgba(0, 0, 0, 0.03);
    border-color: #e5e7eb;
}

[data-theme="light"] .comp-drilldown {
    background: rgba(0, 0, 0, 0.04);
    border-color: #e5e7eb;
}

[data-theme="light"] .anomaly-label {
    color: #6b7280;
}

[data-theme="light"] .anomaly-score-val {
    color: #111827;
}

[data-theme="light"] .drilldown-rationale {
    color: #374151;
}

[data-theme="light"] .raw-table .raw-key {
    color: #9ca3af;
}

[data-theme="light"] .raw-table .raw-val {
    color: #1f2937;
}

[data-theme="light"] .chip-off {
    background: rgba(0, 0, 0, 0.04);
    color: #9ca3af;
    border-color: #e5e7eb;
}

/* ─── Threat Level Badges ──────────────────────────────────────────────────── */
.threat-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.threat-badge[data-level="1"] {
    background: rgba(20, 83, 45, .15);
    color: #4ade80;
    border: 1px solid #14532d;
}

.threat-badge[data-level="2"] {
    background: rgba(14, 79, 92, .15);
    color: #22d3ee;
    border: 1px solid #0e4f5c;
}

.threat-badge[data-level="3"] {
    background: rgba(120, 53, 15, .2);
    color: #fbbf24;
    border: 1px solid #78350f;
}

.threat-badge[data-level="4"] {
    background: rgba(124, 45, 18, .2);
    color: #f97316;
    border: 1px solid #7c2d12;
}

.threat-badge[data-level="5"] {
    background: rgba(69, 10, 10, .25);
    color: #ef4444;
    border: 1px solid #7f1d1d;
    animation: ring-pulse 1s infinite;
}

/* ─── AI Modal Tab ─────────────────────────────────────────────────────────── */
.modal-tab-ai {
    border-left: 1px solid var(--border, #1e293b);
    margin-left: 4px;
    padding-left: 10px;
}

.tab-badge-threat {
    background: transparent;
    color: #fbbf24;
    font-weight: 700;
    font-size: 0.7rem;
    margin-left: 4px;
}

/* ─── Run-AI button ────────────────────────────────────────────────────────── */
.btn-ai-assess {
    background: #1e3a5f;
    color: #60a5fa;
    border: 1px solid #1d4ed8;
    border-radius: 5px;
    padding: 4px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.btn-ai-assess:hover {
    background: #1d4ed8;
    color: #fff;
}

.btn-ai-assess:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ─── AI Assessment Panel ──────────────────────────────────────────────────── */
.ai-tab-header {
    display: flex;
    flex-direction: column;
    padding: 0 0 12px 0;
    border-bottom: 1px solid var(--border, #1e293b);
    margin-bottom: 14px;
}

.ai-tab-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.ai-tab-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .06em;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ai-section-label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-dim, #64748b);
    text-transform: uppercase;
}

.ai-tab-sub {
    font-size: 0.75rem;
    color: var(--text-dim, #64748b);
    min-height: 1em;
}

.ai-assess-card {
    background: var(--bg-surface, #1e293b);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 10px;
}

.ai-headline {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 8px 0 10px 0;
    line-height: 1.4;
    color: var(--text, #e2e8f0);
}

.ai-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-dim, #64748b);
    margin: 12px 0 5px 0;
    text-transform: uppercase;
}

.ai-observations-list,
.ai-intel-list,
.ai-recommended-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ai-obs-item,
.ai-intel-item,
.ai-rec-item {
    font-size: 0.8rem;
    padding: 5px 0;
    border-bottom: 1px solid rgba(15, 23, 42, .4);
    color: var(--text, #e2e8f0);
    line-height: 1.45;
}

.ai-obs-item::before {
    content: "•";
    margin-right: 7px;
    color: var(--text-dim, #64748b);
}

.ai-intel-item::before {
    content: "⚡";
    margin-right: 6px;
}

.ai-rec-item::before {
    content: "→";
    margin-right: 6px;
    color: #60a5fa;
}

.ai-entities-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    margin: 4px 0;
}

.ai-entities-table th {
    text-align: left;
    font-size: 0.65rem;
    color: var(--text-dim, #64748b);
    font-weight: 600;
    padding: 3px 6px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.ai-entities-table td {
    padding: 5px 6px;
    border-bottom: 1px solid rgba(15, 23, 42, .4);
    color: var(--text, #e2e8f0);
    vertical-align: top;
}

.ai-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.7rem;
    color: var(--text-dim, #64748b);
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(15, 23, 42, .4);
}

.ai-review-banner {
    background: rgba(69, 10, 10, .25);
    border: 1px solid #7f1d1d;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.8rem;
    color: #fca5a5;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-empty-state {
    text-align: center;
    padding: 36px 16px;
    color: var(--text-dim, #64748b);
    font-size: 0.85rem;
    line-height: 1.6;
}

.ai-loading-state {
    text-align: center;
    padding: 28px 16px;
    color: #60a5fa;
    font-size: 0.85rem;
}

/* ─── AI Assessment History Modal ─────────────────────────────────────────── */
.ai-history-modal {
    width: min(1200px, 97vw);
    height: min(800px, 94vh);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    max-width: none;
}

.ai-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 22px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 12px;
    background: var(--bg-secondary);
}

.ai-history-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.ai-history-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--accent-blue);
}

.ai-history-region-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 500px;
}

.ai-history-region-sub {
    font-size: 0.68rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-top: 2px;
}

.ai-history-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.btn-ai-history-run {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 7px 16px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: .5px;
    cursor: pointer;
    transition: filter .2s, transform .1s;
    white-space: nowrap;
}

.btn-ai-history-run:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.btn-ai-history-run:hover:not(:disabled) {
    filter: brightness(1.15);
    transform: translateY(-1px);
}

.btn-ai-history-run:active:not(:disabled) {
    transform: translateY(0);
}

.ai-history-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Left: assessment list ── */
.ai-history-list-panel {
    width: 290px;
    min-width: 230px;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    padding: 10px 8px;
    flex-shrink: 0;
    background: var(--bg-primary);
}

.ai-history-list-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 2px 6px 8px;
}

.ai-history-item {
    cursor: pointer;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 4px;
    border: 1px solid transparent;
    transition: background .14s, border-color .14s;
}

.ai-history-item:hover {
    background: rgba(99, 102, 241, .1);
    border-color: rgba(99, 102, 241, .25);
}

.ai-history-item.active {
    background: rgba(79, 70, 229, .16);
    border-color: var(--accent-blue);
}

.ai-history-item-time {
    font-size: 0.67rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.ai-history-item-headline {
    font-size: 0.8rem;
    color: var(--text-primary);
    line-height: 1.38;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.ai-history-item-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}

/* ── Right: detail panel ── */
.ai-history-detail-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    background: var(--bg-secondary);
}

/* Sticky detail header (headline + threat badge) */
.ai-detail-top {
    padding: 18px 24px 0;
    flex-shrink: 0;
}

.ai-detail-date-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.ai-detail-date {
    font-size: 0.68rem;
    color: var(--text-secondary);
}

/* Language toggle (EN / عربي) */
.ai-lang-toggle {
    display: flex;
    gap: 2px;
    background: var(--surface-2, rgba(255, 255, 255, .06));
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px;
}

.ai-lang-btn {
    padding: 3px 10px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: .4px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.ai-lang-btn:hover {
    color: var(--text-primary);
}

.ai-lang-btn.active {
    background: var(--accent-blue);
    color: #fff;
}

.ai-detail-headline {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.45;
    margin-bottom: 14px;
}

/* Section tabs */
.ai-detail-tabs {
    display: flex;
    gap: 2px;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.ai-detail-tabs::-webkit-scrollbar {
    display: none;
}

.ai-detail-tab {
    padding: 8px 14px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: .6px;
    text-transform: uppercase;
    color: var(--text-secondary);
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
}

.ai-detail-tab:hover {
    color: var(--text-primary);
}

.ai-detail-tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}

.ai-detail-tab .tab-count {
    display: inline-block;
    background: var(--border);
    color: var(--text-secondary);
    border-radius: 9px;
    padding: 0 5px;
    font-size: 0.6rem;
    margin-left: 4px;
    vertical-align: middle;
}

.ai-detail-tab.active .tab-count {
    background: rgba(79, 70, 229, .25);
    color: var(--accent-blue);
}

/* Tab content area */
.ai-detail-tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

/* Table styles for detail panels */
.ai-detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

/* RTL table variant — text-align follows writing direction */
.ai-detail-table.rtl th,
.ai-detail-table.rtl td {
    text-align: right;
    padding: 0 0 8px 14px;
}

.ai-detail-table.rtl td {
    padding: 9px 0 9px 14px;
}

/* RTL: accent border on right instead of left */
[dir="rtl"] .ai-detail-list li {
    border-left: none;
    border-right: 3px solid var(--accent-blue);
    text-align: right;
}

[dir="rtl"] .ai-detail-list.intel li {
    border-right-color: #f59e0b;
    border-left: none;
}

[dir="rtl"] .ai-detail-list.actions li {
    border-right-color: #34d399;
    border-left: none;
}

/* RTL detail meta row */
[dir="rtl"] .ai-detail-meta {
    direction: rtl;
    text-align: right;
}

/* RTL: flip the detail-date-row so toggle sits on the left */
[dir="rtl"] .ai-detail-date-row {
    flex-direction: row-reverse;
}

.ai-detail-table thead tr {
    border-bottom: 1px solid var(--border);
}

.ai-detail-table th {
    text-align: left;
    font-size: 0.63rem;
    font-weight: 700;
    letter-spacing: .8px;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 0 10px 8px 0;
}

.ai-detail-table td {
    padding: 9px 10px 9px 0;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: top;
    line-height: 1.55;
}

.ai-detail-table tbody tr:last-child td {
    border-bottom: none;
}

.ai-detail-table tbody tr:hover td {
    background: rgba(255, 255, 255, .02);
}

/* Risk-level pill */
.risk-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
}

.risk-pill.low {
    background: rgba(52, 211, 153, .15);
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, .3);
}

.risk-pill.medium {
    background: rgba(251, 191, 36, .12);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, .3);
}

.risk-pill.high {
    background: rgba(249, 115, 22, .13);
    color: #f97316;
    border: 1px solid rgba(249, 115, 22, .3);
}

.risk-pill.critical {
    background: rgba(239, 68, 68, .14);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, .35);
}

/* List items in detail tabs */
.ai-detail-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-detail-list li {
    padding: 10px 14px;
    border-radius: 7px;
    background: rgba(255, 255, 255, .03);
    border-left: 3px solid var(--accent-blue);
    color: var(--text-primary);
    font-size: 0.85rem;
    line-height: 1.55;
}

.ai-detail-list.intel li {
    border-left-color: var(--accent-cyan);
}

.ai-detail-list.actions li {
    border-left-color: var(--accent-green);
}

/* Asset name cell */
.ai-asset-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.ai-asset-id {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Threat vector chip */
.ai-threat-vector {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Meta row */
.ai-detail-meta {
    display: flex;
    gap: 18px;
    font-size: 0.72rem;
    color: var(--text-secondary);
    padding: 14px 0 4px;
    border-top: 1px solid var(--border);
    margin-top: 16px;
    flex-wrap: wrap;
}

/* Review banner */
.ai-review-banner-detail {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(239, 68, 68, .1);
    border: 1px solid rgba(239, 68, 68, .3);
    border-radius: 7px;
    padding: 8px 14px;
    font-size: 0.8rem;
    color: #fca5a5;
    margin-bottom: 12px;
}

/* Footer / status bar */
.ai-history-footer {
    border-top: 1px solid var(--border);
    padding: 9px 22px;
    font-size: 0.76rem;
    color: #60a5fa;
    flex-shrink: 0;
    background: var(--bg-secondary);
}

/* Region-card AI button */
.card-ai-btn {
    font-size: 0.85rem;
    line-height: 1;
    padding: 3px 5px;
}

/* Light-theme overrides for history modal */
[data-theme="light"] .ai-history-list-panel {
    background: #f4f6fb;
}

[data-theme="light"] .ai-history-detail-panel {
    background: #ffffff;
}

[data-theme="light"] .ai-history-header {
    background: #ffffff;
}

[data-theme="light"] .ai-detail-table td {
    color: var(--text-primary);
}

[data-theme="light"] .ai-detail-list li {
    background: rgba(0, 0, 0, .03);
    color: var(--text-primary);
}

[data-theme="light"] .risk-pill.low {
    background: rgba(22, 112, 80, .1);
    color: #167050;
}

[data-theme="light"] .risk-pill.medium {
    background: rgba(168, 92, 0, .1);
    color: #a85c00;
}

[data-theme="light"] .risk-pill.high {
    background: rgba(176, 56, 10, .1);
    color: #b0380a;
}

[data-theme="light"] .risk-pill.critical {
    background: rgba(185, 28, 28, .1);
    color: #b91c1c;
}

/* ═══════════════════════════════════════════════════════════════════
   LIGHT THEME — Muted brightness overrides for hardcoded colors
   (green, yellow/amber, orange that appear too vivid on light bg)
   ═══════════════════════════════════════════════════════════════════ */

/* Alert severity — border-left stripes */
[data-theme="light"] .alert-sev-warning {
    border-left-color: #8a6000;
}

[data-theme="light"] .alert-sev-high {
    border-left-color: #b05212;
}

[data-theme="light"] .alert-sev-critical {
    border-left-color: #b91c1c;
}

/* Alert severity pills */
[data-theme="light"] .alert-sev-pill.sev-warning {
    background: rgba(138, 96, 0, .12);
    color: #8a6000;
}

[data-theme="light"] .alert-sev-pill.sev-high {
    background: rgba(176, 82, 18, .12);
    color: #b05212;
}

[data-theme="light"] .alert-sev-pill.sev-critical {
    background: rgba(185, 28, 28, .12);
    color: #b91c1c;
}

/* Anomaly / component chips */
[data-theme="light"] .chip-warning {
    background: rgba(138, 96, 0, .10);
    color: #8a6000;
    border-color: rgba(138, 96, 0, .28);
}

[data-theme="light"] .chip-high {
    background: rgba(176, 82, 18, .10);
    color: #b05212;
    border-color: rgba(176, 82, 18, .28);
}

[data-theme="light"] .chip-critical {
    background: rgba(185, 28, 28, .12);
    color: #b91c1c;
    border-color: rgba(185, 28, 28, .30);
}

/* Deviation / ok status boxes */
[data-theme="light"] .ep-dev-box.ep-dev-ok {
    background: rgba(22, 112, 80, .07);
    border-color: rgba(22, 112, 80, .40);
    color: #167050;
}

/* Map legend track lines */
[data-theme="light"] .ep-legend-track {
    background: #167050;
}

[data-theme="light"] .ep-legend-track-vessel {
    background: #167050;
}

/* Route / track toggle active states */
[data-theme="light"] .ep-track-toggle.track-on {
    color: #167050;
    text-shadow: none;
}

/* Drawer — alert cross-track distance */
[data-theme="light"] .drawer-alert-xtd {
    color: var(--accent-orange);
}

/* Connection dot — "connecting" orange glow */
[data-theme="light"] .conn-dot.connected {
    box-shadow: 0 0 5px rgba(22, 112, 80, .45);
}

[data-theme="light"] .conn-dot.connecting {
    box-shadow: 0 0 5px rgba(168, 92, 0, .45);
}

/* Threat badges (AI level labels) */
[data-theme="light"] .threat-badge[data-level="3"] {
    background: rgba(138, 96, 0, .10);
    color: #8a6000;
    border-color: rgba(138, 96, 0, .30);
}

[data-theme="light"] .threat-badge[data-level="4"] {
    background: rgba(176, 82, 18, .10);
    color: #b05212;
    border-color: rgba(176, 82, 18, .30);
}

/* Tab threat-level badge */
[data-theme="light"] .tab-badge-threat {
    color: #8a6000;
}

/* Session card alert count badge (orange glow) */
[data-theme="light"] .alert-count-badge {
    color: var(--accent-orange);
}

/* Threat level 1 (CLEAR / green) — muted for light theme */
[data-theme="light"] .threat-badge[data-level="1"] {
    background: rgba(22, 112, 80, .10);
    color: #167050;
    border-color: rgba(22, 112, 80, .35);
}

/* Threat level 2 (cyan) — muted for light theme */
[data-theme="light"] .threat-badge[data-level="2"] {
    background: rgba(8, 145, 178, .10);
    color: #0e7490;
    border-color: rgba(8, 145, 178, .30);
}

/* AI detail list — actions left-border (green) */
[data-theme="light"] .ai-detail-list.actions li {
    border-left-color: #167050;
}