:root {
    color-scheme: light;
    --bg: #f4f5f3;
    --surface: #ffffff;
    --surface-muted: #f0f1ef;
    --ink: #171a18;
    --muted: #68706b;
    --line: #dfe3df;
    --accent: #d72d2d;
    --accent-dark: #a81f1f;
    --accent-soft: #fff0ef;
    --success: #287653;
    --warning: #a96316;
    --radius-card: 14px;
    --radius-control: 9px;
    --sidebar-width: 430px;
    --header-height: 58px;
    --shadow: 0 18px 55px rgba(24, 30, 26, .16);
    font-family: "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--ink);
}

body {
    overflow: hidden;
}

.app-header {
    position: relative;
    z-index: 1100;
    display: flex;
    height: var(--header-height);
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 0 18px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 4px 18px rgba(22, 28, 24, .07);
}

.app-identity {
    display: flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
}

.app-identity-mark {
    width: 11px;
    height: 19px;
    border-radius: 60% 40% 55% 45%;
    background: var(--accent);
    box-shadow: 0 0 0 5px var(--accent-soft);
    transform: rotate(8deg);
}

.app-identity strong,
.app-identity small {
    display: block;
}

.app-identity strong {
    font-size: 13px;
    letter-spacing: -.02em;
}

.app-identity small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 9px;
}

.app-navigation {
    display: flex;
    align-items: center;
    gap: 3px;
}

.app-menu-toggle {
    display: none;
}

.topbar-button,
.theme-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 7px 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
    transition: background .18s ease, color .18s ease, transform .18s ease;
}

.topbar-button:hover,
.theme-button:hover,
.topbar-button.is-active {
    background: var(--surface-muted);
    color: var(--ink);
}

.topbar-button:active,
.theme-button:active {
    transform: translateY(1px);
}

.topbar-button:disabled {
    cursor: not-allowed;
    opacity: .38;
}

.theme-button {
    margin-left: 5px;
    border: 1px solid var(--line);
}

button,
input {
    font: inherit;
}

button {
    color: inherit;
}

button:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(215, 45, 45, .24);
    outline-offset: 2px;
}

.viewer-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: calc(100dvh - var(--header-height));
}

.sidebar {
    position: relative;
    z-index: 700;
    display: flex;
    min-width: 0;
    height: calc(100dvh - var(--header-height));
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--line);
    box-shadow: 10px 0 34px rgba(22, 28, 24, .08);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 76px;
    padding: 14px 22px;
    border-bottom: 1px solid var(--line);
}

.brand-mark {
    position: relative;
    display: grid;
    width: 34px;
    height: 38px;
    place-items: center;
    border: 1px solid #efb5b1;
    border-radius: 50% 50% 48% 52% / 58% 58% 42% 42%;
    background: var(--accent-soft);
}

.brand-mark::before,
.brand-mark span {
    content: "";
    display: block;
    width: 9px;
    height: 15px;
    border-radius: 50% 50% 45% 55% / 62% 62% 38% 38%;
    background: var(--accent);
    transform: translateY(2px) rotate(8deg);
}

.brand-mark span {
    position: absolute;
    width: 5px;
    height: 9px;
    background: #ff8e73;
    transform: translate(2px, 5px) rotate(4deg);
}

.brand-name,
.brand-subtitle,
.status-label,
.status-meta,
.section-kicker,
.summary-label,
.summary-caption,
.sidebar-footer p,
.detail-type,
.safety-note,
.empty-state p,
.error-state p {
    margin: 0;
}

.brand-name {
    font-size: 16px;
    font-weight: 720;
    letter-spacing: -.02em;
}

.brand-subtitle {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.source-strip {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 62px;
    padding: 12px 22px;
    background: #f8f9f7;
    border-bottom: 1px solid var(--line);
}

.status-indicator {
    width: 9px;
    height: 9px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #9aa19c;
    box-shadow: 0 0 0 4px rgba(154, 161, 156, .12);
}

.status-indicator.is-updated {
    background: var(--success);
    box-shadow: 0 0 0 4px rgba(40, 118, 83, .12);
}

.status-indicator.is-stale,
.status-indicator.is-never_updated {
    background: var(--warning);
    box-shadow: 0 0 0 4px rgba(169, 99, 22, .12);
}

.status-indicator.is-error {
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(215, 45, 45, .12);
}

.status-label {
    font-size: 12px;
    font-weight: 700;
}

.status-meta {
    margin-top: 2px;
    color: var(--muted);
    font-size: 11px;
}

.filters {
    position: relative;
    padding: 22px;
    border-bottom: 1px solid var(--line);
}

.section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.section-kicker,
.detail-type {
    color: var(--accent-dark);
    font-size: 10px;
    font-weight: 750;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.section-heading h1 {
    margin: 5px 0 0;
    font-size: 22px;
    line-height: 1.12;
    letter-spacing: -.035em;
}

.layers-button,
.retry-button,
.close-detail,
.mobile-panel-handle {
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    background: var(--surface);
    cursor: pointer;
    transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.layers-button {
    min-width: 66px;
    padding: 8px 10px;
    color: #424943;
    font-size: 12px;
    font-weight: 700;
}

.layers-button:hover,
.retry-button:hover,
.close-detail:hover {
    border-color: #abb2ad;
    background: var(--surface-muted);
}

.layers-button:active,
.retry-button:active,
.close-detail:active {
    transform: translateY(1px);
}

.filter-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
    margin-top: 18px;
}

.filter-button {
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    background: var(--surface);
    color: #555d58;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}

.filter-button:hover {
    border-color: #b9bfbb;
    background: #f7f8f6;
}

.filter-button:active {
    transform: translateY(1px);
}

.filter-button.is-active {
    border-color: var(--ink);
    background: var(--ink);
    color: #fff;
}

.layers-menu {
    position: absolute;
    top: 62px;
    right: 22px;
    z-index: 30;
    width: 260px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    background: var(--surface);
    box-shadow: var(--shadow);
    max-height: min(680px, calc(100dvh - 150px));
    overflow-y: auto;
}

.layer-swatch-community,
.layer-swatch-province {
    height: 2px;
    border-radius: 0;
    background: #9da39f;
}

.layer-swatch-province {
    height: 2px;
    background: repeating-linear-gradient(90deg, #b0a898 0 5px, transparent 5px 8px);
    border: 1px solid #b0a898;
    border-radius: 1px;
}

.base-map-selector {
    margin: 0;
    padding: 4px 4px 12px;
    border: 0;
    border-bottom: 1px solid var(--line);
}

.base-map-selector legend,
.layers-section-label {
    padding: 0 5px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 750;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.layers-section-label {
    margin: 12px 4px 2px;
}

.base-map-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    margin-top: 8px;
}

.base-map-options label {
    position: relative;
    display: grid;
    min-width: 0;
    gap: 6px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fafbfa;
    cursor: pointer;
    transition: border-color .18s ease, background .18s ease, transform .18s ease;
}

.base-map-options label:hover {
    border-color: #aeb5b0;
    background: #f4f6f3;
}

.base-map-options label:active {
    transform: translateY(1px);
}

.base-map-options input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.base-map-options label:has(input:checked) {
    border-color: var(--ink);
    background: var(--surface);
    box-shadow: inset 0 0 0 1px var(--ink);
}

.base-map-options strong {
    padding: 0 2px 1px;
    font-size: 10px;
}

.base-map-preview {
    display: block;
    height: 43px;
    overflow: hidden;
    border-radius: 5px;
    background-color: #d7ddd6;
}

.base-map-preview.is-streets {
    background:
        linear-gradient(30deg, transparent 44%, rgba(211, 89, 73, .72) 45% 48%, transparent 49%),
        linear-gradient(115deg, transparent 43%, rgba(255, 255, 255, .95) 44% 52%, transparent 53%),
        #dbe5d5;
}

.base-map-preview.is-satellite {
    background:
        radial-gradient(circle at 72% 32%, rgba(116, 145, 85, .9) 0 16%, transparent 17%),
        linear-gradient(135deg, #405e43, #899163 44%, #6d704d 45% 68%, #3e665f);
}

.layer-option {
    display: grid;
    grid-template-columns: 18px 12px 1fr;
    gap: 10px;
    align-items: center;
    padding: 9px;
    cursor: pointer;
}

.layer-option strong,
.layer-option small {
    display: block;
}

.layer-option strong {
    font-size: 12px;
}

.layer-option small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 10px;
}

.layer-swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.layer-swatch-hotspot {
    background: var(--accent);
    box-shadow: 0 0 0 3px rgba(215, 45, 45, .14);
}

.layer-swatch-aemet {
    border-radius: 3px;
    background: linear-gradient(135deg, #4cae4f, #f2cf45 42%, #ef7b32 66%, #b51f35);
}

.layer-swatch-effis {
    border: 1px solid #6f2f1f;
    border-radius: 3px;
    background: rgba(215, 100, 60, .55);
}

.aemet-layer-controls {
    margin: 4px 8px 6px 40px;
    padding: 9px 0 4px;
    border-top: 1px solid var(--line);
}

.aemet-layer-controls > label:first-child {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
}

.aemet-layer-controls input[type="range"] {
    width: 100%;
    margin-top: 7px;
    accent-color: var(--accent);
}

.expired-option {
    display: flex !important;
    align-items: center;
    justify-content: flex-start !important;
    gap: 7px;
    margin-top: 8px;
}

.aemet-status-card {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin-top: 14px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    background: #fafbfa;
}

.aemet-status-card strong,
.aemet-status-card span {
    display: block;
}

.aemet-status-card strong {
    font-size: 11px;
}

.aemet-status-card div > span {
    margin-top: 3px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.35;
}

.aemet-status-dot {
    width: 8px;
    height: 8px;
    margin-top: 3px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #9aa19c;
}

.aemet-status-dot.is-updated { background: var(--success); }
.aemet-status-dot.is-expired { background: var(--warning); }
.aemet-status-dot.is-error,
.aemet-status-dot.is-unavailable { background: var(--accent); }

.sidebar-content {
    min-height: 0;
    flex: 1;
    overflow-y: auto;
    padding: 22px;
}

.incident-list-state {
    min-height: 100%;
}

.incident-list-header {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: end;
    gap: 18px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--line);
}

.summary-number {
    font-size: 42px;
    font-weight: 750;
    line-height: .9;
    letter-spacing: -.07em;
    font-variant-numeric: tabular-nums;
}

.summary-label {
    font-size: 13px;
    font-weight: 700;
}

.summary-caption {
    max-width: 230px;
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.45;
}

.incident-list-context {
    padding-bottom: 1px;
    text-align: right;
}

.incident-list-context span,
.incident-list-context small {
    display: block;
}

.incident-list-context span {
    color: #3e4641;
    font-size: 11px;
    font-weight: 700;
}

.incident-list-context small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 10px;
}

.incident-disclaimer {
    margin: 12px 0 4px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.45;
}

.incident-list {
    margin: 0 -7px;
}

.incident-card {
    position: relative;
    display: grid;
    width: 100%;
    grid-template-columns: 4px minmax(0, 1fr);
    gap: 13px;
    padding: 16px 7px;
    border: 0;
    border-bottom: 1px solid #e7eae7;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
    transition: background .18s ease, transform .18s ease;
}

.incident-card:hover {
    background: #f6f7f5;
}

.incident-card:active {
    transform: translateY(1px);
}

.incident-card:focus-visible {
    border-radius: 8px;
}

.incident-card-rail {
    width: 4px;
    height: 100%;
    min-height: 66px;
    border-radius: 2px;
    background: #9ba19d;
}

.incident-card.is-severe .incident-card-rail { background: #8f171f; }
.incident-card.is-high .incident-card-rail { background: #c84a25; }
.incident-card.is-medium .incident-card-rail { background: #c48620; }
.incident-card.is-low .incident-card-rail { background: #65806d; }
.incident-card.is-unconfirmed .incident-card-rail { background: #9ba19d; }

.incident-card-body,
.incident-card-topline,
.incident-card-meta,
.incident-card-bottom {
    min-width: 0;
}

.incident-card-topline,
.incident-card-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.incident-card-topline strong {
    font-size: 10px;
    letter-spacing: .065em;
    text-transform: uppercase;
}

.incident-card.is-severe .severity-text { color: #8f171f; }
.incident-card.is-high .severity-text { color: #a83b1d; }
.incident-card.is-medium .severity-text { color: #8d5c11; }
.incident-card.is-low .severity-text { color: #486553; }
.incident-card.is-unconfirmed .severity-text { color: #68706b; }

.incident-card-topline time {
    color: var(--muted);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
}

.incident-card-place {
    display: block;
    overflow: hidden;
    margin-top: 6px;
    font-size: 15px;
    font-weight: 720;
    letter-spacing: -.02em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.incident-card-location {
    display: block;
    overflow: hidden;
    margin-top: 4px;
    color: #4f5852;
    font-size: 11px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.incident-card-meta {
    display: flex;
    gap: 7px;
    margin-top: 6px;
    color: var(--muted);
    font-size: 10px;
}

.incident-card-meta span + span::before {
    content: "·";
    margin-right: 7px;
}

.incident-card-bottom {
    margin-top: 10px;
    color: #404741;
    font-size: 10px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.loading-state {
    margin-top: 28px;
}

.skeleton {
    overflow: hidden;
    border-radius: 6px;
    background: linear-gradient(90deg, #eceeeb 25%, #f7f8f6 50%, #eceeeb 75%);
    background-size: 200% 100%;
    animation: skeleton 1.4s ease-in-out infinite;
}

.skeleton-title {
    width: 55%;
    height: 19px;
}

.skeleton-line {
    width: 100%;
    height: 10px;
    margin-top: 12px;
}

.skeleton-short {
    width: 72%;
}

.skeleton-block {
    width: 100%;
    height: 118px;
    margin-top: 22px;
}

@keyframes skeleton {
    to { background-position: -200% 0; }
}

.empty-state,
.error-state {
    padding: 38px 8px 0;
}

.empty-symbol {
    width: 42px;
    height: 42px;
    border: 2px solid #aeb5b0;
    border-radius: 50%;
}

.empty-symbol::after {
    content: "";
    display: block;
    width: 16px;
    height: 2px;
    margin: 18px auto 0;
    background: #aeb5b0;
}

.empty-state h2,
.error-state h2 {
    margin: 18px 0 8px;
    font-size: 18px;
    letter-spacing: -.025em;
}

.empty-state p,
.error-state p {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
}

.retry-button {
    margin-top: 18px;
    padding: 9px 14px;
    font-size: 12px;
    font-weight: 700;
}

.detail-panel {
    padding-bottom: 18px;
}

.incident-detail-classification {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 18px;
}

.severity-badge,
.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 6px 9px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 750;
}

.severity-badge {
    background: #ecefed;
    color: #555d58;
}

.severity-badge.is-severe { background: #f8e6e7; color: #85151d; }
.severity-badge.is-high { background: #fbeae3; color: #9d351b; }
.severity-badge.is-medium { background: #fbf1dc; color: #7f5210; }
.severity-badge.is-low { background: #eaf0eb; color: #3f5e49; }
.severity-badge.is-unconfirmed { background: #ecefed; color: #555d58; }

.status-badge {
    background: #f3f4f2;
    color: #555d58;
}

.incident-reading-list {
    margin-top: 18px;
}

.technical-details {
    margin-top: 22px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.technical-details summary {
    padding: 14px 2px;
    color: var(--accent-dark);
    font-size: 11px;
    font-weight: 750;
    cursor: pointer;
    list-style-position: inside;
}

.technical-details[open] summary {
    border-bottom: 1px solid var(--line);
}

.technical-details .detail-list {
    margin-top: 4px;
}

.technical-details .traceability {
    margin: 20px 0 14px;
}

.traceability {
    margin-top: 24px;
}

.traceability h3 {
    margin: 0;
    font-size: 13px;
    letter-spacing: -.015em;
}

.traceability ul {
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
}

.traceability li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid #eceeeb;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.4;
}

.traceability li strong {
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.detail-header h2 {
    margin: 6px 0 0;
    font-size: 24px;
    line-height: 1.12;
    letter-spacing: -.04em;
}

.close-detail {
    padding: 7px 9px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.classification {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 18px;
    padding: 8px 10px;
    border-radius: var(--radius-control);
    background: var(--accent-soft);
    color: #842521;
    font-size: 11px;
    font-weight: 700;
}

.classification-dot,
.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}

.detail-list {
    margin: 24px 0 0;
}

.detail-list div {
    display: grid;
    grid-template-columns: 42% 58%;
    gap: 10px;
    padding: 11px 0;
    border-bottom: 1px solid #eceeeb;
}

.detail-list dt,
.detail-list dd {
    margin: 0;
    font-size: 12px;
    line-height: 1.35;
}

.detail-list dt {
    color: var(--muted);
}

.detail-list dd {
    text-align: right;
    font-weight: 650;
}

.safety-note {
    margin-top: 20px;
    padding: 14px;
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-control) var(--radius-control) 0;
    background: #faf2f1;
    color: #6f302c;
    font-size: 11px;
    line-height: 1.5;
}

.sidebar-footer {
    padding: 14px 22px 17px;
    border-top: 1px solid var(--line);
    background: #fafbfa;
}

.legend {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 700;
}

.sidebar-footer p {
    margin-top: 7px;
    color: var(--muted);
    font-size: 10px;
}

.sidebar-footer-menu summary {
    display: none;
}

.sidebar-footer-menu:not([open]) > .sidebar-footer-links {
    display: grid;
}

.sidebar-footer-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    margin-top: 11px;
    border-top: 1px solid var(--line);
    border-left: 1px solid var(--line);
}

.sidebar-footer-links a {
    min-width: 0;
    padding: 6px 8px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 9px;
    font-weight: 650;
    line-height: 1.25;
    text-decoration: none;
}

.sidebar-footer-links a:hover {
    background: var(--surface-muted);
    color: var(--ink);
}

.map-stage {
    position: relative;
    min-width: 0;
    height: calc(100dvh - var(--header-height));
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #dfe3df;
}

.map-notice {
    position: absolute;
    z-index: 500;
    top: 18px;
    left: 18px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 300px;
    padding: 10px 13px;
    border: 1px solid rgba(220, 224, 220, .9);
    border-radius: var(--radius-control);
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 9px 28px rgba(20, 27, 23, .12);
}

.map-notice strong {
    font-size: 11px;
}

.map-notice span {
    color: var(--muted);
    font-size: 10px;
}

.map-quick-views {
    position: absolute;
    z-index: 500;
    top: 78px;
    left: 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    max-width: min(560px, calc(100% - 36px));
}

.map-quick-views button {
    min-height: 32px;
    padding: 7px 10px;
    border: 1px solid rgba(210, 215, 211, .95);
    border-radius: 7px;
    background: rgba(255, 255, 255, .94);
    color: var(--ink);
    cursor: pointer;
    font-size: 9px;
    font-weight: 750;
    box-shadow: 0 7px 20px rgba(20, 27, 23, .09);
    transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

.map-quick-views button:hover {
    border-color: #9ca39e;
    background: #fff;
}

.map-quick-views button:active {
    transform: translateY(1px);
}

.map-symbol-legend {
    position: absolute;
    z-index: 500;
    left: 18px;
    bottom: 28px;
    display: grid;
    gap: 6px;
    width: 220px;
    padding: 12px;
    border: 1px solid rgba(220, 224, 220, .92);
    border-radius: var(--radius-control);
    background: rgba(255, 255, 255, .95);
    box-shadow: 0 9px 28px rgba(20, 27, 23, .12);
}

.map-symbol-legend strong,
.drawer-legend h3 {
    margin: 0 0 3px;
    font-size: 11px;
}

.map-symbol-legend span,
.drawer-legend span {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 9px;
    line-height: 1.35;
}

.map-symbol-legend i,
.drawer-legend i {
    flex: 0 0 auto;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #b54d40;
}

.map-symbol-legend i.is-orange,
.drawer-legend i.is-orange { background: #d28a48; }
.map-symbol-legend i.is-grey,
.drawer-legend i.is-grey { background: #8f9691; }
.map-symbol-legend i.is-area,
.drawer-legend i.is-area {
    border: 1px solid #6f2f1f;
    border-radius: 2px;
    background: rgba(215, 100, 60, .32);
}
.map-symbol-legend i.is-line,
.drawer-legend i.is-line {
    height: 2px;
    border-radius: 0;
    background: #9da39f;
}

.drawer-legend {
    display: grid;
    gap: 8px;
    margin-top: 22px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.select-filter-label {
    display: block;
    margin-top: 11px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
}

#filter-zone {
    width: 100%;
    min-height: 39px;
    margin-top: 6px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 11px;
}

.incident-card-country {
    display: block;
    margin-top: 3px;
    color: var(--ink);
    font-size: 10px;
    font-weight: 750;
}

.aemet-map-legend {
    position: absolute;
    z-index: 500;
    right: 18px;
    bottom: 28px;
    width: 220px;
    padding: 12px;
    border: 1px solid rgba(220, 224, 220, .92);
    border-radius: var(--radius-control);
    background: rgba(255, 255, 255, .95);
    box-shadow: 0 9px 28px rgba(20, 27, 23, .12);
}

.effis-map-legend {
    position: absolute;
    z-index: 500;
    right: 18px;
    bottom: 150px;
    width: 220px;
    padding: 12px;
    border: 1px solid rgba(220, 224, 220, .92);
    border-radius: var(--radius-control);
    background: rgba(255, 255, 255, .95);
    box-shadow: 0 9px 28px rgba(20, 27, 23, .12);
}

.effis-map-legend strong,
.effis-map-legend small,
.effis-map-legend span {
    display: block;
}

.effis-map-legend strong { font-size: 11px; }
.effis-map-legend span { margin-top: 8px; font-size: 10px; }
.effis-map-legend span i {
    display: inline-block;
    width: 16px;
    height: 10px;
    margin-right: 6px;
    border: 1px solid #6f2f1f;
    background: rgba(215, 100, 60, .4);
    vertical-align: -1px;
}
.effis-map-legend small {
    margin-top: 7px;
    color: var(--muted);
    font-size: 9px;
}

.detail-type-effis { color: #8a3a25; }
.classification-effis {
    background: #fff1e9;
    color: #793822;
}
.classification-dot-effis { background: #d7643c; }
.safety-note-effis {
    border-left-color: #d7643c;
    background: #fff6f1;
    color: #6e3c2e;
}
.popup-label-effis { color: #8a3a25; }

.aemet-map-legend strong,
.aemet-map-legend small {
    display: block;
}

.aemet-map-legend strong {
    font-size: 11px;
}

.aemet-map-legend small {
    margin-top: 7px;
    color: var(--muted);
    font-size: 9px;
}

.risk-scale {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: 8px;
    margin-top: 9px;
    overflow: hidden;
    border-radius: 4px;
}

.risk-scale i { display: block; }
.risk-low { background: #4cae4f; }
.risk-moderate { background: #f2cf45; }
.risk-high { background: #ef8a32; }
.risk-very-high { background: #d83a32; }
.risk-extreme { background: #7d1538; }

.risk-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    color: var(--muted);
    font-size: 9px;
}

.hotspot-marker {
    position: relative;
    display: block;
    width: 16px;
    height: 16px;
    border: 3px solid #fff;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 2px 9px rgba(113, 22, 22, .46);
}

.incident-marker {
    position: relative;
    display: grid;
    width: 24px;
    height: 24px;
    place-items: center;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #777e79;
    box-shadow: 0 3px 12px rgba(35, 42, 37, .38);
}

.incident-marker i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
}

.incident-marker::after {
    content: "";
    position: absolute;
    inset: -6px;
    border: 1px solid currentColor;
    border-radius: 50%;
    opacity: .32;
}

.incident-marker.is-severe { color: #8f171f; background: #8f171f; }
.incident-marker.is-high { color: #c84a25; background: #c84a25; }
.incident-marker.is-medium { color: #c48620; background: #c48620; }
.incident-marker.is-low { color: #65806d; background: #65806d; }
.incident-marker.is-unconfirmed { color: #777e79; background: #777e79; }

.hotspot-marker::after {
    content: "";
    position: absolute;
    inset: -7px;
    border: 1px solid rgba(215, 45, 45, .3);
    border-radius: 50%;
    background: rgba(215, 45, 45, .08);
}

.leaflet-div-icon {
    border: 0;
    background: transparent;
}

.leaflet-control-zoom {
    overflow: hidden;
    border: 1px solid #d7dbd8 !important;
    border-radius: var(--radius-control) !important;
    box-shadow: 0 8px 22px rgba(24, 30, 26, .13) !important;
}

.leaflet-control-zoom a {
    color: var(--ink) !important;
}

.leaflet-popup-content-wrapper {
    border-radius: var(--radius-card);
    box-shadow: var(--shadow);
}

.leaflet-popup-content {
    margin: 15px 17px;
    font-family: inherit;
}

.aemet-debug-panel {
    display: grid;
    max-width: 620px;
    gap: 4px;
    padding: 9px 11px;
    border: 2px solid #d71920;
    border-radius: 6px;
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 8px 24px rgba(20, 27, 23, .18);
    color: #171a18;
}

.aemet-debug-panel strong {
    color: #a80f16;
    font-size: 11px;
    text-transform: uppercase;
}

.aemet-debug-panel span,
.aemet-debug-panel code {
    font-size: 10px;
    line-height: 1.35;
}

.aemet-debug-panel code {
    white-space: normal;
}

.popup-label {
    color: var(--accent-dark);
    font-size: 10px;
    font-weight: 750;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.popup-title {
    margin: 5px 0 10px;
    font-size: 15px;
}

.popup-meta {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.5;
}

.weather-capsule {
    display: grid;
    gap: 4px;
    margin-top: 11px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    background: var(--surface-muted);
    color: var(--ink);
    font-size: 11px;
    line-height: 1.4;
}

.weather-capsule strong {
    font-size: 10px;
    letter-spacing: .02em;
}

.weather-capsule div {
    display: flex;
    flex-wrap: wrap;
    gap: 3px 5px;
    font-weight: 700;
}

.weather-capsule small {
    color: var(--muted);
    font-size: 9px;
}

.weather-divider {
    color: var(--muted);
}

.weather-detail-capsule {
    margin: 13px 0 4px;
}

.mobile-panel-handle,
.mobile-filter-button,
.mobile-sidebar-minimize,
.mobile-map-actions {
    display: none;
}

.panel-backdrop {
    position: fixed;
    z-index: 1200;
    inset: var(--header-height) 0 0;
    background: rgba(20, 25, 22, .28);
    backdrop-filter: blur(2px);
}

.app-drawer {
    position: fixed;
    z-index: 1250;
    top: var(--header-height);
    right: 0;
    display: flex;
    width: min(440px, 100vw);
    height: calc(100dvh - var(--header-height));
    flex-direction: column;
    border-left: 1px solid var(--line);
    background: var(--surface);
    box-shadow: -18px 0 54px rgba(24, 30, 26, .18);
}

.app-drawer form {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
}

.drawer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding: 23px 24px 19px;
    border-bottom: 1px solid var(--line);
}

.drawer-header h2 {
    margin: 5px 0 0;
    font-size: 23px;
    line-height: 1.12;
    letter-spacing: -.035em;
}

.drawer-close {
    padding: 7px 9px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    font-size: 10px;
    font-weight: 700;
}

.drawer-content {
    min-height: 0;
    flex: 1;
    overflow-y: auto;
    padding: 22px 24px 30px;
}

.drawer-intro {
    max-width: 58ch;
    margin: 0 0 24px;
    color: #464e49;
    font-size: 13px;
    line-height: 1.6;
}

.source-explainer {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 14px;
    padding: 15px 0;
    border-top: 1px solid var(--line);
}

.source-explainer h3,
.source-explainer p {
    margin: 0;
}

.source-explainer h3 {
    font-size: 13px;
}

.source-explainer p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.5;
}

.source-code {
    align-self: start;
    padding: 6px 5px;
    border-radius: 5px;
    background: var(--accent-soft);
    color: var(--accent-dark);
    text-align: center;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: .06em;
}

.source-code.is-aemet { background: #edf2dd; color: #526326; }
.source-code.is-effis { background: #fff0e8; color: #8a3a25; }

.source-timestamps {
    margin: 22px 0 0;
    border-top: 1px solid var(--line);
}

.source-timestamps div {
    display: grid;
    grid-template-columns: 46% 54%;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.source-timestamps dt,
.source-timestamps dd {
    margin: 0;
    font-size: 11px;
}

.source-timestamps dt { color: var(--muted); }
.source-timestamps dd { text-align: right; font-weight: 700; }

.emergency-notice {
    margin: 24px 0 0;
    padding: 15px;
    border-left: 3px solid var(--accent);
    background: var(--accent-soft);
    color: #6f302c;
    font-size: 11px;
    line-height: 1.55;
}

.emergency-notice strong {
    display: block;
    margin-top: 5px;
}

.filter-sections {
    padding-top: 4px;
}

.filter-sections fieldset {
    margin: 0;
    padding: 18px 0;
    border: 0;
    border-bottom: 1px solid var(--line);
}

.filter-sections legend {
    padding: 0;
    font-size: 12px;
    font-weight: 750;
}

.filter-sections fieldset > small {
    display: block;
    margin-top: 10px;
    color: var(--muted);
    font-size: 9px;
    line-height: 1.45;
}

.segmented-filter {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    margin-top: 11px;
}

.segmented-filter label {
    position: relative;
}

.segmented-filter input {
    position: absolute;
    opacity: 0;
}

.segmented-filter span {
    display: grid;
    min-height: 34px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--muted);
    cursor: pointer;
    font-size: 10px;
    font-weight: 700;
}

.segmented-filter input:checked + span {
    border-color: var(--ink);
    background: var(--ink);
    color: var(--surface);
}

.date-filter-grid,
.number-filter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
    margin-top: 11px;
}

.date-filter-grid label,
.number-filter-grid label {
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
}

.date-filter-grid input,
.number-filter-grid input {
    width: 100%;
    min-height: 36px;
    margin-top: 5px;
    padding: 7px 8px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    color: var(--ink);
    font-size: 11px;
}

.filter-check-grid {
    display: grid;
    gap: 9px;
    margin-top: 12px;
}

.filter-check-grid.is-two-columns { grid-template-columns: 1fr 1fr; }
.filter-check-grid.is-three-columns { grid-template-columns: repeat(3, 1fr); }

.filter-check-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #444c47;
    font-size: 11px;
}

.filter-check-grid input { accent-color: var(--accent); }
.filter-check-grid label:has(input:disabled) { color: var(--muted); }
.filter-check-grid small { margin-left: auto; font-size: 8px; }

.drawer-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 14px 24px;
    border-top: 1px solid var(--line);
    background: var(--surface);
}

.primary-action,
.secondary-action,
.text-action {
    min-height: 38px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 10px;
    font-weight: 750;
}

.primary-action {
    border: 1px solid var(--ink);
    background: var(--ink);
    color: var(--surface);
}

.secondary-action {
    border: 1px solid var(--line);
    background: var(--surface);
}

.text-action {
    grid-column: 1 / -1;
    border: 0;
    background: transparent;
    color: var(--accent-dark);
}

.filter-error {
    margin: 0;
    padding: 0 24px 14px;
    color: var(--accent-dark);
    font-size: 10px;
}

body[data-theme="dark"] {
    color-scheme: dark;
    --bg: #171a18;
    --surface: #202421;
    --surface-muted: #2a2f2b;
    --ink: #f1f3ef;
    --muted: #a8b0aa;
    --line: #373d38;
    --accent-soft: #3c2424;
    --accent-dark: #ff8b81;
    --shadow: 0 18px 55px rgba(0, 0, 0, .4);
}

body[data-theme="dark"] .app-header,
body[data-theme="dark"] .source-strip,
body[data-theme="dark"] .sidebar-footer,
body[data-theme="dark"] .aemet-status-card,
body[data-theme="dark"] .map-notice,
body[data-theme="dark"] .map-symbol-legend,
body[data-theme="dark"] .map-quick-views button,
body[data-theme="dark"] .aemet-map-legend,
body[data-theme="dark"] .effis-map-legend {
    background: rgba(32, 36, 33, .96);
}

body[data-theme="dark"] .drawer-intro,
body[data-theme="dark"] .filter-check-grid label,
body[data-theme="dark"] .incident-card-bottom,
body[data-theme="dark"] .incident-card-location {
    color: #c5cbc6;
}

body[data-theme="dark"] .incident-card:hover { background: #292e2a; }
body[data-theme="dark"] .leaflet-popup-content-wrapper,
body[data-theme="dark"] .leaflet-popup-tip { background: #202421; color: #f1f3ef; }
body[data-theme="dark"] .technical-details { border-color: var(--line); }

[hidden] {
    display: none !important;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

@media (max-width: 760px) {
    body {
        overflow: hidden;
    }

    .viewer-shell {
        display: block;
        min-height: calc(100dvh - var(--header-height));
    }

    .map-stage {
        height: calc(100dvh - var(--header-height));
    }

    .sidebar {
        position: fixed;
        inset: auto 0 0;
        z-index: 900;
        width: 100%;
        height: min(78dvh, 680px);
        border-top: 1px solid var(--line);
        border-right: 0;
        border-radius: 18px 18px 0 0;
        box-shadow: 0 -18px 50px rgba(22, 28, 24, .2);
        transform: translateY(calc(100% - 126px));
        transition: transform .24s ease;
    }

    .app-header {
        position: relative;
        gap: 10px;
        padding: 0 12px;
        overflow: visible;
    }

    .app-identity small,
    .app-navigation .topbar-button:disabled {
        display: none;
    }

    .app-identity strong {
        max-width: 106px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-identity {
        min-width: 0;
        flex: 1 1 auto;
    }

    .app-menu-toggle {
        display: inline-flex;
        min-height: 36px;
        align-items: center;
        gap: 9px;
        padding: 7px 10px;
        border: 1px solid var(--line);
        border-radius: 7px;
        background: var(--surface);
        color: var(--ink);
        cursor: pointer;
        font-size: 10px;
        font-weight: 750;
    }

    .app-menu-toggle i,
    .app-menu-toggle i::before {
        display: block;
        width: 16px;
        height: 1px;
        background: currentColor;
        content: "";
        transition: transform .2s ease;
    }

    .app-menu-toggle i::before {
        transform: translateY(5px);
    }

    .app-header.menu-open .app-menu-toggle i {
        transform: translateY(2px) rotate(45deg);
    }

    .app-header.menu-open .app-menu-toggle i::before {
        transform: rotate(-90deg);
    }

    .app-navigation {
        position: absolute;
        z-index: 1150;
        top: 100%;
        right: 10px;
        left: 10px;
        display: none;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0;
        max-height: calc(100dvh - var(--header-height) - 18px);
        overflow-y: auto;
        padding: 8px;
        border: 1px solid var(--line);
        border-radius: 0 0 12px 12px;
        background: var(--surface);
        box-shadow: 0 18px 40px rgba(22, 28, 24, .18);
    }

    .app-header.menu-open .app-navigation {
        display: grid;
    }

    .topbar-button,
    .theme-button {
        width: 100%;
        min-height: 40px;
        justify-content: flex-start;
        margin: 0;
        padding: 9px 10px;
        border-bottom: 1px solid var(--line);
        border-radius: 0;
        font-size: 10px;
    }

    .theme-button {
        max-width: none;
        border: 0;
        border-bottom: 1px solid var(--line);
    }

    .sidebar.is-open {
        transform: translateY(0);
    }

    .brand {
        min-height: 64px;
        padding: 11px 18px;
    }

    .brand-mark {
        width: 29px;
        height: 32px;
    }

    .source-strip {
        min-height: 62px;
        padding: 11px 18px;
    }

    .filters,
    .sidebar-content {
        padding-right: 18px;
        padding-left: 18px;
    }

    .sidebar-footer {
        padding: 10px 18px 12px;
    }

    .sidebar-footer-menu {
        margin-top: 7px;
    }

    .sidebar-footer-menu summary {
        display: block;
        width: max-content;
        color: var(--muted);
        cursor: pointer;
        font-size: 9px;
        font-weight: 750;
        list-style-position: inside;
    }

    .sidebar-footer-menu:not([open]) > .sidebar-footer-links {
        display: none;
    }

    .sidebar-footer-links {
        margin-top: 7px;
    }

    .sidebar-footer p {
        margin: 6px 0 0;
        font-size: 9px;
    }

    .map-notice {
        top: 14px;
        right: 14px;
        left: 14px;
        max-width: none;
    }

    .map-quick-views {
        top: 84px;
        right: 14px;
        left: 14px;
        flex-wrap: nowrap;
        max-width: none;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .map-quick-views button {
        flex: 0 0 auto;
        min-height: 30px;
    }

    .map-symbol-legend {
        display: none;
    }

    .mobile-map-actions {
        position: absolute;
        z-index: 850;
        right: 14px;
        bottom: 144px;
        display: flex;
        gap: 8px;
    }

    .mobile-panel-handle,
    .mobile-filter-button {
        display: block;
        padding: 11px 14px;
        border: 1px solid var(--ink);
        border-radius: 7px;
        background: var(--ink);
        color: #fff;
        cursor: pointer;
        font-size: 12px;
        font-weight: 750;
        box-shadow: 0 9px 26px rgba(20, 27, 23, .24);
    }

    .mobile-filter-button {
        border-color: var(--surface);
        background: var(--surface);
        color: var(--ink);
    }

    .mobile-sidebar-minimize {
        display: inline-flex;
        min-height: 34px;
        align-items: center;
        margin-left: auto;
        padding: 7px 10px;
        border: 1px solid var(--line);
        border-radius: 7px;
        background: var(--surface);
        color: var(--ink);
        cursor: pointer;
        font-size: 10px;
        font-weight: 750;
    }

    .aemet-map-legend {
        right: 14px;
        bottom: 196px;
        width: 190px;
    }

    .effis-map-legend {
        right: 14px;
        bottom: 302px;
        width: 190px;
    }

    .app-drawer {
        top: var(--header-height);
        width: 100%;
        height: calc(100dvh - var(--header-height));
        border-left: 0;
    }

    .drawer-header {
        padding: 19px 18px 16px;
    }

    .drawer-content {
        padding-right: 18px;
        padding-left: 18px;
    }

    .drawer-actions {
        padding-right: 18px;
        padding-left: 18px;
    }
}
