.sales-map-page {
    background: #f6f8fb;
    color: #162033;
}

.sales-map-page .site-header {
    padding-top: 0.75rem;
}

.sales-map-page .site-header .home-topbar {
    margin-bottom: 0;
    padding-bottom: 0.75rem;
}

.sales-map-shell {
    padding-top: 14px;
    padding-bottom: 48px;
}

.sales-map-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 520px);
    gap: 24px;
    align-items: center;
    margin-bottom: 14px;
}

.eyebrow {
    margin: 0 0 8px;
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.sales-map-hero h1 {
    max-width: 860px;
    margin-bottom: 0;
    color: #101828;
    font-size: clamp(2rem, 4vw, 4.2rem);
    font-weight: 800;
    letter-spacing: 0;
}

.sales-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 0;
}

.sales-metrics div {
    min-height: 96px;
    padding: 16px;
    border: 1px solid #d9e2ef;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.07);
}

.sales-metrics dt {
    margin-bottom: 6px;
    color: #0f172a;
    font-family: var(--font-heading, Outfit, sans-serif);
    font-size: clamp(1.2rem, 2vw, 1.75rem);
    font-weight: 800;
    line-height: 1.1;
}

.sales-metrics dd {
    margin: 0;
    color: #667085;
    font-size: 0.74rem;
    font-weight: 800;
    line-height: 1.3;
    text-transform: uppercase;
}

.sales-map-dashboard {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 16px;
    align-items: stretch;
}

.selected-market-panel,
.map-workspace,
.estimate-lab article,
.source-strip {
    border: 1px solid #d9e2ef;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
}

.map-workspace {
    min-width: 0;
    padding: 14px;
}

.selected-market-panel {
    min-height: 700px;
    padding: 18px;
}

.map-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.metric-mode-group {
    display: inline-grid;
    grid-template-columns: repeat(3, minmax(88px, auto));
    gap: 6px;
}

.metric-mode,
.map-actions button,
.month-control button {
    min-height: 38px;
    border: 1px solid #d5dce6;
    border-radius: 8px;
    background: #ffffff;
    color: #344054;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 800;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.metric-mode {
    padding: 0 12px;
}

.metric-mode:hover,
.metric-mode:focus-visible,
.map-actions button:hover,
.map-actions button:focus-visible,
.month-control button:hover,
.month-control button:focus-visible {
    border-color: #94a3b8;
    background: #f8fafc;
    outline: none;
}

.metric-mode.active {
    border-color: #0f172a;
    background: #0f172a;
    color: #ffffff;
}

.map-actions {
    display: inline-grid;
    grid-template-columns: 38px 68px 38px;
    gap: 6px;
}

.month-control {
    display: grid;
    grid-template-columns: 38px minmax(140px, 1fr) 38px 96px;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
}

#month-range {
    width: 100%;
    accent-color: #0f766e;
}

#selected-month-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 10px;
    border: 1px solid #d9e2ef;
    border-radius: 8px;
    background: #f8fafc;
    color: #0f172a;
    font-size: 0.82rem;
    font-weight: 900;
    white-space: nowrap;
}

.map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-bottom: 12px;
    color: #475467;
    font-size: 0.8rem;
    font-weight: 800;
}

.map-legend span,
.confidence-grid span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.legend-dot,
.confidence-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 999px;
}

.legend-dot.mega {
    background: #ef4444;
}

.legend-dot.high {
    background: #f97316;
}

.legend-dot.mid {
    background: #22c55e;
}

.legend-dot.low {
    background: #38bdf8;
}

.legend-dot.trace {
    background: #c7d2fe;
}

.legend-dot.none {
    border: 1px solid #cbd5e1;
    background: #ffffff;
}

.map-frame {
    position: relative;
    min-height: 566px;
    overflow: hidden;
    border: 1px solid #dbe4ef;
    border-radius: 8px;
    background: #eaf2fb;
}

#sales-map {
    display: block;
    width: 100%;
    height: 566px;
}

.country-shape {
    vector-effect: non-scaling-stroke;
    cursor: pointer;
    transition: fill 0.18s ease, opacity 0.18s ease, stroke 0.18s ease;
}

.country-shape:hover,
.country-shape.active {
    stroke: #0f172a;
    stroke-width: 1.35;
}

.country-shape.quality-estimate {
    stroke-dasharray: 4 2;
}

.country-shape.bucket-none {
    fill: #ffffff;
}

.sales-marker {
    cursor: pointer;
    paint-order: stroke;
    stroke: #ffffff;
    stroke-width: 2.3;
    transition: opacity 0.18s ease, stroke 0.18s ease;
    vector-effect: non-scaling-stroke;
}

.sales-marker.quality-estimate {
    stroke-dasharray: 3 2;
}

.sales-marker:hover,
.sales-marker.active {
    stroke: #0f172a;
    stroke-width: 2.8;
}

.graticule {
    fill: none;
    stroke: rgba(100, 116, 139, 0.22);
    stroke-width: 0.7;
}

.sphere {
    fill: transparent;
}

.map-tooltip {
    position: absolute;
    z-index: 4;
    display: none;
    max-width: 275px;
    padding: 8px 10px;
    border: 1px solid #d0d7e2;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.94);
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.35;
    pointer-events: none;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.22);
}

.map-tooltip strong,
.map-tooltip span {
    display: block;
}

.map-tooltip strong {
    margin-bottom: 3px;
    font-size: 0.84rem;
}

.map-loading {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #475467;
    font-weight: 800;
    background: rgba(255, 255, 255, 0.45);
}

.map-loading.hidden {
    display: none;
}

.ranked-markets-panel {
    margin-top: 12px;
    padding: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff;
}

.panel-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.panel-header.compact {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
}

.panel-header h2,
.trend-panel h2,
.source-panel h2,
.estimate-lab h2,
.source-strip h2 {
    margin: 0;
    color: #111827;
    font-size: 1.05rem;
    font-weight: 800;
}

.panel-header p,
.trend-panel p {
    margin: 0;
    color: #667085;
    font-size: 0.8rem;
    font-weight: 700;
}

.market-table-wrap {
    overflow-x: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.market-table {
    width: 100%;
    min-width: 650px;
    border-collapse: collapse;
    background: #ffffff;
    font-size: 0.86rem;
}

.market-table th,
.market-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    vertical-align: middle;
}

.market-table th {
    background: #f8fafc;
    color: #475467;
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
}

.market-table tbody tr:last-child td {
    border-bottom: 0;
}

.market-table tr.active td {
    background: #f0fdfa;
}

.market-table button {
    border: 0;
    background: transparent;
    color: #0f172a;
    cursor: pointer;
    font: inherit;
    font-weight: 800;
    text-align: left;
}

.market-table button:hover,
.market-table button:focus-visible {
    color: #0f766e;
    outline: none;
}

.table-quality,
.detail-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 26px;
    border-radius: 8px;
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 900;
    line-height: 1.1;
}

.table-quality {
    min-width: 72px;
    padding: 0 8px;
}

.detail-status {
    min-height: 30px;
    max-width: 120px;
    padding: 0 10px;
    font-size: 0.74rem;
}

.table-quality.actual,
.detail-status.actual,
.confidence-dot.actual {
    background: #0f766e;
}

.table-quality.proxy,
.detail-status.proxy,
.confidence-dot.proxy {
    background: #2563eb;
}

.table-quality.estimate,
.detail-status.estimate,
.confidence-dot.estimate {
    background: #7c3aed;
}

.table-quality.none,
.detail-status.none {
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #475467;
}

.market-detail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
}

.detail-label {
    margin: 0 0 4px;
    color: #667085;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1.2;
    text-transform: uppercase;
}

.market-detail h2 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 800;
}

.market-detail>p,
.quality-note {
    grid-column: 1 / -1;
    margin: 0;
    color: #526071;
    font-size: 0.9rem;
    line-height: 1.45;
}

.detail-metrics {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
}

.detail-metrics div {
    min-height: 74px;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}

.detail-metrics dt {
    margin-bottom: 4px;
    color: #0f172a;
    font-family: var(--font-heading, Outfit, sans-serif);
    font-size: 1.15rem;
    font-weight: 800;
}

.detail-metrics dd {
    margin: 0;
    color: #667085;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.quality-note {
    padding-top: 4px;
    font-size: 0.82rem;
    font-weight: 700;
}

.trend-panel,
.source-panel {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid #e2e8f0;
}

.trend-chart {
    display: grid;
    grid-template-columns: repeat(17, minmax(12px, 1fr));
    gap: 5px;
    align-items: end;
    height: 160px;
    margin-top: 12px;
}

.trend-bar {
    position: relative;
    display: grid;
    grid-template-rows: minmax(0, 1fr) 18px;
    gap: 5px;
    height: 100%;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #667085;
    cursor: pointer;
    font-size: 0.62rem;
    font-weight: 800;
}

.trend-bar i {
    align-self: end;
    display: block;
    height: var(--bar-height);
    min-height: 2px;
    border-radius: 5px 5px 0 0;
    background: #38bdf8;
    transition: height 0.18s ease, background 0.18s ease;
}

.trend-bar.actual i {
    background: #0f766e;
}

.trend-bar.proxy i {
    background: #2563eb;
}

.trend-bar.estimate i {
    background: #7c3aed;
}

.trend-bar.empty i {
    height: 2px;
    background: #d9e2ef;
}

.trend-bar.selected i {
    background: #f97316;
}

.trend-bar span {
    overflow: hidden;
    text-align: center;
    text-overflow: clip;
}

.trend-bar:hover i,
.trend-bar:focus-visible i {
    outline: 2px solid #0f172a;
    outline-offset: 2px;
}

.source-panel ul {
    display: grid;
    gap: 10px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.source-panel li {
    display: grid;
    gap: 4px;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    color: #526071;
    font-size: 0.8rem;
    line-height: 1.4;
}

.source-panel a,
.source-strip a,
.estimate-lab a {
    color: #2563eb;
    font-weight: 800;
}

.estimate-lab {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.estimate-lab article {
    padding: 18px;
}

.estimate-lab p {
    margin: 8px 0 0;
    color: #526071;
    font-size: 0.9rem;
    line-height: 1.5;
}

.estimate-lab ul {
    display: grid;
    gap: 8px;
    margin: 12px 0 0;
    padding-left: 18px;
    color: #475467;
    font-size: 0.88rem;
}

.confidence-grid {
    display: grid;
    gap: 8px;
    margin-top: 14px;
    color: #475467;
    font-size: 0.84rem;
    font-weight: 800;
}

.source-strip {
    margin-top: 16px;
    padding: 18px;
}

.source-strip h2 {
    margin-bottom: 6px;
}

.source-strip p {
    max-width: 1080px;
    margin: 0 0 12px;
    color: #526071;
    line-height: 1.5;
}

.source-strip ul {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 8px 16px;
    margin: 0;
    padding-left: 18px;
    color: #475467;
    font-size: 0.88rem;
}

.source-strip .data-date {
    margin: 14px 0 0;
    color: #667085;
    font-size: 0.82rem;
    font-weight: 800;
}

.map-preview-mode,
.map-preview-mode body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: #eaf2fb;
}

.map-preview-mode [include-html],
.map-preview-mode .development-banner,
.map-preview-mode .site-header,
.map-preview-mode header,
.map-preview-mode footer,
.map-preview-mode .sales-map-hero,
.map-preview-mode .map-toolbar,
.map-preview-mode .month-control,
.map-preview-mode .map-legend,
.map-preview-mode .ranked-markets-panel,
.map-preview-mode .selected-market-panel,
.map-preview-mode .estimate-lab,
.map-preview-mode .source-strip {
    display: none !important;
}

.map-preview-mode .sales-map-shell {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
}

.map-preview-mode .sales-map-dashboard,
.map-preview-mode .map-workspace,
.map-preview-mode .map-frame {
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

.map-preview-mode .sales-map-dashboard {
    display: block;
}

.map-preview-mode .map-workspace,
.map-preview-mode .map-frame {
    border: 0;
    border-radius: 0;
    background: #eaf2fb;
    box-shadow: none;
}

.map-preview-mode #sales-map {
    width: 100%;
    height: 100vh;
}

@media (max-width: 1180px) {
    .sales-map-hero,
    .sales-map-dashboard,
    .estimate-lab {
        grid-template-columns: 1fr;
    }

    .selected-market-panel {
        min-height: auto;
    }
}

@media (max-width: 760px) {
    .sales-map-shell {
        padding-top: 12px;
    }

    .sales-metrics,
    .detail-metrics {
        grid-template-columns: 1fr;
    }

    .map-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .metric-mode-group {
        grid-template-columns: 1fr;
    }

    .map-actions {
        width: 100%;
        grid-template-columns: 44px 1fr 44px;
    }

    .month-control {
        grid-template-columns: 38px 1fr 38px;
    }

    #selected-month-label {
        grid-column: 1 / -1;
    }

    .map-frame {
        min-height: 430px;
    }

    #sales-map {
        height: 430px;
    }

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

    .detail-status {
        width: fit-content;
        max-width: 100%;
    }

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

    .trend-chart {
        gap: 3px;
    }
}
