:root {
    --background: #f7f9fb;
    --foreground: #17191d;
    --muted: #5d6673;
    --line: #d8dee4;
    --green: #138f2d;
    --red: #ed1c24;
    --blue: #2563eb;
    --orange: #f97316;
    --accent: var(--green);
    --surface: #ffffff;
    --map: #e4efe9;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--foreground);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
    width: min(1200px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0;
}

.topbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.brand-logo {
    display: block;
    width: min(240px, 64vw);
    height: auto;
    margin-bottom: 18px;
}

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

.accessibility-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.user-tools {
    display: grid;
    justify-items: end;
    gap: 10px;
    margin-left: auto;
}

.user-tools .accessibility-toolbar {
    justify-content: flex-end;
    margin-top: 0;
}

.accessibility-toolbar button {
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 8px 10px;
    background: var(--surface);
    color: var(--foreground);
    font: inherit;
    font-weight: 700;
}

.accessibility-toolbar button[aria-pressed="true"] {
    border-color: var(--blue);
    outline: 3px solid rgba(37, 99, 235, 0.22);
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--accent);
    font-weight: 700;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: 36px;
}

.search {
    display: grid;
    gap: 6px;
    min-width: min(360px, 100%);
}

.global-search {
    position: relative;
}

.global-search-options {
    top: calc(100% + 6px);
}

.language-switcher {
    display: grid;
    gap: 6px;
    width: min(180px, 100%);
}

input[type="search"] {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 11px 12px;
    font: inherit;
}

.language-switcher select {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 11px 12px;
    background: var(--surface);
    font: inherit;
}

input[type="search"]:focus,
.language-switcher select:focus {
    border-color: var(--blue);
    outline: 3px solid rgba(37, 99, 235, 0.18);
}

.workspace {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 18px;
}

.filters,
.place,
.map-placeholder,
.user-map,
.place-result,
.detail-section {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 10px 30px rgba(23, 25, 29, 0.05);
}

.filters {
    display: grid;
    align-content: start;
    gap: 14px;
    padding: 18px;
}

.filters label {
    display: flex;
    align-items: center;
    gap: 10px;
    line-height: 1.4;
}

.need-icon {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    color: var(--foreground);
}

.target-filter-list {
    display: grid;
    gap: 12px;
}

.filter-group {
    border-top: 1px solid var(--line);
    padding-top: 12px;
}

.filter-group summary {
    cursor: pointer;
    font-weight: 800;
}

.filter-group[open] summary {
    margin-bottom: 12px;
}

.results {
    display: grid;
    grid-template-columns: minmax(260px, 0.85fr) minmax(320px, 1.15fr);
    gap: 18px;
}

.map-results {
    position: relative;
    display: grid;
    grid-template-columns: minmax(320px, 1.25fr) minmax(280px, 0.75fr);
    gap: 18px;
}

.place {
    padding: 18px;
}

.place span {
    color: var(--blue);
    font-weight: 700;
}

.place p {
    color: var(--muted);
    line-height: 1.5;
}

.map-placeholder {
    display: grid;
    min-height: 420px;
    place-items: center;
    background: var(--map);
    color: var(--green);
    font-weight: 700;
}

.user-map {
    min-height: 560px;
    overflow: hidden;
    background: var(--map);
}

.place-results {
    display: grid;
    align-content: start;
    gap: 12px;
    max-height: 560px;
    overflow: auto;
}

.place-results-panel {
    display: grid;
    align-content: start;
    gap: 12px;
}

.local-place-search {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

.place-result {
    display: grid;
    gap: 6px;
    padding: 14px;
    color: inherit;
    text-decoration: none;
}

.place-result span {
    color: var(--blue);
    font-weight: 800;
}

.place-result-compliance,
.detail-compliance-list {
    display: grid;
    gap: 6px;
}

.place-result-compliance-item,
.detail-compliance {
    display: flex;
    align-items: center;
    gap: 8px;
}

.place-result-compliance .need-icon {
    width: 26px;
    height: 26px;
    flex-basis: 26px;
}

.place-result-compliance-item span {
    color: inherit;
    font-weight: 600;
}

.detail-compliance {
    padding: 10px 0;
    border-top: 1px solid var(--line);
}

.detail-compliance:first-child {
    border-top: 0;
}

.detail-compliance .need-icon {
    width: 32px;
    height: 32px;
}

.detail-compliance strong {
    margin-right: auto;
}

.detail-compliance span {
    color: var(--muted);
    font-weight: 700;
}

.place-result strong {
    font-size: 18px;
}

.place-result small,
.place-result em,
.empty-results {
    color: var(--muted);
}

.leaflet-popup-content {
    display: grid;
    gap: 4px;
}

.detail-shell {
    max-width: 920px;
}

.detail-language {
    margin: 0;
}

.back-link {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    border: 1px solid var(--blue);
    border-radius: 8px;
    padding: 9px 13px;
    background: var(--blue);
    color: #ffffff;
    text-decoration: none;
    font-weight: 800;
}

.back-link:hover,
.back-link:focus-visible {
    background: transparent;
    color: var(--blue);
    outline: 3px solid rgba(37, 99, 235, 0.2);
}

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

.detail-header {
    margin-bottom: 24px;
}

.detail-section {
    margin-top: 18px;
    padding: 20px;
}

.detail-facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 0 0 16px;
}

.detail-facts div {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.detail-facts dt {
    color: var(--muted);
    font-weight: 700;
}

.detail-facts dd {
    margin: 6px 0 0;
    font-weight: 800;
}

.fact-icon {
    display: inline-grid;
    width: 28px;
    height: 28px;
    margin-right: 6px;
    place-items: center;
    border: 2px solid currentColor;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
}

.fact-positive { color: var(--green); }
.fact-negative { color: var(--red); }
.fact-unknown { color: var(--muted); }

.detail-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.compliance-reason {
    display: grid;
    gap: 4px;
    margin: 0 0 10px 40px;
    padding: 10px 12px;
    border-left: 3px solid var(--orange);
    color: var(--muted);
}

.detail-map {
    width: 100%;
    min-height: 340px;
    border-radius: 8px;
    overflow: hidden;
    background: #e5eee9;
}

.area-picker {
    display: grid;
    gap: 12px;
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.area-picker h2 {
    margin: 0;
}

.area-picker label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

.area-picker input,
.area-picker select {
    width: 100%;
}

.area-combobox {
    position: relative;
}

.area-options {
    position: absolute;
    z-index: 1000;
    top: calc(100% + 5px);
    right: 0;
    left: 0;
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 12px 28px rgba(20, 35, 28, 0.16);
}

.area-options button {
    display: flex;
    width: 100%;
    justify-content: space-between;
    gap: 12px;
    border: 0;
    border-radius: 0;
    background: #ffffff;
    color: var(--ink);
    text-align: left;
}

.area-options button:hover,
.area-options button:focus-visible {
    background: rgba(19, 143, 45, 0.08);
}

.area-options button > span:first-child {
    display: grid;
    gap: 3px;
}

.area-options button small {
    color: var(--muted);
    font-weight: 500;
}

.area-options p {
    margin: 0;
    padding: 12px;
    color: var(--muted);
}

.category-picker {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    border: 0;
}

.category-picker legend {
    margin-bottom: 6px;
    font-weight: 700;
}

.category-filter {
    display: flex !important;
    grid-template-columns: none;
    align-items: center;
    gap: 8px !important;
    padding: 5px 0;
}

.category-filter input {
    width: auto;
}

.area-required {
    position: absolute;
    z-index: 500;
    top: 14px;
    right: auto;
    left: 72px;
    display: block;
    max-width: min(420px, calc(100% - 28px));
    min-height: auto;
    padding: 14px 18px;
    border: 2px dashed var(--line);
    border-radius: 12px;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    color: var(--muted);
    text-align: left;
    font-weight: 700;
    pointer-events: none;
}

[hidden] {
    display: none !important;
}

.high-contrast {
    --background: #000000;
    --foreground: #ffffff;
    --muted: #ffffff;
    --line: #ffffff;
    --surface: #000000;
    --map: #222222;
    --blue: #66ccff;
    --green: #7cff7c;
    --red: #ff7070;
    --orange: #ffd166;
}

.high-contrast *,
.high-contrast *::before,
.high-contrast *::after {
    box-shadow: none !important;
}

@media (max-width: 860px) {
    .topbar,
    .workspace,
    .results,
    .map-results {
        grid-template-columns: 1fr;
    }

    .topbar {
        display: grid;
        align-items: start;
    }

    .user-tools {
        justify-items: start;
        margin-left: 0;
    }

    .user-tools .accessibility-toolbar {
        justify-content: flex-start;
    }

    .detail-topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .detail-facts {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .app-shell {
        width: min(100% - 20px, 1200px);
        padding: 14px 0;
    }

    .brand-logo {
        width: min(200px, 58vw);
    }

    .filters,
    .detail-section {
        padding: 14px;
    }

    .user-map,
    .user-map {
        min-height: 320px;
    }

    .detail-compliance {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .compliance-reason {
        margin-left: 0;
    }

    .area-required {
        top: auto;
        right: 14px;
        bottom: 14px;
        left: 14px;
        max-width: none;
    }
}
