/* District choropleth map for by-district indicators.
   Renders inside the featured panel's .featured-chart slot in place of the
   Chart.js canvas. Pure SVG (no Leaflet). See static/js/dashboard/mapService.js
   and the renderMap/renderDistrictTableHtml functions in controller.js. */

.dashboard-shell .featured-map {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    min-height: 0;
}

.dashboard-shell .featured-chart.is-map-panel {
    height: 470px;
    min-height: 470px;
}

/* ---- Toolbar (metric chips + map/table toggle) -------------------------- */

.dashboard-shell .district-map-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    margin-bottom: 12px;
}

.dashboard-shell .map-toolbar-label {
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-right: 2px;
}

.dashboard-shell .map-metric-chips {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.dashboard-shell .map-chip {
    appearance: none;
    border: 1px solid #d4e0ec;
    background: #ffffff;
    color: #33506b;
    font: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    padding: 5px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.dashboard-shell .map-chip:hover {
    border-color: var(--dashboard-brand-blue, #0081cc);
    color: var(--dashboard-brand-navy, #0f4c81);
    transform: translateY(-1px);
}

.dashboard-shell .map-chip.is-active {
    background: linear-gradient(135deg, var(--dashboard-brand-navy, #0f4c81), #243f7d);
    border-color: var(--dashboard-brand-navy, #0f4c81);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(15, 76, 129, 0.28);
}

.dashboard-shell .map-view-toggle {
    display: inline-flex;
    border: 1px solid #d4e0ec;
    border-radius: 10px;
    overflow: hidden;
    background: #f3f7fb;
}

.dashboard-shell .map-view-btn {
    appearance: none;
    border: none;
    background: transparent;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    color: #50647b;
    padding: 6px 14px;
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease;
}

.dashboard-shell .map-view-btn svg {
    width: 15px;
    height: 15px;
}

.dashboard-shell .map-view-btn:hover {
    color: var(--dashboard-brand-navy, #0f4c81);
}

.dashboard-shell .map-view-btn.is-active {
    background: #ffffff;
    color: var(--dashboard-brand-navy, #0f4c81);
    box-shadow: inset 0 0 0 1px #d4e0ec;
}

/* ---- Map + detail layout ------------------------------------------------- */

.dashboard-shell .district-map-layout {
    display: flex;
    gap: 16px;
    width: 100%;
    height: 100%;
    min-height: 0;
}

.dashboard-shell .district-map-stage {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dashboard-shell .district-map-frame {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border: 1px solid #d7e6f2;
    border-radius: 16px;
    background:
        linear-gradient(180deg, rgba(178, 230, 250, 0.22) 0%, rgba(255, 255, 255, 0.96) 40%),
        #ffffff;
    padding: 14px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.9),
        0 10px 24px rgba(45, 81, 161, 0.07);
    overflow: hidden;
}

/* ---- Insight strip (highest / lowest / reference pills) ------------------ */

.dashboard-shell .map-insight-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    flex: 0 0 auto;
}

.dashboard-shell .map-insight-pill {
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border: 1px solid #d7e6f2;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.9);
    color: #33506b;
    font-size: 0.78rem;
    line-height: 1.15;
    box-shadow: 0 2px 6px rgba(45, 81, 161, 0.05);
}

.dashboard-shell .map-insight-icon {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 8px;
    flex: 0 0 auto;
}

.dashboard-shell .map-insight-icon svg {
    width: 13px;
    height: 13px;
    fill: currentColor;
    stroke: currentColor;
}

.dashboard-shell .map-insight-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.dashboard-shell .map-insight-text span {
    color: #64748b;
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dashboard-shell .map-insight-text strong {
    min-width: 0;
    overflow: hidden;
    color: #16334f;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dashboard-shell .map-insight-pill em {
    color: var(--dashboard-brand-navy, #0f4c81);
    font-size: 0.94rem;
    font-style: normal;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.dashboard-shell .map-insight-pill.is-high {
    border-color: rgba(45, 81, 161, 0.3);
    background: linear-gradient(135deg, rgba(178, 230, 250, 0.3), rgba(255, 255, 255, 0.92));
}

.dashboard-shell .map-insight-pill.is-high .map-insight-icon {
    background: var(--dashboard-brand-navy, #2d51a1);
    color: #ffffff;
}

.dashboard-shell .map-insight-pill.is-low {
    border-color: rgba(246, 141, 50, 0.3);
    background: linear-gradient(135deg, rgba(246, 141, 50, 0.1), rgba(255, 255, 255, 0.92));
}

.dashboard-shell .map-insight-pill.is-low .map-insight-icon {
    background: #f68d32;
    color: #ffffff;
}

.dashboard-shell .map-insight-pill.is-low em {
    color: #b95d18;
}

.dashboard-shell .map-insight-pill.is-reference {
    border-color: rgba(75, 168, 71, 0.26);
    background: linear-gradient(135deg, rgba(75, 168, 71, 0.09), rgba(255, 255, 255, 0.92));
}

.dashboard-shell .map-insight-pill.is-reference .map-insight-icon {
    background: #4ba847;
    color: #ffffff;
}

.dashboard-shell .map-insight-pill.is-reference .map-insight-text strong {
    white-space: normal;
}

.dashboard-shell .map-insight-pill.is-empty {
    display: inline-flex;
    align-items: center;
    color: #64748b;
    font-weight: 700;
}

/* ---- Map canvas ----------------------------------------------------------- */

.dashboard-shell .district-map-svg {
    display: block;
    flex: 1 1 auto;
    width: 100%;
    min-height: 300px;
    border: 1px solid rgba(45, 81, 161, 0.1);
    border-radius: 12px;
    background-color: #f7fbfe;
    background-image: radial-gradient(circle, rgba(45, 81, 161, 0.07) 1px, transparent 1.4px);
    background-size: 15px 15px;
    filter: drop-shadow(0 10px 18px rgba(45, 81, 161, 0.08));
}

@keyframes districtIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: none; }
}

@keyframes labelIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.dashboard-shell .district-path {
    stroke: #ffffff;
    stroke-width: 0.7;
    stroke-linejoin: round;
    cursor: pointer;
    outline: none;
    animation: districtIn 360ms ease backwards;
    transition: fill 350ms ease, fill-opacity 140ms ease, stroke-width 140ms ease, filter 160ms ease;
}

.dashboard-shell .district-path:hover,
.dashboard-shell .district-path.is-active,
.dashboard-shell .district-path:focus-visible {
    stroke: #0b2e4f;
    stroke-width: 1.5;
    fill-opacity: 0.9;
    filter: drop-shadow(0 3px 5px rgba(11, 46, 79, 0.3));
}

.dashboard-shell .district-path.is-selected {
    stroke: #0b2e4f;
    stroke-width: 1.9;
    fill-opacity: 1;
    filter: drop-shadow(0 0 6px rgba(11, 46, 79, 0.45));
}

.dashboard-shell .district-path.is-muted {
    fill-opacity: 0.45;
}

.dashboard-shell .district-path.is-dimmed {
    fill-opacity: 0.15;
}

.dashboard-shell .district-path.is-high-rank {
    stroke: #0b2e4f;
    stroke-width: 1.05;
}

.dashboard-shell .district-path.is-low-rank {
    stroke: #b95d18;
    stroke-width: 1;
    stroke-dasharray: 2.4 1.6;
}

/* Compass rose (decorative) */
.dashboard-shell .map-compass {
    pointer-events: none;
    opacity: 0.85;
}

.dashboard-shell .map-compass circle {
    fill: rgba(255, 255, 255, 0.92);
    stroke: rgba(45, 81, 161, 0.28);
    stroke-width: 0.8;
}

.dashboard-shell .map-compass path {
    fill: var(--dashboard-brand-navy, #2d51a1);
}

.dashboard-shell .map-compass text {
    fill: var(--dashboard-brand-navy, #2d51a1);
    font-family: "Public Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 7.5px;
    font-weight: 800;
}

/* ---- District labels ------------------------------------------------------- */

.dashboard-shell .district-labels,
.dashboard-shell .district-label {
    pointer-events: none;
}

.dashboard-shell .district-label {
    animation: labelIn 420ms ease backwards;
}

.dashboard-shell .district-label text {
    fill: #16334f;
    stroke: rgba(255, 255, 255, 0.96);
    stroke-linejoin: round;
    stroke-width: 3px;
    paint-order: stroke;
    font-family: "Public Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 8.3px;
    font-weight: 800;
    line-height: 1;
}

.dashboard-shell .district-label-name {
    fill: #16334f;
}

.dashboard-shell .district-label-value {
    fill: var(--dashboard-brand-navy, #0f4c81);
    font-size: 8px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

/* Labels sitting on the two darkest shades flip to light text with a dark
   halo so they stay readable without a glowing white outline. */
.dashboard-shell .district-label.on-dark text {
    fill: #ffffff;
    stroke: rgba(6, 31, 54, 0.55);
    stroke-width: 2.6px;
}

.dashboard-shell .district-label.on-dark .district-label-name {
    fill: #ffffff;
}

.dashboard-shell .district-label.on-dark .district-label-value {
    fill: #d9f0ff;
}

/* Medium districts: slightly smaller two-line labels. */
.dashboard-shell .district-label.is-tier-mid text {
    font-size: 7.7px;
}

.dashboard-shell .district-label.is-tier-mid .district-label-value {
    font-size: 7.5px;
}

/* Tiny districts (Kigali city): value only — the hover tooltip carries the
   name, so the map stays uncluttered. */
.dashboard-shell .district-label.is-tier-small .district-label-name {
    display: none;
}

.dashboard-shell .district-label.is-tier-small text {
    font-size: 7.4px;
    stroke-width: 2.6px;
}

.dashboard-shell .district-label.is-high-rank text {
    font-size: 8.8px;
}

.dashboard-shell .district-label.is-low-rank:not(.on-dark) text,
.dashboard-shell .district-label.is-low-rank:not(.on-dark) .district-label-value {
    fill: #8a4a12;
}

.dashboard-shell .district-label.has-no-data {
    opacity: 0.55;
}

.dashboard-shell .district-label.is-active text,
.dashboard-shell .district-label.is-selected text {
    stroke-width: 3.8px;
}

.dashboard-shell .district-label.is-muted {
    opacity: 0.42;
}

/* Podium badges: rank 1/2/3 get gold/silver/bronze, bottom 3 get an orange
   ▼ marker. Hidden unless the label carries a rank tone class. */
.dashboard-shell .rank-badge {
    visibility: hidden;
}

.dashboard-shell .district-label.is-high-rank .rank-badge,
.dashboard-shell .district-label.is-low-rank .rank-badge {
    visibility: visible;
}

.dashboard-shell .rank-badge circle {
    fill: #a7b4c2;
    stroke: #ffffff;
    stroke-width: 1;
}

.dashboard-shell .district-label[data-rank-number="1"] .rank-badge circle {
    fill: #e9b44c;
}

.dashboard-shell .district-label[data-rank-number="2"] .rank-badge circle {
    fill: #a7b4c2;
}

.dashboard-shell .district-label[data-rank-number="3"] .rank-badge circle {
    fill: #c98a4b;
}

.dashboard-shell .district-label.is-low-rank .rank-badge circle {
    fill: #f68d32;
}

.dashboard-shell .rank-badge text {
    fill: #ffffff;
    stroke: none;
    font-family: "Public Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 7px;
    font-weight: 800;
}

.dashboard-shell .district-label.is-low-rank .rank-badge text {
    font-size: 6px;
}

/* ---- Detail panel --------------------------------------------------------- */

.dashboard-shell .district-map-aside {
    flex: 0 0 252px;
    min-height: 0;
    overflow-y: auto;
}

.dashboard-shell .district-detail {
    height: 100%;
    border: 1px solid #d7e6f2;
    border-radius: 16px;
    background: #ffffff;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 14px 28px rgba(45, 81, 161, 0.08);
    animation: detail-fade 200ms ease;
}

@keyframes detail-fade {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

.dashboard-shell .detail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dashboard-shell .detail-kicker {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
}

.dashboard-shell .detail-close {
    appearance: none;
    border: none;
    background: #eef3f9;
    color: #50647b;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 0.7rem;
    line-height: 1;
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease;
}

.dashboard-shell .detail-close:hover {
    background: var(--dashboard-brand-navy, #0f4c81);
    color: #ffffff;
}

.dashboard-shell .detail-name {
    margin: 0;
    font-size: 1.08rem;
    font-weight: 700;
    color: #16334f;
}

.dashboard-shell .detail-value-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.dashboard-shell .detail-value {
    font-size: 2.1rem;
    font-weight: 800;
    line-height: 1.05;
    background: linear-gradient(135deg, var(--dashboard-brand-navy, #2d51a1), var(--dashboard-brand-blue, #33a7df));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-variant-numeric: tabular-nums;
}

.dashboard-shell .detail-unit {
    max-width: 120px;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.2;
    color: #50647b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dashboard-shell .detail-sub {
    font-size: 0.8rem;
    color: #64748b;
}

.dashboard-shell .detail-compare {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 999px;
    align-self: flex-start;
}

.dashboard-shell .detail-compare strong,
.dashboard-shell .detail-compare span {
    display: inline-block;
}

.dashboard-shell .detail-compare.is-above {
    background: rgba(13, 148, 91, 0.12);
    color: #0c7a4d;
}

.dashboard-shell .detail-compare.is-below {
    background: rgba(190, 49, 68, 0.1);
    color: #b3273e;
}

.dashboard-shell .detail-stats {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dashboard-shell .detail-stats li {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr) auto;
    gap: 8px;
    align-items: baseline;
    font-size: 0.82rem;
    border-bottom: 1px dashed #e2ebf4;
    padding-bottom: 6px;
}

.dashboard-shell .detail-stats li span {
    color: #64748b;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dashboard-shell .detail-stats li strong {
    color: #16334f;
    font-weight: 700;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dashboard-shell .detail-stats li em {
    font-style: normal;
    font-weight: 700;
    color: var(--dashboard-brand-navy, #0f4c81);
}

.dashboard-shell .detail-hint {
    margin: auto 0 0;
    font-size: 0.78rem;
    color: #7a8da3;
}

.dashboard-shell .detail-breakdown {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: 4px;
}

.dashboard-shell .detail-breakdown-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

.dashboard-shell .detail-bar-row {
    display: grid;
    grid-template-columns: 48px 1fr auto;
    gap: 8px;
    align-items: center;
    font-size: 0.8rem;
    color: #33506b;
}

.dashboard-shell .detail-bar-row em {
    font-style: normal;
    font-weight: 700;
    color: #16334f;
}

.dashboard-shell .detail-bar-row.is-active em,
.dashboard-shell .detail-bar-row.is-active span {
    color: var(--dashboard-brand-navy, #0f4c81);
}

.dashboard-shell .detail-bar {
    height: 8px;
    background: #e9eff6;
    border-radius: 999px;
    overflow: hidden;
}

.dashboard-shell .detail-bar i {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--dashboard-brand-blue, #0081cc), var(--dashboard-brand-navy, #0f4c81));
    transition: width 350ms ease;
}

/* ---- Legend (segmented quantile bar) --------------------------------------- */

.dashboard-shell .map-legend {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.78rem;
    color: #50647b;
    padding-top: 2px;
}

.dashboard-shell .map-legend-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 12px;
}

.dashboard-shell .map-legend-title {
    font-weight: 700;
    color: #1f3a56;
    white-space: nowrap;
}

.dashboard-shell .map-legend-extent {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.68rem;
    color: #64748b;
}

.dashboard-shell .map-legend-extent em {
    font-style: normal;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.62rem;
}

.dashboard-shell .map-legend-extent strong {
    color: #16334f;
    font-variant-numeric: tabular-nums;
}

.dashboard-shell .map-legend-extent-arrow {
    position: relative;
    flex: 0 0 30px;
    height: 3px;
    border-radius: 2px;
    background: linear-gradient(90deg, #b2e6fa, #2d51a1);
}

.dashboard-shell .map-legend-extent-arrow::after {
    content: "";
    position: absolute;
    right: -1px;
    top: 50%;
    transform: translateY(-50%);
    border-left: 5px solid #2d51a1;
    border-top: 3.4px solid transparent;
    border-bottom: 3.4px solid transparent;
}

.dashboard-shell .map-legend-bar {
    display: flex;
    gap: 3px;
    width: 100%;
}

.dashboard-shell .map-legend-item {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    cursor: pointer;
    padding: 2px 1px 3px;
    border-radius: 6px;
    transition: background 140ms ease, transform 140ms ease;
}

.dashboard-shell .map-legend-item:hover {
    background: rgba(178, 230, 250, 0.24);
    transform: translateY(-1px);
}

.dashboard-shell .map-legend-seg {
    display: block;
    height: 10px;
    border-radius: 2.5px;
    box-shadow: inset 0 0 0 1px rgba(15, 76, 129, 0.12);
    transition: transform 140ms ease, box-shadow 140ms ease;
}

.dashboard-shell .map-legend-item:first-child .map-legend-seg {
    border-radius: 6px 2.5px 2.5px 6px;
}

.dashboard-shell .map-legend-item:last-child .map-legend-seg {
    border-radius: 2.5px 6px 6px 2.5px;
}

.dashboard-shell .map-legend-item:hover .map-legend-seg {
    transform: scaleY(1.3);
    box-shadow: inset 0 0 0 1px rgba(15, 76, 129, 0.3);
}

.dashboard-shell .map-legend-range {
    overflow: hidden;
    color: #64748b;
    font-size: 0.64rem;
    font-variant-numeric: tabular-nums;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dashboard-shell .map-legend-item:hover .map-legend-range {
    color: var(--dashboard-brand-navy, #0f4c81);
    font-weight: 700;
}

.dashboard-shell .map-legend-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
}

.dashboard-shell .map-legend-reference {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(246, 141, 50, 0.12);
    color: #8a4a12;
    font-size: 0.74rem;
    font-weight: 700;
    white-space: nowrap;
}

.dashboard-shell .map-legend-hint {
    font-size: 0.7rem;
    color: #94a3b8;
}

.dashboard-shell .map-legend-empty {
    font-style: italic;
}

/* ---- Floating hover tooltip ------------------------------------------------ */

.dashboard-shell .map-tooltip {
    position: absolute;
    z-index: 6;
    min-width: 148px;
    max-width: 220px;
    padding: 10px 12px 9px;
    border: 1px solid rgba(45, 81, 161, 0.22);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 14px 32px rgba(11, 46, 79, 0.18), 0 2px 8px rgba(11, 46, 79, 0.1);
    color: #16334f;
    font-size: 0.78rem;
    line-height: 1.3;
    pointer-events: none;
}

.dashboard-shell .map-tooltip[hidden] {
    display: none;
}

.dashboard-shell .map-tooltip-head {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 2px;
}

.dashboard-shell .map-tooltip-dot {
    flex: 0 0 auto;
    width: 11px;
    height: 11px;
    border-radius: 3.5px;
    border: 1px solid rgba(15, 76, 129, 0.25);
    background: #d9e1eb;
}

.dashboard-shell .map-tooltip-name {
    min-width: 0;
    overflow: hidden;
    font-size: 0.86rem;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dashboard-shell .map-tooltip-value {
    color: var(--dashboard-brand-navy, #0f4c81);
    font-size: 1.28rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}

.dashboard-shell .map-tooltip-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 8px;
    margin-top: 1px;
    font-size: 0.7rem;
    color: #64748b;
}

.dashboard-shell .map-tooltip-rank {
    font-weight: 700;
}

.dashboard-shell .map-tooltip-delta {
    font-weight: 700;
}

.dashboard-shell .map-tooltip-delta.is-up {
    color: #0c7a4d;
}

.dashboard-shell .map-tooltip-delta.is-down {
    color: #b3273e;
}

/* ---- Loading state ---------------------------------------------------------- */

.dashboard-shell .map-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 100%;
    color: #50647b;
    font-size: 0.9rem;
    font-weight: 700;
}

.dashboard-shell .map-loading-spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(45, 81, 161, 0.18);
    border-top-color: var(--dashboard-brand-navy, #2d51a1);
    border-radius: 50%;
    animation: mapSpin 800ms linear infinite;
}

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

/* ---- Wide-format data table view ------------------------------------------- */

.dashboard-shell .district-table-view {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    height: 100%;
    min-height: 0;
    animation: detail-fade 200ms ease;
}

.dashboard-shell .district-table-caption {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 10px;
    font-size: 0.82rem;
    color: #16334f;
}

.dashboard-shell .district-table-caption span {
    font-size: 0.76rem;
    color: #7a8da3;
}

.dashboard-shell .district-table-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    border: 1px solid #e2ebf4;
    border-radius: 12px;
    background: #ffffff;
}

.dashboard-shell .district-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.dashboard-shell .district-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f3f7fb;
    color: #33506b;
    font-weight: 700;
    text-align: left;
    padding: 9px 14px;
    border-bottom: 1px solid #e2ebf4;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.dashboard-shell .district-table thead th:hover {
    color: var(--dashboard-brand-navy, #0f4c81);
}

.dashboard-shell .district-table thead th.is-sorted {
    color: var(--dashboard-brand-navy, #0f4c81);
}

.dashboard-shell .district-table th.is-numeric,
.dashboard-shell .district-table td.is-numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.dashboard-shell .district-table tbody td {
    padding: 7px 14px;
    border-bottom: 1px solid #eef3f9;
    color: #33506b;
}

.dashboard-shell .district-table tbody tr[data-map-district] {
    cursor: pointer;
    transition: background 120ms ease;
}

.dashboard-shell .district-table tbody tr[data-map-district]:hover {
    background: #f3f8fd;
}

.dashboard-shell .district-table tbody tr.is-selected {
    background: rgba(0, 129, 204, 0.1);
}

.dashboard-shell .district-table tbody tr.is-selected .district-cell {
    color: var(--dashboard-brand-navy, #0f4c81);
    font-weight: 700;
}

.dashboard-shell .district-table tbody tr.is-national {
    background: #f8fafc;
    font-weight: 700;
}

.dashboard-shell .district-table tbody tr.is-national td {
    color: #16334f;
    border-bottom: 2px solid #dbe6f1;
}

.dashboard-shell .district-table .district-cell {
    font-weight: 600;
    color: #16334f;
}

/* ---- Responsive -------------------------------------------------------------- */

@media (max-width: 860px) {
    .dashboard-shell .featured-chart.is-map-panel {
        height: auto !important;
        min-height: 760px;
    }

    .dashboard-shell .featured-chart.is-map-panel .featured-map {
        height: auto;
        min-height: 728px;
    }

    .dashboard-shell .district-map-layout {
        flex-direction: column;
        height: auto;
        min-height: 728px;
        overflow-y: auto;
    }

    .dashboard-shell .district-map-stage {
        min-height: 320px;
    }

    .dashboard-shell .district-map-frame {
        padding: 10px;
    }

    .dashboard-shell .district-map-svg {
        min-height: 260px;
    }

    .dashboard-shell .district-label text {
        font-size: 7.4px;
        stroke-width: 2.6px;
    }

    .dashboard-shell .district-label-value {
        font-size: 7.2px;
    }

    .dashboard-shell .district-map-aside {
        flex: 0 0 auto;
        overflow-y: visible;
    }

    .dashboard-shell .district-detail {
        height: auto;
        min-height: 230px;
    }

    .dashboard-shell .district-map-toolbar {
        justify-content: flex-start;
    }

    .dashboard-shell .map-legend-hint {
        display: none;
    }

    .dashboard-shell .map-legend-foot {
        justify-content: center;
    }
}

@media (max-width: 520px) {
    .dashboard-shell .map-insight-strip {
        grid-template-columns: 1fr;
    }

    .dashboard-shell .map-legend-range {
        font-size: 0.58rem;
    }

    .dashboard-shell .map-legend-extent {
        display: none;
    }

    .dashboard-shell .district-label-name {
        display: none;
    }

    .dashboard-shell .district-label text,
    .dashboard-shell .district-label.is-high-rank text {
        font-size: 7px;
    }

    .dashboard-shell .district-label-value {
        font-size: 7px;
    }

    .dashboard-shell .map-tooltip {
        min-width: 132px;
        max-width: 180px;
    }
}

@media (prefers-reduced-motion: reduce) {
    /* Both consumers of the detail-fade keyframes. */
    .dashboard-shell .district-detail,
    .dashboard-shell .district-table-view {
        animation: none !important;
    }

    .dashboard-shell .district-path,
    .dashboard-shell .district-label {
        animation: none !important;
        transition: none;
    }

    .dashboard-shell .map-loading-spinner {
        animation: none;
    }
}
