.dashboard-shell.is-trade-business .portal-command,
.dashboard-shell.is-trade-business .portal-header,
.dashboard-shell.is-trade-business .evidence-layout,
.dashboard-shell.is-trade-business .section-block {
    display: none;
}

.ec-dashboard-view {
    --ec-bg: #f8fafc;
    --ec-surface: #ffffff;
    --ec-line: #d9e3ea;
    --ec-navy: #2d51a1;
    --ec-navy-soft: #383838;
    --ec-orange: #f68d32;
    --ec-orange-soft: #fff1e8;
    --ec-blue: #33a7df;
    --ec-green: #2d51a1;
    --ec-teal: #33a7df;
    --ec-muted: #5e6672;
    --ec-radius: 12px;
    --ec-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    color: var(--ec-navy-soft);
    font-family: "Source Sans 3", sans-serif;
}

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

.ec-dashboard {
    display: grid;
    gap: clamp(18px, 2.5vw, 28px);
    background: var(--ec-bg);
    border-radius: var(--ec-radius);
    padding: clamp(12px, 2vw, 20px);
}

.ec-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: start;
    padding: clamp(16px, 2.5vw, 24px);
    background: var(--ec-surface);
    border: 1px solid var(--ec-line);
    border-radius: var(--ec-radius);
    box-shadow: var(--ec-shadow);
}

.ec-header h1 {
    margin: 0;
    font-family: "Outfit", "Source Sans 3", sans-serif;
    font-size: clamp(1.15rem, 2vw, 1.35rem);
    font-weight: 700;
    color: #1e293b;
    line-height: 1.3;
}

.ec-header-meta {
    text-align: right;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ec-muted);
}

.ec-header-meta p {
    margin: 0;
}

.ec-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.ec-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 12px;
    border: 1px solid var(--ec-line);
    border-radius: 8px;
    background: var(--ec-surface);
    color: var(--ec-muted);
    font: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.ec-tab:hover {
    background: #f1f5f9;
}

.ec-tab.is-active {
    border-color: var(--ec-navy);
    background: #f1f5f9;
    color: var(--ec-navy);
}

.ec-tab-icon {
    display: inline-flex;
    width: 14px;
    height: 14px;
}

.ec-tab-icon svg {
    width: 14px;
    height: 14px;
}

.ec-main {
    display: grid;
    gap: clamp(16px, 2vw, 24px);
}

/* ----------------------------- filter bar ----------------------------- */

.ec-filterbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--ec-line);
}

.ec-seg {
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--ec-line);
    border-radius: 9px;
    background: #f1f5f9;
    gap: 2px;
}

.ec-seg-btn {
    border: 0;
    border-radius: 7px;
    padding: 5px 12px;
    background: transparent;
    color: var(--ec-muted);
    font: inherit;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.ec-seg-btn:hover {
    color: var(--ec-navy);
}

.ec-seg-btn.is-active {
    background: var(--ec-surface);
    color: var(--ec-navy);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.ec-seg-btn--female.is-active {
    color: var(--ec-orange);
}

.ec-seg-btn--male.is-active {
    color: var(--ec-navy);
}

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

.ec-filter-note {
    font-size: 0.65rem;
    color: var(--ec-muted);
}

/* --------------------------- panel controls --------------------------- */

.ec-panel-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px;
    margin: 0 0 12px;
}

.ec-ctl {
    display: grid;
    gap: 3px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--ec-muted);
}

.ec-ctl select {
    max-width: 190px;
    padding: 4px 8px;
    border: 1px solid var(--ec-line);
    border-radius: 7px;
    background: var(--ec-surface);
    color: var(--ec-navy-soft);
    font: inherit;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: normal;
    cursor: pointer;
}

.ec-ctl select:focus-visible {
    outline: 2px solid var(--ec-navy);
    outline-offset: 1px;
}

.ec-ctl-reset {
    border: 1px solid var(--ec-line);
    border-radius: 7px;
    padding: 4px 10px;
    background: var(--ec-surface);
    color: var(--ec-muted);
    font: inherit;
    font-size: 0.68rem;
    font-weight: 700;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.ec-ctl-reset:hover {
    color: #b91c1c;
    border-color: #fecaca;
}

.ec-panel-actions {
    display: inline-flex;
    gap: 4px;
    margin-left: auto;
}

.ec-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 1px solid var(--ec-line);
    border-radius: 7px;
    background: var(--ec-surface);
    color: var(--ec-muted);
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.ec-icon-btn svg {
    width: 13px;
    height: 13px;
}

.ec-icon-btn:hover {
    color: var(--ec-navy);
    border-color: var(--ec-navy);
    transform: translateY(-1px);
}

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

/* ------------------------- indicator cards (v3) ------------------------- */

.ec-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #e2e8f0;
    color: var(--ec-muted);
    font-size: 0.58rem;
    font-weight: 800;
}

.ec-tab.is-active .ec-tab-badge {
    background: var(--ec-navy);
    color: #fff;
}

.ec-search {
    flex: 1 1 220px;
    min-width: 170px;
    max-width: 320px;
    padding: 7px 12px;
    border: 1px solid var(--ec-line);
    border-radius: 8px;
    background: #f8fafc;
    color: var(--ec-navy-soft);
    font: inherit;
    font-size: 0.74rem;
}

.ec-search:focus-visible {
    outline: 2px solid var(--ec-navy);
    outline-offset: 1px;
}

.ec-card.is-hidden {
    display: none;
}

.ec-card--wide {
    grid-column: span 2;
}

.ec-card-title {
    display: block;
    overflow: visible;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.4;
    color: #334155;
}

.ec-insight {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: -6px 0 12px;
    padding: 8px 12px;
    border-radius: 8px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    font-size: 0.72rem;
    line-height: 1.45;
    color: #78350f;
}

.ec-insight-icon {
    flex-shrink: 0;
    display: inline-flex;
    width: 14px;
    height: 14px;
    margin-top: 1px;
    color: #d97706;
}

.ec-insight-icon svg {
    width: 14px;
    height: 14px;
}

.ec-views {
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--ec-line);
    border-radius: 9px;
    background: #f1f5f9;
    gap: 2px;
}

.ec-skeleton {
    position: absolute;
    inset: 0;
    border-radius: 8px;
    background: linear-gradient(100deg, #f1f5f9 40%, #f8fafc 50%, #f1f5f9 60%);
    background-size: 200% 100%;
    animation: ec-shimmer 1.4s ease-in-out infinite;
}

@keyframes ec-shimmer {
    0% { background-position: 120% 0; }
    100% { background-position: -80% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .ec-skeleton {
        animation: none;
    }
}

.ec-chart-frame--donut {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(140px, 180px);
    gap: 16px;
    align-items: center;
}

.ec-donut-side {
    display: grid;
    gap: 14px;
    font-size: 0.72rem;
    color: var(--ec-muted);
}

.ec-donut-side strong {
    display: block;
    margin-top: 2px;
    font-size: 1.1rem;
    color: var(--ec-navy);
}

.ec-kpis--n1 { grid-template-columns: minmax(0, 1fr); }
.ec-kpis--n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ec-kpis--n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.ec-code-chip {
    display: inline-block;
    margin-right: 8px;
    padding: 2px 7px;
    border-radius: 6px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: var(--ec-navy);
    font-size: 0.58rem;
    letter-spacing: 0.04em;
}

.ec-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: clamp(12px, 1.8vw, 20px);
}

.ec-kpi-card {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    border: 1px solid var(--ec-line);
    border-radius: var(--ec-radius);
    background: var(--ec-surface);
    box-shadow: var(--ec-shadow);
}

.ec-kpi-card--blue {
    background: #edf9fe;
    border-color: #b2e6fa;
}

.ec-kpi-card--orange,
.ec-kpi-card--orange-soft {
    background: #fff1e8;
    border-color: rgba(246, 141, 50, 0.32);
}

.ec-kpi-card--green,
.ec-kpi-card--teal {
    background: #edf9fe;
    border-color: #b2e6fa;
}

.ec-kpi-card h3 {
    margin: 0;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ec-muted);
}

.ec-kpi-value {
    margin: 6px 0 0;
    font-family: "Outfit", sans-serif;
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    font-weight: 700;
    line-height: 1;
    color: var(--ec-navy);
}

.ec-kpi-card--orange .ec-kpi-value {
    color: var(--ec-orange);
}

.ec-kpi-card--green .ec-kpi-value {
    color: var(--ec-navy);
}

.ec-kpi-card--teal .ec-kpi-value {
    color: var(--ec-blue);
}

.ec-kpi-detail {
    margin: 6px 0 0;
    font-size: 0.68rem;
    color: var(--ec-muted);
    line-height: 1.4;
}

.ec-kpi-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    color: rgba(30, 58, 138, 0.35);
}

.ec-kpi-card--orange .ec-kpi-icon {
    color: rgba(246, 141, 50, 0.46);
}

.ec-panels {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(14px, 2vw, 22px);
}

.ec-panel {
    background: var(--ec-surface);
    border: 1px solid var(--ec-line);
    border-radius: var(--ec-radius);
    padding: clamp(16px, 2vw, 22px);
    box-shadow: var(--ec-shadow);
    min-height: 320px;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.18s ease, transform 0.18s ease;
}

.ec-panel:hover {
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.09);
    transform: translateY(-1px);
}

@media (prefers-reduced-motion: reduce) {
    .ec-panel,
    .ec-panel:hover {
        transition: none;
        transform: none;
    }
}

.ec-panel--donut {
    align-items: center;
}

.ec-panel-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px 16px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(45, 81, 161, 0.08);
}

.ec-panel-head::before {
    content: "";
    width: 4px;
    height: 20px;
    border-radius: 2px;
    background: var(--ec-blue, #0B4FFF);
    flex-shrink: 0;
    margin-top: 3px;
}

.ec-panel-head--blue::before {
    background: var(--ec-blue, #0B4FFF);
}

.ec-panel-head--green::before {
    background: var(--ec-green, #4BA847);
}

.ec-panel-head--navy::before {
    background: var(--ec-navy, #2D51A1);
}

.ec-panel-head h2,
.ec-card-title {
    margin: 0;
    font-size: 0.88rem !important;
    font-weight: 600 !important;
    letter-spacing: -0.005em;
    text-transform: none !important;
    color: #0F172A !important;
    line-height: 1.35 !important;
    display: block !important;
    overflow: visible !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
}

.ec-panel-insight {
    margin: -8px 0 14px;
    font-size: 0.72rem;
    line-height: 1.45;
    color: var(--ec-muted);
}

.ec-chart-frame,
.ec-donut-wrap {
    position: relative;
    flex: 1;
    min-height: 240px;
}

.ec-donut-canvas {
    position: relative;
    height: 220px;
}

.ec-donut-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(140px, 180px);
    gap: 16px;
    align-items: center;
    width: 100%;
}

.ec-donut-legend {
    display: grid;
    gap: 14px;
    font-size: 0.72rem;
    color: var(--ec-muted);
}

.ec-donut-legend strong {
    display: block;
    margin-top: 2px;
    font-size: 1.1rem;
    color: var(--ec-navy);
}

.ec-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.ec-dot--female {
    background: var(--ec-orange);
}

.ec-dot--male {
    background: var(--ec-navy);
}

.ec-unavailable,
.ec-empty {
    padding: 24px;
    border: 1px dashed var(--ec-line);
    border-radius: var(--ec-radius);
    background: #f8fafc;
    text-align: center;
    color: var(--ec-muted);
}

.ec-unavailable strong,
.ec-empty strong {
    display: block;
    margin-bottom: 6px;
    color: #1e293b;
}

.ec-source {
    padding: 16px 8px 4px;
    text-align: center;
    font-size: 0.62rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ec-muted);
}

/* Publication (NISR-style) table view, toggled from the chart/table switch. */
.ec-mode-toggle {
    display: inline-flex;
    gap: 2px;
    margin-right: 4px;
}

.ec-pub-body {
    padding: 4px 2px 0;
}

.ec-pub-scroll {
    overflow-x: auto;
    margin-bottom: 10px;
}

.ec-pub-subtitle {
    margin: 6px 0 4px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--ec-navy);
}

.ec-pub-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.72rem;
    color: var(--ec-navy-soft);
}

.ec-pub-table th,
.ec-pub-table td {
    border: 1px solid var(--ec-line);
    padding: 4px 8px;
    text-align: left;
    white-space: nowrap;
}

.ec-pub-table thead th {
    background: #eef3fb;
    color: var(--ec-navy);
    font-weight: 700;
    text-align: center;
}

.ec-pub-table th[scope="row"] {
    text-align: left;
    font-weight: 600;
}

.ec-pub-num {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
}

.ec-pub-table tbody tr.ec-pub-total {
    background: #f6f9fc;
}

.ec-pub-table tbody tr.ec-pub-total td,
.ec-pub-table tbody tr.ec-pub-total th {
    font-weight: 700;
    border-top: 2px solid var(--ec-line);
}

/* Sectioned (hierarchical DHS) tables: banner rows separate disaggregation
   sections (Residence, Province, Education, Wealth …); indented stubs mark
   nested subgroups within a section. */
.ec-pub-table tbody tr.ec-pub-section th {
    background: #f1f5f9;
    color: var(--ec-navy);
    font-weight: 700;
    text-align: left;
    border-top: 2px solid var(--ec-line);
}

.ec-pub-table tbody th.ec-pub-indent {
    padding-left: 22px;
    font-weight: 400;
}

/* Keep the descriptive stub column visible while a wide table scrolls
   horizontally. Sticky cells need opaque backgrounds so numbers passing
   underneath do not show through. */
.ec-pub-table th[scope="row"] {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #fff;
}

.ec-pub-table tbody tr.ec-pub-section th {
    position: sticky;
    left: 0;
    z-index: 1;
}

.ec-pub-table tbody tr.ec-pub-total th[scope="row"] {
    background: #f6f9fc;
}

/* Toggle + controls rows in the hand-built sector views reuse the shared
   ec-mode-toggle segmented buttons next to their own card tools. */
.sp-card-tools-row,
.ec5-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

@media (max-width: 1100px) {
    .ec-kpis,
    .ec-kpis--n3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ec-panels {
        grid-template-columns: 1fr;
    }

    .ec-card--wide {
        grid-column: auto;
    }
}

@media (max-width: 720px) {
    .ec-header {
        grid-template-columns: 1fr;
    }

    .ec-header-meta {
        text-align: left;
    }

    .ec-kpis {
        grid-template-columns: 1fr;
    }

    .ec-donut-wrap,
    .ec-chart-frame--donut {
        grid-template-columns: 1fr;
    }

    .ec-kpis--n2,
    .ec-kpis--n3 {
        grid-template-columns: 1fr;
    }

    .dashboard-shell.is-trade-business .sidebar {
        display: none;
    }

    .dashboard-shell.is-trade-business .mobile-bottom-nav {
        display: flex;
    }
}

@media (min-width: 721px) {
    .dashboard-shell.is-trade-business .content {
        padding-top: 0;
    }
}

.ec-tab:focus-visible {
    outline: 2px solid var(--ec-navy);
    outline-offset: 2px;
}

/* ---- Chart-excellence additions (benchmark cards, sort, expand) ----------- */

/* Per-card provenance line shown under every chart in chart mode. */
.ec-card-source {
    margin: 6px 4px 0;
    font-size: 0.66rem;
    line-height: 1.35;
    color: var(--ec-muted);
    letter-spacing: 0.01em;
}

/* Full-screen chart overlay. */
body.ec-expand-lock {
    overflow: hidden;
}

.ec-expand-overlay {
    position: fixed;
    inset: 0;
    z-index: 1300;
    display: grid;
    place-items: center;
    padding: clamp(12px, 3vw, 40px);
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
}

.ec-expand-panel {
    width: min(1100px, 100%);
    max-height: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: clamp(14px, 2.4vw, 24px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.32);
}

.ec-expand-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.ec-expand-title {
    margin: 0;
    font-size: clamp(1rem, 2.2vw, 1.35rem);
    line-height: 1.25;
    color: var(--ec-navy-soft);
}

.ec-expand-close {
    flex: 0 0 auto;
}

.ec-expand-body {
    position: relative;
    flex: 1 1 auto;
    min-height: min(62vh, 560px);
}

.ec-expand-canvas {
    width: 100% !important;
    height: 100% !important;
}

@media (prefers-reduced-motion: reduce) {
    .ec-expand-overlay {
        backdrop-filter: none;
    }
}
