/* ===== Base Reset ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    height: 100vh;
    overflow: hidden;
}

/* ===== Map ===== */
#map {
    width: 100%;
    height: 100vh;
}

/* ===== Search Bar ===== */
#search-container {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: 90%;
    max-width: 480px;
}

#search-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
    outline: none;
}

#search-input:focus {
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
}

#search-results {
    background: white;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

#search-results .result-item {
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    font-size: 14px;
}

#search-results .result-item:hover {
    background: #f0f7ff;
}

/* ===== Layer Controls ===== */
#layer-controls {
    position: absolute;
    top: 70px;
    right: 12px;
    z-index: 1000;
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    font-size: 14px;
}

#layer-controls h3 {
    margin-bottom: 8px;
    font-size: 14px;
    color: #333;
}

#layer-controls label {
    display: block;
    margin: 6px 0;
    cursor: pointer;
    color: #444;
}

#layer-controls #listings-control.hidden {
    display: none;
}

/* ===== Risk Panel ===== */
#risk-panel {
    position: absolute;
    top: 70px;
    left: 12px;
    z-index: 1000;
    background: white;
    width: 320px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
    padding: 16px;
    font-size: 14px;
    line-height: 1.5;
}

#risk-panel.hidden {
    display: none;
}

#close-panel {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #888;
}

#close-panel:hover {
    color: #333;
}

#risk-content h2 {
    font-size: 16px;
    margin-bottom: 12px;
    color: #222;
}

.risk-section {
    margin-bottom: 14px;
    padding: 10px;
    border-radius: 6px;
    background: #f8f9fa;
}

.risk-section h3 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    color: #555;
}

.risk-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 13px;
}

.risk-badge.yes {
    background: #fee2e2;
    color: #dc2626;
}

.risk-badge.no {
    background: #dcfce7;
    color: #16a34a;
}

.price-value {
    font-size: 20px;
    font-weight: 700;
    color: #1d4ed8;
}

.prop-table {
    width: 100%;
    font-size: 13px;
}

.prop-table td {
    padding: 2px 0;
}

.prop-table td:first-child {
    color: #777;
    width: 60px;
}

.disclaimer-text {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #ddd;
    font-size: 11px;
    color: #888;
}

/* ===== Disclaimer Footer ===== */
#disclaimer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.7);
    color: #ccc;
    text-align: center;
    padding: 6px 12px;
    font-size: 11px;
}

/* ===== Legend (price heatmap) ===== */
.legend {
    background: white;
    padding: 8px 12px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    font-size: 12px;
    line-height: 1.6;
}

.legend i {
    width: 16px;
    height: 16px;
    display: inline-block;
    margin-right: 6px;
    vertical-align: middle;
    border-radius: 2px;
}

/* ===== Attribution Modal ===== */
#attribution-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
}

#attribution-modal.hidden {
    display: none;
}

#attribution-content {
    position: relative;
    background: white;
    border-radius: 12px;
    padding: 24px 28px;
    max-width: 640px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

#attribution-content h2 {
    font-size: 18px;
    margin-bottom: 8px;
    color: #222;
}

#close-attribution {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #888;
}

#close-attribution:hover {
    color: #333;
}

#attribution-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 8px;
}

#attribution-table th {
    text-align: left;
    padding: 8px 10px;
    background: #f1f5f9;
    color: #475569;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#attribution-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #e2e8f0;
    color: #334155;
}

#attribution-table a {
    color: #2563eb;
    text-decoration: none;
}

#attribution-table a:hover {
    text-decoration: underline;
}

/* ===== Risk Score Gauge ===== */
.risk-score-section {
    background: #f0f4ff;
    border: 1px solid #dbeafe;
}

.risk-gauge-container {
    margin: 8px 0 6px;
}

.risk-gauge-bar {
    width: 100%;
    height: 12px;
    background: #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
}

.risk-gauge-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.6s ease;
}

.risk-gauge-label {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-top: 6px;
}

.risk-gauge-number {
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
}

.risk-gauge-max {
    font-size: 14px;
    color: #999;
}

.risk-gauge-text {
    font-size: 14px;
    font-weight: 700;
    margin-left: auto;
}

.risk-breakdown {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: #666;
    margin-top: 4px;
}

.risk-breakdown span {
    cursor: help;
}

/* ===== Report Button ===== */
.report-btn {
    width: 100%;
    padding: 10px 16px;
    background: #1d4ed8;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.report-btn:hover {
    background: #1e40af;
}

.report-btn:disabled {
    background: #93c5fd;
    cursor: not-allowed;
}

/* ===== Listing Markers ===== */
.listing-marker {
    background: none;
    border: none;
}

.listing-pin {
    width: 28px;
    height: 28px;
    background: #16a34a;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.listing-popup {
    min-width: 180px;
}

.listing-popup strong {
    font-size: 13px;
    color: #222;
}

.listing-price {
    font-size: 16px;
    font-weight: 700;
    color: #16a34a;
}

/* ===== History Toggle Button ===== */
#open-history {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1001;
    background: white;
    border: none;
    padding: 10px 14px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    font-size: 13px;
    font-weight: 600;
    color: #444;
    cursor: pointer;
}

#open-history:hover {
    background: #f8f9fa;
    color: #1d4ed8;
}

/* Push layer-controls below the history button */
#layer-controls {
    top: 56px;
}

/* ===== History Panel ===== */
#history-panel {
    position: absolute;
    top: 70px;
    right: 12px;
    z-index: 1000;
    background: white;
    width: 340px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
    padding: 16px;
    font-size: 13px;
}

#history-panel.hidden {
    display: none;
}

#history-panel h2 {
    font-size: 16px;
    margin-bottom: 12px;
    color: #222;
}

#close-history {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #888;
}

#close-history:hover {
    color: #333;
}

.history-section-h {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #777;
    margin: 12px 0 6px;
    border-bottom: 1px solid #eee;
    padding-bottom: 4px;
}

.history-empty, .history-hint {
    font-size: 12px;
    color: #888;
    margin: 8px 0;
    line-height: 1.5;
}

.history-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 6px;
    border-radius: 6px;
    margin-bottom: 4px;
}

.history-item:hover {
    background: #f8f9fa;
}

.history-compare-cb {
    margin-top: 4px;
    cursor: pointer;
    flex-shrink: 0;
}

.history-item-body {
    flex: 1;
    min-width: 0;
}

.history-item-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.history-item-address {
    flex: 1;
    font-weight: 600;
    font-size: 13px;
    color: #222;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-fav-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

.history-item-meta {
    font-size: 11px;
    color: #666;
    margin-top: 2px;
}

.history-item-actions {
    margin-top: 4px;
    display: flex;
    gap: 6px;
}

.history-view-btn, .history-remove-btn {
    background: #eef2ff;
    color: #1d4ed8;
    border: none;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
}

.history-view-btn:hover {
    background: #dbeafe;
}

.history-remove-btn {
    background: #fee2e2;
    color: #dc2626;
    padding: 3px 8px;
}

.history-remove-btn:hover {
    background: #fecaca;
}

.history-compare-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 6px;
    margin-bottom: 10px;
    font-size: 12px;
    color: #0369a1;
}

.history-compare-bar > span {
    flex: 1;
}

.history-compare-bar button {
    background: #1d4ed8;
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    font-weight: 600;
}

.history-compare-bar button:disabled {
    background: #93c5fd;
    cursor: not-allowed;
}

.history-compare-bar #history-compare-clear {
    background: #e2e8f0;
    color: #475569;
}

/* ===== Favourite Button (in risk panel) ===== */
.favourite-btn {
    width: 100%;
    padding: 8px 14px;
    background: white;
    color: #555;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 8px;
}

.favourite-btn:hover {
    background: #f8f9fa;
    border-color: #eab308;
    color: #ca8a04;
}

.favourite-btn.is-fav {
    background: #fef9c3;
    border-color: #eab308;
    color: #854d0e;
}

/* ===== Comparison Modal ===== */
#compare-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
}

#compare-modal.hidden {
    display: none;
}

#compare-content {
    position: relative;
    background: white;
    border-radius: 12px;
    padding: 24px 28px;
    max-width: 95vw;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

#compare-content h2 {
    font-size: 18px;
    margin-bottom: 12px;
    color: #222;
}

#close-compare {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #888;
}

#close-compare:hover {
    color: #333;
}

.compare-table-wrap {
    overflow-x: auto;
}

.compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.compare-table th, .compare-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    text-align: left;
    vertical-align: top;
}

.compare-table thead th {
    background: #f1f5f9;
    color: #475569;
    border-bottom: 2px solid #cbd5e1;
}

.compare-table tbody th {
    width: 140px;
    color: #777;
    font-weight: 600;
    background: #fafbfc;
}

.compare-head-addr {
    font-weight: 700;
    color: #222;
    margin-bottom: 2px;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compare-head-sub {
    font-size: 11px;
    color: #888;
    font-weight: 400;
    margin-bottom: 6px;
}

.compare-view-btn {
    background: #eef2ff;
    color: #1d4ed8;
    border: none;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    font-weight: 600;
}

.compare-view-btn:hover {
    background: #dbeafe;
}

.compare-disclaimer {
    margin-top: 12px;
    font-size: 11px;
    color: #888;
}

/* ===== Paywall Modal ===== */
#paywall-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

#paywall-modal.hidden {
    display: none;
}

#paywall-content {
    background: #fff;
    border-radius: 12px;
    max-width: 520px;
    width: 100%;
    padding: 28px 28px 22px;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-height: 92vh;
    overflow-y: auto;
}

#close-paywall {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #94a3b8;
    line-height: 1;
}

#close-paywall:hover {
    color: #1e293b;
}

#paywall-content h2 {
    margin: 0 0 6px;
    color: #1d4ed8;
    font-size: 22px;
}

.paywall-sub {
    color: #475569;
    font-size: 13px;
    margin: 0 0 14px;
    line-height: 1.5;
}

.paywall-includes {
    list-style: none;
    padding: 0;
    margin: 0 0 18px;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 12px 14px;
}

.paywall-includes li {
    font-size: 13px;
    color: #1e293b;
    padding: 3px 0 3px 22px;
    position: relative;
    line-height: 1.45;
}

.paywall-includes li::before {
    content: "✓";
    color: #16a34a;
    font-weight: 700;
    position: absolute;
    left: 4px;
    top: 3px;
}

.paywall-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.paywall-option {
    background: #fff;
    border: 2px solid #cbd5e1;
    border-radius: 10px;
    padding: 14px 12px;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
    position: relative;
}

.paywall-option:hover {
    border-color: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(29, 78, 216, 0.12);
}

.paywall-option.recommended {
    border-color: #1d4ed8;
    background: #eff6ff;
}

.paywall-option-tag {
    position: absolute;
    top: -10px;
    right: 10px;
    background: #1d4ed8;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 10px;
    letter-spacing: 0.5px;
}

.paywall-option-title {
    font-size: 13px;
    color: #1e293b;
    font-weight: 600;
    margin-bottom: 4px;
}

.paywall-option-price {
    font-size: 24px;
    color: #1d4ed8;
    font-weight: 700;
    margin: 2px 0;
}

.paywall-option-sub {
    font-size: 11px;
    color: #64748b;
    margin-top: 2px;
}

.paywall-pack-note {
    text-align: center;
    font-size: 11px;
    color: #64748b;
    margin: 4px 0 10px;
}

.paywall-fine {
    font-size: 11px;
    color: #94a3b8;
    text-align: center;
    margin: 6px 0 0;
    line-height: 1.5;
}

.preview-paywall-cta {
    margin-top: 16px;
    padding: 16px;
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    color: #fff;
    border-radius: 10px;
    text-align: center;
}

.preview-paywall-cta h3 {
    margin: 0 0 6px;
    color: #fff;
    font-size: 16px;
}

.preview-paywall-cta p {
    margin: 0 0 12px;
    font-size: 12px;
    opacity: 0.92;
    line-height: 1.5;
}

.preview-paywall-cta button {
    background: #fff;
    color: #1d4ed8;
    border: none;
    padding: 10px 22px;
    font-weight: 700;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.preview-paywall-cta button:hover {
    background: #f1f5f9;
}

.preview-paywall-cta .pack-credits {
    background: rgba(255, 255, 255, 0.15);
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    font-size: 12px;
}

.briefing-btn {
    width: 100%;
    padding: 10px 16px;
    background: #fff;
    color: #1d4ed8;
    border: 2px solid #1d4ed8;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 8px;
}

.briefing-btn:hover {
    background: #eff6ff;
}

.briefing-btn:disabled {
    border-color: #93c5fd;
    color: #93c5fd;
    cursor: not-allowed;
}

.briefing-hint {
    font-size: 11px;
    color: #475569;
    text-align: center;
    margin-top: 6px;
    line-height: 1.4;
}

/* ===== Loading / Error States ===== */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #cbd5e1;
    border-top-color: #1d4ed8;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
    flex-shrink: 0;
}

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

.panel-loading {
    display: flex;
    align-items: center;
    padding: 20px 4px;
    color: #666;
    font-size: 14px;
}

.panel-error {
    padding: 16px 4px;
    color: #b91c1c;
    font-size: 13px;
    line-height: 1.5;
}

.panel-error-hint {
    color: #888;
    font-size: 12px;
    margin-top: 6px;
}

.result-item.result-status {
    color: #888;
    cursor: default;
    display: flex;
    align-items: center;
}

.result-item.result-status:hover {
    background: none;
}

/* Layer-toggle loading/error hints (class goes on the <label>) */
#layer-controls label.layer-loading {
    color: #888;
}

#layer-controls label.layer-loading::after {
    content: " \23F3";
}

#layer-controls label.layer-error::after {
    content: " (unavailable)";
    color: #dc2626;
    font-size: 11px;
    font-weight: 600;
}

/* ===== Mobile ===== */
@media (max-width: 600px) {
    .paywall-options {
        grid-template-columns: 1fr;
    }

    #risk-panel {
        width: calc(100% - 24px);
        top: auto;
        bottom: 40px;
        max-height: 50vh;
    }

    #layer-controls {
        top: 102px;
        right: 8px;
        padding: 8px 12px;
        width: calc(100% - 16px);
    }

    #open-history {
        top: 64px;
        right: 8px;
        padding: 6px 10px;
        font-size: 12px;
    }

    #history-panel {
        width: calc(100% - 24px);
        top: auto;
        bottom: 40px;
        max-height: 60vh;
    }

    /* Centred search bar collides with Leaflet's top-left zoom control on
       narrow screens - hug the right side instead, clear of the zoom buttons. */
    #search-container {
        left: auto;
        right: 8px;
        transform: none;
        width: calc(100% - 60px);
    }
}

/* ===== 2026 launch shell: map-first brand and calmer information hierarchy ===== */
:root {
    --fl-navy: #0b2432;
    --fl-navy-2: #12394a;
    --fl-teal: #0f8b8d;
    --fl-teal-dark: #087274;
    --fl-mint: #dff5ef;
    --fl-ink: #14232b;
    --fl-muted: #60727c;
    --fl-border: #d9e4e8;
    --fl-surface: #ffffff;
}

body {
    color: var(--fl-ink);
    background: #dce8eb;
}

#app-brand {
    position: absolute;
    z-index: 1002;
    top: 11px;
    left: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 7px 12px 7px 8px;
    border: 1px solid rgba(255, 255, 255, 0.85);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 6px 22px rgba(11, 36, 50, 0.16);
    color: var(--fl-navy);
    text-decoration: none;
    backdrop-filter: blur(8px);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    overflow: hidden;
    border-radius: 10px;
    background: linear-gradient(145deg, var(--fl-navy), var(--fl-teal));
}

.brand-mark span {
    width: 24px;
    height: 5px;
    margin: -2px 0;
    border: 2px solid rgba(255, 255, 255, 0.94);
    border-top: 0;
    border-radius: 0 0 50% 50%;
}

.brand-copy {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-copy strong {
    font-size: 17px;
    letter-spacing: -0.3px;
}

.brand-copy small {
    margin-top: 3px;
    color: var(--fl-muted);
    font-size: 9px;
    letter-spacing: 0.35px;
    text-transform: uppercase;
}

#search-input {
    min-height: 48px;
    padding: 12px 18px 12px 44px;
    border: 1px solid rgba(15, 139, 141, 0.24);
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 8px 28px rgba(11, 36, 50, 0.2);
    color: var(--fl-ink);
}

#search-container::before {
    content: "⌕";
    position: absolute;
    z-index: 2;
    top: 7px;
    left: 14px;
    color: var(--fl-teal-dark);
    font-size: 27px;
    line-height: 1;
    pointer-events: none;
}

#search-input:focus {
    border-color: var(--fl-teal);
    box-shadow: 0 8px 30px rgba(15, 139, 141, 0.28), 0 0 0 3px rgba(15, 139, 141, 0.13);
}

#search-results {
    border: 1px solid var(--fl-border);
    border-top: 0;
    border-radius: 0 0 12px 12px;
}

#open-history,
#toggle-layers {
    min-height: 40px;
    border: 1px solid rgba(15, 139, 141, 0.16);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 5px 18px rgba(11, 36, 50, 0.15);
    color: var(--fl-navy);
}

#toggle-layers {
    position: absolute;
    z-index: 1001;
    top: 59px;
    right: 12px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

#toggle-layers::before {
    content: "◫";
    margin-right: 6px;
    color: var(--fl-teal-dark);
}

#toggle-layers.is-active {
    border-color: var(--fl-teal);
    background: var(--fl-mint);
}

#layer-controls {
    top: 106px;
    min-width: 244px;
    padding: 13px 15px 14px;
    border: 1px solid var(--fl-border);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(11, 36, 50, 0.18);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

#layer-controls.is-collapsed {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.98);
    pointer-events: none;
}

.layer-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

#layer-controls .layer-heading h3 {
    margin: 0;
    color: var(--fl-navy);
    font-size: 13px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

#close-layers {
    border: 0;
    background: transparent;
    color: #78909b;
    font-size: 21px;
    line-height: 1;
    cursor: pointer;
}

#layer-controls label {
    padding: 2px 0;
    color: #334b56;
}

#show-coverage {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #b8ccd1;
    border-radius: 8px;
    background: #f4f9f9;
    color: var(--fl-navy);
    font-weight: 700;
    cursor: pointer;
}

#show-coverage:hover {
    border-color: var(--fl-teal);
    background: var(--fl-mint);
}

.verification-list {
    margin: 5px 0 0 18px;
    color: #455b64;
    font-size: 11px;
    line-height: 1.45;
}

#welcome-card {
    position: absolute;
    z-index: 999;
    top: 82px;
    left: 12px;
    width: min(370px, calc(100% - 24px));
    padding: 21px 22px 19px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 16px;
    background: linear-gradient(150deg, rgba(11, 36, 50, 0.97), rgba(18, 70, 80, 0.95));
    box-shadow: 0 18px 48px rgba(11, 36, 50, 0.28);
    color: #fff;
    backdrop-filter: blur(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#welcome-card.is-dismissed,
#welcome-card.is-result-open {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    pointer-events: none;
}

#close-welcome {
    position: absolute;
    top: 9px;
    right: 11px;
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.72);
    font-size: 22px;
    cursor: pointer;
}

.welcome-eyebrow {
    margin-bottom: 8px;
    color: #8ee0d5;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.1px;
    text-transform: uppercase;
}

#welcome-card h1 {
    max-width: 320px;
    font-size: 24px;
    line-height: 1.16;
    letter-spacing: -0.55px;
}

#welcome-card > p {
    margin-top: 10px;
    color: #d7e7ea;
    font-size: 13px;
    line-height: 1.55;
}

.trust-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 14px 0;
}

.trust-row span {
    padding: 5px 8px;
    border: 1px solid rgba(142, 224, 213, 0.3);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    color: #dff9f4;
    font-size: 10px;
}

#welcome-search {
    width: 100%;
    padding: 10px 14px;
    border: 0;
    border-radius: 9px;
    background: #6bd0c2;
    color: #082833;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

#welcome-search:hover {
    background: #88e0d3;
}

#welcome-card > small {
    display: block;
    margin-top: 10px;
    color: #a9c1c7;
    font-size: 9.5px;
    line-height: 1.4;
}

#risk-panel {
    top: 82px;
    width: 380px;
    max-height: calc(100vh - 128px);
    border: 1px solid var(--fl-border);
    border-radius: 14px;
    box-shadow: 0 16px 45px rgba(11, 36, 50, 0.24);
}

#risk-content h2 {
    padding-right: 22px;
    color: var(--fl-navy);
    font-size: 18px;
    line-height: 1.25;
}

.risk-section {
    border: 1px solid #e4ecef;
    border-radius: 9px;
    background: #f7fafb;
}

.risk-section h3 {
    color: #48606a;
    font-size: 11px;
    letter-spacing: 0.75px;
}

.risk-score-section {
    border-color: #bce1da;
    background: linear-gradient(145deg, #edf9f5, #f7fbfc);
}

.methodology-note {
    margin-top: 7px;
    color: var(--fl-muted);
    font-size: 10.5px;
    line-height: 1.45;
}

.verify-list {
    display: grid;
    gap: 8px;
    margin: 8px 0 4px 18px;
    color: #415862;
    font-size: 11px;
    line-height: 1.45;
}

.verify-list.compact {
    gap: 4px;
}

.verify-item strong,
.verify-item span {
    display: block;
}

.verify-item strong {
    color: #263f49;
}

.verify-item span {
    margin-top: 2px;
    color: var(--fl-muted);
}

.report-group {
    margin: 0 0 10px;
    overflow: hidden;
    border: 1px solid var(--fl-border);
    border-radius: 10px;
    background: #fff;
}

.report-group > summary {
    padding: 10px 12px;
    background: #eef5f6;
    color: var(--fl-navy);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.2px;
    cursor: pointer;
}

.report-group-body {
    padding: 10px 10px 0;
}

.report-group-body .risk-section:last-child {
    margin-bottom: 10px;
}

.preview-paywall-cta {
    background: linear-gradient(135deg, var(--fl-teal-dark), var(--fl-navy));
}

.report-btn {
    background: var(--fl-teal-dark);
}

.report-btn:hover {
    background: #075e60;
}

#disclaimer {
    background: rgba(11, 36, 50, 0.94);
    color: #c8d8dc;
}

@media (max-width: 1100px) and (min-width: 701px) {
    .brand-copy small {
        display: none;
    }
}

@media (max-width: 700px) {
    #app-brand {
        top: 8px;
        left: 8px;
        min-height: 48px;
        padding: 6px;
    }

    .brand-copy {
        display: none;
    }

    .brand-mark {
        width: 36px;
        height: 36px;
    }

    #search-container {
        top: 8px;
        right: 8px;
        width: calc(100% - 64px);
    }

    #search-input {
        min-height: 48px;
        font-size: 15px;
    }

    #open-history {
        top: 64px;
        right: 8px;
        min-height: 36px;
    }

    #toggle-layers {
        top: 64px;
        right: 92px;
        min-height: 36px;
        padding: 6px 10px;
        font-size: 12px;
    }

    #layer-controls {
        top: 106px;
        right: 8px;
        width: calc(100% - 16px);
        max-height: calc(100vh - 154px);
        overflow-y: auto;
    }

    #welcome-card {
        top: 112px;
        left: 8px;
        width: calc(100% - 16px);
        padding: 18px 18px 16px;
    }

    #welcome-card h1 {
        font-size: 21px;
    }

    #risk-panel {
        left: 8px;
        bottom: 35px;
        width: calc(100% - 16px);
        max-height: 80vh;
        padding: 15px;
        border-radius: 15px 15px 8px 8px;
    }

    #history-panel {
        left: 8px;
        right: auto;
        bottom: 35px;
        width: calc(100% - 16px);
        max-height: 78vh;
    }

    #disclaimer {
        overflow: hidden;
        padding: 5px 8px;
        white-space: nowrap;
        text-overflow: ellipsis;
    }
}

/* Standalone legal/support pages use the same identity without the map shell. */
body.legal-page {
    width: min(900px, 100%);
    height: auto;
    min-height: 100vh;
    margin: 0 auto;
    overflow: auto;
    padding: 28px 24px 48px;
    background: #f5f8f9;
    color: var(--fl-ink);
    line-height: 1.65;
}

.legal-page h1 {
    margin: 8px 0 4px;
    color: var(--fl-navy);
    font-size: clamp(28px, 5vw, 42px);
    letter-spacing: -0.8px;
}

.legal-page h2 {
    margin: 26px 0 8px;
    color: var(--fl-navy-2);
    font-size: 18px;
}

.legal-page p,
.legal-page li {
    max-width: 76ch;
}

.legal-page ul {
    margin: 8px 0 12px 22px;
}

.legal-page a {
    color: var(--fl-teal-dark);
}

.legal-brand {
    display: inline-flex;
    margin-bottom: 14px;
    color: var(--fl-navy) !important;
    font-size: 19px;
    font-weight: 800;
    text-decoration: none;
}

.legal-callout {
    margin: 22px 0;
    padding: 18px 20px;
    border: 1px solid #bce1da;
    border-radius: 12px;
    background: #edf9f5;
}

.legal-callout h2 {
    margin-top: 0;
}

/* ===== Recovery code (purchase restore without email) ===== */
#recovery-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2100;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

#recovery-content {
    background: #fff;
    border-radius: 14px;
    padding: 24px;
    width: min(460px, 100%);
    box-shadow: 0 18px 48px rgba(11, 36, 50, 0.28);
}

#recovery-content h3 {
    margin-bottom: 10px;
    font-size: 17px;
    color: #0b2432;
}

#recovery-content p {
    font-size: 13px;
    line-height: 1.55;
    color: #445;
}

#recovery-code {
    display: block;
    margin: 14px 0;
    padding: 12px;
    border: 1px solid var(--fl-border, #d6e2e6);
    border-radius: 8px;
    background: #f4f8f9;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 12px;
    word-break: break-all;
    user-select: all;
}

.recovery-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.recovery-actions button {
    flex: 1;
    padding: 10px 14px;
    border: 0;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

#copy-recovery {
    background: #6bd0c2;
    color: #082833;
}

#close-recovery {
    background: #e8eef0;
    color: #33474f;
}

#recovery-content small {
    color: #6b8088;
    font-size: 11px;
}

/* ===== Why page ===== */
.why-lead {
    font-size: 16px !important;
    line-height: 1.6 !important;
    color: #2b4149 !important;
}

.why-limits {
    background: #fff8f1;
    border-color: #f0d9c2;
}

a.why-cta {
    display: inline-block;
    margin-top: 4px;
    padding: 12px 22px;
    border-radius: 10px;
    background: #12606b;
    color: #fff;
    font-weight: 800;
    font-size: 14px;
    text-decoration: none;
}

a.why-cta:hover {
    background: #17747f;
}

.welcome-why {
    display: inline-block;
    margin-top: 6px;
    color: #8ee0d5;
    font-weight: 700;
    text-decoration: underline;
}

/* The why page is long-form prose; give paragraphs room to breathe. */
.legal-page .why-lead ~ p,
.legal-page .legal-callout p + p,
.legal-page h2 + p {
    margin-bottom: 12px;
}
