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

/* Skip link for keyboard users */
.skip-link {
    position: absolute;
    top: -100px;
    left: 10px;
    background: #1e88e5;
    color: #fff;
    padding: 10px 16px;
    border-radius: 4px;
    z-index: 9999;
    font-size: 14px;
    text-decoration: none;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 10px;
}

/* Visually hidden but accessible to screen readers */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus styles for all interactive elements */
:focus-visible {
    outline: 2px solid #1e88e5;
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 2px solid #1e88e5;
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a2e;
}

#map {
    height: 100%;
    width: 100%;
    background: #1a1a2e;
}

/* Dark theme for Leaflet */
.leaflet-container {
    background: #1a1a2e;
}

/* Tile filter applied dynamically via JS based on selected layer */
.leaflet-tile-pane[data-layer="dark"] {
    filter: brightness(0.6) invert(1) contrast(3) hue-rotate(200deg) saturate(0.3) invert(1);
}

.leaflet-tile-pane[data-layer="street"] {
    filter: none;
}

.leaflet-tile-pane[data-layer="satellite"] {
    filter: none;
}

/* Controls */
#controls {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1000;
    display: flex;
    gap: 8px;
}

#filter-toggle {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: rgba(26, 26, 46, 0.95);
    color: #e0e0e0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: background 0.2s;
}

#filter-toggle:hover {
    background: rgba(40, 40, 70, 0.95);
}

#filter-toggle.active {
    background: #1e88e5;
    color: #fff;
}

/* Search */
#search-container {
    position: relative;
}

#suburb-search {
    width: 180px;
    height: 40px;
    padding: 0 12px;
    border-radius: 8px;
    border: none;
    background: rgba(26, 26, 46, 0.95);
    color: #e0e0e0;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

#suburb-search::placeholder {
    color: #666;
}

#suburb-search:focus {
    outline: none;
    box-shadow: 0 0 0 2px #1e88e5;
}

#search-results {
    position: absolute;
    top: 44px;
    left: 0;
    right: 0;
    background: rgba(26, 26, 46, 0.98);
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#search-results.hidden {
    display: none;
}

.search-result {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 13px;
    color: #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.search-result:last-child {
    border-bottom: none;
}

.search-result:hover,
.search-result.selected {
    background: rgba(255, 255, 255, 0.1);
}

.search-result.selected {
    outline: 2px solid #1e88e5;
    outline-offset: -2px;
}

.search-result-count {
    font-size: 11px;
    color: #888;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 10px;
}

/* Location button */
#location-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: rgba(26, 26, 46, 0.95);
    color: #e0e0e0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: background 0.2s;
}

#location-btn:hover {
    background: rgba(40, 40, 70, 0.95);
}

#location-btn.active {
    background: #4caf50;
    color: #fff;
}

#location-btn.loading {
    animation: pulse-btn 1s infinite;
}

@keyframes pulse-btn {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Reset view button */
#reset-view-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: rgba(26, 26, 46, 0.95);
    color: #e0e0e0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: background 0.2s;
}

#reset-view-btn:hover {
    background: rgba(40, 40, 70, 0.95);
}

/* Layers toggle button */
#layers-toggle {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: rgba(26, 26, 46, 0.95);
    color: #e0e0e0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: background 0.2s;
}

#layers-toggle:hover {
    background: rgba(40, 40, 70, 0.95);
}

#layers-toggle.active {
    background: #1e88e5;
    color: #fff;
}

/* Layers panel */
#layers-panel {
    position: fixed;
    top: 60px;
    right: 10px;
    background: rgba(26, 26, 46, 0.98);
    border-radius: 12px;
    padding: 12px;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    transition: transform 0.2s ease, opacity 0.2s ease;
}

#layers-panel.hidden {
    transform: translateY(-10px);
    opacity: 0;
    pointer-events: none;
}

.layers-title {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.layers-title.overlay-section {
    margin-top: 12px;
}

.layers-options {
    display: flex;
    gap: 8px;
}

.layer-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px;
    border-radius: 8px;
    border: 2px solid transparent;
    background: rgba(255, 255, 255, 0.05);
    color: #aaa;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.layer-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
}

.layer-btn.active {
    border-color: #1e88e5;
    color: #fff;
}

.layer-preview {
    width: 48px;
    height: 32px;
    border-radius: 4px;
    background-size: cover;
    background-position: center;
}

.dark-preview {
    background: linear-gradient(135deg, #1a1a2e 0%, #2d2d44 50%, #1a1a2e 100%);
}

.street-preview {
    background: linear-gradient(135deg, #f2efe9 0%, #c8d7c5 50%, #aad3df 100%);
}

.satellite-preview {
    background: linear-gradient(135deg, #2d4a2d 0%, #3d5a3d 50%, #1a3a1a 100%);
}

/* Resources toggle button */
#resources-toggle {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: rgba(26, 26, 46, 0.95);
    color: #e0e0e0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: background 0.2s;
}

#resources-toggle:hover {
    background: rgba(40, 40, 70, 0.95);
}

#resources-toggle.active {
    background: #ff9800;
    color: #fff;
}

/* Resources panel */
#resources-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 320px;
    max-width: 100vw;
    background: rgba(26, 26, 46, 0.98);
    z-index: 1005;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow: hidden;
}

#resources-panel.hidden {
    transform: translateX(100%);
}

.resources-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.resources-header h2 {
    margin: 0;
    font-size: 18px;
    color: #fff;
    font-weight: 600;
}

#resources-close {
    background: none;
    border: none;
    color: #888;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#resources-close:hover {
    color: #fff;
}

.resources-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.resource-section {
    margin-bottom: 24px;
}

.resource-section:last-child {
    margin-bottom: 0;
}

.resource-section h3 {
    font-size: 13px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 12px 0;
}

/* Contact list */
.contact-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.contact-item {
    display: flex;
    flex-direction: column;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.2s;
}

.contact-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.contact-item.emergency {
    background: rgba(229, 57, 53, 0.2);
    border: 1px solid rgba(229, 57, 53, 0.4);
}

.contact-item.emergency:hover {
    background: rgba(229, 57, 53, 0.3);
}

.contact-number {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 2px;
}

.contact-item.emergency .contact-number {
    color: #ff6b6b;
}

.contact-label {
    font-size: 12px;
    color: #888;
}

/* Checklist */
.checklist {
    list-style: none;
    padding: 0;
    margin: 0;
}

.checklist li {
    position: relative;
    padding: 8px 0 8px 24px;
    font-size: 13px;
    color: #e0e0e0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.checklist li:last-child {
    border-bottom: none;
}

.checklist li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 12px;
    width: 12px;
    height: 12px;
    border: 2px solid #4caf50;
    border-radius: 3px;
}

/* Link list */
.link-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.link-list a {
    display: block;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    color: #64b5f6;
    text-decoration: none;
    font-size: 13px;
    transition: background 0.2s;
}

.link-list a:hover {
    background: rgba(255, 255, 255, 0.1);
}

.link-list a::after {
    content: ' ↗';
    opacity: 0.5;
}

/* History toggle button */
#history-toggle {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: rgba(26, 26, 46, 0.95);
    color: #e0e0e0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: background 0.2s;
}

#history-toggle:hover {
    background: rgba(40, 40, 70, 0.95);
}

#history-toggle.active {
    background: #9c27b0;
    color: #fff;
}

/* History panel */
#history-panel {
    position: fixed;
    top: 60px;
    right: 10px;
    width: 240px;
    background: rgba(26, 26, 46, 0.98);
    border-radius: 12px;
    padding: 12px;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    transition: transform 0.2s ease, opacity 0.2s ease;
}

#history-panel.hidden {
    transform: translateY(-10px);
    opacity: 0;
    pointer-events: none;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.history-title {
    font-size: 13px;
    font-weight: 600;
    color: #e0e0e0;
}

.heatmap-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #888;
    cursor: pointer;
}

.heatmap-toggle input {
    accent-color: #9c27b0;
}

.history-stats {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.stat-item {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: #fff;
}

.stat-label {
    font-size: 10px;
    color: #888;
    text-transform: uppercase;
}

.history-breakdown {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.breakdown-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

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

.breakdown-label {
    flex: 1;
    color: #aaa;
}

.breakdown-count {
    color: #e0e0e0;
    font-weight: 600;
}

.history-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#history-storage {
    font-size: 10px;
    color: #666;
}

.clear-btn {
    padding: 4px 10px;
    border-radius: 4px;
    border: none;
    background: rgba(229, 57, 53, 0.2);
    color: #e53935;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.2s;
}

.clear-btn:hover {
    background: rgba(229, 57, 53, 0.4);
}

/* Latest incidents panel */
#latest-panel {
    position: fixed;
    top: 60px;
    right: 60px;
    width: 280px;
    max-height: calc(100vh - 180px);
    background: rgba(26, 26, 46, 0.95);
    border-radius: 12px;
    z-index: 999;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    overflow: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

#latest-panel.collapsed {
    max-height: 44px;
}

#latest-panel.collapsed #latest-incidents {
    display: none;
}

#latest-panel.collapsed #latest-collapse {
    transform: rotate(180deg);
}

.latest-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 13px;
    font-weight: 600;
    color: #e0e0e0;
}

#latest-collapse {
    background: none;
    border: none;
    color: #888;
    font-size: 12px;
    cursor: pointer;
    padding: 4px;
    transition: transform 0.2s;
}

#latest-collapse:hover {
    color: #fff;
}

#latest-incidents {
    max-height: calc(100vh - 240px);
    overflow-y: auto;
}

.latest-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background 0.2s, opacity 0.3s ease;
    /* Age-based opacity - fades over time for active incidents */
    opacity: var(--age-opacity, 1);
}

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

.latest-item:hover {
    background: rgba(255, 255, 255, 0.05);
    opacity: min(calc(var(--age-opacity, 1) + 0.2), 1);
}

/* Inactive incidents override age-based opacity */
.latest-item.inactive {
    opacity: 0.4;
}

.latest-item.inactive:hover {
    opacity: 0.7;
}

.latest-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.latest-icon svg {
    width: 100%;
    height: 100%;
}

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

.latest-title {
    font-size: 12px;
    color: #e0e0e0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.latest-suburb {
    font-size: 11px;
    color: #888;
}

.latest-status {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 8px;
    text-transform: uppercase;
    font-weight: 600;
    flex-shrink: 0;
}

.latest-empty {
    padding: 20px;
    text-align: center;
    color: #666;
    font-size: 13px;
}

.latest-overlays {
    display: flex;
    gap: 12px;
    padding: 8px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.latest-overlay-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #aaa;
    cursor: pointer;
    transition: color 0.2s;
}

.latest-overlay-toggle:hover {
    color: #fff;
}

.latest-overlay-toggle input {
    width: 14px;
    height: 14px;
    accent-color: #4fc3f7;
    cursor: pointer;
}

.latest-overlay-toggle input:checked + span {
    color: #4fc3f7;
}

/* Mobile: hide latest panel */
@media (max-width: 600px) {
    #latest-panel {
        display: none;
    }
}

/* Radius selector */
#radius-selector {
    position: fixed;
    top: 60px;
    left: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(26, 26, 46, 0.98);
    padding: 8px 10px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

#radius-selector.hidden {
    transform: translateY(-10px);
    opacity: 0;
    pointer-events: none;
}

.radius-label {
    font-size: 12px;
    color: #888;
}

.radius-btn {
    padding: 4px 8px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    color: #aaa;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.radius-btn:hover {
    border-color: rgba(255, 255, 255, 0.4);
    color: #e0e0e0;
}

.radius-btn.active {
    background: #4caf50;
    border-color: #4caf50;
    color: #fff;
}

#clear-location {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(229, 57, 53, 0.2);
    color: #e53935;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
}

#clear-location:hover {
    background: rgba(229, 57, 53, 0.4);
}

#notify-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: #888;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
    transition: all 0.2s;
}

#notify-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

#notify-btn.active {
    background: #ff9800;
    border-color: #ff9800;
    color: #fff;
}

/* Notification settings panel */
#notify-settings {
    position: fixed;
    top: 95px;
    left: 10px;
    background: rgba(26, 26, 46, 0.98);
    border-radius: 12px;
    padding: 12px;
    z-index: 1001;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    min-width: 160px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

#notify-settings.hidden {
    transform: translateY(-10px);
    opacity: 0;
    pointer-events: none;
}

.notify-header {
    font-size: 12px;
    color: #888;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.notify-agencies {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.notify-agency-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #e0e0e0;
    transition: background 0.2s;
}

.notify-agency-option:hover {
    background: rgba(255, 255, 255, 0.1);
}

.notify-agency-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #ff9800;
    cursor: pointer;
}

.notify-agency-option .chip-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.notify-disable-btn {
    width: 100%;
    margin-top: 10px;
    padding: 8px 12px;
    border: 1px solid rgba(229, 57, 53, 0.5);
    border-radius: 6px;
    background: transparent;
    color: #e53935;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.notify-disable-btn:hover {
    background: rgba(229, 57, 53, 0.2);
    border-color: #e53935;
}

/* Filter panel */
#filter-panel {
    position: fixed;
    top: 60px;
    left: 10px;
    background: rgba(26, 26, 46, 0.98);
    border-radius: 12px;
    padding: 12px;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    max-width: calc(100vw - 20px);
    transition: transform 0.2s ease, opacity 0.2s ease;
}

#filter-panel.hidden {
    transform: translateY(-10px);
    opacity: 0;
    pointer-events: none;
}

.filter-section {
    margin-bottom: 12px;
    border: none;
    padding: 0;
}

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

.filter-label,
.filter-section legend {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    color: #aaa;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-chip:hover {
    border-color: rgba(255, 255, 255, 0.4);
    color: #e0e0e0;
}

.filter-chip.active {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
}

.chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* Agency Colors - for chip-dots, breakdown-dots, and icons */
[data-agency="ambulance"] {
    background: #1e88e5;
}

[data-agency="fire"] {
    background: #e53935;
}

[data-agency="ses"] {
    background: #ff9800;
}

[data-agency="police"] {
    background: #5e35b1;
}

[data-agency="other"] {
    background: #607d8b;
}

/* Agency text colors - for popup titles and icons */
[data-agency-color="ambulance"] {
    color: #1e88e5;
}

[data-agency-color="fire"] {
    color: #e53935;
}

[data-agency-color="ses"] {
    color: #ff9800;
}

[data-agency-color="police"] {
    color: #5e35b1;
}

[data-agency-color="other"] {
    color: #607d8b;
}

/* Status bar */
#status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(26, 26, 46, 0.95);
    color: #e0e0e0;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    z-index: 1000;
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#incident-count {
    font-weight: 600;
}

#last-update {
    color: #4caf50;
    font-size: 12px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(76, 175, 80, 0.15);
    transition: all 0.3s ease;
}

#last-update:empty {
    display: none;
}

#last-update.stale {
    color: #ff9800;
    background: rgba(255, 152, 0, 0.15);
}

#last-update.very-stale {
    color: #f44336;
    background: rgba(244, 67, 54, 0.15);
    animation: stale-pulse 2s infinite;
}

@keyframes stale-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Badge Labels */
.badge-label {
    font-size: 10px;
    color: #e0e0e0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 4px;
}

/* AQI Badge */
#aqi-badge {
    display: flex;
    align-items: center;
    gap: 4px;
}

.aqi-value {
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 12px;
}

.aqi-label {
    font-size: 11px;
    color: #888;
}

/* AQI Level Colors */
.aqi-value[data-level="good"],
.aqi-marker[data-level="good"] {
    background: #00e400;
    color: #000;
}

.aqi-value[data-level="fair"],
.aqi-marker[data-level="fair"] {
    background: #ffff00;
    color: #000;
}

.aqi-value[data-level="poor"],
.aqi-marker[data-level="poor"] {
    background: #ff7e00;
    color: #000;
}

.aqi-value[data-level="very-poor"],
.aqi-marker[data-level="very-poor"] {
    background: #ff0000;
    color: #fff;
}

.aqi-value[data-level="hazardous"],
.aqi-marker[data-level="hazardous"] {
    background: #7e0023;
    color: #fff;
}

.aqi-value[data-level="no-data"],
.aqi-marker[data-level="no-data"] {
    background: #666;
    color: #fff;
}

/* Fire Danger Badge */
#fire-danger-badge {
    display: flex;
    align-items: center;
    gap: 4px;
}

#fire-danger-badge.hidden {
    display: none;
}

.fire-danger-value {
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
}

/* Fire Danger Rating Levels */
.fire-danger-value[data-rating="no-rating"] {
    background: #4a4a4a;
    color: #fff;
}

.fire-danger-value[data-rating="moderate"] {
    background: #00a651;
    color: #fff;
}

.fire-danger-value[data-rating="high"] {
    background: #fff200;
    color: #000;
}

.fire-danger-value[data-rating="very-high"] {
    background: #f7941d;
    color: #000;
}

.fire-danger-value[data-rating="severe"] {
    background: #ed1c24;
    color: #fff;
}

.fire-danger-value[data-rating="extreme"] {
    background: #a6192e;
    color: #fff;
}

.fire-danger-value[data-rating="catastrophic"] {
    background: #000;
    color: #fff;
}

/* AQI Map Markers */
.aqi-marker-container {
    background: transparent !important;
}

.aqi-marker {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    opacity: 0.85;
}

/* Incident popup */
.popup {
    position: fixed;
    bottom: 50px;
    left: 10px;
    right: 10px;
    max-width: 400px;
    margin: 0 auto;
    background: rgba(26, 26, 46, 0.98);
    border-radius: 12px;
    padding: 16px;
    z-index: 1001;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.popup.hidden {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}

#popup-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

#popup-close:hover {
    color: #fff;
}

#popup-content {
    color: #e0e0e0;
}

#popup-content h3 {
    margin-bottom: 12px;
    font-size: 16px;
    line-height: 1.3;
    display: flex;
    align-items: center;
    gap: 8px;
}

.popup-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.popup-icon svg {
    width: 100%;
    height: 100%;
}

#popup-content .detail {
    display: flex;
    margin-bottom: 8px;
    font-size: 14px;
}

#popup-content .detail-label {
    color: #888;
    min-width: 80px;
    flex-shrink: 0;
}

#popup-content .detail-value {
    color: #e0e0e0;
}

#popup-content .status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-top: 8px;
}

.status-responding { background: #2e7d32; color: #fff; }
.status-onscene { background: #1565c0; color: #fff; }
.status-pending { background: #f57c00; color: #fff; }
.status-default { background: #555; color: #fff; }

/* Popup action buttons */
.popup-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.popup-share-btn,
.popup-directions-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}

.popup-share-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
}

.popup-share-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.popup-directions-btn {
    background: #1e88e5;
    color: #fff;
}

.popup-directions-btn:hover {
    background: #1976d2;
}

/* Offline indicator */
#offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #f57c00;
    color: #fff;
    text-align: center;
    padding: 8px;
    font-size: 13px;
    z-index: 1002;
    transition: transform 0.3s ease;
}

#offline-indicator.hidden {
    transform: translateY(-100%);
}

/* Error toast */
#error-toast {
    position: fixed;
    bottom: 60px;
    left: 10px;
    right: 10px;
    max-width: 400px;
    margin: 0 auto;
    background: rgba(198, 40, 40, 0.95);
    color: #fff;
    padding: 12px 40px 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    z-index: 1003;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

#error-toast.hidden {
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
}

#error-dismiss {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}

#error-dismiss:hover {
    color: #fff;
}

/* Loading overlay */
#loading-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    background: rgba(26, 26, 46, 0.95);
    padding: 24px 32px;
    border-radius: 12px;
    color: #e0e0e0;
    font-size: 14px;
    z-index: 1004;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    transition: opacity 0.3s ease;
}

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

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #1e88e5;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Skeleton loading */
.skeleton {
    display: inline-block;
    background: linear-gradient(90deg,
        rgba(255, 255, 255, 0.1) 25%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0.1) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

.skeleton-text {
    width: 100px;
    height: 14px;
}

.skeleton-badge {
    width: 50px;
    height: 20px;
    border-radius: 10px;
}

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

/* Custom markers */
.incident-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    transition: transform 0.2s ease, opacity 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
    opacity: var(--age-opacity, 1);
    position: relative;
}

.incident-marker svg {
    width: 100%;
    height: 100%;
}

.incident-marker:hover {
    transform: scale(1.2);
    opacity: min(calc(var(--age-opacity, 1) + 0.2), 1);
}

/* Radar ring effect for new incidents */
.incident-marker.new-incident::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: radar-ring 1.5s ease-out forwards;
    pointer-events: none;
}

@keyframes radar-ring {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.8);
        opacity: 1;
    }
    100% {
        box-shadow: 0 0 0 30px rgba(255, 255, 255, 0);
        opacity: 0;
    }
}

/* Cluster markers */
.cluster-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 700;
    color: #fff;
    border: 3px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.cluster-marker span {
    font-size: 14px;
}

.cluster-small {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #1e88e5, #1565c0);
}

.cluster-medium {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, #ff9800, #f57c00);
}

.cluster-large {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #e53935, #c62828);
}

.custom-cluster {
    background: transparent !important;
}

/* Faded style for inactive/completed incidents */
.incident-marker.inactive {
    opacity: 0.4;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3)) grayscale(0.3);
}

.incident-marker.inactive:hover {
    opacity: 0.7;
}

/* Pulse animation for active incidents */
.incident-marker.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4);
    }
    70% {
        box-shadow: 0 0 0 12px rgba(255, 255, 255, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
    }
}

/* Leaflet control styling */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

.leaflet-control-zoom a {
    background: rgba(26, 26, 46, 0.95) !important;
    color: #e0e0e0 !important;
    border: none !important;
}

.leaflet-control-zoom a:hover {
    background: rgba(40, 40, 70, 0.95) !important;
    color: #fff !important;
}

.leaflet-control-attribution {
    background: rgba(26, 26, 46, 0.8) !important;
    color: #666 !important;
    font-size: 10px;
}

.leaflet-control-attribution a {
    color: #888 !important;
}

/* Safe area insets for notched devices */
@supports (padding: env(safe-area-inset-bottom)) {
    #status-bar {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }

    .popup {
        bottom: calc(50px + env(safe-area-inset-bottom));
    }
}

/* Alert banner for weather/emergency warnings */
#alert-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1100;
    padding: 10px 16px;
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#alert-banner.hidden {
    display: none;
}

#alert-banner.severe {
    background: linear-gradient(135deg, #dc3545, #c82333);
}

#alert-banner.warning {
    background: linear-gradient(135deg, #ffc107, #e0a800);
    color: #000;
}

#alert-banner .alert-icon {
    font-size: 16px;
}

#alert-banner .alert-dismiss {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: inherit;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.7;
}

#alert-banner .alert-dismiss:hover {
    opacity: 1;
}

/* Overlay toggles in layers panel */
.overlay-toggles {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 0;
}

.overlay-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

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

.overlay-toggle input {
    width: 16px;
    height: 16px;
    accent-color: #4fc3f7;
}

.overlay-icon {
    font-size: 16px;
}

/* Hospital/ED marker styles */
.hospital-marker {
    background: rgba(26, 26, 46, 0.95);
    border: 2px solid #4fc3f7;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 11px;
    color: #fff;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    text-align: center;
}

.hospital-marker.ed {
    border-color: #f44336;
}

.hospital-marker.wic {
    border-color: #4caf50;
}

.hospital-marker .wait-time {
    font-weight: 700;
    font-size: 13px;
}

.hospital-marker .queue {
    font-size: 10px;
    opacity: 0.8;
}

.hospital-marker .facility-name {
    font-size: 9px;
    opacity: 0.7;
    margin-top: 2px;
}

/* Closed Walk-in Centre */
.hospital-marker.closed {
    opacity: 0.5;
    border-color: #666;
    background: rgba(50, 50, 50, 0.9);
}

.hospital-marker .closed-label {
    font-size: 10px;
    font-weight: 700;
    color: #999;
    letter-spacing: 0.5px;
}

.hospital-popup .closed-banner {
    background: #666;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 8px;
    text-align: center;
}

.hospital-popup .wic-hours {
    font-size: 10px;
    color: #888;
    margin-bottom: 8px;
    text-align: center;
}

/* Power outage marker - base styles */
.outage-marker {
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Active outage - pulsing orange/red */
.outage-marker.active {
    background: rgba(255, 87, 34, 0.9);
    border: 2px solid #ff5722;
    animation: outage-pulse 1.5s infinite;
}

/* Scheduled maintenance - static blue-grey */
.outage-marker.scheduled {
    background: rgba(96, 125, 139, 0.8);
    border: 2px solid #78909c;
    opacity: 0.8;
}

.outage-marker.scheduled:hover {
    opacity: 1;
}

@keyframes outage-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 2px 8px rgba(255, 87, 34, 0.4); }
    50% { transform: scale(1.15); box-shadow: 0 2px 16px rgba(255, 87, 34, 0.6); }
}

/* Hospital popup */
.hospital-popup {
    min-width: 200px;
}

.hospital-popup h4 {
    margin: 0 0 8px 0;
    color: #4fc3f7;
    font-size: 14px;
}

/* Outage popup header colors */
.hospital-popup h4[data-outage-status="active"] {
    color: #ff5722;
}

.hospital-popup h4[data-outage-status="scheduled"] {
    color: #78909c;
}

/* Outage detail status colors */
.outage-detail[data-status="active"] {
    color: #ff5722;
}

.outage-detail[data-status="scheduled"] {
    color: #78909c;
}

.outage-detail {
    font-size: 11px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.outage-reason {
    opacity: 0.7;
}

.hospital-popup.ed h4 {
    color: #f44336;
}

.hospital-popup .wait-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}

.hospital-popup .stat {
    text-align: center;
    padding: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.hospital-popup .stat-value {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
}

.hospital-popup .stat-label {
    font-size: 10px;
    opacity: 0.7;
}

.hospital-popup .updated {
    font-size: 10px;
    opacity: 0.6;
    text-align: right;
}

/* NSW RFS Fire Markers */
.nsw-fire-marker {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nsw-fire-marker svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.nsw-fire-marker.emergency {
    animation: fire-emergency-pulse 0.8s infinite;
}

.nsw-fire-marker.watch-act {
    animation: fire-pulse 1.5s infinite;
}

@keyframes fire-emergency-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

@keyframes fire-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* NSW Fire Popup */
.nsw-fire-popup h4 {
    color: #ff9800;
}

.nsw-fire-popup h4[data-alert-level="emergency-warning"] {
    color: #ff1744;
}

.nsw-fire-popup h4[data-alert-level="watch-and-act"] {
    color: #ff9800;
}

.nsw-fire-popup h4[data-alert-level="advice"] {
    color: #ffeb3b;
}

.fire-alert-level {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.fire-alert-level[data-level="emergency-warning"] {
    background: #7e0023;
    color: #fff;
}

.fire-alert-level[data-level="watch-and-act"] {
    background: #ff7e00;
    color: #000;
}

.fire-alert-level[data-level="advice"] {
    background: #ffcc00;
    color: #000;
}

.fire-details {
    font-size: 12px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.fire-details > div {
    margin-bottom: 4px;
}

.fire-link {
    display: block;
    margin-top: 10px;
    padding: 6px 12px;
    background: rgba(255, 152, 0, 0.2);
    color: #ff9800;
    text-decoration: none;
    text-align: center;
    border-radius: 4px;
    font-size: 12px;
}

.fire-link:hover {
    background: rgba(255, 152, 0, 0.3);
}
