/* Clevertech Microwave Link Map — parchment visual contract */

:root,
[data-theme="dark"] {
    --bg: #1C1B19;
    --stage: #262421;
    --ink: #E8E4DF;
    --muted: #9C958C;
    --quiet: #8A847E;
    --line: #3E3A35;
    --hair: #4A4540;
    --accent: #D9B85B;
    --on-accent: #2D3644;
    --data: #80BCE0;
    --bg-base: var(--bg);
    --bg-panel: var(--stage);
    --bg-elevated: #2E2C28;
    --bg-surface: #35322E;
    --bg-panel-translucent: var(--stage);
    --bg-base-overlay: rgba(28, 27, 25, 0.92);
    --border-color: var(--hair);
    --border-active: var(--line);
    --border: var(--hair);
    --text-primary: var(--ink);
    --text-secondary: var(--muted);
    --text-tertiary: var(--quiet);
    --accent-hover: var(--ink);
    --accent-subtle: rgba(217, 184, 91, 0.12);
    --success: #6aab6a;
    --warning: #c9a227;
    --error: #d46a6a;
    --shadow-sm: none;
    --shadow-md: none;
    --radius-sm: 0;
    --radius-md: 2px;
    --radius-lg: 2px;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
    --mono: ui-monospace, Menlo, monospace;
    --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

[data-theme="light"] {
    --bg: #EBE7E4;
    --stage: #F4F2F0;
    --ink: #2D3644;
    --muted: #555D69;
    --quiet: #8F8B87;
    --line: #C9C4C0;
    --hair: #C9C4C0;
    --accent: #8B6513;
    --on-accent: #FFF;
    --data: #356F91;
    --bg-base: var(--bg);
    --bg-panel: var(--stage);
    --bg-elevated: #E4E0DC;
    --bg-surface: #DDD9D5;
    --bg-panel-translucent: var(--stage);
    --bg-base-overlay: rgba(235, 231, 228, 0.92);
    --border-color: var(--hair);
    --border-active: var(--line);
    --border: var(--hair);
    --text-primary: var(--ink);
    --text-secondary: var(--muted);
    --text-tertiary: var(--quiet);
    --accent-hover: var(--ink);
    --accent-subtle: rgba(139, 101, 19, 0.1);
    --success: #4a8f4a;
    --warning: #9a7b1a;
    --error: #b54a4a;
}

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

        body {
            font-family: var(--serif);
            -webkit-font-smoothing: antialiased;
            background-color: var(--bg-base);
            color: var(--text-primary);
            overflow: hidden;
            height: 100vh;
            height: 100dvh;
            display: flex;
            flex-direction: column;
            transition: background-color 0.3s ease, color 0.3s ease;
        }

        select, input {
            color-scheme: dark;
        }
        [data-theme="light"] select,
        [data-theme="light"] input {
            color-scheme: light;
        }

        /* ── Focus Visible ── */
        :focus-visible {
            outline: 2px solid var(--accent);
            outline-offset: 2px;
        }

        /* ══════════════════════════════════════════
           Header - Telecom Style
           ══════════════════════════════════════════ */
        .header {
            background: var(--bg-panel);
            color: var(--text-primary);
            padding: 0 var(--space-4);
            height: 48px;
            display: flex;
            align-items: center;
            border-bottom: 1px solid var(--hair);
            z-index: 1000;
            position: relative;
            flex-shrink: 0;
            transition: background-color 0.3s ease, border-color 0.3s ease;
        }

        .header-content {
            width: 100%;
            max-width: 1600px;
            margin: 0 auto;
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: var(--space-4);
        }

        .logo {
            display: flex;
            align-items: center;
            gap: var(--space-2);
            text-decoration: none;
            color: inherit;
            flex-shrink: 0;
            transition: opacity var(--transition-fast);
        }
        .logo:hover { opacity: 0.85; }

        .logo-img {
            display: block;
            width: auto;
            height: 28px;
            max-width: 180px;
            flex-shrink: 0;
        }

        .brand-logo {
            position: relative;
            display: block;
            color: var(--ink);
            flex-shrink: 0;
            width: auto;
            height: 28px;
        }
        .brand-logo .logo-img,
        .brand-logo .logo-mark {
            visibility: hidden;
        }
        .brand-logo::after {
            content: "";
            position: absolute;
            inset: 0;
            background: currentColor;
            -webkit-mask: url("/static/clevertech-logo.svg?v=4") center/contain no-repeat;
            mask: url("/static/clevertech-logo.svg?v=4") center/contain no-repeat;
        }

        .logo h1 {
            font-family: var(--mono);
            font-size: 13px;
            font-weight: 400;
            letter-spacing: -0.02em;
            line-height: 1;
            margin: 0;
            padding: 0;
            border: 0;
            color: var(--text-primary);
        }
        .logo > div {
            display: flex;
            align-items: center;
        }

        .header-stats {
            display: flex;
            align-items: center;
            gap: var(--space-4);
            margin-left: auto;
            flex-shrink: 0;
        }

        .stat-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 1px;
            line-height: 1;
            white-space: nowrap;
        }

        .stat-item .stat-value {
            font-family: var(--mono);
            font-size: 12px;
            font-weight: 400;
            letter-spacing: 0;
            line-height: 1;
            color: var(--accent);
        }

        .stat-item .stat-label {
            font-family: var(--mono);
            font-size: 9px;
            font-weight: 400;
            text-transform: uppercase;
            letter-spacing: 0.06em;
            line-height: 1;
            color: var(--text-tertiary);
        }

        .theme-toggle {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 32px;
            height: 32px;
            background: transparent;
            border: 1px solid var(--border-color);
            border-radius: var(--radius-sm);
            cursor: pointer;
            color: var(--text-secondary);
            transition: background-color var(--transition-fast),
                        color var(--transition-fast),
                        border-color var(--transition-fast);
            flex-shrink: 0;
            margin-left: var(--space-2);
        }
        .theme-toggle:hover {
            background: var(--bg-elevated);
            color: var(--text-primary);
            border-color: var(--border-active);
        }
        .theme-icon--light { display: block; }
        .theme-icon--dark  { display: none; }
        [data-theme="light"] .theme-icon--light { display: none; }
        [data-theme="light"] .theme-icon--dark  { display: block; }

        .header-nav {
            display: flex;
            align-items: center;
            gap: 2px;
        }

        .header-nav .nav-link {
            display: inline-flex;
            align-items: center;
            padding: 6px 10px;
            font-family: var(--mono);
            font-size: 11px;
            font-weight: 400;
            letter-spacing: 0.04em;
            color: var(--text-secondary);
            text-decoration: none;
            border-radius: var(--radius-sm);
            white-space: nowrap;
            transition: background var(--transition-fast), color var(--transition-fast);
        }

        .header-nav .nav-link:hover {
            background: var(--accent-subtle);
            color: var(--text-primary);
        }

        .header-nav .nav-signin {
            background: var(--accent);
            color: var(--on-accent);
            padding: 6px 14px;
            font-weight: 400;
            border: 1px solid var(--accent);
        }

        .header-nav .nav-signin:hover {
            background: var(--ink);
            border-color: var(--ink);
            color: var(--stage);
        }

        @media (max-width: 768px) {
            .header-stats { display: none; }
            .header-nav .nav-link { display: none; }
            .header-nav .nav-signin { display: inline-flex; }
            .header { padding: 0 var(--space-3); height: 44px; }
        }

        /* ── Mobile Menu Button (Telecom style) ── */
        .mobile-menu-btn {
            display: none;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            gap: 4px;
            width: 32px;
            height: 32px;
            background: transparent;
            border: none;
            cursor: pointer;
            padding: 0;
            flex-shrink: 0;
            margin-left: var(--space-2);
            margin-right: var(--space-2);
        }

        .mobile-menu-btn span {
            display: block;
            width: 18px;
            height: 2px;
            background: var(--text-secondary);
            border-radius: 1px;
            transition: transform var(--transition-fast), opacity var(--transition-fast);
        }

        .mobile-menu-btn.active span:nth-child(1) {
            transform: rotate(45deg) translate(5px, 5px);
        }
        .mobile-menu-btn.active span:nth-child(2) {
            opacity: 0;
        }
        .mobile-menu-btn.active span:nth-child(3) {
            transform: rotate(-45deg) translate(5px, -5px);
        }

        @media (max-width: 768px) {
            .mobile-menu-btn {
                display: flex;
            }
        }

        /* ══════════════════════════════════════════
           Layout - Sidebar always visible on desktop
           ══════════════════════════════════════════ */
        .main-container {
            flex: 1;
            display: flex;
            overflow: hidden;
            min-height: 0;
            position: relative;
        }

        /* Sidebar - Telecom style, static on desktop */
        .sidebar {
            width: 280px;
            background: var(--bg-panel);
            border-right: 1px solid var(--hair);
            overflow-y: auto;
            padding: var(--space-4);
            flex-shrink: 0;
            transition: width var(--transition-normal), padding var(--transition-normal),
                        background-color var(--transition-fast), border-color var(--transition-fast);
            scrollbar-width: thin;
            scrollbar-color: var(--bg-surface) transparent;
            z-index: 900;
        }

        .sidebar::-webkit-scrollbar {
            width: 6px;
        }
        .sidebar::-webkit-scrollbar-track {
            background: transparent;
        }
        .sidebar::-webkit-scrollbar-thumb {
            background: var(--bg-surface);
            border-radius: 3px;
        }
        .sidebar::-webkit-scrollbar-thumb:hover {
            background: var(--text-tertiary);
        }

        /* On mobile: drawer behavior */
        @media (max-width: 768px) {
            .sidebar {
                position: absolute;
                top: 0;
                left: 0;
                bottom: 0;
                width: 280px;
                background: var(--bg-panel) !important;
                transform: translateX(-100%);
                z-index: 1001;
                border-right: 1px solid var(--border-color);
                box-shadow: none;
            }
            .sidebar.open {
                transform: translateX(0);
            }
            .main-container {
                position: relative;
            }
        }

        

        .sidebar-header {
            display: flex;
            align-items: center;
            justify-content: flex-end;
            min-height: 0;
        }

        .sidebar-close-btn {
            display: none;
            align-items: center;
            justify-content: center;
            width: 28px;
            height: 28px;
            background: transparent;
            border: none;
            color: var(--text-tertiary);
            cursor: pointer;
            border-radius: var(--radius-sm);
            transition: background var(--transition-fast), color var(--transition-fast);
            flex-shrink: 0;
        }
        .sidebar-close-btn:hover {
            background: var(--bg-elevated);
            color: var(--text-primary);
        }

        /* Map container */
        .map-container {
            position: relative;
            flex: 1;
            min-width: 0;
            min-height: 0;
            background: var(--bg-base);
        }

        /* Desktop: collapsible sidebar in the flex row so zoom sits on the map pane */
        @media (min-width: 768px) {
            .sidebar {
                position: relative;
                width: 280px;
                transform: none;
                z-index: 901;
                overflow-y: auto;
            }
            .sidebar.closed {
                width: 0;
                padding: 0;
                border-right: 0;
                overflow: hidden;
                pointer-events: none;
            }
            .sidebar-close-btn {
                display: flex;
            }
            .mobile-menu-btn {
                display: flex;
            }
            .header-stats {
                display: flex;
            }
        }

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

        /* Context menu */
        .context-menu {
            position: absolute;
            background: var(--bg-panel) !important;
            border: 1px solid var(--border-color);
            border-radius: var(--radius-md);
            box-shadow: none;
            padding: var(--space-1);
            z-index: 2000;
            min-width: 180px;
            display: none;
        }
        .context-menu.visible {
            display: block;
        }
        .context-menu-btn {
            display: flex;
            align-items: center;
            gap: var(--space-2);
            width: 100%;
            padding: var(--space-2) var(--space-3);
            background: transparent;
            border: none;
            color: var(--text-primary);
            font-size: 13px;
            font-family: var(--serif);
            text-align: left;
            cursor: pointer;
            border-radius: var(--radius-sm);
            transition: background var(--transition-fast);
        }
        .context-menu-btn:hover {
            background: var(--bg-elevated);
        }
        .context-menu-info {
            padding: var(--space-2) var(--space-3);
            font-size: 11px;
            color: var(--text-tertiary);
            border-top: 1px solid var(--border-color);
            margin-top: var(--space-1);
        }

        /* Interference panel - styled like telecom panels */
        .interference-panel {
            position: absolute;
            bottom: 36px;
            right: 20px;
            width: 340px;
            max-height: calc(100vh - 56px);
            overflow: auto;
            background: var(--bg-panel) !important;
            border: 1px solid var(--border-color);
            border-radius: var(--radius-lg);
            box-shadow: none;
            padding: var(--space-4);
            z-index: 1500;
            display: none;
            color: var(--text-primary);
            font-family: var(--sans);
        }
        .interference-panel.visible {
            display: block;
        }
        .interference-panel h2,
        .interference-panel h3,
        .interference-panel label,
        .interference-panel .filter-group label,
        .interference-panel .risk-badge,
        .interference-panel .btn {
            font-family: var(--sans);
        }
        .interference-status {
            margin: var(--space-3) 0 0;
            font-family: var(--sans);
            font-size: 12px;
            line-height: 1.45;
            color: var(--warning);
        }
        .interference-panel h2 {
            color: var(--accent);
            margin: 0 28px var(--space-3) 0;
            font-size: 13px;
            font-weight: 600;
            letter-spacing: 0.04em;
            text-transform: uppercase;
            border-bottom: 1px solid var(--border-color);
            padding-bottom: var(--space-2);
        }
        .interference-summary {
            margin-bottom: var(--space-3);
        }
        .interference-recommendation {
            margin: var(--space-2) 0 0;
            font-size: 13px;
            line-height: 1.45;
            color: var(--text-primary);
        }
        .interference-counts {
            display: flex;
            gap: var(--space-2);
            flex-wrap: wrap;
            margin-bottom: var(--space-3);
        }
        .interference-count {
            padding: 4px 8px;
            border: 1px solid var(--border-color);
            border-radius: var(--radius-sm);
            font-size: 12px;
            color: var(--text-secondary);
        }
        .interference-count .dot { margin-right: 4px; }
        .interference-note {
            border: 1px solid var(--border-color);
            background: var(--bg-elevated);
            border-radius: var(--radius-md);
            padding: var(--space-3);
            margin-bottom: var(--space-3);
        }
        .interference-note-title {
            font-size: 13px;
            font-weight: 600;
            color: var(--success);
        }
        .interference-note.is-warning .interference-note-title {
            color: var(--warning);
        }
        .interference-note-body {
            margin-top: 4px;
            font-size: 12px;
            color: var(--text-secondary);
        }
        .interference-list-title {
            margin: var(--space-4) 0 var(--space-2);
            font-size: 12px;
            font-weight: 600;
            letter-spacing: 0.04em;
            text-transform: uppercase;
            color: var(--text-secondary);
        }
        .interference-item-top {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: var(--space-2);
            margin-bottom: 4px;
        }
        .interference-freq {
            font-weight: 600;
            color: var(--text-primary);
        }
        .interference-licensee {
            font-size: 13px;
            color: var(--text-secondary);
        }
        .interference-meta {
            margin-top: 4px;
            font-size: 12px;
            color: var(--text-tertiary);
        }
        .interference-panel .close-btn {
            position: absolute;
            top: 12px;
            right: 12px;
            background: none;
            border: none;
            color: var(--text-tertiary);
            font-size: 18px;
            cursor: pointer;
            padding: 4px;
            line-height: 1;
            transition: color var(--transition-fast);
        }
        .interference-panel .close-btn:hover {
            color: var(--text-primary);
        }

        /* Radius info */
        .radius-info {
            position: absolute;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            background: var(--bg-panel-translucent);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-sm);
            padding: 6px 14px;
            z-index: 1500;
            font-size: 12px;
            color: var(--text-secondary);
            display: none;
            white-space: nowrap;
            backdrop-filter: none;
        }
        .radius-info.visible {
            display: block;
        }

        .rate-limit-banner {
            position: absolute;
            top: 16px;
            left: 50%;
            transform: translateX(-50%);
            background: var(--bg-panel) !important;
            border: 1px solid var(--warning);
            border-radius: var(--radius-sm);
            padding: 8px 16px;
            z-index: 1500;
            font-size: 12px;
            color: var(--warning);
            display: none;
            white-space: nowrap;
            backdrop-filter: none;
            box-shadow: none;
            cursor: pointer;
            transition: opacity var(--transition-fast);
        }
        .rate-limit-banner.visible {
            display: block;
        }

        /* Licensee modal */
        .licensee-modal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: var(--bg-base-overlay);
            z-index: 2000;
            display: none;
            overflow-y: auto;
            backdrop-filter: none;
        }
        .licensee-modal.visible {
            display: flex;
            align-items: flex-start;
            justify-content: center;
            padding: 20px;
        }
        .licensee-modal-content {
            background: var(--bg-panel) !important;
            border: 1px solid var(--border-color);
            border-radius: var(--radius-lg);
            max-width: 800px;
            width: 100%;
            padding: var(--space-5);
            position: relative;
            max-height: 90vh;
            overflow-y: auto;
            box-shadow: none;
        }
        .licensee-modal-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            margin-bottom: var(--space-4);
            border-bottom: 1px solid var(--border-color);
            padding-bottom: var(--space-3);
        }
        .licensee-modal-header h2 {
            margin: 0;
            color: var(--text-primary);
            font-size: 1.15rem;
            flex: 1;
            padding-right: 12px;
        }
        .licensee-modal-close {
            background: var(--bg-elevated);
            border: none;
            color: var(--text-tertiary);
            font-size: 18px;
            cursor: pointer;
            border-radius: var(--radius-sm);
            padding: 4px 10px;
            transition: all var(--transition-fast);
        }
        .licensee-modal-close:hover {
            background: var(--bg-surface);
            color: var(--text-primary);
        }

        /* Leaflet controls dark theme using tokens */
        .leaflet-control-zoom a,
        .leaflet-bar a,
        .leaflet-control-layers,
        .leaflet-control-attribution {
            background: var(--bg-panel) !important;
            color: var(--text-primary) !important;
            border: 1px solid var(--border-color) !important;
        }
        .leaflet-control-zoom a:hover,
        .leaflet-bar a:hover {
            background: var(--bg-elevated) !important;
            color: var(--text-primary) !important;
        }
        .leaflet-control-layers label,
        .leaflet-control-layers input,
        .leaflet-control-attribution a {
            color: var(--text-primary) !important;
        }
        .leaflet-control-layers-toggle {
            background-color: var(--bg-panel) !important;
        }
        .leaflet-control-layers-expanded {
            background: var(--bg-panel) !important;
            color: var(--text-primary) !important;
        }

        /* ══════════════════════════════════════════
           Sidebar Content Styling (missing content-level CSS)
           Uses telecom-style CSS custom properties from :root
           ══════════════════════════════════════════ */

        .stat-card {
            background: var(--bg-elevated);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-md);
            padding: var(--space-4);
            margin-top: var(--space-4);
            margin-bottom: var(--space-4);
            text-align: center;
        }
        .stat-card .stat-value {
            font-family: var(--mono);
            font-size: 1.4rem;
            font-weight: 400;
            color: var(--accent);
            line-height: 1.1;
            letter-spacing: 0;
        }
        .stat-card .stat-label {
            font-family: var(--mono);
            font-size: 10px;
            color: var(--text-tertiary);
            text-transform: uppercase;
            letter-spacing: 0.06em;
            font-weight: 400;
            margin-top: var(--space-1);
        }

        h1 {
            font-size: 1.3rem;
            margin-bottom: var(--space-4);
            color: var(--text-primary);
            border-bottom: 1px solid var(--border-color);
            padding-bottom: var(--space-2);
        }
        h2 {
            font-family: var(--mono);
            font-size: 10px;
            font-weight: 400;
            color: var(--quiet);
            text-transform: uppercase;
            letter-spacing: 0.06em;
            margin: var(--space-5) 0 var(--space-3) 0;
            padding-bottom: var(--space-1);
            border-bottom: 1px solid var(--border-color);
        }

        .filter-group {
            margin-bottom: var(--space-3);
        }
        .filter-group label {
            display: block;
            font-family: var(--mono);
            font-size: 10px;
            font-weight: 400;
            letter-spacing: 0.04em;
            text-transform: uppercase;
            color: var(--quiet);
            margin-bottom: var(--space-1);
        }
        .filter-group select,
        .filter-group input[type="text"],
        .filter-group input[type="number"] {
            width: 100%;
            height: 32px;
            padding: 0 var(--space-2);
            background: var(--bg-elevated);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-sm);
            color: var(--text-primary);
            font-size: 13px;
            font-family: var(--serif);
            transition: border-color var(--transition-fast);
        }
        .filter-group select:focus,
        .filter-group input[type="text"]:focus,
        .filter-group input[type="number"]:focus {
            outline: none;
            border-color: var(--accent);
            box-shadow: none;
        }
        .filter-group input[type="range"] {
            width: 100%;
            accent-color: var(--accent);
            cursor: pointer;
        }

        .coord-hint {
            font-size: 12px;
            color: var(--text-tertiary);
            line-height: 1.4;
            margin: 0 0 var(--space-2);
        }
        .coord-hint span {
            font-family: var(--mono);
            color: var(--text-secondary);
        }
        .coord-error {
            font-size: 12px;
            color: var(--error);
            line-height: 1.3;
            margin-bottom: var(--space-2);
        }
        .coord-error:empty {
            display: none;
        }
        .coord-field input.coord-input-error {
            border-color: var(--error);
        }
        .coord-field input.coord-paste-success {
            border-color: var(--success);
        }

        .btn {
            width: 100%;
            height: 32px;
            padding: 0 var(--space-3);
            border: 1px solid var(--accent);
            border-radius: var(--radius-sm);
            font-size: 12px;
            font-weight: 400;
            font-family: var(--mono);
            letter-spacing: 0.04em;
            cursor: pointer;
            transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
            margin-bottom: var(--space-1);
            line-height: 1;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            background: var(--accent);
            color: var(--on-accent);
        }
        .btn:hover {
            background: var(--ink);
            border-color: var(--ink);
            color: var(--stage);
        }
        .btn-primary {
            background: var(--accent);
            color: var(--on-accent);
        }
        .btn-primary:hover {
            background: var(--ink);
            border-color: var(--ink);
            color: var(--stage);
        }
        .btn-secondary {
            background: transparent;
            color: var(--text-secondary);
            border: 1px solid var(--border-color);
        }
        .btn-secondary:hover {
            background: var(--bg-elevated);
            color: var(--text-primary);
            border-color: var(--ink);
        }

        .band-legend {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            gap: var(--space-2);
            margin-top: var(--space-2);
        }
        .band-item {
            display: flex;
            align-items: center;
            gap: var(--space-1);
            font-size: 12px;
            color: var(--text-secondary);
        }
        .band-color {
            width: 20px;
            height: 4px;
            border-radius: 2px;
            flex-shrink: 0;
        }

        .loading {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: var(--bg-panel);
            padding: var(--space-6) var(--space-8);
            border-radius: var(--radius-lg);
            border: 1px solid var(--border-color);
            box-shadow: none;
            z-index: 2000;
            text-align: center;
            color: var(--text-primary);
            font-family: var(--serif);
        }
        .loading-spinner {
            width: 36px;
            height: 36px;
            border: 3px solid var(--border-color);
            border-top-color: var(--accent);
            border-radius: 50%;
            animation: spin 0.8s linear infinite;
            margin: 0 auto var(--space-3);
        }
        @keyframes spin {
            to { transform: rotate(360deg); }
        }
        .hidden {
            display: none !important;
        }

        .leaflet-popup-content-wrapper {
            background: var(--bg-panel) !important;
            color: var(--text-primary) !important;
            border: 1px solid var(--border-color) !important;
            border-radius: var(--radius-lg) !important;
            box-shadow: none !important;
            font-family: var(--serif);
        }
        .leaflet-popup-tip {
            background: var(--bg-panel) !important;
            border: 1px solid var(--border-color) !important;
        }
        .leaflet-popup-close-button {
            color: var(--text-tertiary) !important;
        }
        .leaflet-popup-close-button:hover {
            color: var(--text-primary) !important;
        }
        .popup-content h3 {
            color: var(--text-primary);
            margin-bottom: var(--space-2);
            font-size: 1rem;
        }
        .popup-content .row {
            display: flex;
            justify-content: space-between;
            margin-bottom: 4px;
            font-size: 12px;
        }
        .popup-content .label {
            color: var(--text-secondary);
        }
        .popup-content .value {
            color: var(--text-primary);
            font-weight: 500;
        }
        .coord-azimuth {
            cursor: help;
            border-bottom: 1px dotted var(--muted);
        }
        .elevation-chart-title {
            font-family: var(--sans);
            font-size: 0.7rem;
            color: var(--muted);
            text-align: center;
            margin-bottom: 2px;
        }
        .elevation-terrain {
            fill: var(--accent);
            fill-opacity: 0.22;
            stroke: var(--accent);
            stroke-width: 1.5;
        }
        .elevation-los {
            stroke: var(--accent);
            stroke-width: 1.5;
            stroke-dasharray: 4 3;
        }
        .elevation-tx,
        .elevation-tx-label {
            stroke: var(--success);
            fill: var(--success);
        }
        .elevation-tx {
            stroke-width: 2;
        }
        .elevation-rx,
        .elevation-rx-label {
            stroke: #e07a3d;
            fill: #e07a3d;
        }
        .elevation-rx {
            stroke-width: 2;
        }
        .elevation-tx-label,
        .elevation-rx-label,
        .elevation-axis {
            font-family: var(--sans);
            font-size: 8px;
            font-weight: 600;
        }
        .elevation-ground {
            fill: var(--ink);
        }
        .elevation-axis {
            fill: var(--muted);
            font-weight: 400;
            stroke: none;
        }

        .marker-cluster-small {
            background-color: rgba(217, 184, 91, 0.15) !important;
        }
        .marker-cluster-small div {
            background-color: var(--accent) !important;
            color: var(--on-accent) !important;
            font-family: var(--mono);
            font-weight: 400;
        }
        .marker-cluster-medium {
            background-color: rgba(217, 184, 91, 0.22) !important;
        }
        .marker-cluster-medium div {
            background-color: var(--accent) !important;
            color: var(--on-accent) !important;
            font-family: var(--mono);
            font-weight: 400;
        }
        .marker-cluster-large {
            background-color: rgba(139, 101, 19, 0.28) !important;
        }
        .marker-cluster-large div {
            background-color: #6D4F0E !important;
            color: #F4F2F0 !important;
            font-family: var(--mono);
            font-weight: 400;
        }
        .marker-cluster {
            border: none !important;
        }
        [data-theme="light"] .marker-cluster-small {
            background-color: rgba(139, 101, 19, 0.12) !important;
        }
        [data-theme="light"] .marker-cluster-medium {
            background-color: rgba(139, 101, 19, 0.16) !important;
        }
        [data-theme="light"] .marker-cluster-large {
            background-color: rgba(109, 79, 14, 0.18) !important;
        }

        .risk-badge {
            display: inline-block;
            padding: 3px 8px;
            border-radius: var(--radius-sm);
            font-size: 10px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.04em;
        }
        .risk-critical { background: var(--error); color: #fff; }
        .risk-high { background: #c9844a; color: #fff; }
        .risk-medium { background: var(--warning); color: var(--on-accent); }
        .risk-low { background: var(--success); color: #fff; }
        .risk-none { background: var(--bg-surface); color: var(--text-tertiary); }
        .risk-critical-text { color: var(--error); }
        .risk-high-text { color: #c9844a; }
        .risk-medium-text { color: var(--warning); }
        .risk-low-text { color: var(--success); }
        .interference-item {
            background: var(--bg-elevated);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-md);
            padding: var(--space-3);
            margin-bottom: var(--space-2);
            cursor: pointer;
            transition: border-color var(--transition-fast);
        }
        .interference-item:hover {
            border-color: var(--accent);
        }
        .interference-item.risk-critical-border { border-left: 3px solid var(--error); }
        .interference-item.risk-high-border { border-left: 3px solid #c9844a; }
        .interference-item.risk-medium-border { border-left: 3px solid var(--warning); }
        .interference-item.risk-low-border { border-left: 3px solid var(--success); }

        .licensee-stats-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: var(--space-2);
            margin-bottom: var(--space-4);
        }
        .licensee-stat-card {
            background: var(--bg-elevated);
            border-radius: var(--radius-md);
            padding: var(--space-3);
            text-align: center;
            border: 1px solid var(--border-color);
        }
        .licensee-stat-card .stat-value {
            font-size: 1.3rem;
            font-weight: 700;
            color: var(--text-primary);
            margin-bottom: var(--space-1);
        }
        .licensee-stat-card .stat-label {
            font-size: 10px;
            color: var(--text-tertiary);
            text-transform: uppercase;
            letter-spacing: 0.05em;
            font-weight: 600;
        }
        .licensee-section {
            margin-bottom: var(--space-4);
        }
        .licensee-section h3 {
            color: var(--text-primary);
            font-size: 0.9rem;
            margin-bottom: var(--space-2);
            display: flex;
            align-items: center;
            gap: var(--space-2);
        }
        .licensee-band-bar {
            display: flex;
            align-items: center;
            gap: var(--space-2);
            margin-bottom: var(--space-1);
        }
        .licensee-band-label {
            width: 70px;
            font-size: 12px;
            color: var(--text-secondary);
            text-align: right;
            flex-shrink: 0;
        }
        .licensee-band-track {
            flex: 1;
            height: 20px;
            background: var(--bg-elevated);
            border-radius: 4px;
            overflow: hidden;
        }
        .licensee-band-fill {
            height: 100%;
            border-radius: 4px;
            transition: width 0.5s ease;
        }
        .licensee-band-count {
            font-size: 12px;
            color: var(--text-primary);
            width: 60px;
            text-align: right;
        }
        .licensee-province-list {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: var(--space-2);
        }
        .licensee-province-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: var(--bg-elevated);
            padding: var(--space-2) var(--space-3);
            border-radius: var(--radius-sm);
            font-size: 13px;
            border: 1px solid var(--border-color);
        }
        .licensee-province-item .province-name {
            color: var(--text-primary);
        }
        .licensee-province-item .province-count {
            color: var(--text-primary);
            font-weight:  700;
        }
        .licensee-loading {
            text-align: center;
            padding: var(--space-8);
            color: var(--text-secondary);
        }
        .licensee-err {
            color: var(--error);
            text-align: center;
            padding: var(--space-5);
        }
        .licensee-profile-link {
            color: var(--accent);
            cursor: pointer;
            text-decoration: none;
            transition: color var(--transition-fast);
        }
        .licensee-profile-link:hover {
            color: var(--text-primary);
            text-decoration: underline;
        }
        .leaflet-popup-content a.auth-tafl-link {
            color: var(--accent);
            font-weight: 500;
            text-decoration: underline;
            text-underline-offset: 2px;
        }
        .leaflet-popup-content a.auth-tafl-link:hover {
            color: var(--text-primary);
        }

        #export-btn {
            background: rgba(48,209,88,0.12) !important;
            border: 1px solid var(--success) !important;
            color: var(--success) !important;
        }
        #export-btn:hover {
            background: rgba(48,209,88,0.20) !important;
        }

        .custom-marker {
            background: transparent !important;
            border: none !important;
        }

        input[type="range"] {
            -webkit-appearance: none;
            appearance: none;
            width: 100%;
            height: 4px;
            background: var(--bg-surface);
            border-radius: 2px;
            outline: none;
        }
        input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: var(--accent);
            cursor: pointer;
            border: 2px solid var(--bg-panel);
            box-shadow: none;
        }
