/* =====================================================================================
   P25 Log Tool — design tokens
   Light is the default; dark applies via [data-theme="dark"] (set before first paint by
   App.razor) and, without JS, via prefers-color-scheme.
   ===================================================================================== */

:root {
    --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    --mono: "JetBrains Mono", "Cascadia Mono", Consolas, Menlo, monospace;

    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-hover: #f1f5f9;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-muted: #64748b;
    --text-subtle: #94a3b8;

    --accent: #0891b2;
    --accent-hover: #0e7490;
    --accent-soft: #ecfeff;
    --accent-soft-border: #a5f3fc;
    --accent-text: #0e7490;
    --on-accent: #ffffff;

    --success: #15803d;
    --success-soft: #dcfce7;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --warning: #b45309;
    --warning-soft: #fef3c7;
    --warning-border: #fcd34d;

    --sidebar-bg: #0f172a;
    --sidebar-text: #cbd5e1;
    --sidebar-muted: #64748b;
    --sidebar-hover: #1e293b;
    --sidebar-active: rgba(34, 211, 238, 0.14);
    --sidebar-active-text: #67e8f9;

    --chart-band: #f8fafc;
    --chart-grid: #eef2f6;
    --chart-link: rgba(71, 85, 105, 0.45);
    --chart-neutral: #cbd5e1;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 10px 30px -10px rgba(15, 23, 42, 0.25);
    --focus: 0 0 0 3px rgba(8, 145, 178, 0.35);

    --sidebar-w: 248px;
    --topbar-h: 56px;

    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #0b1120;
    --surface: #111827;
    --surface-2: #0f172a;
    --surface-hover: #1e293b;
    --border: #1f2a3c;
    --border-strong: #334155;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-subtle: #64748b;

    --accent: #22d3ee;
    --accent-hover: #67e8f9;
    --accent-soft: rgba(34, 211, 238, 0.12);
    --accent-soft-border: rgba(34, 211, 238, 0.35);
    --accent-text: #67e8f9;
    --on-accent: #083344;

    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, 0.14);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.14);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.12);
    --warning-border: rgba(251, 191, 36, 0.35);

    --sidebar-bg: #070b16;
    --sidebar-hover: #111a2e;

    --chart-band: #0f172a;
    --chart-grid: #1e293b;
    --chart-link: rgba(148, 163, 184, 0.5);
    --chart-neutral: #64748b;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 12px 32px -10px rgba(0, 0, 0, 0.7);
    --focus: 0 0 0 3px rgba(34, 211, 238, 0.35);

    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --bg: #0b1120; --surface: #111827; --surface-2: #0f172a; --surface-hover: #1e293b;
        --border: #1f2a3c; --border-strong: #334155; --text: #e2e8f0; --text-muted: #94a3b8; --text-subtle: #64748b;
        --accent: #22d3ee; --accent-hover: #67e8f9; --accent-soft: rgba(34, 211, 238, 0.12); --accent-text: #67e8f9; --on-accent: #083344;
        color-scheme: dark;
    }
}

/* =====================================================================================
   Base
   ===================================================================================== */

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

html, body {
    margin: 0;
    height: 100%;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "cv11", "ss01";
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
strong { font-weight: 600; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }

.icon { flex: 0 0 auto; display: block; }
.muted { color: var(--text-muted); }
.warn { color: var(--warning); }
.spacer { flex: 1 1 auto; }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* =====================================================================================
   App shell: sidebar + top bar
   ===================================================================================== */

.shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
    flex: 0 0 var(--sidebar-w);
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    z-index: 30;
}

.brand {
    display: flex; align-items: center; gap: 10px;
    height: var(--topbar-h);
    padding: 0 18px;
    color: #fff;
    text-decoration: none !important;
    flex: 0 0 auto;
}
.brand img { border-radius: 8px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--sidebar-muted); }

.nav { flex: 1 1 auto; overflow-y: auto; padding: 8px 10px 16px; }
.nav-section {
    margin: 18px 10px 6px;
    font-size: 11px; font-weight: 600;
    letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--sidebar-muted);
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 10px;
    margin: 1px 0;
    border-radius: 8px;
    color: var(--sidebar-text);
    font-weight: 500; font-size: 13.5px;
    text-decoration: none !important;
    transition: background-color .12s, color .12s;
}
.nav-item .icon { opacity: .75; }
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: var(--sidebar-active-text); }
.nav-item.active .icon { opacity: 1; }

.sidebar-footer { padding: 12px 14px 16px; border-top: 1px solid rgba(255, 255, 255, 0.06); }
.theme-switch {
    display: flex; gap: 2px;
    padding: 3px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 9px;
}
.theme-switch button {
    flex: 1 1 0;
    display: flex; justify-content: center;
    padding: 6px 0;
    border: 0; border-radius: 7px;
    background: transparent;
    color: var(--sidebar-muted);
    cursor: pointer;
}
.theme-switch button:hover { color: #fff; }
.theme-switch button.on { background: rgba(255, 255, 255, 0.12); color: #fff; }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    flex: 0 0 var(--topbar-h);
    display: flex; align-items: center; gap: 12px;
    padding: 0 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: 10;
}
.topbar-hint { color: var(--text-subtle); font-size: 13px; }
.icon-btn.nav-toggle { display: none; }

.file-chip {
    display: inline-flex; align-items: center; gap: 8px;
    min-width: 0;
    padding: 5px 12px 5px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 13px;
}
.file-chip-name { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 38vw; }
.file-chip-meta { white-space: nowrap; color: var(--text-subtle); }
.file-chip-meta::before { content: "·"; margin-right: 8px; }

.status-pill {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 13px; font-weight: 500;
    min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; flex: 0 0 auto; }
@keyframes pulse { 50% { opacity: .35; } }

.content { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

.nav-scrim { display: none; }

/* =====================================================================================
   Buttons & inputs
   ===================================================================================== */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 36px;
    padding: 0 14px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit; font-weight: 500; font-size: 13.5px;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: background-color .12s, border-color .12s, color .12s;
    text-decoration: none !important;
}
.btn:hover:not(:disabled):not(.disabled) { background: var(--surface-hover); }
.btn:disabled, .btn.disabled { opacity: .55; cursor: default; pointer-events: none; }
.btn.small { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled):not(.disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.btn.active { background: var(--accent-soft); border-color: var(--accent-soft-border); color: var(--accent-text); }

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    border: 0; border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn.small { width: 28px; height: 28px; }

input[type="text"], input[type="search"], select {
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit; font-size: 13.5px;
    transition: border-color .12s, box-shadow .12s;
}
input[type="text"]:focus, input[type="search"]:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; flex: 0 0 auto; }

/* =====================================================================================
   Pages, cards, notices, empty states
   ===================================================================================== */

.page { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }

.page-header {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    padding: 22px 28px 16px;
    flex: 0 0 auto;
}
.page-heading { min-width: 0; }
.page-header h1 { margin: 0; font-size: 22px; line-height: 1.25; font-weight: 650; letter-spacing: -0.02em; }
.page-subtitle { margin: 4px 0 0; color: var(--text-muted); font-size: 13.5px; max-width: 80ch; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.header-warn { display: inline-flex; align-items: center; gap: 6px; color: var(--warning); font-size: 13px; font-weight: 500; max-width: 70ch; }

.page-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 0 28px 24px; }
.page-body.scroll { overflow: auto; display: block; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.section-title { margin: 26px 0 12px; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }
.section-title:first-child { margin-top: 0; }

.notice {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 9px 14px;
    margin-bottom: 12px;
    background: var(--warning-soft);
    border: 1px solid var(--warning-border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
    flex: 0 0 auto;
}
.notice > .icon { color: var(--warning); }
.notice.error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.notice.error > .icon { color: var(--danger); }

.empty-state {
    margin: auto;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    max-width: 460px;
    padding: 48px 20px;
    text-align: center;
    color: var(--text-muted);
    white-space: pre-line;
}
.empty-state h2 { margin: 6px 0 0; color: var(--text); font-size: 17px; font-weight: 600; }
.empty-state p { margin: 0; }
.empty-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 48px; height: 48px;
    border-radius: 14px;
    background: var(--accent-soft);
    color: var(--accent-text);
}
.empty-state.error .empty-icon { background: var(--danger-soft); color: var(--danger); }
.empty-state.error p { color: var(--text); }

.spinner {
    width: 30px; height: 30px; margin: 0 auto 10px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
.spinner.small { width: 22px; height: 22px; border-width: 2.5px; margin: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================================================
   Overview / import
   ===================================================================================== */

.import-progress { padding: 18px 20px; max-width: 760px; }
.import-progress-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.import-title { font-weight: 600; }

.progress { height: 6px; background: var(--surface-hover); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), #22d3ee); border-radius: 999px; transition: width .25s ease; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.stat { padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat-label { display: inline-flex; align-items: center; gap: 7px; color: var(--text-muted); font-size: 12.5px; font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-meta { color: var(--text-subtle); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat.warn .stat-label .icon { color: var(--warning); }
.stat:not(.warn) .stat-label .icon { color: var(--accent); }

.link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.link-card {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px;
    color: var(--text);
    text-decoration: none !important;
    transition: border-color .15s, box-shadow .15s, transform .15s;
}
.link-card:hover { border-color: var(--accent-soft-border); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.link-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; flex: 0 0 auto;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent-text);
}
.link-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.link-title { font-weight: 600; }
.link-desc { color: var(--text-muted); font-size: 12.5px; }
.link-arrow { color: var(--text-subtle); transition: transform .15s, color .15s; }
.link-card:hover .link-arrow { color: var(--accent-text); transform: translateX(2px); }

.dropzone {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
    max-width: 760px;
    margin: 8px 0 0;
    padding: 56px 24px;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--text-muted);
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background-color .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 56px; height: 56px;
    border-radius: 16px;
    background: var(--accent-soft);
    color: var(--accent-text);
}
.dropzone-text { display: flex; flex-direction: column; gap: 4px; }
.dropzone-text strong { color: var(--text); font-size: 16px; }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone[hidden] { display: none; }
.dropzone.compact { flex-direction: row; justify-content: flex-start; text-align: left; padding: 16px 20px; margin-top: 26px; }
.dropzone.compact .dropzone-icon { width: 40px; height: 40px; border-radius: 10px; }
.dropzone.compact .dropzone-text strong { font-size: 14px; }

/* =====================================================================================
   Tables (replaces the WPF DataGrid)
   ===================================================================================== */

.table-filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-bottom: 12px; flex: 0 0 auto; }
.search-box { position: relative; display: flex; align-items: center; }
.search-box .icon { position: absolute; left: 10px; color: var(--text-subtle); pointer-events: none; }
.table-search { width: min(320px, 70vw); padding-left: 32px !important; }
.table-filter { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.table-filter select { max-width: 220px; height: 34px; }

.table-wrap {
    overflow: auto;
    max-width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.table-wrap.fill { flex: 1 1 auto; min-height: 0; }
.table-wrap:not(.fill) { display: inline-block; }

table.grid { border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 100%; font-variant-numeric: tabular-nums; }
table.grid th {
    position: sticky; top: 0; z-index: 1;
    padding: 10px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 11.5px; font-weight: 600;
    letter-spacing: 0.04em; text-transform: uppercase;
    white-space: nowrap;
    user-select: none;
}
table.grid th.sortable { cursor: pointer; }
table.grid th.sortable:hover { color: var(--text); }
.sort-indicator { color: var(--accent-text); }
table.grid td {
    padding: 0 14px;
    height: 36px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    vertical-align: middle;
}
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover td { background: var(--surface-hover); }
.left { text-align: left; }
.center { text-align: center; }
.right { text-align: right; }
td.pre { white-space: pre; font-family: var(--mono); font-size: 12px; tab-size: 4; padding-top: 8px !important; padding-bottom: 8px !important; line-height: 1.55; }
td.mono { font-family: var(--mono); font-size: 12px; color: var(--text-muted); }
td.no-rows { color: var(--text-muted); text-align: center; height: 80px !important; }
.row-count { color: var(--text-subtle); font-size: 12.5px; padding-top: 8px; flex: 0 0 auto; }

.badge {
    display: inline-flex; align-items: center;
    padding: 1px 9px;
    border-radius: 999px;
    font-size: 11.5px; font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.6;
}
.badge.rx { background: var(--success-soft); color: var(--success); }
.badge.tx { background: var(--danger-soft); color: var(--danger); }

/* =====================================================================================
   Report layouts
   ===================================================================================== */

.summary-columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; overflow: auto; align-items: start; }
.summary-columns > div {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 16px 18px;
}
.summary-columns .section-title { margin-top: 0; }
.plain-list { list-style: none; margin: 0; padding: 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.plain-list li { padding: 5px 0; border-bottom: 1px solid var(--border); }
.plain-list li:last-child { border-bottom: 0; }
.plain-list.pre li { white-space: pre-line; }

.system-summary { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 20px; align-items: start; }
.system-main, .system-side { min-width: 0; }
.system-main .table-wrap, .system-side .table-wrap { display: block; margin-bottom: 4px; }
.system-side .table-wrap { min-width: 180px; max-height: 70vh; }
.system-side .table-search { width: 100%; }

/* =====================================================================================
   Charts, timeline and map panels
   ===================================================================================== */

.page-body.chart-layout, .page-body.map-layout {
    flex-direction: row;
    padding: 0;
    margin: 0 28px 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.page-body.chart-layout > .empty-state, .page-body.map-layout > .empty-state { margin: auto; }

.chart-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.chart-main > .notice { margin: 12px 12px 0; }
.chart-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 10px 6px 6px 10px; }
.chart-host { width: 100%; }

.side-panel {
    flex: 0 0 260px;
    overflow: auto;
    border-left: 1px solid var(--border);
    background: var(--surface-2);
    padding: 16px;
    display: flex; flex-direction: column; gap: 2px;
}
.side-panel.left { border-left: 0; border-right: 1px solid var(--border); flex-basis: 270px; order: -1; }
.side-actions { display: flex; gap: 8px; margin: 6px 0 10px; }
.side-actions .btn { flex: 1 1 0; }
.side-heading { display: block; margin: 18px 0 6px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }
.side-heading.first { margin-top: 0; }

.check { display: flex; align-items: center; gap: 8px; padding: 5px 6px; margin: 0 -6px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.check:hover { background: var(--surface-hover); }
.check.disabled { opacity: .5; cursor: default; }
.check-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.check-count { margin-left: auto; color: var(--text-subtle); font-size: 11.5px; white-space: nowrap; }
.swatch { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 3px; }

/* Timeline side panel */
.timeline-side { flex-basis: 300px; gap: 0; padding: 0; }
.side-section { padding: 16px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; }
.side-section:last-child { border-bottom: 0; }
.preset-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 10px; }

.legend { font-size: 12.5px; gap: 7px; color: var(--text-muted); }
.legend > div { display: flex; align-items: center; gap: 8px; }
.legend strong { color: var(--text); }
.key { display: inline-block; flex: 0 0 auto; }
.key.tri-up, .key.tri-down, .key.tri-up-open { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; }
.key.tri-up { border-bottom: 10px solid currentColor; }
.key.tri-down { border-top: 10px solid currentColor; }
.key.tri-up-open { border-bottom: 10px solid currentColor; opacity: .55; }
.key.link { width: 18px; height: 4px; background: var(--chart-link); border-radius: 2px; }
.key.bar { width: 18px; height: 10px; border-radius: 3px; }

.event-detail { gap: 6px; font-size: 12.5px; }
.event-detail-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 15px; }
.event-section { margin-top: 10px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }
table.fields { border-collapse: collapse; width: 100%; }
table.fields th, table.fields td { text-align: left; vertical-align: top; padding: 4px 4px; border-bottom: 1px solid var(--border); }
table.fields th { font-weight: 500; color: var(--text-muted); white-space: nowrap; width: 42%; }
table.fields td { word-break: break-word; font-variant-numeric: tabular-nums; }
code.raw { display: block; font-family: var(--mono); font-size: 11px; word-break: break-all; background: var(--surface); border: 1px solid var(--border); padding: 6px 8px; border-radius: 6px; }

/* Map */
.map-host { flex: 1 1 auto; min-width: 0; min-height: 300px; }
.threshold-form { display: flex; flex-direction: column; gap: 8px; }
.threshold-form p { margin: 0 0 4px; font-size: 12.5px; }
.threshold-form label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
.threshold-form input { width: 88px; }
.leaflet-container { font-family: var(--font); background: var(--surface-2); }
.leaflet-popup-content { white-space: pre-wrap; font-family: var(--font); font-size: 12px; }
.marker-label {
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    color: var(--text);
    border: none;
    box-shadow: none;
    font-family: var(--font);
    font-size: 11px;
    padding: 1px 5px;
    border-radius: 4px;
}
.marker-label::before { display: none; }
:root[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9); }
:root[data-theme="dark"] .leaflet-control-attribution { background: rgba(17, 24, 39, 0.8); color: var(--text-muted); }
:root[data-theme="dark"] .leaflet-popup-content-wrapper, :root[data-theme="dark"] .leaflet-popup-tip { background: var(--surface); color: var(--text); }

/* Plotly modebar blends into the card */
.modebar { background: transparent !important; }
.modebar-btn path { fill: var(--text-subtle) !important; }
.modebar-btn:hover path, .modebar-btn.active path { fill: var(--accent) !important; }

/* =====================================================================================
   Blazor error / reconnect UI
   ===================================================================================== */

#blazor-error-ui {
    display: none;
    position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
    z-index: 2000;
    align-items: center; gap: 10px;
    padding: 10px 44px 10px 16px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-left: 4px solid var(--danger);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}
#blazor-error-ui .icon { color: var(--danger); }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 14px; top: 9px; color: var(--text-muted); }

/* =====================================================================================
   Narrow screens: sidebar becomes a drawer
   ===================================================================================== */

@media (max-width: 960px) {
    .sidebar {
        position: fixed; inset: 0 auto 0 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: var(--shadow-lg);
    }
    .shell.nav-open .sidebar { transform: none; }
    .shell.nav-open .nav-scrim { display: block; position: fixed; inset: 0; background: rgba(2, 6, 23, 0.45); z-index: 25; }
    .icon-btn.nav-toggle { display: inline-flex; margin-left: -8px; }
    .topbar { padding: 0 16px; gap: 8px; }
    .file-chip-meta { display: none; }
    .page-header { padding: 16px 16px 12px; }
    .page-body { padding: 0 16px 16px; }
    .page-body.chart-layout, .page-body.map-layout { margin: 0 16px 16px; flex-direction: column; }
    .side-panel, .side-panel.left, .timeline-side { flex: 0 0 auto; max-height: 38vh; border-left: 0; border-right: 0; border-top: 1px solid var(--border); order: 0; }
    .side-panel.left { border-top: 0; border-bottom: 1px solid var(--border); }
    .map-host { min-height: 55vh; }
    .summary-columns, .system-summary { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .topbar .btn-primary span { display: none; }
    .topbar .btn-primary { padding: 0 10px; }
    .file-chip-name { max-width: 46vw; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* =====================================================================================
   Analysis pages: issues, access performance, RF quality
   ===================================================================================== */

.badge.error { background: var(--danger-soft); color: var(--danger); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.info { background: var(--accent-soft); color: var(--accent-text); }

table.grid td.wrap { white-space: normal; min-width: 280px; max-width: 640px; padding-top: 8px; padding-bottom: 8px; line-height: 1.45; color: var(--text-muted); }
table.grid td.strong-cell { font-weight: 500; }
a.cell-link { font-weight: 600; }

.small-print { font-size: 12px; }

.severity-summary { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; flex: 0 0 auto; }
.severity-tile {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    font-size: 13px; color: var(--text-muted);
}
.severity-count { font-size: 18px; font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; }
.severity-tile.error .icon { color: var(--danger); }
.severity-tile.warning .icon { color: var(--warning); }
.severity-tile.info .icon { color: var(--accent); }

.analysis-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); gap: 16px; margin-top: 16px; align-items: start; }
.figure { padding: 14px 14px 6px; min-width: 0; }
.figure-head { padding: 0 4px 6px; }
.figure-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.figure-head p { margin: 2px 0 0; font-size: 12.5px; }
.figure-host { width: 100%; }
.figure-empty { padding: 28px 8px; text-align: center; font-size: 13px; }
.table-card { padding: 14px; min-width: 0; overflow: auto; }
.table-card .table-wrap { box-shadow: none; }

.threshold-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 10px 16px; margin-top: 16px; font-size: 13px; }
.threshold-bar label { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); }
.threshold-bar input { width: 72px; }

.issues-banner {
    display: flex; align-items: center; gap: 14px;
    margin-top: 14px; padding: 14px 18px;
    color: var(--text); text-decoration: none !important;
    border-left: 4px solid var(--success);
    transition: box-shadow .15s, transform .15s;
}
.issues-banner:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.issues-banner.has-errors { border-left-color: var(--danger); }
.issues-banner.has-warnings { border-left-color: var(--warning); }
.issues-banner-icon { color: var(--success); display: inline-flex; }
.issues-banner.has-errors .issues-banner-icon { color: var(--danger); }
.issues-banner.has-warnings .issues-banner-icon { color: var(--warning); }
.issues-banner-cta { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; color: var(--accent-text); font-weight: 600; white-space: nowrap; }

@media (max-width: 960px) {
    .analysis-grid { grid-template-columns: 1fr; }
}

.stat-grid.compact { margin-bottom: 14px; flex: 0 0 auto; }
.stat-grid.compact .stat { padding: 12px 16px; }
.stat-grid.compact .stat-value { font-size: 22px; }

/* =====================================================================================
   Compare logs
   ===================================================================================== */

.compare-sets { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; }
.set-card { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.set-head { display: flex; align-items: center; gap: 10px; }
.set-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 8px;
    font-weight: 700; font-size: 13px; color: #fff;
}
.set-badge.a { background: #0891b2; }
.set-badge.b { background: #a855f7; }
.set-files { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-card .dropzone.compact.set-drop { margin-top: 8px; max-width: none; padding: 12px 14px; }
.set-card .progress { margin: 6px 0; }

.findings { margin-top: 16px; padding: 14px 18px; }
.findings ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.findings li { line-height: 1.5; }

.compare-stats { margin-top: 16px; }
.map-card { margin-top: 16px; padding: 14px; }
.map-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.compare-map { height: 520px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }

.compare-legend {
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: 8px;
    box-shadow: var(--shadow); padding: 8px 10px; min-width: 190px;
    font: 12px var(--font);
}
.compare-legend-title { font-weight: 600; margin-bottom: 6px; }
.compare-legend-bar { height: 10px; border-radius: 3px; }
.compare-legend-ticks { display: flex; justify-content: space-between; color: var(--text-muted); font-size: 11px; margin-top: 2px; }
.compare-legend-note { color: var(--text-subtle); font-size: 11px; margin-top: 4px; }

table.grid td.better { color: var(--success); font-weight: 600; }
table.grid td.worse { color: var(--danger); font-weight: 600; }
table.grid td.muted-cell { color: var(--text-muted); }
button.link-button {
    background: none; border: 0; padding: 0;
    font: inherit; font-weight: 600; color: var(--accent-text);
    cursor: pointer;
}
button.link-button:hover { text-decoration: underline; }

/* =====================================================================================
   Site hunting
   ===================================================================================== */

.page-body.hunting > .card, .page-body.hunting > .figure { margin-top: 16px; }
.hunt-detail { padding-bottom: 8px; }
.hunt-detail h3 .badge { margin-left: 8px; vertical-align: middle; }
.hunt-detail .figure { box-shadow: none; border: 0; margin: 0; }
.hop-strip {
    list-style: none; margin: 0; padding: 4px 18px 12px;
    display: flex; flex-wrap: wrap; gap: 6px 22px; align-items: stretch;
}
.hop {
    position: relative;
    display: flex; flex-direction: column; gap: 1px;
    min-width: 118px; padding: 6px 10px;
    border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius);
    background: var(--surface-2);
    font-size: 12px; font-variant-numeric: tabular-nums;
}
.hop + .hop::before {
    content: "→"; position: absolute; left: -18px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: 13px;
}
.hop-kind { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 600; }
.hop-freq { font-weight: 600; color: var(--text); }
.hop-meta { color: var(--text-muted); }
.hop.serving { border-left-color: #0891b2; }
.hop.call { border-left-color: #94a3b8; opacity: 0.85; }
.hop.sampled { border-left-color: #f59e0b; }
.hop.sampled.lost { border-left-color: var(--danger); background: var(--danger-soft); }
.hop.moved { border-left-color: var(--success); background: var(--success-soft); }
.hop.moved .hop-kind { color: var(--success); }
.hop-actions { padding: 0 18px 4px; }

/* CRC errors over time (RF quality) */
.crc-section > .card, .crc-section > .figure, .crc-section > .analysis-grid { margin-top: 16px; }
.crc-section .analysis-grid > .card { min-width: 0; }
