/* ==========================================================================
   BDS Tanzania - public member map (/dashboard)
   Styles for the Leaflet map (street + satellite, green location pins), the
   KPI strip, the ranked region/district list, the insight card (donut +
   coverage), the registration trend chart and the data table.

   All colours live here as custom properties so the map, the legend, the bars
   and the table can never drift apart.
   ========================================================================== */

:root {
    /* Choropleth intensity - a soft blue background scale. Deliberately light
       so the green member pins stay the strongest signal on the map. */
    --bdst-band-withheld: #dfe6ea;
    --bdst-band-zero: #f3f8fa;
    --bdst-band-lt-min: #d7ebf5;
    --bdst-band-low: #cfe7f2;
    --bdst-band-mid: #8ec6de;
    --bdst-band-high: #4a9fc4;

    /* Member pins (green = membership) */
    --bdst-bubble: #16a34a;
    --bdst-bubble-soft: rgba(22, 163, 74, 0.18);
    --bdst-bubble-ink: #0b5c2e;

    /* Neutrals + brand */
    --bdst-ink: #0c1e21;
    --bdst-muted: #5a6772;
    --bdst-line: #e4ecec;
    --bdst-soft: #f6f9f9;
    --bdst-brand: #1997c6;
    /* Focus indicator colour - dark enough for >= 3:1 contrast on white
       (WCAG 1.4.11) even over the light blue tints and brand colour. */
    --bdst-focus: #0d6f8c;

    --bdst-radius: 18px;
    --bdst-shadow: 0 10px 30px rgba(12, 30, 33, 0.06);

    /* Crisp card shadow, for the white cards sitting on the light band below. */
    --bdst-card-shadow: 0 1px 2px rgba(12, 30, 33, 0.05), 0 12px 28px rgba(12, 30, 33, 0.07);

    /* The light page band the white cards sit on. */
    --bdst-surface: #f5f8fa;

    /* Brand colour used as a solid fill behind white text. The light brand
       blue only reaches 3.4:1 against white, so filled controls use this
       deeper shade (about 5.9:1) instead. */
    --bdst-brand-ink: #0c6d89;
}

/* --------------------------------------------------------------------------
   Accessibility helpers
   -------------------------------------------------------------------------- */

/* Fallback for Bootstrap's .visually-hidden, so the dashboard markup keeps
   its hidden labels even if Bootstrap loads late or partially. */
.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;
}

/* Skip link: invisible until keyboard-focussed, then pinned top-left so it is
   the very first thing a keyboard user can reach (WCAG 2.4.1). */
.bdst-skiplink {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 2000;
    padding: 10px 18px;
    border-radius: 8px;
    background: #ffffff;
    color: var(--bdst-focus);
    font: 600 14px/1 "Plus Jakarta Sans", system-ui, sans-serif;
    text-decoration: none;
    box-shadow: 0 6px 18px rgba(12, 30, 33, 0.2);
    transition: top 0.15s ease;
}

.bdst-skiplink:focus,
.bdst-skiplink:focus-visible {
    top: 12px;
    outline: 2px solid var(--bdst-focus);
    outline-offset: 2px;
}

/* Map pins and region polygons are interactive (they drill into districts);
   give them a visible focus ring in the focus colour. */
.bdst-pin:focus-visible,
.bdst-pin:focus {
    outline: 3px solid var(--bdst-focus);
    outline-offset: 3px;
    border-radius: 999px;
}

path.leaflet-interactive:focus-visible,
path.leaflet-interactive:focus {
    stroke: var(--bdst-focus);
    stroke-width: 3;
}

.leaflet-control-zoom a:focus-visible {
    outline: 2px solid var(--bdst-focus);
    outline-offset: -2px;
}

/* --------------------------------------------------------------------------
   Dashboard surface + section header
   -------------------------------------------------------------------------- */

/* The National Overview band: a light slate that makes the white cards read as
   cards and defines the section against the white template around it. */
.bdst-surface {
    background: var(--bdst-surface);
}

.bdst-dash-intro {
    padding: 58px 0 30px;
}

/* Title block centred on the page; the privacy badge sits at the top-right on
   wide screens and falls below the text, centred, on narrower ones. */
.bdst-page-head {
    position: relative;
    text-align: center;
}

.bdst-page-headtext {
    max-width: 980px;
    margin: 0 auto;
}

/* .sec-heading is templated to centre itself at a fixed width; inside the
   header it is simply the centred text block. */
.bdst-page-head .sec-heading {
    width: auto;
    margin: 0;
    text-align: center;
}

.bdst-page-sub {
    max-width: 700px;
    margin: 14px auto 0;
}

.bdst-badge {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin-top: 22px;
    padding: 10px 18px;
    border: 1px solid var(--bdst-line);
    border-radius: 999px;
    background: #ffffff;
    color: var(--bdst-muted);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    box-shadow: var(--bdst-card-shadow);
    transition: border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

/* Wide screens have room for the badge beside the centred heading. */
@media (min-width: 992px) {
    .bdst-badge {
        position: absolute;
        top: 0;
        right: 0;
        margin-top: 0;
    }
}

.bdst-badge i {
    font-size: 15px;
    color: var(--bdst-brand);
}

.bdst-badge-text {
    white-space: nowrap;
}

.bdst-badge em {
    font-style: normal;
    font-weight: 700;
    color: var(--bdst-ink);
}

.bdst-badge:hover {
    border-color: rgba(25, 151, 198, 0.4);
    box-shadow: 0 6px 18px rgba(12, 30, 33, 0.1);
}

.bdst-badge:focus-visible {
    outline: 2px solid var(--bdst-focus);
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   KPI strip
   -------------------------------------------------------------------------- */

.bdst-dash-kpis {
    padding: 0 0 28px;
}

.bdst-kpi {
    display: flex;
    align-items: center;
    gap: 18px;
    height: 100%;
    padding: 24px 26px;
    background: #fff;
    border: 1px solid var(--bdst-line);
    border-radius: var(--bdst-radius);
    box-shadow: var(--bdst-shadow);
}

.bdst-kpi-icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: rgba(25, 151, 198, 0.1);
    color: var(--bdst-brand);
    font-size: 21px;
}

.bdst-kpi--members .bdst-kpi-icon {
    background: var(--bdst-bubble-soft);
    color: var(--bdst-bubble);
}

.bdst-kpi-body {
    min-width: 0;
}

.bdst-kpi-value {
    display: block;
    font-size: 34px;
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.01em;
    color: var(--bdst-ink);
    font-variant-numeric: tabular-nums;
}

.bdst-kpi-value.is-text {
    font-size: 22px;
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bdst-kpi-label {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--bdst-muted);
}

.bdst-kpi-sub {
    display: block;
    margin-top: 2px;
    font-size: 13px;
    color: var(--bdst-muted);
}

/* --------------------------------------------------------------------------
   Notices
   -------------------------------------------------------------------------- */

.bdst-notice {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 18px 22px;
    margin-bottom: 24px;
    border-radius: 14px;
    background: var(--bdst-soft);
    border: 1px solid var(--bdst-line);
    color: var(--bdst-muted);
    font-size: 15px;
    line-height: 1.6;
}

.bdst-notice i {
    margin-top: 3px;
    font-size: 19px;
    color: var(--bdst-brand);
}

.bdst-notice strong {
    color: var(--bdst-ink);
}

.bdst-notice a {
    color: var(--bdst-brand);
    font-weight: 600;
}

.bdst-notice--gate {
    background: #fff8e8;
    border-color: #f0dcae;
}

.bdst-notice--gate i {
    color: #b6862b;
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.bdst-dash-main {
    padding: 0 0 28px;
}

.bdst-map-card,
.bdst-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 22px;
    background: #fff;
    border: 1px solid var(--bdst-line);
    border-radius: var(--bdst-radius);
    box-shadow: var(--bdst-shadow);
}

/* Cards sit on the light surface, so they take the crisper shadow there. */
.bdst-surface .bdst-kpi,
.bdst-surface .bdst-map-card,
.bdst-surface .bdst-panel,
.bdst-surface .bdst-insight-card,
.bdst-surface .bdst-trend-card {
    box-shadow: var(--bdst-card-shadow);
}

.bdst-card-title {
    margin: 0 0 4px;
    font-size: 20px;
    font-weight: 700;
    color: var(--bdst-ink);
}

.bdst-card-sub {
    margin: 0 0 16px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--bdst-muted);
}

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

#bdst-map {
    height: 480px;
    border-radius: 12px;
    background: #eaf1f4;
    z-index: 1;
}

/* Collapse the map box until Leaflet has actually built it, so a browser with
   JavaScript off does not show a large empty panel (the <noscript> note and
   the ranked list carry the same figures). The class is added immediately
   before L.map(), so Leaflet still measures a visible, correctly sized box. */
#bdst-map:not(.is-ready) {
    display: none;
}

/* The frame positions the floating pills and legend over the map. */
.bdst-map-frame {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
}

/* Street / Satellite pills, floating over the top-right corner. */
.bdst-map-pills {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 5;
    display: inline-flex;
    gap: 2px;
    padding: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.65);
    box-shadow: 0 6px 18px rgba(12, 30, 33, 0.18);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.bdst-map-pill {
    padding: 7px 15px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--bdst-ink);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease;
}

.bdst-map-pill:hover {
    background: rgba(12, 30, 33, 0.06);
}

.bdst-map-pill.is-active {
    background: var(--bdst-brand-ink);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(12, 30, 33, 0.22);
}

.bdst-map-pill.is-active:hover {
    background: var(--bdst-brand-ink);
}

.bdst-map-pill:focus-visible {
    outline: 2px solid var(--bdst-focus);
    outline-offset: 1px;
}

/* Legend, floating over the bottom-left corner. It is lifted clear of
   Leaflet's attribution strip, which stays on the bottom-right. */
.bdst-map-legend {
    position: absolute;
    left: 12px;
    bottom: 32px;
    z-index: 5;
    max-width: calc(100% - 24px);
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 10px 30px rgba(12, 30, 33, 0.18);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.bdst-map-legend[hidden] {
    display: none;
}

.bdst-map-legend-title {
    display: block;
    margin-bottom: 8px;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--bdst-muted);
}

/* Leaflet uses its own font stack; align it with the site. */
.leaflet-container {
    font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

.leaflet-container a {
    color: var(--bdst-brand);
}

/* Location pins: tiny circle markers (Leaflet circleMarker). Clean, small,
   and crisp on both Street and Satellite base layers. */
.bdst-pin {
    filter: drop-shadow(0 2px 3px rgba(12, 30, 33, 0.25));
    cursor: pointer;
    transition: filter 0.18s ease;
}

.bdst-pin:hover,
.bdst-pin.is-hover {
    filter: drop-shadow(0 4px 6px rgba(12, 30, 33, 0.35));
    /* NO transform scale — prevents vibration/shift on hover */
}

.bdst-pin.is-active {
    filter: drop-shadow(0 4px 8px rgba(12, 30, 33, 0.4));
}

/* Leaflet circleMarker renders as SVG <path> (for the circle),
   so we target the path element for active state. */
.bdst-pin.is-active path {
    stroke-width: 3 !important;
}

/* Pin tooltip styling - dark background for contrast on both base layers */
.bdst-pin-tooltip {
    background: rgba(12, 30, 33, 0.92) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 8px !important;
    color: #ffffff !important;
    box-shadow: 0 6px 20px rgba(12, 30, 33, 0.35) !important;
    padding: 8px 12px !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
}

.bdst-pin-tooltip:before {
    border-top-color: rgba(12, 30, 33, 0.92) !important;
}

.bdst-pin-tooltip strong {
    color: #ffffff !important;
}

.bdst-pin-tooltip span[style*="color:#666"],
.bdst-pin-tooltip span[style*="color: #666"] {
    color: rgba(255, 255, 255, 0.7) !important;
}

/* Attribution stays readable on both base layers. */
.leaflet-bottom.leaflet-right {
    font-size: 11px;
}

.bdst-map-status {
    min-height: 22px;
    margin-top: 12px;
    font-size: 14px;
    color: var(--bdst-muted);
}

.bdst-map-fallback {
    padding: 40px 20px;
    border: 1px dashed rgba(25, 151, 198, 0.35);
    border-radius: 12px;
    text-align: center;
    color: var(--bdst-muted);
}

/* --------------------------------------------------------------------------
   Legend + bubble key
   -------------------------------------------------------------------------- */

.bdst-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 7px 16px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.bdst-legend li {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12.5px;
    color: var(--bdst-muted);
    white-space: nowrap;
}

.bdst-legend .bdst-swatch {
    width: 18px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(12, 30, 33, 0.12);
}

.bdst-swatch--withheld { background: var(--bdst-band-withheld); }
.bdst-swatch--zero { background: var(--bdst-band-zero); }
.bdst-swatch--lt_min { background: var(--bdst-band-lt-min); }
.bdst-swatch--low { background: var(--bdst-band-low); }
.bdst-swatch--mid { background: var(--bdst-band-mid); }
.bdst-swatch--high { background: var(--bdst-band-high); }

/* Green pin key: three sample sizes read straight off the live scale. */
.bdst-pin-key {
    display: flex;
    align-items: flex-end;
    gap: 20px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--bdst-line);
}

.bdst-pin-key[hidden] {
    display: none;
}

.bdst-key-title {
    margin-right: auto;
    align-self: center;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--bdst-muted);
}

.bdst-key-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 7px;
    height: 74px;
    min-width: 40px;
}

.bdst-key-pin {
    display: flex;
    align-items: flex-end;
    line-height: 0;
    filter: drop-shadow(0 2px 3px rgba(12, 30, 33, 0.25));
}

.bdst-key-pin svg {
    display: block;
}

.bdst-key-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--bdst-muted);
    font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Panel (ranked region list + district drill-down)
   -------------------------------------------------------------------------- */

.bdst-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.bdst-select,
.bdst-input {
    min-width: 0;
    padding: 9px 12px;
    border: 1px solid var(--bdst-line);
    border-radius: 10px;
    background: #fff;
    color: var(--bdst-ink);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
}

.bdst-select {
    flex: 1 1 170px;
    max-width: 100%;
}

.bdst-input {
    flex: 1 1 150px;
}

.bdst-select:focus,
.bdst-input:focus {
    border-color: var(--bdst-brand);
    outline: 2px solid var(--bdst-focus);
    outline-offset: 1px;
}

.bdst-view {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.bdst-view[hidden] {
    display: none;
}

.bdst-rows-head {
    display: grid;
    grid-template-columns: 26px 1fr auto;
    gap: 10px;
    padding: 0 8px 8px;
    border-bottom: 1px solid var(--bdst-line);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--bdst-muted);
}

.bdst-rows-head span:last-child {
    text-align: right;
}

.bdst-rows-scroll {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 452px;
    overflow-y: auto;
}

.bdst-rows {
    padding: 0;
    margin: 0;
    list-style: none;
}

/* District rows are not ranked, so the rank column is dropped. */
.bdst-rows--plain .bdst-row-inner {
    grid-template-columns: 1fr auto;
}

#bdst-district-view .bdst-rows {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 452px;
    overflow-y: auto;
}

.bdst-row {
    border-bottom: 1px solid var(--bdst-line);
}

.bdst-row:last-child {
    border-bottom: 0;
}

.bdst-row-btn,
.bdst-row-inner {
    display: grid;
    grid-template-columns: 26px 1fr auto;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 8px;
    border: 0;
    border-radius: 9px;
    background: none;
    text-align: left;
    font: inherit;
    color: inherit;
}

.bdst-row-btn {
    cursor: pointer;
}

.bdst-row-btn:hover {
    background: var(--bdst-soft);
}

.bdst-row-btn:focus-visible {
    outline: 2px solid var(--bdst-focus);
    outline-offset: -2px;
}

.bdst-row.is-active .bdst-row-btn {
    background: rgba(22, 163, 74, 0.09);
}

.bdst-row-rank {
    text-align: right;
    font-size: 12px;
    font-weight: 700;
    color: var(--bdst-muted);
    font-variant-numeric: tabular-nums;
}

.bdst-row-body {
    min-width: 0;
}

.bdst-row-name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--bdst-ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bdst-row-track {
    display: block;
    height: 7px;
    margin-top: 6px;
    border-radius: 999px;
    background: #edf2f4;
    overflow: hidden;
}

.bdst-row-fill {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #4ec27f, var(--bdst-bubble));
}

.bdst-row-count {
    min-width: 26px;
    text-align: right;
    font-size: 15px;
    font-weight: 800;
    color: var(--bdst-ink);
    font-variant-numeric: tabular-nums;
}

.bdst-row--zero .bdst-row-name {
    font-weight: 500;
    color: var(--bdst-muted);
}

.bdst-row--zero .bdst-row-count {
    font-weight: 600;
    color: var(--bdst-muted);
}

.bdst-row--zero .bdst-row-fill {
    background: #cdd8dc;
}

.bdst-zero-toggle {
    width: 100%;
    margin-top: 10px;
    padding: 9px 12px;
    border: 1px dashed var(--bdst-line);
    border-radius: 10px;
    background: #fbfdfd;
    color: var(--bdst-muted);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.bdst-zero-toggle:hover,
.bdst-zero-toggle:focus {
    color: var(--bdst-brand);
    border-color: rgba(25, 151, 198, 0.45);
    outline: none;
}

.bdst-zero-toggle:focus-visible {
    outline: 2px solid var(--bdst-focus);
    outline-offset: 1px;
}

.bdst-back {
    align-self: flex-start;
    margin-top: 14px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--bdst-brand);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.bdst-back:hover,
.bdst-back:focus {
    text-decoration: underline;
}

.bdst-back:focus-visible {
    outline: 2px solid var(--bdst-focus);
    outline-offset: 2px;
    border-radius: 4px;
}

.bdst-empty {
    padding: 16px 8px;
    font-size: 14px;
    color: var(--bdst-muted);
}

/* --------------------------------------------------------------------------
   Data table
   -------------------------------------------------------------------------- */

.bdst-dash-table {
    padding: 0 0 84px;
}

.bdst-table-disclosure > summary {
    padding: 12px 0;
    color: var(--bdst-brand);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.bdst-table-disclosure > summary:hover {
    text-decoration: underline;
}

.bdst-table-disclosure[open] > summary {
    margin-bottom: 12px;
}

.bdst-table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--bdst-line);
    border-radius: 14px;
    overflow: hidden;
}

.bdst-table th,
.bdst-table td {
    padding: 13px 18px;
    text-align: left;
    font-size: 15px;
    border-bottom: 1px solid var(--bdst-line);
}

.bdst-table thead th {
    background: var(--bdst-soft);
    font-weight: 700;
    color: var(--bdst-ink);
    white-space: nowrap;
}

.bdst-table tbody tr:last-child th,
.bdst-table tbody tr:last-child td {
    border-bottom: 0;
}

.bdst-table tbody th {
    font-weight: 600;
    color: var(--bdst-ink);
}

.bdst-table td.bdst-table-num {
    width: 220px;
    font-variant-numeric: tabular-nums;
}

.bdst-table .bdst-cell-muted {
    color: var(--bdst-muted);
}

.bdst-table .bdst-row-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 10px;
    border-radius: 3px;
    border: 1px solid rgba(12, 30, 33, 0.12);
    vertical-align: -2px;
}

/* --------------------------------------------------------------------------
   Registration trend card
   -------------------------------------------------------------------------- */

.bdst-dash-trends {
    padding: 0 0 28px;
}

.bdst-trend-card {
    padding: 26px;
    background: #fff;
    border: 1px solid var(--bdst-line);
    border-radius: var(--bdst-radius);
    box-shadow: var(--bdst-shadow);
}

.bdst-trend-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
}

.bdst-trend-headtext {
    min-width: 0;
}

.bdst-trend-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

/* Pill segmented control (Monthly / Yearly). */
.bdst-segmented {
    display: inline-flex;
    padding: 4px;
    border: 1px solid var(--bdst-line);
    border-radius: 999px;
    background: var(--bdst-soft);
}

.bdst-seg {
    padding: 7px 16px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--bdst-muted);
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease;
}

.bdst-seg:hover {
    color: var(--bdst-ink);
}

.bdst-seg.is-active {
    background: #fff;
    color: var(--bdst-ink);
    box-shadow: 0 2px 8px rgba(12, 30, 33, 0.12);
}

.bdst-seg:focus-visible {
    outline: 2px solid var(--bdst-focus);
    outline-offset: 1px;
}

/* Icon button (refresh). */
.bdst-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--bdst-line);
    border-radius: 10px;
    background: #fff;
    color: var(--bdst-muted);
    font-size: 14px;
    cursor: pointer;
    transition: color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.bdst-icon-btn:hover {
    color: var(--bdst-bubble);
    border-color: rgba(22, 163, 74, 0.45);
    box-shadow: 0 4px 12px rgba(12, 30, 33, 0.08);
}

.bdst-icon-btn:focus-visible {
    outline: 2px solid var(--bdst-focus);
    outline-offset: 1px;
}

.bdst-icon-btn .fa-rotate.is-spinning {
    animation: bdst-spin 0.8s linear infinite;
}

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

/* The chart shelf: mostly empty when the figures are withheld, filled with
   CSS-drawn bars once data is published. */
.bdst-chart {
    margin-top: 18px;
    min-height: 260px;
}

.bdst-chart-empty {
    margin: 0;
    padding: 48px 20px;
    border: 1px dashed var(--bdst-line);
    border-radius: 14px;
    text-align: center;
    color: var(--bdst-muted);
    font-size: 14px;
}

.bdst-bars {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 3px;
    height: 250px;
    padding: 18px 4px 0;
}

.bdst-bar-col {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.bdst-bar {
    display: block;
    width: 100%;
    max-width: 34px;
    min-height: 2px;
    border-radius: 6px 6px 3px 3px;
    background: linear-gradient(180deg, #41c07a, var(--bdst-bubble));
}

.bdst-bar-col--zero .bdst-bar {
    background: #e3ebee;
}

.bdst-bar-col:hover .bdst-bar {
    background: linear-gradient(180deg, #2eae6a, #0e8c43);
}

.bdst-bar-val {
    font-size: 11px;
    font-weight: 700;
    color: var(--bdst-ink);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.bdst-bar-tick {
    font-size: 10px;
    font-weight: 600;
    color: var(--bdst-muted);
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.bdst-bars--dense .bdst-bar-val {
    display: none;
}

.bdst-trend-status {
    margin: 14px 0 0;
    font-size: 13px;
    color: var(--bdst-muted);
}

/* --------------------------------------------------------------------------
   Data table header + export
   -------------------------------------------------------------------------- */

.bdst-table-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.bdst-btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 10px 18px;
    border: 1px solid var(--bdst-line);
    border-radius: 10px;
    background: #fff;
    color: var(--bdst-ink);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.bdst-btn-ghost i {
    color: #2e9e5b;
    font-size: 16px;
}

.bdst-btn-ghost:hover {
    color: var(--bdst-bubble-ink);
    border-color: rgba(22, 163, 74, 0.45);
    box-shadow: 0 4px 14px rgba(12, 30, 33, 0.08);
}

.bdst-btn-ghost:focus-visible {
    outline: 2px solid var(--bdst-focus);
    outline-offset: 1px;
}

/* --------------------------------------------------------------------------
   Quick insights: member-share bar + geographic coverage
   -------------------------------------------------------------------------- */

.bdst-dash-insights {
    padding: 0 0 28px;
}

.bdst-insight-card {
    padding: 26px;
    background: #fff;
    border: 1px solid var(--bdst-line);
    border-radius: var(--bdst-radius);
    box-shadow: var(--bdst-shadow);
}

.bdst-insight-grid {
    display: grid;
    grid-template-columns: 1.25fr 1fr;
    gap: 40px;
    align-items: start;
}

@media (max-width: 991.98px) {
    .bdst-insight-grid {
        grid-template-columns: 1fr;
        gap: 34px;
    }
}

/* One proportional strip: each region is a block whose width is its share of
   the membership, so the split reads at a glance. */
.bdst-share-bar {
    display: flex;
    width: 100%;
    height: 24px;
    border-radius: 999px;
    overflow: hidden;
    background: #edf2f4;
    box-shadow: inset 0 0 0 1px rgba(12, 30, 33, 0.06);
}

.bdst-share-bar:empty {
    display: none;
}

.bdst-share-seg {
    display: block;
    flex-basis: 0%;
    min-width: 4px;
    height: 100%;
    border-right: 2px solid #fff;
    transition: flex-grow 0.5s ease;
}

.bdst-share-seg:last-child {
    border-right: 0;
}

.bdst-share-legend {
    padding: 0;
    margin: 18px 0 0;
    list-style: none;
}

.bdst-share-legend li {
    display: grid;
    grid-template-columns: 14px 1fr auto auto;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid var(--bdst-line);
    font-size: 14px;
}

.bdst-share-legend li:last-child {
    border-bottom: 0;
}

.bdst-share-swatch {
    width: 14px;
    height: 14px;
    border-radius: 4px;
}

.bdst-share-name {
    font-weight: 600;
    color: var(--bdst-ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bdst-share-stat {
    color: var(--bdst-muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.bdst-share-pct {
    min-width: 44px;
    text-align: right;
    font-weight: 800;
    color: var(--bdst-ink);
    font-variant-numeric: tabular-nums;
}

.bdst-share-note {
    margin: 14px 0 0;
    font-size: 13px;
    color: var(--bdst-muted);
}

.bdst-coverage {
    display: flex;
    flex-direction: column;
    gap: 22px;
    margin-top: 6px;
}

.bdst-coverage-row {
    display: grid;
    grid-template-columns: 84px 1fr auto;
    align-items: center;
    gap: 14px;
}

.bdst-coverage-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--bdst-ink);
}

.bdst-coverage-track {
    display: block;
    height: 12px;
    border-radius: 999px;
    background: #edf2f4;
    overflow: hidden;
}

.bdst-coverage-fill {
    display: block;
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, #4ec27f, var(--bdst-bubble));
    transition: width 0.5s ease;
}

.bdst-coverage-value {
    font-size: 14px;
    font-weight: 800;
    color: var(--bdst-ink);
    font-variant-numeric: tabular-nums;
}

/* KPI values flash softly when auto-refresh changes them. */
.bdst-kpi-value.is-updated {
    animation: bdst-flash 0.9s ease;
}

@keyframes bdst-flash {
    0% {
        color: var(--bdst-bubble);
        opacity: 0.4;
    }
    100% {
        color: var(--bdst-ink);
        opacity: 1;
    }
}

/* --------------------------------------------------------------------------
   Reduced motion (WCAG 2.3.3): keep the data, drop the motion.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .bdst-pin,
    .bdst-pin.is-active,
    .bdst-seg,
    .bdst-icon-btn,
    .bdst-btn-ghost,
    .bdst-badge,
    .bdst-map-pill,
    .bdst-share-seg,
    .bdst-coverage-fill,
    .bdst-bar,
    .bdst-row-fill,
    .bdst-kpi-value.is-updated,
    .bdst-icon-btn .fa-rotate.is-spinning,
    .bdst-skiplink {
        transition: none !important;
        animation: none !important;
    }

    .bdst-pin:hover,
    .bdst-pin.is-hover,
    .bdst-pin.is-active {
        transform: none;
    }

    /* The template hides .wow elements until they animate; without motion
       they must simply be visible. */
    .wow {
        visibility: visible !important;
        animation: none !important;
    }
}

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

@media (max-width: 1199.98px) {
    .bdst-map-card,
    .bdst-panel {
        height: auto;
    }

    .bdst-rows-scroll {
        max-height: 420px;
    }
}

@media (max-width: 767.98px) {
    #bdst-map {
        height: 340px;
    }

    .bdst-kpi-value {
        font-size: 28px;
    }

    .bdst-rows-head {
        display: none;
    }

    .bdst-rows-scroll {
        max-height: 360px;
    }

    .bdst-table td.bdst-table-num {
        width: auto;
    }

    .bdst-trend-head {
        flex-direction: column;
    }

    .bdst-trend-tools {
        width: 100%;
        justify-content: space-between;
    }

    .bdst-bars {
        height: 210px;
    }

    .bdst-bar-val {
        font-size: 10px;
    }

    .bdst-map-pill {
        padding: 7px 13px;
    }

    /* On narrower screens the floating legend would cover a quarter of the
       map, so it moves under the map and flows normally instead. */
    .bdst-map-frame {
        overflow: visible;
    }

    .bdst-map-legend {
        position: static;
        max-width: none;
        margin-top: 10px;
        border-radius: 12px;
    }

    .bdst-table-head {
        flex-direction: column;
    }
}

@media (max-width: 575.98px) {
    .bdst-dash-intro {
        padding: 42px 0 26px;
    }
}
