/* ============================================
   SzegedenKözlekedNénk - Dark Theme Stylesheet
   ============================================ */

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #1c2128;
    --border: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --red: #f85149;
    --orange: #d29922;
    --green: #3fb950;
    --purple: #bc8cff;
    --blue: #58a6ff;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header */
header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

header h1 {
    font-size: 1.2rem;
    white-space: nowrap;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    flex: 1;
}

nav {
    display: flex;
    gap: 12px;
    align-items: center;
}

nav a {
    color: var(--accent);
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.82rem;
    transition: background 0.2s;
}

nav a:hover, nav a.active {
    background: rgba(88, 166, 255, 0.1);
}

.btn-fetch {
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.btn-logout {
    color: #f85149 !important;
    opacity: 0.8;
}
.btn-logout:hover {
    opacity: 1;
    background: rgba(248, 81, 73, 0.1);
}

.btn-push {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}
.btn-push:hover {
    background: rgba(88, 166, 255, 0.1);
    border-color: var(--accent);
}

/* AI Disclaimer Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px 32px;
    max-width: 480px;
    width: 100%;
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.modal-card h3 {
    margin: 0 0 14px;
    font-size: 1.25rem;
    color: #d29922;
}
.modal-card p {
    margin: 0 0 12px;
    line-height: 1.6;
    color: var(--text-secondary);
}
.btn-accept {
    display: block;
    width: 100%;
    margin-top: 18px;
    padding: 10px;
    border: none;
    border-radius: 6px;
    background: #238636;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}
.btn-accept:hover {
    background: #2ea043;
}

/* Main content */
main {
    padding: 16px 0;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 12px;
}

/* Stats Cards */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    text-align: center;
    padding: 12px 8px;
    transition: transform 0.2s, border-color 0.2s;
}

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

.stat-number {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}

.stat-card.highlight .stat-number {
    color: var(--orange);
}

.stat-card.accent .stat-number {
    color: var(--red);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Charts */
.chart-card {
    min-height: 220px;
}

.chart-card.wide {
    grid-column: span 4;
    min-height: 180px;
}

.chart-card.half-wide {
    grid-column: span 2;
    min-height: 180px;
}

.chart-card h3 {
    font-size: 0.85rem;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

/* Filters */
.filters {
    margin-bottom: 12px;
    padding: 10px 14px;
}

.filter-row {
    display: flex;
    gap: 16px;
    align-items: end;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group select,
.filter-group input {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.9rem;
    min-width: 150px;
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}

.btn:hover {
    background: var(--accent-hover);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
}

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

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(88, 166, 255, 0.05);
}

/* Incidents */
.incidents-section h2 {
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.incident-card {
    border-left: 3px solid var(--border);
    transition: border-color 0.2s, transform 0.1s;
}

.incident-card:hover {
    transform: translateX(4px);
}

.incident-card.type-baleset {
    border-left-color: var(--red);
}

.incident-card.type-forgalmi_zavar {
    border-left-color: var(--orange);
}

.incident-card.type-kisiklas {
    border-left-color: var(--purple);
}

.incident-card.type-gazolas {
    border-left-color: #c0392b;
}

.incident-card.type-potlobusz {
    border-left-color: var(--blue);
}

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

.incident-header time {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-left: auto;
}

.incident-card h3,
.incident-card h4 {
    font-size: 1.05rem;
    margin-bottom: 8px;
}

.incident-card h3 a,
.incident-card h4 a {
    color: var(--text-primary);
    text-decoration: none;
}

.incident-card h3 a:hover,
.incident-card h4 a:hover {
    color: var(--accent);
}

.incident-location {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.incident-lines {
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.line-badge {
    display: inline-block;
    background: rgba(88, 166, 255, 0.15);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    margin: 2px 4px;
}

.incident-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.incident-footer {
    display: flex;
    gap: 8px;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.source-szkt {
    background: rgba(88, 166, 255, 0.15);
    color: var(--accent);
}

.source-szeged365 {
    background: rgba(46, 204, 113, 0.15);
    color: var(--green);
}

.type-badge {
    background: rgba(210, 153, 34, 0.15);
    color: var(--orange);
}

.resolved {
    background: rgba(63, 185, 80, 0.15);
    color: var(--green);
}

.active {
    background: rgba(248, 81, 73, 0.15);
    color: var(--red);
}

.match-score {
    font-size: 0.8rem;
    color: var(--purple);
}

/* Severity badges */
.severity-critical {
    background: rgba(248, 81, 73, 0.25);
    color: #ff6b6b;
    border: 1px solid rgba(248, 81, 73, 0.3);
}

.severity-high {
    background: rgba(210, 153, 34, 0.25);
    color: #f0a830;
    border: 1px solid rgba(210, 153, 34, 0.3);
}

.severity-medium {
    background: rgba(227, 217, 105, 0.2);
    color: #e3d969;
    border: 1px solid rgba(227, 217, 105, 0.25);
}

.severity-low {
    background: rgba(63, 185, 80, 0.2);
    color: var(--green);
    border: 1px solid rgba(63, 185, 80, 0.25);
}

.severity-unknown {
    background: rgba(139, 148, 158, 0.15);
    color: var(--text-secondary);
}

/* AI Analysis box */
.ai-analysis {
    background: rgba(88, 166, 255, 0.06);
    border: 1px solid rgba(88, 166, 255, 0.15);
    border-left: 3px solid var(--accent);
    margin: 16px 0;
    padding: 16px !important;
}

.ai-analysis h4 {
    margin-bottom: 8px;
    color: var(--accent);
}

.ai-analysis p {
    margin-bottom: 12px;
}

.ai-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.ai-meta span {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 4px;
}

/* AI summary in list */
.ai-summary {
    font-size: 0.85rem;
    color: var(--accent);
    margin: 4px 0;
    font-style: italic;
}

.incident-potlobusz {
    color: var(--orange);
    font-weight: 600;
    font-size: 0.9rem;
}

/* Detail page */
.incident-detail {
    border-left: 4px solid var(--accent);
}

.incident-detail h2 {
    font-size: 1.5rem;
    margin: 16px 0;
}

.incident-meta {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.incident-meta time {
    color: var(--text-secondary);
}

.incident-content {
    line-height: 1.8;
    margin-bottom: 20px;
}

.incident-content p {
    margin-bottom: 12px;
}

/* Linked articles section */
.linked-articles {
    margin-top: 30px;
}

.linked-articles h3 {
    font-size: 1.2rem;
    margin-bottom: 16px;
}

.incident-card.linked {
    border-left-color: var(--green);
}

/* ============================================
   Source Tabs
   ============================================ */
.source-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}

.source-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.85rem;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
}

.source-tab:hover {
    color: var(--text-primary);
    border-bottom-color: var(--text-secondary);
}

.source-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-count {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.source-tab.active .tab-count {
    background: rgba(88, 166, 255, 0.15);
    color: var(--accent);
}

/* ============================================
   Active Alerts
   ============================================ */
.active-alerts {
    margin-bottom: 14px;
}

.active-alerts h2 {
    font-size: 1rem;
    margin-bottom: 8px;
    color: var(--red);
}

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

.alert-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--red);
    border-radius: 6px;
    padding: 10px 14px;
    text-decoration: none;
    color: var(--text-primary);
    transition: border-color 0.2s, background 0.2s;
}

.alert-card:hover {
    background: rgba(248, 81, 73, 0.06);
    border-color: var(--red);
}

.alert-card.severity-border-critical { border-left-color: #ff6b6b; }
.alert-card.severity-border-high { border-left-color: #f0a830; }
.alert-card.severity-border-medium { border-left-color: #e3d969; }
.alert-card.severity-border-low { border-left-color: var(--green); }

.alert-left {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 100px;
}

.alert-center {
    flex: 1;
}

.alert-lines {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.alert-vehicle-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-left: 8px;
}

.alert-location {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.alert-right {
    text-align: right;
    min-width: 80px;
}

.alert-time {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.potlobusz-badge {
    background: rgba(210, 153, 34, 0.2);
    color: var(--orange);
}

/* ============================================
   Vehicle Type Badges
   ============================================ */
.line-badge.vehicle-villamos {
    background: rgba(243, 156, 18, 0.2);
    color: #f39c12;
}

.line-badge.vehicle-trolibusz {
    background: rgba(52, 152, 219, 0.2);
    color: #3498db;
}

.line-badge.vehicle-tram-train {
    background: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
}

.line-badge.vehicle-unknown {
    background: rgba(139, 148, 158, 0.15);
    color: var(--text-secondary);
}

/* ============================================
   Incident Table
   ============================================ */
.incident-table-wrap {
    overflow-x: auto;
    margin-bottom: 16px;
}

.incident-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.incident-table thead th {
    text-align: left;
    padding: 7px 10px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.incident-table tbody tr {
    cursor: pointer;
    border-bottom: 1px solid rgba(48, 54, 61, 0.5);
    transition: background 0.15s;
}

.incident-table tbody tr:hover {
    background: rgba(88, 166, 255, 0.06);
}

.incident-table td {
    padding: 7px 10px;
    vertical-align: middle;
}

.incident-row.severity-row-critical { border-left: 3px solid #ff6b6b; }
.incident-row.severity-row-high { border-left: 3px solid #f0a830; }
.incident-row.severity-row-medium { border-left: 3px solid #e3d969; }
.incident-row.severity-row-low { border-left: 3px solid var(--green); }
.incident-row.severity-row-unknown { border-left: 3px solid var(--text-secondary); }

.col-time {
    white-space: nowrap;
    min-width: 80px;
}

.time-relative {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
}

.time-absolute {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.col-lines {
    white-space: nowrap;
}

.col-vehicle {
    font-size: 0.85rem;
    white-space: nowrap;
}

.col-location {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.col-type, .col-severity, .col-status {
    white-space: nowrap;
}

.col-admin-action {
    white-space: nowrap;
}

.col-admin-action form {
    margin: 0;
}

.text-muted {
    color: var(--text-secondary);
}

.empty-cell {
    text-align: center;
    padding: 24px !important;
    color: var(--text-secondary);
}

.active-badge {
    background: rgba(248, 81, 73, 0.15);
    color: var(--red);
    animation: pulse-active 2s infinite;
}

@keyframes pulse-active {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ============================================
   Charts grid - 4 columns
   ============================================ */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

@media (max-width: 1280px) {
    .charts-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .chart-card.wide {
        grid-column: span 3;
    }
    .chart-card.half-wide {
        grid-column: span 3;
    }
}

@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .chart-card.wide {
        grid-column: span 2;
    }
    .chart-card.half-wide {
        grid-column: span 2;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 14px;
    }

    nav {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
    }

    nav a {
        font-size: 0.8rem;
        padding: 6px 8px;
    }

    .source-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        gap: 2px;
    }

    .source-tab {
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 8px 12px;
    }

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

    .chart-card.wide {
        grid-column: span 1;
    }

    .chart-card.half-wide {
        grid-column: span 1;
    }

    .alert-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .alert-left {
        flex-direction: row;
        gap: 6px;
    }

    .alert-right {
        text-align: left;
    }

    .incident-table {
        font-size: 0.8rem;
    }

    .incident-table td,
    .incident-table th {
        padding: 8px 6px;
    }

    .col-vehicle,
    .col-location {
        display: none;
    }

    .header-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-row {
        flex-direction: column;
    }

    .filter-group select,
    .filter-group input {
        min-width: auto;
        width: 100%;
    }

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

    #incident-map {
        height: 320px;
    }

    .map-layer-control {
        position: static;
        margin-top: 10px;
        width: 100%;
        min-width: 0;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .layer-control-title {
        grid-column: 1 / -1;
        margin-bottom: 0;
    }

    .layer-group {
        margin-bottom: 0;
    }

    .modal-overlay {
        align-items: flex-start;
        padding: 10px;
        overflow-y: auto;
    }

    .modal-card {
        max-width: 100%;
        max-height: none;
        padding: 16px 14px;
        border-radius: 10px;
    }

    .modal-card h3 {
        font-size: 1.06rem;
        margin-bottom: 10px;
    }

    .modal-card p {
        font-size: 0.92rem;
        line-height: 1.45;
        word-break: break-word;
    }

    .btn-accept {
        margin-top: 12px;
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .stats-cards {
        grid-template-columns: 1fr;
    }

    .pagination {
        flex-wrap: wrap;
        gap: 10px;
    }

    .incident-table {
        font-size: 0.76rem;
    }

    .incident-table td,
    .incident-table th {
        padding: 7px 5px;
    }

    #incident-map {
        height: 270px;
    }

    .map-layer-control {
        grid-template-columns: 1fr;
    }
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
}

.page-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ===== Incident Map ===== */
.map-section {
    padding: 14px;
}

.map-section h2 {
    margin-bottom: 10px;
    font-size: 1rem;
}

.map-container {
    position: relative;
}

.map-layer-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.map-layer-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

#incident-map {
    height: 420px;
    border-radius: 8px;
    border: 1px solid var(--border);
    z-index: 1;
}

/* Layer Control Panel */
.map-layer-control {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    background: rgba(13, 17, 23, 0.92);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    min-width: 155px;
    max-width: calc(100% - 20px);
    max-height: calc(100% - 20px);
    overflow: auto;
    backdrop-filter: blur(6px);
}

/* Heatmap Filter Panel */
.heatmap-filter-panel {
    margin-top: 10px;
    max-width: 400px;
    background: rgba(13, 17, 23, 0.92);
    border: 1px solid var(--border);
    border-radius: 8px;
    backdrop-filter: blur(6px);
}

.filter-panel-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    border-radius: 8px;
    transition: background 0.2s;
}

.filter-panel-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
}

.filter-panel-toggle .toggle-icon {
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.filter-panel-content {
    padding: 0 12px 12px 12px;
}

.heatmap-filter-panel .filter-section {
    margin-bottom: 12px;
}

.heatmap-filter-panel .filter-section:last-child {
    margin-bottom: 0;
}

.heatmap-filter-panel .filter-section > label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.heatmap-filter-panel select {
    width: 100%;
    padding: 6px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
}

.heatmap-filter-panel select:focus {
    outline: none;
    border-color: var(--accent);
}


.heatmap-filter-panel .filter-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.heatmap-filter-panel .filter-checkboxes label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-primary);
    cursor: pointer;
}

.heatmap-filter-panel .filter-checkboxes input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
    cursor: pointer;
    margin: 0;
}

.layer-control-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.layer-group {
    margin-bottom: 8px;
}

.layer-group:last-child {
    margin-bottom: 0;
}

.layer-group-title {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.layer-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 2px 0;
}

.layer-checkbox input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
    cursor: pointer;
    margin: 0;
}

.layer-color {
    display: inline-block;
    width: 14px;
    height: 4px;
    border-radius: 2px;
}

.layer-icon {
    font-size: 0.75rem;
    width: 14px;
    text-align: center;
}

.map-legend {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: center;
    font-size: 0.85rem;
}

/* Heatmap Legend */
.heatmap-legend {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 1000;
    background: rgba(13, 17, 23, 0.92);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    min-width: 200px;
    backdrop-filter: blur(6px);
}

.legend-gradient {
    height: 12px;
    border-radius: 4px;
    background: linear-gradient(to right, blue, lime, yellow, red);
    margin-bottom: 6px;
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-primary);
}

.legend-labels span {
    white-space: nowrap;
}

.map-legend strong {
    margin-right: 4px;
}

.map-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.map-legend-line {
    display: inline-block;
    width: 20px;
    height: 4px;
    border-radius: 2px;
}

.map-legend-item small {
    color: var(--text-secondary);
}

.incident-marker .marker-pin {
    --pin-color: #ff6b6b;
    display: flex;
    flex-direction: column;
    align-items: center;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.incident-marker .pin-head {
    width: 18px;
    height: 18px;
    border-radius: 50% 50% 50% 0;
    background: var(--pin-color);
    transform: rotate(-45deg);
    border: 2px solid rgba(255,255,255,0.8);
    box-sizing: border-box;
}

.incident-marker .pin-needle {
    width: 2px;
    height: 10px;
    background: linear-gradient(to bottom, var(--pin-color), #555);
    margin-top: -2px;
    border-radius: 0 0 1px 1px;
}

.incident-marker .marker-pin.marker-active .pin-head {
    animation: marker-pulse 2s infinite;
}

@keyframes marker-pulse {
    0%, 100% { box-shadow: 0 0 4px rgba(255,255,255,0.2); }
    50% { box-shadow: 0 0 12px rgba(255,255,255,0.5); }
}

.map-popup {
    font-size: 0.85rem;
    line-height: 1.5;
    color: #222;
}

.map-popup strong {
    color: #111;
}

/* Keep this block after base map styles so it wins on small screens. */
@media (max-width: 1024px) {
    .map-container {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .map-layer-toggle {
        display: inline-flex;
        width: 100%;
    }

    .map-layer-control {
        position: static;
        top: auto;
        right: auto;
        width: 100%;
        min-width: 0;
        max-width: 100%;
        max-height: none;
        overflow: visible;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .map-layer-control.is-collapsed {
        display: none;
    }

    .layer-control-title {
        grid-column: 1 / -1;
        margin-bottom: 0;
    }

    .layer-group {
        margin-bottom: 0;
    }

    .heatmap-filter-panel {
        width: 100%;
    }

    .heatmap-filter-panel .filter-checkboxes {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .heatmap-legend {
        position: static;
        margin-top: 10px;
        width: 100%;
        min-width: 0;
    }
}

@media (max-width: 520px) {
    .map-layer-control {
        grid-template-columns: 1fr;
    }

    .heatmap-filter-panel .filter-checkboxes {
        grid-template-columns: 1fr;
    }
}

/* Footer */
footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 12px 0;
    margin-top: 20px;
    text-align: center;
}

footer p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 4px;
}

footer a {
    color: var(--accent);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}
