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

:root,
[data-theme="dark"] {
    --bg: #0f1923;
    --bg2: #1a2736;
    --bg3: #243447;
    --accent: #00d4aa;
    --accent2: #e94560;
    --text: #e0e8f0;
    --muted: #6b8299;
    --border: #2a3f52;
    --card: #1a2736;
    --radius: 10px;
}

[data-theme="light"] {
    --bg: #f0f2f5;
    --bg2: #ffffff;
    --bg3: #e4e6ea;
    --accent: #00a884;
    --accent2: #e94560;
    --text: #1a1a2e;
    --muted: #65748a;
    --border: #d1d5db;
    --card: #ffffff;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

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

.last-updated {
    float: right;
    font-size: 0.65rem;
    font-weight: 400;
    color: var(--muted);
    letter-spacing: 0;
    text-transform: none;
}

.auto-refresh-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding: 5px 10px;
    background: var(--bg);
    border-radius: 6px;
    border: 1px solid var(--border);
}

.auto-refresh-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse-dot 2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.auto-refresh-text {
    font-size: 0.7rem;
    color: var(--muted);
    font-weight: 500;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 20px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    gap: 12px;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--accent), #00a884);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: #0f1923;
}

.topbar-brand h1 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.brand-sub {
    font-size: 0.7rem;
    color: var(--muted);
}

.topbar-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg);
    border-radius: 8px;
    padding: 3px;
}

.tab-btn {
    padding: 7px 18px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active {
    background: var(--accent);
    color: #0f1923;
    font-weight: 600;
}

.topbar-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.btn-theme, .btn-alert {
    padding: 5px 12px;
    font-size: 0.72rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    transition: all 0.2s;
}

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

.btn-alert {
    background: var(--accent);
    color: #0f1923;
    border: 1px solid var(--accent);
}

.btn-alert.btn-outline {
    background: transparent;
    color: var(--accent);
}

.topbar-live {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--muted);
    white-space: nowrap;
}

.live-dot {
    width: 8px;
    height: 8px;
    background: #e74c3c;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}

.main-content {
    height: calc(100vh - 56px);
    overflow: hidden;
}

.tab-content { display: none; height: 100%; }
.tab-content.active { display: block; }

.map-layout {
    display: flex;
    height: 100%;
}

.sidebar {
    width: 340px;
    min-width: 340px;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--bg);
    position: relative;
    z-index: 2;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.sidebar { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: visible;
    position: relative;
}

.card-header {
    padding: 10px 14px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
}

.card-body {
    padding: 12px 14px;
}

.form-select, .form-input {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

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

.filter-group {
    margin-top: 10px;
}

.form-label {
    display: block;
    font-size: 0.72rem;
    color: var(--muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.date-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.date-row input { flex: 1; }
.date-sep { color: var(--muted); font-size: 0.8rem; }

.service-filter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 8px;
}
.service-cb {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    color: var(--text);
    cursor: pointer;
    padding: 3px 0;
}
.service-cb input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
    cursor: pointer;
}
.svc-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.search-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.search-row .form-input {
    flex: 1;
}

.search-count {
    font-size: 0.72rem;
    color: var(--muted);
    white-space: nowrap;
}

.btn-export {
    width: 100%;
    margin-top: 8px;
    padding: 8px;
    background: var(--bg3);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.btn-export:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-load {
    width: 100%;
    margin-top: 10px;
    padding: 11px;
    background: var(--accent);
    color: #0f1923;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.15s, opacity 0.15s;
    position: relative;
    z-index: 10;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    touch-action: manipulation;
}

.btn-load:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-small {
    padding: 6px 14px;
    background: var(--accent);
    color: #0f1923;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.muted { color: var(--muted); font-size: 0.83rem; }
.center-text { text-align: center; padding: 20px; }

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid rgba(42, 63, 82, 0.5);
    font-size: 0.83rem;
}

.stat-row .label { color: var(--muted); }
.stat-row .value { color: var(--text); font-weight: 600; }

.stat-category {
    display: flex;
    align-items: center;
    padding: 3px 0;
    font-size: 0.78rem;
    gap: 6px;
}

.stat-category .cat-name {
    color: var(--muted);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-category .cat-count {
    color: var(--accent);
    font-weight: 600;
    min-width: 28px;
    text-align: right;
}

.stat-category .cat-bar {
    height: 3px;
    border-radius: 2px;
    min-width: 4px;
}

.stats-section-title {
    margin-top: 8px;
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.detail-close {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    margin-left: auto;
    font-family: inherit;
}

.detail-close:hover { color: var(--text); }

.detail-section-title {
    font-size: 0.7rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin: 10px 0 4px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.detail-section-title:first-child { margin-top: 0; }

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 4px 0;
    border-bottom: 1px solid rgba(42, 63, 82, 0.25);
    gap: 8px;
}

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

.detail-row .detail-label {
    font-size: 0.72rem;
    color: var(--muted);
    white-space: nowrap;
    flex-shrink: 0;
}

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

.detail-severity-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 8px;
}

.detail-timeline {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 0;
}

.timeline-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
}

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

.timeline-line {
    width: 2px;
    height: 12px;
    background: var(--border);
    margin-left: 3px;
}

.timeline-label { color: var(--muted); }
.timeline-value { color: var(--text); font-weight: 500; }

.legend-body {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.legend-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    font-size: 0.72rem;
    color: var(--text);
    background: var(--bg);
    border-radius: 20px;
}

.legend-chip::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--c);
}

#map {
    flex: 1;
    z-index: 1;
}

.leaflet-popup-content-wrapper {
    background: var(--card);
    color: var(--text);
    border-radius: 10px;
    border: 1px solid var(--border);
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    padding: 0;
}

.leaflet-popup-tip { background: var(--card); }

.leaflet-popup-content {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.5;
    min-width: 240px;
}

.popup-header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.popup-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.popup-header-text {
    flex: 1;
    min-width: 0;
}

.popup-title {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text);
    margin: 0;
    line-height: 1.2;
}

.popup-subtitle {
    font-size: 0.72rem;
    color: var(--muted);
    margin-top: 2px;
}

.popup-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.popup-body {
    padding: 8px 14px 10px;
}

.popup-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 0;
    border-bottom: 1px solid rgba(42, 63, 82, 0.3);
}

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

.popup-label { color: var(--muted); white-space: nowrap; font-size: 0.78rem; }
.popup-value { color: var(--text); font-size: 0.78rem; text-align: right; font-weight: 500; }

.popup-footer {
    padding: 6px 14px 10px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.popup-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.68rem;
    font-weight: 500;
    background: rgba(42, 63, 82, 0.5);
    color: var(--muted);
}

.popup-severity {
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.severity-high { background: rgba(231,76,60,0.2); color: #e74c3c; }
.severity-medium { background: rgba(230,126,34,0.2); color: #e67e22; }
.severity-low { background: rgba(149,165,166,0.2); color: #95a5a6; }

@keyframes pulse-ring {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(2.5); opacity: 0; }
}

.pulse-marker {
    position: relative;
}

.pulse-marker::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    border-radius: 50%;
    background: inherit;
    animation: pulse-ring 1.5s ease-out infinite;
}

.view-toggle {
    display: flex;
    gap: 4px;
    background: var(--bg);
    border-radius: 6px;
    padding: 3px;
}

.view-btn {
    flex: 1;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.view-btn.active {
    background: var(--accent);
    color: #0f1923;
}

.view-btn:hover:not(.active) {
    color: var(--text);
}

/* TOAST NOTIFICATIONS */
.toast-container {
    position: fixed;
    top: 64px;
    right: 16px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 400px;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.82rem;
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.3s, transform 0.3s;
}

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

.toast-icon { font-size: 1rem; flex-shrink: 0; line-height: 1.3; }
.toast-msg { flex: 1; color: var(--text); line-height: 1.4; }
.toast-close {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 0 2px;
    font-family: inherit;
    line-height: 1;
}

.toast-warning { border-left: 3px solid #f39c12; }
.toast-error { border-left: 3px solid #e74c3c; }
.toast-success { border-left: 3px solid #2ecc71; }
.toast-info { border-left: 3px solid #3498db; }
.toast-alert { border-left: 3px solid #e74c3c; background: rgba(231,76,60,0.1); }

/* AUDIO PLAYER */
.audio-player {
    grid-column: 1 / -1;
    background: var(--card);
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    overflow: hidden;
    margin-top: 8px;
}

.audio-player-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg3);
    border-bottom: 1px solid var(--border);
}

.audio-player-title {
    font-size: 0.82rem;
    color: var(--text);
}

.audio-player-close {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
    font-family: inherit;
}

.tg-listen-btn {
    flex-shrink: 0;
    padding: 4px 10px;
    background: var(--accent);
    color: #0f1923;
    border: none;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.2s;
}

.tg-listen-btn:hover { opacity: 0.85; }

.tg-listening {
    background: #e74c3c;
    color: white;
}

/* COURT */
.court-inputs {
    display: flex;
    gap: 8px;
    flex: 1;
}

.court-inputs .court-input {
    flex: 1;
}

.court-results-header {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.court-source-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--accent);
    color: var(--bg);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.court-case-actions {
    margin-top: 8px;
    display: flex;
    gap: 6px;
}

.court-portal-links {
    margin-top: 16px;
    padding: 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.court-portal-label {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 600;
}

.court-section-divider {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.court-section-divider h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.arrest-record {
    border-left: 3px solid #e74c3c;
}

.court-no-results {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
}

/* NEWS TAB */
.news-layout {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    height: 100%;
    overflow-y: auto;
}

.news-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.news-header h2 {
    font-size: 1.2rem;
    color: var(--text);
}

.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 14px;
}

.news-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: border-color 0.2s, transform 0.2s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.news-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.news-source, .news-card-source {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--accent);
    color: #0f1923;
    margin-bottom: 8px;
}

.news-title, .news-card-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
    line-height: 1.4;
}

.news-summary, .news-card-summary {
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.5;
    margin-bottom: 8px;
}

.news-date {
    font-size: 0.72rem;
    color: var(--muted);
}

/* COURT TAB */
.court-layout {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px;
    height: 100%;
    overflow-y: auto;
}

.court-header {
    margin-bottom: 16px;
}

.court-header h2 {
    font-size: 1.2rem;
    color: var(--text);
}

.court-search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: flex-end;
}

.court-input {
    flex: 1;
}

.court-search-box .btn-load {
    width: auto;
    margin-top: 0;
    padding: 9px 24px;
    white-space: nowrap;
}

.court-results { min-height: 200px; }

.court-case {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 10px;
}

.court-case-header {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--accent);
    margin-bottom: 6px;
}

.court-case-row {
    display: flex;
    gap: 8px;
    font-size: 0.82rem;
    margin-bottom: 2px;
}

.court-case-label { color: var(--muted); min-width: 100px; }
.court-case-value { color: var(--text); }

/* RADIO SCANNER TAB */
.radio-layout {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    height: 100%;
    overflow-y: auto;
}

.radio-header {
    margin-bottom: 20px;
}

.radio-header h2 {
    font-size: 1.2rem;
    color: var(--text);
    margin-bottom: 4px;
}

.radio-links {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

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

.btn-outline:hover {
    background: var(--accent);
    color: #0f1923;
}

.radio-system-info {
    margin-bottom: 16px;
}

.sys-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.sys-info-grid > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.radio-filter-row {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.radio-filter-row .form-select {
    max-width: 250px;
}

.talkgroup-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 10px;
}

.tg-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: border-color 0.2s;
}

.tg-card:hover {
    border-color: var(--accent);
}

.tg-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.tg-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.tg-dec {
    font-size: 0.72rem;
    color: var(--muted);
    font-family: monospace;
}

.tg-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
}

.tg-desc {
    font-size: 0.75rem;
    color: var(--muted);
}

.tg-audio-link {
    display: inline-block;
    padding: 4px 10px;
    background: var(--accent);
    color: #0f1923;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    text-decoration: none;
    margin-top: 4px;
    align-self: flex-start;
}

.tg-section-header {
    grid-column: 1 / -1;
    padding: 8px 0 4px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    margin-top: 8px;
}

.tg-section-header:first-child {
    margin-top: 0;
}

/* ANALYTICS TAB */
.analytics-layout {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    height: 100%;
    overflow-y: auto;
}

.analytics-header h2 { margin-bottom: 4px; }

.analytics-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    gap: 16px;
    color: var(--muted);
}

.analytics-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.analytics-fade-in {
    animation: fadeSlideIn 0.4s ease-out forwards;
}

.trend-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 16px 0;
}

.trend-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.trend-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 12px rgba(0, 230, 180, 0.08);
}

.trend-card.skeleton {
    background: linear-gradient(90deg, var(--card) 25%, var(--border) 50%, var(--card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

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

.trend-card-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
}

.trend-card-label {
    font-size: 0.82rem;
    color: var(--muted);
    margin-top: 6px;
}

.trend-card-change {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 8px;
}

.chart-container {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.chart-container h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 12px 0;
}

.chart-wrapper {
    position: relative;
    height: 260px;
}

.chart-wrapper-sm {
    height: 220px;
}

.analytics-chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.analytics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
}

.hotspot-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.hotspot-item:last-child { border-bottom: none; }

.hotspot-rank {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    min-width: 32px;
    text-align: center;
}

.hotspot-info { flex: 1; }

.hotspot-area {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
}

.hotspot-stats {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 2px;
}

.safety-row {
    display: grid;
    grid-template-columns: 1fr auto auto 80px;
    gap: 8px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.safety-row:last-of-type { border-bottom: none; }

.safety-district {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
}

.safety-grade {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 4px;
    text-align: center;
    min-width: 24px;
}

.safety-count {
    font-size: 0.75rem;
    color: var(--muted);
    text-align: right;
}

.safety-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.safety-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.8s ease-out;
}

/* PROXIMITY SEARCH */
.proximity-card .form-input { margin-bottom: 8px; }
.proximity-result { font-size: 0.78rem; color: var(--accent); margin-top: 6px; }
.proximity-actions { display: flex; gap: 6px; margin-top: 8px; }

/* LEGAL DISCLAIMER */
.legal-disclaimer {
    font-size: 0.7rem;
    color: var(--muted);
    padding: 8px 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 12px;
    line-height: 1.4;
}

/* PDF BUTTON */
.btn-pdf {
    background: #e67e22;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    width: 100%;
    margin-top: 6px;
}
.btn-pdf:hover { background: #d35400; }

/* LOADING */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 25, 35, 0.88);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay p { margin-top: 14px; color: var(--muted); }

/* MOBILE MENU TOGGLE */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 1.2rem;
    cursor: pointer;
    font-family: inherit;
    line-height: 1;
}

.sidebar-toggle {
    display: none;
    width: 100%;
    padding: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    border-radius: var(--radius);
    text-align: center;
}

/* RESPONSIVE */
@media (max-width: 900px) {
    .topbar {
        flex-wrap: wrap;
        height: auto;
        padding: 8px 12px;
        gap: 6px;
    }

    .topbar-brand h1 { font-size: 0.85rem; }
    .brand-sub { display: none; }
    .brand-icon { width: 28px; height: 28px; font-size: 0.9rem; }

    .mobile-menu-btn { display: block; }

    .topbar-tabs {
        display: none;
        order: 3;
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 2px;
    }

    .topbar-tabs.open { display: flex; }

    .tab-btn {
        padding: 10px 14px;
        font-size: 0.78rem;
        flex: 1;
        min-width: 70px;
        text-align: center;
        min-height: 44px;
    }

    .topbar-actions {
        order: 2;
        gap: 4px;
    }

    .topbar-live {
        font-size: 0.72rem;
        margin-left: auto;
    }

    .main-content {
        height: calc(100vh - 50px);
        overflow: hidden;
    }

    .map-layout {
        flex-direction: column;
        height: 100%;
    }

    .sidebar {
        width: 100%;
        min-width: unset;
        max-height: 30vh;
        overflow-y: auto;
        padding: 6px;
        gap: 4px;
        flex-shrink: 0;
        scroll-behavior: smooth;
        transition: max-height 0.3s ease, padding 0.3s ease;
    }

    .sidebar.collapsed {
        max-height: 0;
        padding: 0 6px;
        overflow: hidden;
    }

    .sidebar .card {
        margin-bottom: 0;
    }

    .sidebar.collapsed .proximity-card,
    .sidebar.collapsed .stats-card {
        display: none;
    }

    .service-type-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2px;
    }

    .service-cb {
        padding: 6px 4px;
        min-height: 44px;
        font-size: 0.75rem;
    }

    .sidebar-toggle {
        display: block;
        min-height: 40px;
    }

    #map {
        flex: 1;
        min-height: 0;
    }

    .card-header { padding: 6px 10px; font-size: 0.7rem; }
    .card-body { padding: 6px 10px; }

    .form-select, .form-input {
        padding: 10px;
        font-size: 0.9rem;
        min-height: 44px;
    }

    .btn-load {
        padding: 12px;
        font-size: 0.9rem;
        min-height: 44px;
    }

    .btn-export, .btn-pdf {
        min-height: 44px;
        font-size: 0.85rem;
    }

    .stat-category { font-size: 0.75rem; }
    .stat-row { font-size: 0.8rem; }

    .legend-card { display: none; }

    .trend-summary { grid-template-columns: 1fr; }
    .analytics-grid { grid-template-columns: 1fr; }
    .analytics-chart-grid { grid-template-columns: 1fr; }
    .safety-row { grid-template-columns: 1fr auto auto 60px; }

    .news-layout, .court-layout, .radio-layout, .analytics-layout {
        padding: 12px;
    }

    .news-grid {
        grid-template-columns: 1fr;
    }

    .news-card {
        padding: 14px;
    }

    .news-card-title { font-size: 0.9rem; }

    .court-search-box {
        flex-direction: column;
    }

    .court-inputs {
        flex-direction: column;
    }

    .court-input { width: 100%; }

    .court-search-box .btn-load {
        width: 100%;
    }

    .radio-filter-row {
        flex-direction: column;
        gap: 6px;
    }

    .radio-filter-row .form-select { max-width: 100%; }

    .talkgroup-grid {
        grid-template-columns: 1fr;
    }

    .radio-links {
        flex-direction: column;
    }

    .radio-links .btn-small, .radio-links .btn-outline {
        text-align: center;
        padding: 12px;
        font-size: 0.85rem;
        min-height: 44px;
    }

    .sys-info-grid {
        grid-template-columns: 1fr 1fr;
    }

    .leaflet-popup-content {
        font-size: 0.82rem;
        max-width: 240px;
    }

    .leaflet-popup-close-button {
        width: 28px !important;
        height: 28px !important;
        font-size: 20px !important;
    }

    .toast-container {
        left: 12px;
        right: 12px;
        max-width: none;
        bottom: 12px;
    }

    .toast {
        font-size: 0.82rem;
        padding: 10px 14px;
    }

    .topbar-actions .btn-theme,
    .topbar-actions .btn-alert {
        padding: 6px 10px;
        font-size: 0.68rem;
        min-height: 36px;
    }

    .auto-refresh-bar {
        padding: 4px 8px;
    }

    .incident-card {
        width: 100%;
        max-width: 100%;
        right: 0;
        top: auto;
        bottom: 0;
        max-height: 50vh;
        border-radius: 12px 12px 0 0;
    }

    .view-toggle {
        gap: 2px;
    }

    .view-btn {
        padding: 8px 12px;
        min-height: 40px;
        font-size: 0.78rem;
    }

    .proximity-actions {
        flex-direction: row;
        gap: 6px;
    }

    .proximity-actions button {
        flex: 1;
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    .topbar { padding: 6px 8px; }
    .topbar-brand h1 { font-size: 0.75rem; }
    .brand-icon { width: 24px; height: 24px; font-size: 0.8rem; }

    .tab-btn {
        padding: 10px 8px;
        font-size: 0.72rem;
        min-height: 44px;
    }

    .sidebar {
        max-height: 28vh;
        padding: 4px;
    }

    .card-header { padding: 5px 8px; font-size: 0.68rem; }
    .card-body { padding: 5px 8px; }

    .service-type-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .sys-info-grid { grid-template-columns: 1fr; }

    .tg-card { padding: 10px; gap: 4px; }
    .tg-name { font-size: 0.82rem; }

    .trend-card {
        padding: 12px;
    }

    .trend-card-value {
        font-size: 1.4rem;
    }

    .court-case {
        padding: 10px;
    }

    .hotspot-list, .safety-table {
        font-size: 0.8rem;
    }
}
