/* =========================================================================
   ABP MALAWI MAP — STYLESHEET v4.5
   Improved chart container sizing and visibility
   ========================================================================= */

/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
    --mmp-teal:        #26a69a;
    --mmp-teal-dark:   #00897b;
    --mmp-accent:      #5c6bc0;
    --mmp-text:        #1a1a1a;
    --mmp-mid:         #4a5568;
    --mmp-light:       #718096;
    --mmp-border:      #e0e0e0;
    --mmp-bg:          #f7f8fa;
    --mmp-white:       #ffffff;
    --mmp-card-shadow: none;
    --mmp-no-data:     #f0f2f5;
    --mmp-has-data:    #26a69a;
    --mmp-active:      #e53935;
    --mmp-dimmed-op:   .18;
}

/* ── Section wrapper ───────────────────────────────────────────────────── */
.abp-map-section-wrapper {
    width: 100%;
    margin: 0;
    font-family: 'Inter', system-ui, sans-serif;
}

/* ── Dashboard shell ────────────────────────────────────────────────────── */
.abp-mmp-dashboard {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
    position: relative;
}

/* ── Loading overlay ────────────────────────────────────────────────────── */
.abp-map-overlay {
    display: none;
}

.abp-mmp-dashboard.is-loading .abp-map-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    position: absolute;
    inset: 0;
    z-index: 50;
    background: rgba(247, 248, 250, 0.92);
    min-height: 320px;
}

.abp-mmp-dashboard.is-loading .abp-map-pane,
.abp-mmp-dashboard.is-loading .abp-data-pane {
    visibility: hidden;
}

.abp-map-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid rgba(38, 166, 154, 0.18);
    border-top-color: var(--mmp-teal);
    border-radius: 50%;
    animation: abp-spin 0.75s linear infinite;
    flex-shrink: 0;
}

@keyframes abp-spin {
    to { transform: rotate(360deg); }
}

.abp-map-overlay-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--mmp-mid);
    letter-spacing: 0.03em;
}

.abp-mmp-dashboard:not(.is-loading) .abp-map-pane,
.abp-mmp-dashboard:not(.is-loading) .abp-data-pane {
    animation: abp-fade-in 0.35s ease both;
}

@keyframes abp-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (min-width: 900px) {
    .abp-mmp-dashboard {
        flex-direction: row;
        align-items: stretch;
        gap: 0;
        max-height: calc(100vh - 100px);
    }
}

/* ============================================================
   LEFT PANE — SVG map card
   ============================================================ */
.abp-map-pane {
    flex: 0 0 48%;
    min-width: 320px;
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: visible;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 520px;
}

@media (min-width: 900px) {
    .abp-map-pane {
        align-self: stretch;
        min-height: 560px;
        max-height: calc(100vh - 80px);
    }
}

@media (max-width: 899px) {
    .abp-map-pane {
        width: 100%;
        min-width: 0;
        min-height: 0;        /* height comes from the map box + location picker */
        max-height: none;
    }
}

/* SVG container */
.abp-map-svg-wrap {
    width: 100%;
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    min-height: 0;
    overflow: hidden;
    border-radius: 0;
}

/* The SVG fills the wrapper exactly; its tight viewBox + preserveAspectRatio
   "meet" scale the whole country to fit, centred — nothing is cropped at the
   northern/southern tips on any screen. (Previously width:170% + margin-left:-15%
   over-zoomed a padded 1000×1000 canvas and cut off the ends on phones.) */
.abp-map-svg-wrap {
    min-height: 520px;
}
.abp-map-svg-wrap svg {
    position: absolute;
    inset: 6px 0;           /* small gap so border strokes at the tips aren't clipped */
    width: 100%;
    height: calc(100% - 12px);
    display: block;
    overflow: visible;
}

@media (max-width: 899px) {
    /* Malawi is ~1.76× taller than wide: size the box from the screen width so
       the map is as large as possible on a phone, without cropping. */
    .abp-map-svg-wrap {
        flex: 0 0 auto;
        height: clamp(420px, 150vw, 640px);
        min-height: 0;
    }
}

/* SVG path defaults */
.abp-map-svg-wrap path {
    fill: var(--mmp-no-data);
    stroke: #b0b8c4;
    stroke-width: 0.8px;
    transition: fill .22s, opacity .22s, filter .18s;
    cursor: default;
}

.abp-map-svg-wrap path.has-data:hover {
    filter: brightness(.88);
}

.abp-map-svg-wrap path.has-data {
    fill: var(--mmp-has-data);
    stroke: rgba(255,255,255,.7);
    stroke-width: 1.4px;
}

.abp-map-svg-wrap path.active {
    fill: var(--mmp-active) !important;
    stroke: #fff !important;
    stroke-width: 2px !important;
    filter: drop-shadow(0 0 7px rgba(229,57,53,.45));
    opacity: 1 !important;
}

.abp-map-svg-wrap path.region-northern  { fill: #ef6c00; }
.abp-map-svg-wrap path.region-central   { fill: #1565c0; }
.abp-map-svg-wrap path.region-southern  { fill: #6a1b9a; }
.abp-map-svg-wrap path.region-dimmed    { opacity: var(--mmp-dimmed-op); filter: grayscale(35%); }

.abp-map-loading {
    color: var(--mmp-light);
    font-size: 1rem;
    text-align: center;
    padding: 40px 20px;
}

.abp-map-error {
    color: #c62828;
    font-size: .9rem;
    padding: 20px;
    text-align: center;
}

/* ── Location selector dropdown pill ───────────────────────────── */
.abp-map-loc-trigger {
    position: absolute;
    top: 58px;
    right: 18px;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    height: 36px;
    border-radius: 20px;
    background: rgba(255,255,255,.95);
    border: 1.5px solid rgba(38,166,154,.35);
    box-shadow: 0 3px 12px rgba(0,0,0,.14), 0 1px 3px rgba(0,0,0,.1);
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s, background .2s;
    min-width: 148px;
    max-width: 200px;
    overflow: visible;
}

.abp-map-loc-trigger:hover {
    border-color: var(--mmp-teal);
    box-shadow: 0 4px 16px rgba(38,166,154,.25), 0 1px 4px rgba(0,0,0,.12);
    background: #fff;
}

.abp-loc-pin-icon {
    width: 15px;
    height: 15px;
    color: var(--mmp-teal);
    flex-shrink: 0;
    pointer-events: none;
}

.abp-loc-select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    font-size: 16px;
    border: none;
    background: transparent;
    appearance: auto;
    z-index: 2;
}

.abp-map-loc-trigger::after {
    content: attr(data-label);
    flex: 1;
    font-size: .80rem;
    font-weight: 600;
    color: var(--mmp-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

.abp-loc-chevron {
    width: 14px;
    height: 14px;
    color: var(--mmp-teal);
    flex-shrink: 0;
    pointer-events: none;
}

.abp-map-loc-trigger.disabled {
    opacity: .45;
    pointer-events: none;
}

/* ============================================================
   RIGHT PANE — data panel
   ============================================================ */
.abp-data-pane {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    background: transparent;
}

@media (min-width: 900px) {
    .abp-data-pane {
        align-self: stretch;
        overflow-y: auto;
        max-height: calc(100vh - 100px);
        padding-right: 4px;
        scrollbar-width: thin;
        scrollbar-color: var(--mmp-border) transparent;
        align-content: flex-start;
    }
    .abp-data-pane::-webkit-scrollbar       { width: 5px; }
    .abp-data-pane::-webkit-scrollbar-thumb { background: var(--mmp-border); border-radius: 3px; }
}

.abp-panel-loading,
.abp-no-data {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 40px 24px;
    text-align: center;
    color: var(--mmp-light);
    font-style: italic;
    box-shadow: none;
}

/* ── Panel header ───────────────────────────────────────────────── */
.abp-panel-header {
    padding-bottom: 6px;
    margin-bottom: 4px;
}

.abp-panel-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.abp-panel-title {
    font-size: 1.9rem;
    font-weight: 800;
    color: var(--mmp-text);
    margin: 0;
    line-height: 1.15;
}

.abp-panel-sub {
    font-size: .85rem;
    color: var(--mmp-light);
    margin: 3px 0 0;
    font-weight: 400;
}

/* Level badges */
.abp-lvl-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
    white-space: nowrap;
}

.abp-lvl-badge.nat      { background: #e0f7f5; color: #00695c; border: 1px solid #b2dfdb; }
.abp-lvl-badge.reg      { background: #fff3e0; color: #e65100; border: 1px solid #ffcc80; }
.abp-lvl-badge.reg.north  { background: #fff3e0; color: #bf360c; }
.abp-lvl-badge.reg.central{ background: #e3f2fd; color: #0d47a1; border-color: #90caf9; }
.abp-lvl-badge.reg.south  { background: #f3e5f5; color: #4a148c; border-color: #ce93d8; }
.abp-lvl-badge.dist     { background: #e8eaf6; color: #283593; border: 1px solid #c5cae9; }
.abp-lvl-badge.ta       { background: #f3e5f5; color: #6a1b9a; border: 1px solid #ce93d8; }

/* ── TA sub-selector ────────────────────────────────────────────── */
.abp-ta-sel-wrap {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 14px 16px;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.abp-ta-sel-lbl {
    font-size: .82rem;
    font-weight: 600;
    color: var(--mmp-mid);
}

#abp-ta-sel {
    width: 100%;
    padding: 9px 36px 9px 12px;
    border: 1px solid var(--mmp-border);
    border-radius: 8px;
    font-size: .93rem;
    color: var(--mmp-text);
    background: var(--mmp-bg);
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2326a69a'%3e%3cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    cursor: pointer;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

#abp-ta-sel:focus {
    border-color: var(--mmp-teal);
    box-shadow: 0 0 0 3px rgba(38,166,154,.2);
}

/* ── Region district chips ──────────────────────────────────────── */
.abp-chips-card {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 16px;
    box-shadow: none;
}

.abp-chips-card h3 {
    font-size: .88rem;
    font-weight: 700;
    color: var(--mmp-text);
    margin: 0 0 10px;
}

.abp-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.abp-region-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border-radius: 20px;
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: transform .15s, box-shadow .15s;
}

.abp-region-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 9px rgba(0,0,0,.12);
}

.abp-region-chip.north   { background: #fff3e0; color: #bf360c; border-color: #ffcc80; }
.abp-region-chip.central { background: #e3f2fd; color: #0d47a1; border-color: #90caf9; }
.abp-region-chip.south   { background: #f3e5f5; color: #4a148c; border-color: #ce93d8; }

/* ============================================================
   INDICATOR CARDS — All types
   ============================================================ */

/* ── Card Containers ────────────────────────────────────────────── */
.abp-cards-section {
    padding: 4px 0;
}

.abp-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    padding: 8px 0;
}

.abp-kpi-grid {
    padding: 8px 0;
}

.abp-progress-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    padding: 8px 0 4px;
    border-top: 1px solid #e5e7eb;
    margin-top: 4px;
}

/* ── Base Indicator Card ────────────────────────────────────────── */
.abp-indicator-card {
    background: var(--mmp-white);
    border: 1px solid var(--mmp-border);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    display: flex;
    flex-direction: column;
    min-width: 0;
    word-break: break-word;
    overflow-wrap: break-word;
}

.abp-indicator-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.07);
    border-color: var(--mmp-teal);
}

/* ── KPI Card ───────────────────────────────────────────────────── */
.abp-card-kpi {
    padding: 16px;
}

.abp-card-kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.abp-card-kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
    border: 1px solid var(--mmp-border);
    transition: transform 0.2s ease;
}

.abp-indicator-card:hover .abp-card-kpi-icon {
    transform: scale(1.05);
}

.abp-card-kpi-trend {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

.abp-trend-emerald {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.abp-trend-red {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.abp-trend-blue {
    background: #eff6ff;
    color: #3b82f6;
    border: 1px solid #bfdbfe;
}

.abp-trend-gray {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #e5e7eb;
}

.abp-trend-orange {
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
}

.abp-card-kpi-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.abp-card-kpi-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9ca3af;
    margin: 0 0 2px 0;
    line-height: 1.3;
}

.abp-card-kpi-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--mmp-text);
    margin: 2px 0 2px;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.abp-card-kpi-unit {
    font-size: 0.7rem;
    color: #9ca3af;
    margin: 2px 0 0;
    line-height: 1.3;
}

.abp-card-kpi-trend-label {
    font-size: 0.65rem;
    color: #9ca3af;
    margin: 2px 0 0;
    line-height: 1.3;
    font-style: italic;
}

/* ── Progress Card ──────────────────────────────────────────────── */
.abp-card-progress {
    padding: 16px;
}

.abp-card-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.abp-card-progress-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
    border: 1px solid var(--mmp-border);
    transition: transform 0.2s ease;
}

.abp-indicator-card:hover .abp-card-progress-icon {
    transform: scale(1.05);
}

.abp-card-progress-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--mmp-text);
    letter-spacing: -0.02em;
}

.abp-card-progress-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #6b7280;
    margin: 0 0 8px 0;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.abp-card-progress-track {
    width: 100%;
    height: 6px;
    background: #f1f5f9;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 4px;
}

.abp-card-progress-bar {
    height: 100%;
    border-radius: 8px;
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.abp-card-progress-subtext {
    font-size: 0.65rem;
    color: #9ca3af;
    margin: 4px 0 0;
    line-height: 1.3;
    font-style: italic;
}

/* ── Circular Progress Card ────────────────────────────────────── */
.abp-card-progress-circular {
    align-items: center;
    text-align: center;
    padding: 16px 12px;
    flex-direction: column;
    gap: 8px;
}

.abp-card-progress-circ-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
}

.abp-circ-svg {
    display: block;
    overflow: visible;
}

.abp-circ-fill {
    transition: stroke-dashoffset 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

.abp-card-progress-circ-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.abp-card-progress-circular .abp-card-progress-label {
    margin: 0;
    text-align: center;
}

.abp-card-progress-circular .abp-card-progress-subtext {
    text-align: center;
}

/* ── Simple Card ────────────────────────────────────────────────── */
.abp-card-simple {
    padding: 16px;
}

.abp-card-simple .abp-indicator-title {
    font-size: 0.75rem;
    color: #6b7280;
    margin-bottom: 4px;
    font-weight: 600;
    line-height: 1.35;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    word-break: break-word;
}

.abp-card-simple .abp-indicator-value {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.15;
    word-break: break-word;
    overflow-wrap: break-word;
}

.abp-card-simple .abp-indicator-description {
    font-size: 0.75rem;
    color: #6b7280;
    line-height: 1.4;
    word-break: break-word;
    margin-top: 4px;
}

/* ── Responsive for cards ────────────────────────────────────────── */
@media (max-width: 768px) {
    .abp-cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }
    .abp-progress-cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }
    .abp-card-kpi-value {
        font-size: 1.4rem;
    }
    .abp-card-simple .abp-indicator-value {
        font-size: 1.4rem;
    }
    .abp-card-kpi-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .abp-cards-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 4px 0;
    }
    .abp-progress-cards-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 4px 0;
    }
    .abp-card-kpi {
        padding: 12px;
    }
    .abp-card-kpi-value {
        font-size: 1.1rem;
    }
    .abp-card-simple .abp-indicator-value {
        font-size: 1.1rem;
    }
    .abp-card-kpi-label {
        font-size: 0.6rem;
    }
    .abp-card-progress {
        padding: 12px;
    }
    .abp-card-progress-value {
        font-size: 1rem;
    }
    .abp-card-progress-icon {
        width: 30px;
        height: 30px;
        font-size: 0.75rem;
    }
    .abp-card-simple {
        padding: 12px;
    }
    .abp-card-simple .abp-indicator-title {
        font-size: 0.65rem;
    }
}

/* ============================================================
   TABLE CHART SECTION — ENHANCED FOR LARGER CHARTS
   ============================================================ */

.abp-ts-section:not([data-ts-shared]) {
    padding: 8px 0 16px;
}

/* ── Controls Bar ── */
.abp-ts-section:not([data-ts-shared]) .abp-ts-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 16px;
    background: var(--mmp-bg);
    border: 1px solid var(--mmp-border);
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.875rem;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-view-toggle {
    display: inline-flex;
    border: 1px solid #b2dfdb;
    border-radius: 6px;
    overflow: hidden;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-view-toggle button {
    padding: 6px 16px;
    font-size: 0.82rem;
    font-weight: 600;
    background: #fff;
    color: var(--mmp-text);
    border: none;
    cursor: pointer;
    line-height: 1.4;
    transition: background 0.15s, color 0.15s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-view-toggle button + button {
    border-left: 1px solid #b2dfdb;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-view-toggle button:hover {
    background: #e0f2f0;
    color: var(--mmp-teal-dark);
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-view-toggle button.active {
    background: linear-gradient(135deg, var(--mmp-teal) 0%, var(--mmp-teal-dark) 100%);
    color: #fff;
}

/* ── Table Pane ── */
.abp-ts-section:not([data-ts-shared]) .abp-ts-table-pane {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    border: 1px solid var(--mmp-border);
    margin-bottom: 16px;
    background: #fff;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-table thead tr {
    background: linear-gradient(135deg, var(--mmp-teal) 0%, var(--mmp-teal-dark) 100%);
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-table thead th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #fff;
    border-bottom: none;
    white-space: nowrap;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-table thead th:first-child { border-radius: 8px 0 0 0; }
.abp-ts-section:not([data-ts-shared]) .abp-ts-table thead th:last-child  { border-radius: 0 8px 0 0; }

.abp-ts-section:not([data-ts-shared]) .abp-ts-table tbody tr {
    border-bottom: 1px solid var(--mmp-border);
    transition: background 0.1s;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-table tbody tr:nth-child(even) {
    background: var(--mmp-bg);
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-table tbody tr:hover {
    background: #e0f2f0;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-table td {
    padding: 8px 14px;
    color: var(--mmp-text);
    border-bottom: 1px solid var(--mmp-border);
    white-space: nowrap;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-table td:first-child {
    font-weight: 600;
    color: var(--mmp-mid, #4a5568);
    white-space: nowrap;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-more-rows td {
    text-align: center;
    color: #999;
    font-style: italic;
    font-size: 0.78rem;
    padding: 10px 14px;
}

/* ── Chart Container ── */
.abp-ts-section:not([data-ts-shared]) .abp-ts-chart-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    margin-top: 12px;
    padding: 0 4px;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-chart-container.multi {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 768px) {
    .abp-ts-section:not([data-ts-shared]) .abp-ts-chart-container.multi {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

/* ── Chart Card — Larger and more spacious ── */
.abp-ts-section:not([data-ts-shared]) .abp-ts-chart-card {
    background: var(--mmp-white);
    border: 1px solid var(--mmp-border);
    border-radius: 10px;
    padding: 20px 20px 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: box-shadow 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-chart-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.10);
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-chart-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--mmp-text);
    margin: 0 0 4px;
    text-align: center;
    letter-spacing: 0.01em;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-chart-unit {
    font-size: 0.78rem;
    color: var(--mmp-light);
    text-align: center;
    margin-bottom: 14px;
    font-weight: 500;
}

/* ── Chart Pane — LARGER HEIGHT ── */
.abp-ts-section:not([data-ts-shared]) .abp-ts-chart-pane {
    position: relative;
    height: 280px;
    width: 100%;
    min-height: 200px;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-chart-canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* ── Responsive Chart Heights ── */
@media (max-width: 1024px) {
    .abp-ts-section:not([data-ts-shared]) .abp-ts-chart-pane {
        height: 260px;
    }
}

@media (max-width: 768px) {
    .abp-ts-section:not([data-ts-shared]) .abp-ts-chart-pane {
        height: 220px;
    }
    .abp-ts-section:not([data-ts-shared]) .abp-ts-chart-container.multi {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

@media (max-width: 600px) {
    .abp-ts-section:not([data-ts-shared]) .abp-ts-chart-pane {
        height: 190px;
    }
    .abp-ts-section:not([data-ts-shared]) .abp-ts-chart-card {
        padding: 14px 12px 10px;
    }
    .abp-ts-section:not([data-ts-shared]) .abp-ts-chart-title {
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .abp-ts-section:not([data-ts-shared]) .abp-ts-chart-pane {
        height: 180px;
    }
    .abp-ts-section:not([data-ts-shared]) .abp-ts-chart-card {
        padding: 12px 10px 8px;
    }
    .abp-ts-section:not([data-ts-shared]) .abp-ts-chart-title {
        font-size: 0.8rem;
    }
    .abp-ts-section:not([data-ts-shared]) .abp-ts-chart-unit {
        font-size: 0.7rem;
        margin-bottom: 10px;
    }
}

/* ── Graphs Section (regular graphs) ── */
.abp-graphs-wrap {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.abp-graphs-wrap.multi {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 700px) {
    .abp-graphs-wrap.multi { 
        grid-template-columns: 1fr; 
    }
}

.abp-graph-card {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 16px 16px 12px;
    box-shadow: none;
}

.abp-graph-title {
    font-size: .88rem;
    font-weight: 700;
    color: var(--mmp-mid);
    margin: 0 0 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    text-align: center;
}

.abp-canvas-wrap {
    position: relative;
    height: 260px;
    width: 100%;
    min-height: 200px;
}

@media (max-width: 768px) {
    .abp-canvas-wrap {
        height: 220px;
    }
}

@media (max-width: 480px) {
    .abp-canvas-wrap {
        height: 180px;
    }
    .abp-graph-card {
        padding: 10px 10px 8px;
    }
}

/* ── Responsive Table ── */
@media (max-width: 768px) {
    .abp-ts-section:not([data-ts-shared]) .abp-ts-table {
        font-size: 0.78rem;
    }
    .abp-ts-section:not([data-ts-shared]) .abp-ts-table thead th {
        padding: 8px 10px;
        font-size: 0.68rem;
    }
    .abp-ts-section:not([data-ts-shared]) .abp-ts-table td {
        padding: 6px 10px;
    }
}

@media (max-width: 480px) {
    .abp-ts-section:not([data-ts-shared]) .abp-ts-table {
        font-size: 0.72rem;
    }
    .abp-ts-section:not([data-ts-shared]) .abp-ts-table thead th {
        padding: 6px 8px;
        font-size: 0.62rem;
    }
    .abp-ts-section:not([data-ts-shared]) .abp-ts-table td {
        padding: 5px 8px;
    }
}

/* ============================================================
   ARTICLE SECTION
   ============================================================ */
.abp-article-section {
    background: transparent;
    border: none;
    border-left: 4px solid var(--mmp-teal);
    border-radius: 0;
    padding: 18px 20px;
    box-shadow: none;
}

.abp-article-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--mmp-text);
    margin: 0 0 10px;
}

.abp-article-body {
    font-size: .92rem;
    line-height: 1.75;
    color: var(--mmp-mid);
}

.abp-article-body p {
    margin: 0 0 .8em;
}

.abp-article-body p:last-child {
    margin-bottom: 0;
}

/* ============================================================
   THEMED TEXT BOX  — "Statistics by Theme" style
   ============================================================ */
.abp-themed-text-box {
    padding: 0;
}

/* Header bar */
.abp-ttb-header {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--mmp-text, #1a1a1a);
    margin: 0 0 14px;
    padding-bottom: 8px;
    border-bottom: 3px solid var(--mmp-teal, #26a69a);
    letter-spacing: -.01em;
}

/* Tab button strip */
.abp-ttb-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.abp-ttb-tab {
    display: inline-flex;
    align-items: center;
    padding: 7px 16px;
    font-size: .82rem;
    font-weight: 600;
    border-radius: 20px;
    border: 1.5px solid var(--mmp-border, #e0e0e0);
    background: rgba(38, 166, 154, 0.08);
    color: var(--mmp-mid, #4a5568);
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
    font-family: inherit;
    line-height: 1.3;
    letter-spacing: .01em;
}

.abp-ttb-tab:hover {
    background: rgba(38, 166, 154, 0.15);
    border-color: var(--mmp-teal, #26a69a);
    color: var(--mmp-teal-dark, #00897b);
}

.abp-ttb-tab.active {
    background: rgba(38, 166, 154, 0.18);
    border-color: var(--mmp-teal, #26a69a);
    color: var(--mmp-teal-dark, #00897b);
    box-shadow: 0 0 0 2px rgba(38, 166, 154, 0.15);
}

/* Tab panels */
.abp-ttb-panels {
    position: relative;
}

.abp-ttb-panel {
    display: none;
    animation: abp-ttb-fadein .2s ease;
}

.abp-ttb-panel.active {
    display: block;
}

@keyframes abp-ttb-fadein {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.abp-ttb-desc {
    font-size: .9rem;
    line-height: 1.7;
    color: var(--mmp-mid, #4a5568);
    margin: 0 0 14px;
}

/* Read More button */
.abp-ttb-readmore {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 18px;
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    background: transparent;
    color: var(--mmp-teal, #26a69a);
    border: 2px solid var(--mmp-teal, #26a69a);
    border-radius: 4px;
    text-decoration: none;
    transition: background .15s, color .15s;
}

.abp-ttb-readmore::after {
    content: '→';
    font-size: .85em;
}

.abp-ttb-readmore:hover {
    background: var(--mmp-teal, #26a69a);
    color: #fff;
    text-decoration: none;
}

/* Sub-heading inside a tab panel */
.abp-ttb-heading {
    font-size: 1rem;
    font-weight: 700;
    color: var(--mmp-teal-dark, #00897b);
    margin: 0 0 10px;
    line-height: 1.35;
}

/* Stat highlight block */
.abp-ttb-stat-block {
    margin: 0 0 18px;
}
.abp-ttb-stat-value {
    font-size: 2.8rem;
    font-weight: 300;
    color: var(--mmp-text, #1a1a1a);
    line-height: 1;
    letter-spacing: -0.02em;
}
.abp-ttb-stat-unit {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--mmp-mid, #4a5568);
    margin-left: 6px;
    vertical-align: middle;
}
.abp-ttb-stat-label {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--mmp-teal, #26a69a);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-top: 8px;
}

/* Section titles above cards / charts inside a tab */
.abp-ttb-cards-title,
.abp-ttb-tc-title {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--mmp-mid, #4a5568);
    margin: 18px 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--mmp-border, #e0e0e0);
}

/* Cards section inside a themed tab — no extra card wrapper padding */
.abp-ttb-panel .abp-cards-section {
    margin-top: 4px;
}

/* Table/chart section inside a themed tab */
.abp-ttb-panel .abp-ts-section:not([data-ts-shared]) {
    margin-top: 8px;
}

/* View-toggle buttons inside tabs */
.abp-ttb-panel .abp-ts-section:not([data-ts-shared]) .abp-ts-view-toggle {
    display: inline-flex;
    gap: 0;
    border: 1px solid var(--mmp-border, #e0e0e0);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 12px;
}
.abp-ttb-panel .abp-ts-section:not([data-ts-shared]) .abp-ts-view-toggle button {
    padding: 5px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    background: #fff;
    color: var(--mmp-mid, #4a5568);
    border: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-family: inherit;
}
.abp-ttb-panel .abp-ts-section:not([data-ts-shared]) .abp-ts-view-toggle button:not(:last-child) {
    border-right: 1px solid var(--mmp-border, #e0e0e0);
}
.abp-ttb-panel .abp-ts-section:not([data-ts-shared]) .abp-ts-view-toggle button.active,
.abp-ttb-panel .abp-ts-section:not([data-ts-shared]) .abp-ts-view-toggle button:hover {
    background: var(--mmp-teal, #26a69a);
    color: #fff;
}

/* Chart canvas wrapper inside tabs */
.abp-ttb-panel .abp-ts-section:not([data-ts-shared]) .abp-ts-chart-container {
    position: relative;
    width: 100%;
    min-height: 220px;
}
.abp-ttb-panel .abp-canvas-wrap {
    position: relative;
    width: 100%;
    min-height: 200px;
}
.abp-ttb-panel .abp-ts-section:not([data-ts-shared]) .abp-ts-chart-canvas {
    display: block;
    max-width: 100%;
}


/* ============================================================
   RESOURCES / DOWNLOADS
   ============================================================ */
.abp-resources-section {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 18px;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.abp-res-heading {
    font-size: .88rem;
    font-weight: 700;
    color: var(--mmp-text);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 7px;
}

.abp-res-heading svg {
    width: 16px;
    height: 16px;
    color: var(--mmp-teal);
    flex-shrink: 0;
}

/* Doc cards grid inside map panel */
.abp-data-pane .abp-doc-cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 7px;
}

.abp-data-pane .abp-doc-card {
    padding: 8px 10px;
    gap: 8px;
}

.abp-data-pane .abp-doc-card__icon {
    width: 26px;
    height: 26px;
}

.abp-data-pane .abp-doc-card__icon svg {
    width: 14px;
    height: 14px;
}

.abp-data-pane .abp-doc-card__name {
    font-size: 0.72rem;
}

.abp-data-pane .abp-doc-card__type-label {
    font-size: 0.58rem;
}

/* ============================================================
   HOVER TOOLTIP
   ============================================================ */
.abp-hover-tip {
    position: fixed;
    z-index: 99999;
    pointer-events: none;
    opacity: 0;
    transform: translateY(8px) scale(.96);
    transition: opacity .14s ease, transform .14s ease;
    max-width: 240px;
    min-width: 190px;
    filter: drop-shadow(0 8px 24px rgba(0,0,0,.42));
}

.abp-hover-tip.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.abp-hover-tip.flip .abp-tip-arrow {
    top: -7px; bottom: auto;
    border-top: none;
    border-bottom: 7px solid #0d1b24;
}

.abp-tip-head {
    background: linear-gradient(135deg, var(--mmp-teal), var(--mmp-teal-dark));
    border-radius: 12px 12px 0 0;
    padding: 9px 14px;
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: .82rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: .03em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.abp-tip-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: rgba(255,255,255,.7);
    flex-shrink: 0;
    box-shadow: 0 0 6px rgba(255,255,255,.6);
}

.abp-tip-body {
    background: linear-gradient(160deg, #1a2f3d, #0d1b24);
    padding: 11px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    border: 1px solid rgba(38,166,154,.22);
    border-top: none;
}

.abp-tip-row {
    display: flex;
    align-items: center;
    line-height: 1.2;
}

.abp-tip-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.abp-tip-lbl {
    font-size: .67rem;
    color: rgba(255,255,255,.45);
    text-transform: uppercase;
    letter-spacing: .06em;
    flex: 1;
}

.abp-tip-val {
    font-size: .83rem;
    font-weight: 700;
    color: #d0f5ee;
    white-space: nowrap;
}

.abp-tip-hint {
    background: #0d1b24;
    border: 1px solid rgba(38,166,154,.18);
    border-top: 1px solid rgba(255,255,255,.06);
    border-radius: 0 0 12px 12px;
    padding: 6px 14px;
    font-size: .63rem;
    color: rgba(255,255,255,.25);
    text-align: center;
    letter-spacing: .04em;
}

.abp-tip-arrow {
    display: none;
}

/* ============================================================
   INDICATOR / TOPIC SELECTOR — horizontal strip
   ============================================================ */
.abp-map-pane {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
}

.abp-indicator-panel {
    width: 100%;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 7px 14px;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
    box-sizing: border-box;
    overflow: hidden;
}

.abp-indicator-panel.visible {
    display: flex;
}

.abp-ind-chips-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 1px 0;
    max-width: 100%;
}

.abp-ind-chips-wrap::-webkit-scrollbar { display: none; }

.abp-ind-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 13px;
    border-radius: 20px;
    font-size: .71rem;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid var(--mmp-border);
    background: var(--mmp-bg);
    color: var(--mmp-mid);
    white-space: nowrap;
    flex-shrink: 0;
    transition: background .15s, border-color .15s, color .15s, transform .12s, box-shadow .12s;
    line-height: 1.2;
}

.abp-ind-chip:hover {
    border-color: var(--mmp-teal);
    background: #e0f7f5;
    color: var(--mmp-teal-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 7px rgba(38,166,154,.18);
}

.abp-ind-chip.active {
    background: var(--mmp-teal);
    border-color: var(--mmp-teal-dark);
    color: #fff;
    box-shadow: 0 2px 8px rgba(38,166,154,.3);
}

.abp-map-svg-wrap path.ind-highlight {
    fill: #00897b !important;
    stroke: rgba(255,255,255,.85);
    stroke-width: 1.8px;
    filter: drop-shadow(0 0 5px rgba(0,137,123,.45));
}

.abp-map-svg-wrap path.ind-dimmed {
    fill: #e8edf1 !important;
    opacity: 0.35;
    stroke: #c8cdd4;
}

.abp-tip-ind-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    border-radius: 10px;
    padding: 2px 7px;
    margin-bottom: 6px;
}

/* ============================================================
   RESPONSIVE OVERRIDES
   ============================================================ */
@media (max-width: 899px) {
    .abp-map-pane {
        border-radius: 0;
        overflow: visible;
    }

    .abp-map-loc-trigger {
        position: static;
        display: flex;
        align-items: center;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        height: 48px;
        padding: 0 16px;
        border-radius: 0;
        border: 1px solid rgba(38,166,154,.35);
        border-top: none;
        background: #fff;
        box-shadow: 0 4px 10px rgba(0,0,0,.10);
        gap: 10px;
        cursor: pointer;
        min-width: 0;
        overflow: visible;
        margin: 0;
    }

    .abp-map-loc-trigger.disabled {
        opacity: .55;
        pointer-events: none;
    }

    .abp-loc-pin-icon {
        width: 18px;
        height: 18px;
    }

    .abp-map-loc-trigger::after {
        font-size: .88rem;
        flex: 1;
    }

    .abp-loc-chevron {
        width: 16px;
        height: 16px;
        margin-left: auto;
    }

    .abp-loc-select {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        font-size: 16px;
    }

    .abp-data-pane {
        border-radius: 0;
    }

    .abp-mmp-dashboard {
        border: none;
        border-radius: 0;
        overflow: hidden;
        box-shadow: none;
    }
}

@media (max-width: 600px) {
    .abp-panel-title        { font-size: 1.5rem; }
    .abp-map-pane           { min-height: 280px; }
    .abp-indicator-panel    { padding: 6px 10px; gap: 5px; }
    .abp-ind-chip           { padding: 3px 9px; font-size: .67rem; }
    .abp-map-loc-trigger    { height: 52px; }
}

/* ============================================================
   CHART ANIMATION — Smooth appearance
   ============================================================ */
.abp-ts-section:not([data-ts-shared]) .abp-ts-chart-card {
    animation: abp-chart-fade 0.4s ease both;
}

@keyframes abp-chart-fade {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-chart-card:nth-child(2) {
    animation-delay: 0.1s;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-chart-card:nth-child(3) {
    animation-delay: 0.2s;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-chart-card:nth-child(4) {
    animation-delay: 0.3s;
}

/* ============================================================
   CHOROPLETH HEATMAP
   ============================================================ */

/* Override the default has-data teal when choropleth is active.
   The JS sets inline fills; we just make sure transitions look good. */
.abp-map-svg-wrap path.choropleth-district {
    transition: fill .25s ease, opacity .2s, filter .18s;
}

.abp-map-svg-wrap path.choropleth-district:hover {
    filter: brightness(.82) saturate(1.3);
    cursor: pointer;
}

/* ── Choropleth vertical legend ── */
/* Positioned inside .abp-map-pane (position:relative, overflow:visible).
   The legend was previously inside .abp-map-svg-wrap which has overflow:hidden,
   causing it to be clipped / overlap incorrectly. */
.abp-choro-legend {
    position: absolute;
    bottom: 18px;
    right: 14px;
    z-index: 30;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    pointer-events: none;
    font-family: 'Inter', system-ui, sans-serif;
}

.abp-choro-legend-title {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--mmp-mid, #4a5568);
    text-align: right;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    max-width: 90px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: rgba(255,255,255,0.88);
    padding: 2px 5px;
    border-radius: 3px;
}

.abp-choro-legend-body {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
}

.abp-choro-bar-svg {
    width: 16px;
    height: 100px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.12);
    display: block;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    flex-shrink: 0;
}

.abp-choro-legend-label {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--mmp-mid, #4a5568);
    background: rgba(255,255,255,0.88);
    padding: 1px 5px;
    border-radius: 3px;
    white-space: nowrap;
    line-height: 1.3;
    backdrop-filter: blur(2px);
}

.abp-choro-lbl-high { align-self: flex-end; }
.abp-choro-lbl-low  { align-self: flex-end; }

@media (max-width: 600px) {
    .abp-choro-legend {
        bottom: 10px;
        right: 8px;
    }
    .abp-choro-bar-svg {
        width: 13px;
        height: 72px;
    }
    .abp-choro-legend-label {
        font-size: 0.58rem;
    }
}

/* ============================================================
   THEMED TABS — Frontend (.abp-themed-tabs)
   Used by the map data pane to show per-location tab content.
   ============================================================ */

.abp-themed-tabs {
    padding: 0;
}

/* Section title above the tab row */
.abp-tt-section-title {
    font-size: .95rem;
    font-weight: 800;
    color: var(--mmp-text, #1a1a1a);
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 3px solid var(--mmp-teal, #26a69a);
    letter-spacing: -.01em;
    line-height: 1.3;
}

/* ── Tab button strip ── */
.abp-tt-btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.abp-tt-btn {
    display: inline-flex;
    align-items: center;
    padding: 7px 18px;
    font-size: .82rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: 20px;
    border: 1.5px solid var(--mmp-border, #e0e0e0);
    background: var(--mmp-white, #fff);
    color: var(--mmp-mid, #4a5568);
    cursor: pointer;
    line-height: 1.3;
    letter-spacing: .01em;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .12s;
    white-space: nowrap;
}

.abp-tt-btn:hover {
    background: #e0f7f5;
    border-color: var(--mmp-teal, #26a69a);
    color: var(--mmp-teal-dark, #00897b);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(38,166,154,.18);
}

.abp-tt-btn.abp-tt-btn-active,
.abp-tt-btn[aria-selected="true"] {
    background: linear-gradient(135deg, var(--mmp-teal, #26a69a), var(--mmp-teal-dark, #00897b));
    border-color: var(--mmp-teal-dark, #00897b);
    color: #fff;
    box-shadow: 0 3px 12px rgba(38,166,154,.35);
    transform: translateY(-1px);
}

/* ── Tab panels ── */
.abp-tt-panels {
    position: relative;
}

.abp-tt-panel {
    animation: abp-tt-fadein .2s ease both;
}

.abp-tt-panel[hidden] {
    display: none;
}

@keyframes abp-tt-fadein {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Text / description paragraph ── */
.abp-tt-description {
    font-size: .9rem;
    line-height: 1.7;
    color: var(--mmp-mid, #4a5568);
    margin: 0 0 14px;
}

/* ── Read More link ── */
.abp-tt-read-more {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 18px;
    margin-bottom: 16px;
    font-size: .8rem;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: .05em;
    text-transform: uppercase;
    text-decoration: none;
    background: transparent;
    color: var(--mmp-teal, #26a69a);
    border: 2px solid var(--mmp-teal, #26a69a);
    border-radius: 4px;
    transition: background .15s, color .15s, box-shadow .15s;
    line-height: 1.3;
}

.abp-tt-read-more:hover {
    background: var(--mmp-teal, #26a69a);
    color: #fff;
    text-decoration: none;
    box-shadow: 0 3px 10px rgba(38,166,154,.3);
}

.abp-tt-rm-arrow {
    font-size: .9em;
    transition: transform .15s;
}

.abp-tt-read-more:hover .abp-tt-rm-arrow {
    transform: translateX(3px);
}

/* ── Section title above cards ── */
.abp-tt-cards-title {
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--mmp-mid, #4a5568);
    margin: 16px 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--mmp-border, #e0e0e0);
}

/* ── Spacing inside panels ── */
.abp-tt-panel .abp-indicator-cards-grid,
.abp-tt-panel .abp-kpi-grid,
.abp-tt-panel .abp-progress-cards-grid {
    margin-top: 4px;
}

.abp-tt-panel .abp-ts-section:not([data-ts-shared]) {
    margin-top: 8px;
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .abp-tt-btn {
        padding: 6px 13px;
        font-size: .76rem;
    }
    .abp-tt-section-title {
        font-size: .88rem;
    }
}

/* ============================================================
   SEGMENTED CARDS — KPI & Progress multi-value layout
   (abp-card-segs-2, abp-card-segs-3 modifier classes)
   ============================================================ */

/* Wrap that holds 1–3 value segments side by side */
.abp-card-segs-wrap {
    display: flex;
    align-items: stretch;
    gap: 0;
    flex: 1;
    min-width: 0;
}

/* Each individual segment */
.abp-card-seg {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0 4px;
}

.abp-card-seg:first-child { padding-left: 0; }
.abp-card-seg:last-child  { padding-right: 0; }

/* Vertical divider between segments */
.abp-card-seg-divider {
    width: 1px;
    background: var(--mmp-border, #e0e0e0);
    align-self: stretch;
    margin: 4px 6px;
    flex-shrink: 0;
}

/* Segment sub-label (e.g. "Male", "Female", "Total") */
.abp-card-seg-label {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9ca3af;
    margin: 0 0 3px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 2-segment modifier: tighten icon/value sizes slightly */
.abp-card-segs-2 .abp-card-kpi-value  { font-size: 1.35rem; }
.abp-card-segs-2 .abp-card-kpi-icon   { width: 36px; height: 36px; font-size: 1rem; }
.abp-card-segs-2 .abp-card-kpi-unit   { font-size: 0.62rem; }

/* 3-segment modifier: compress further so all fit */
.abp-card-segs-3 .abp-card-kpi-value  { font-size: 1.1rem; letter-spacing: -0.01em; }
.abp-card-segs-3 .abp-card-kpi-icon   { width: 28px; height: 28px; font-size: 0.8rem; border-radius: 8px; }
.abp-card-segs-3 .abp-card-kpi-unit   { font-size: 0.58rem; }
.abp-card-segs-3 .abp-card-kpi-trend  { font-size: 0.58rem; padding: 1px 5px; }
.abp-card-segs-3 .abp-card-seg-label  { font-size: 0.57rem; }
.abp-card-segs-3 .abp-card-seg-divider { margin: 4px 4px; }

/* Circular progress segment */
.abp-card-seg-circular {
    align-items: center;
    text-align: center;
    gap: 4px;
}

/* ── Indicator cards grid — the actual grid layout ── */
.abp-indicator-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
    gap: 12px;
    padding: 4px 0;
}

.abp-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    padding: 4px 0;
}

/* Single card spanning full width when it has multiple segments */
.abp-indicator-cards-grid .abp-card-segs-2,
.abp-kpi-grid .abp-card-segs-2 {
    grid-column: span 2;
}
.abp-indicator-cards-grid .abp-card-segs-3,
.abp-kpi-grid .abp-card-segs-3 {
    grid-column: 1 / -1;
}

@media (max-width: 480px) {
    .abp-indicator-cards-grid .abp-card-segs-2,
    .abp-kpi-grid .abp-card-segs-2,
    .abp-indicator-cards-grid .abp-card-segs-3,
    .abp-kpi-grid .abp-card-segs-3 {
        grid-column: 1 / -1;
    }
    .abp-indicator-cards-grid,
    .abp-kpi-grid {
        grid-template-columns: 1fr;
    }
    .abp-card-segs-3 .abp-card-kpi-value { font-size: 1rem; }
}

/* ============================================================
   PANEL HEADER ENHANCEMENTS
   ============================================================ */

/* Location name — slightly smaller on very large values */
.abp-panel-title {
    word-break: break-word;
}

/* Decorative accent under the location title */
.abp-panel-header {
    border-bottom: 2px solid var(--mmp-border, #e0e0e0);
    padding-bottom: 10px;
    margin-bottom: 12px;
}

/* Sub-text (region name, district count) gets a light left border accent */
.abp-panel-sub {
    padding-left: 10px;
    border-left: 3px solid var(--mmp-teal, #26a69a);
    display: inline-block;
    margin-top: 4px;
    font-size: .82rem;
    color: var(--mmp-mid, #4a5568);
}

/* ============================================================
   TABLE CHART — MISSING & ENHANCED STYLES
   ============================================================ */

/* Chart / table section title */
.abp-ts-section:not([data-ts-shared]) .abp-ts-title {
    font-size: .9rem;
    font-weight: 700;
    color: var(--mmp-text, #1a1a1a);
    margin: 0 0 10px;
    letter-spacing: -.01em;
    line-height: 1.3;
}

/* Source citation line */
.abp-ts-section:not([data-ts-shared]) .abp-ts-source {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    color: var(--mmp-light, #718096);
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--mmp-border, #e0e0e0);
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-source::before {
    content: '📎';
    font-size: 0.7rem;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-source a {
    color: var(--mmp-teal, #26a69a);
    text-decoration: none;
    font-weight: 600;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-source a:hover {
    text-decoration: underline;
}

/* Controls bar — hide entirely when there's nothing inside it */
.abp-ts-section:not([data-ts-shared]) .abp-ts-controls:empty {
    display: none;
}

/* Pagination bar */
.abp-ts-section:not([data-ts-shared]) .abp-ts-pagination {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 2px;
    font-size: 0.78rem;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-prev-btn,
.abp-ts-section:not([data-ts-shared]) .abp-ts-next-btn {
    padding: 4px 12px;
    border: 1px solid var(--mmp-border, #e0e0e0);
    border-radius: 4px;
    background: var(--mmp-white, #fff);
    color: var(--mmp-mid, #4a5568);
    cursor: pointer;
    font-size: 0.78rem;
    font-family: inherit;
    transition: background .12s, border-color .12s, color .12s;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-prev-btn:hover:not(:disabled),
.abp-ts-section:not([data-ts-shared]) .abp-ts-next-btn:hover:not(:disabled) {
    background: #e0f7f5;
    border-color: var(--mmp-teal, #26a69a);
    color: var(--mmp-teal-dark, #00897b);
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-prev-btn:disabled,
.abp-ts-section:not([data-ts-shared]) .abp-ts-next-btn:disabled {
    opacity: .4;
    cursor: default;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-page-info {
    color: var(--mmp-mid, #4a5568);
    min-width: 80px;
    text-align: center;
    font-size: 0.78rem;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-no-rows {
    padding: 10px 0;
    color: var(--mmp-light, #718096);
    font-size: 0.82rem;
    font-style: italic;
    text-align: center;
}

/* Charts grid layouts */
.abp-ts-section:not([data-ts-shared]) .abp-ts-charts-grid-single {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 12px;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-charts-grid-two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 12px;
}

.abp-ts-section:not([data-ts-shared]) .abp-ts-charts-grid-multi {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

@media (max-width: 768px) {
    .abp-ts-section:not([data-ts-shared]) .abp-ts-charts-grid-two,
    .abp-ts-section:not([data-ts-shared]) .abp-ts-charts-grid-multi {
        grid-template-columns: 1fr;
    }
}

/* Table outer wrapper — subtle animation when appearing */
.abp-ts-section:not([data-ts-shared]) .abp-ts-table-outer {
    animation: abp-fade-in .2s ease both;
}

/* Zebra stripe contrast boost for readability */
.abp-ts-section:not([data-ts-shared]) .abp-ts-table tbody tr:nth-child(odd) {
    background: #fff;
}

/* Numeric columns right-align */
.abp-ts-section:not([data-ts-shared]) .abp-ts-table td[data-ts-series="1"] {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--mmp-teal-dark, #00897b);
}

/* ── Print styles ── */
@media print {
    .abp-ts-section:not([data-ts-shared]) .abp-ts-chart-pane {
        height: 300px !important;
        break-inside: avoid;
    }
    .abp-ts-section:not([data-ts-shared]) .abp-ts-chart-card {
        break-inside: avoid;
        page-break-inside: avoid;
        border: 1px solid #ddd;
    }
    .abp-map-pane {
        max-height: none !important;
    }
    .abp-data-pane {
        max-height: none !important;
        overflow: visible !important;
    }
}

/* ============================================================
   MULTI-METRIC SELECTOR + NO-DATA KEY
   ============================================================ */
.abp-metric-picker {
    position: absolute;
    top: 46px;
    left: 12px;
    z-index: 25;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: rgba(255,255,255,.95);
    border: 1px solid rgba(38,166,154,.35);
    border-radius: 8px;
    padding: 5px 8px 6px;
    box-shadow: 0 3px 12px rgba(0,0,0,.12);
    max-width: 220px;
}
.abp-metric-picker label {
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--mmp-light);
}
.abp-metric-picker select {
    font: inherit;
    font-size: .8rem;
    font-weight: 600;
    color: var(--mmp-teal-dark);
    border: 0;
    background: transparent;
    padding: 2px 0;
    max-width: 100%;
    cursor: pointer;
}
.abp-metric-picker select:focus-visible { outline: 2px solid var(--mmp-teal); outline-offset: 2px; }

.abp-nodata-key {
    position: absolute;
    bottom: 14px;
    left: 12px;
    z-index: 25;
    display: flex;
    align-items: center;
    gap: 7px;
    max-width: 230px;
    padding: 5px 10px;
    font-size: .7rem;
    line-height: 1.3;
    color: var(--mmp-mid);
    background: rgba(255,255,255,.92);
    border: 1px solid var(--mmp-border);
    border-radius: 6px;
    pointer-events: auto;
}
.abp-nodata-swatch {
    flex: 0 0 14px;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid #c8cdd4;
}
@media (max-width: 899px) {
    .abp-nodata-key { bottom: 62px; }
}
@media (max-width: 600px) {
    .abp-metric-picker { max-width: 170px; top: 40px; }
    .abp-nodata-key { bottom: 66px; font-size: .64rem; }
}