/* ===== Analysis Page — Interactive Dashboard ===== */

/* ── Base colour tokens used throughout this file ── */
:root {
    --dash-green: #006b3f;
    --dash-gold:  #006b3f;
    --dash-blue:  #4b5563;
    --dash-gray:  #6b7280;
    --dash-border: #e5e7eb;
    --dash-shadow: 0 2px 12px rgba(0,0,0,.07);
}

/* ── Hero ── */
/* ── Sticky Filter Bar ── */
.analysis-filter-bar {
    background: #fff;
    border-bottom: 1px solid var(--dash-border);
    padding: 10px 0;
    position: sticky;
    top: 0; /* overridden at runtime by syncFilterBarTop() */
    z-index: 500;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

.filter-inner {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--dash-gray);
    white-space: nowrap;
}

.filter-pills {
    display: flex;
    gap: 4px;
}

.fpill {
    padding: 5px 13px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 20px;
    cursor: pointer;
    border: 1.5px solid var(--dash-border);
    background: #fff;
    color: #374151;
    transition: all .15s;
    user-select: none;
    font-family: inherit;
}

.fpill:hover {
    border-color: var(--primary, #12436D);
    color: var(--primary, #12436D);
}

.fpill.fpill-on {
    background: var(--primary, #12436D);
    color: #fff;
    border-color: var(--primary, #12436D);
}

.fpill.fpill-gold.fpill-on {
    background: var(--primary, #12436D);
    color: #fff;
    border-color: var(--primary, #12436D);
}

.filter-sep {
    width: 1px;
    height: 26px;
    background: var(--dash-border);
    flex-shrink: 0;
}

.filter-hint {
    margin-left: auto;
    font-size: 12px;
    color: var(--dash-gray);
}

/* ── KPI Strip ── */
.kpi-strip {
    background: #fff;
    border-bottom: none;
    padding: 1.25rem 1.5rem 0.75rem;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}

.kpi-card {
    text-align: center;
    padding: 0.7rem 0.6rem 0.45rem;
    border: 1px solid var(--dash-border);
    border-radius: 12px;
    background: rgba(255,255,255,.6);
    transition: none;
}

.kpi-card:hover { transform: none; }

.kpi-card.kpi-highlight { border-top-color: transparent; }
.kpi-card.kpi-alt       { border-top-color: transparent; }

.kpi-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--dark, #212529);
    line-height: 1.2;
    letter-spacing: -1px;
}

.kpi-card.kpi-highlight .kpi-value { color: var(--dark, #212529); }
.kpi-card.kpi-alt .kpi-value       { color: var(--dark, #212529); }

.kpi-label {
    display: block;
    font-size: 0.78rem;
    color: var(--dark, #212529);
    text-transform: none;
    letter-spacing: 0;
    margin-top: 0.3rem;
    white-space: normal;
    font-weight: 600;
    line-height: 1.4;
}

/* ── Dashboard Sections ── */
.dash-section {
    padding: 1.8rem 1.25rem 2.4rem;
}

.dash-green {
    background: rgba(0, 107, 63, .03);
    border-top: 3px solid rgba(0, 107, 63, .15);
    border-bottom: 1px solid rgba(0, 107, 63, .1);
}

.dash-navy {
    background: rgba(18, 67, 109, .03);
    border-top: 3px solid rgba(18, 67, 109, .15);
    border-bottom: 1px solid rgba(18, 67, 109, .1);
}

/* Block header */
.dash-block-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--dash-border);
}

.dash-block-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.dash-icon-green { background: rgba(0,107,63,.1);  color: var(--dash-green); }
.dash-icon-navy  { background: rgba(18,67,109,.08); color: #12436D; }

.dash-block-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--dark, #212529);
    letter-spacing: -.2px;
}

.dash-block-desc {
    font-size: 0.8rem;
    color: var(--dash-gray);
    margin-top: 3px;
}

/* ── Chart Grids ── */
.dash-g2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.dash-g3 {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 16px;
}

/* ── Dash Cards ── */
.dash-card {
    background: #fff;
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: 0 1px 8px rgba(15, 23, 42, .04);
    border: 1px solid var(--dash-border);
}

.dash-card-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .45px;
    color: var(--dash-gray);
    margin-bottom: 10px;
    padding-bottom: 7px;
    border-bottom: 1px solid var(--dash-border);
}

/* ── Funder Table ── */
.ft-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.ft-table th {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--dash-gray);
    padding: 0 6px 7px;
    text-align: left;
    border-bottom: 1px solid var(--dash-border);
}

.ft-table td {
    padding: 6px;
    border-bottom: 1px solid var(--dash-border);
    vertical-align: middle;
}

.ft-table tr:last-child td { border-bottom: none; }

.ft-donor-name {
    font-weight: 700;
    color: var(--dark, #212529);
    line-height: 1.3;
}

.ft-donor-sector {
    font-size: 12px;
    line-height: 1.35;
    color: var(--dash-gray);
    margin-top: 2px;
    margin-bottom: 4px;
}

.ft-rk {
    font-size: 12px;
    font-weight: 700;
    color: var(--dash-gray);
    width: 18px;
}

.ft-amount {
    font-weight: 700;
    text-align: right;
    color: var(--dash-green);
    white-space: nowrap;
}

.mini-bar-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.mini-bar-row {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(80px, 1.3fr) auto;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--dash-gray);
}

.mini-bar-label {
    color: var(--dark, #212529);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-bar-track {
    background: #eef2f7;
    border-radius: 999px;
    height: 7px;
    position: relative;
    overflow: hidden;
}

.mini-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--dash-green), #66b38d);
    border-radius: 999px;
}

.mini-bar-value {
    font-weight: 700;
    color: var(--dash-green);
    white-space: nowrap;
}

.mini-empty {
    font-size: 12px;
    color: var(--dash-gray);
    padding: 8px 0;
}

.ft-bar-bg {
    background: #f3f4f6;
    border-radius: 3px;
    height: 4px;
    margin-top: 3px;
}

.ft-bar-fill {
    height: 4px;
    border-radius: 3px;
    background: var(--dash-green);
}

/* ── Donut Legend ── */
.donut-legend {
    margin-top: 10px;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.donut-legend-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.donut-legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    flex-shrink: 0;
}

.donut-legend-name { flex: 1; }
.donut-legend-pct  { font-weight: 700; }

/* ── Top Projects ── */
.top-proj-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tp-card {
    background: transparent;
    border-radius: 0;
    padding: 10px 0;
    border: none;
    border-left: none;
}

.tp-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--dark, #212529);
    margin-bottom: 4px;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    line-height: 1.4;
    word-break: break-word;
}

.tp-meta {
    font-size: 12px;
    color: var(--dash-gray);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.tp-amt {
    font-size: 12px;
    font-weight: 800;
    color: var(--dash-green);
    margin-top: 4px;
}

/* ── Status Bars ── */
.status-bars {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.sb-row {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
}

.sb-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sb-label { flex: 1; }
.sb-val   { font-weight: 700; width: 30px; text-align: right; }

.sb-track {
    flex: 2;
    background: #f3f4f6;
    border-radius: 3px;
    height: 5px;
}

.sb-fill  { height: 5px; border-radius: 3px; }
.sb-pct   { font-size: 12px; color: var(--dash-gray); width: 36px; text-align: right; }

/* ── Multi/Solo Split ── */
.mss-block {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--dash-border);
}

.mss-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--dash-gray);
    margin-bottom: 8px;
}

.mss-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.mss-num {
    font-size: 14px;
    font-weight: 800;
    min-width: 38px;
    text-align: center;
}

.mss-green { color: var(--dash-green); }
.mss-gray  { color: var(--dash-gray); }

.mss-track {
    flex: 1;
    background: #f3f4f6;
    border-radius: 4px;
    height: 6px;
}

.mss-fill {
    height: 6px;
    background: var(--dash-green);
    border-radius: 4px;
}

.mss-sublabels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--dash-gray);
    margin-top: 4px;
}

/* ── CTA Section ── */
.analysis-cta {
    background: var(--header-bg, #1D352E);
    color: rgba(255,255,255,.7);
    text-align: center;
    padding: 2.5rem 1.5rem;
}

.analysis-cta p {
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
    line-height: 1.7;
}

.analysis-cta strong { color: rgba(255,255,255,.9); }

.btn-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: var(--white);
    font-weight: 600;
    font-size: 0.96rem;
    padding: 0.8rem 1.5rem;
    border-radius: 999px;
    text-decoration: none;
    border: 1px solid var(--primary);
    transition: all 0.2s ease;
}

.btn-cta:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-1px);
    opacity: 1;
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .dash-g2 { grid-template-columns: 1fr; }
    .dash-g3 { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
    .filter-inner { gap: 12px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
}

.status-card {
    padding: 0.75rem 1rem;
    background: var(--bg-secondary, #f9fafb);
    border-radius: 8px;
    border-left: 4px solid transparent;
}

.story-alt .status-card {
    background: #fff;
}

.status-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary, #1f2937);
}

.status-card-value {
    font-size: 0.85rem;
    color: var(--text-secondary, #6b7280);
}

.status-card-value small {
    font-weight: 400;
}

.status-card-amount {
    font-size: 0.82rem;
    color: var(--text-secondary, #9ca3af);
    margin-top: 0.1rem;
}

/* CTA Section */
.analysis-cta {
    text-align: center;
    padding: 3rem 1.5rem;
    background: #fff;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

.analysis-cta p {
    color: var(--text-secondary, #6b7280);
    font-size: 0.95rem;
    margin-bottom: 1.25rem;
}

.btn-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.8rem 1.5rem;
    background: var(--primary);
    color: var(--white);
    border: 1px solid var(--primary);
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.96rem;
    transition: all 0.2s ease;
}

.btn-cta:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-1px);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .kpi-value {
        font-size: 1.1rem;
    }

    .story-section {
        padding: 2.5rem 1rem;
    }

    .story-header h2 {
        font-size: 1.2rem;
    }

    .story-text {
        font-size: 0.95rem;
    }

    .chart-container {
        height: 280px;
    }

    .chart-container.chart-tall {
        height: 340px;
    }

    .story-charts-row {
        flex-direction: column;
    }

    .chart-card {
        padding: 1rem;
    }

    .analysis-cta {
        padding: 2rem 1rem;
    }
}


/* ===== Analysis Hub — Sidebar + Category Layout ===== */

/* Compact hero for hub */
/* Hub layout: sidebar left + main right */
.hub-layout {
    background: linear-gradient(180deg, #f8fafc 0%, #f3f6f8 100%);
    min-height: calc(100vh - 200px);
    padding: 0;
}

.hub-container {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 0;
    align-items: start;
    max-width: 1200px;
}

/* ── Sidebar ── */
.hub-sidebar {
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(8px);
    border-right: 1px solid var(--dash-border, #e5e7eb);
    min-height: calc(100vh - 160px);
    position: sticky;
    top: 0;
    padding: 1.25rem 0 2rem;
    box-shadow: inset -1px 0 0 rgba(15, 23, 42, 0.03);
}

.sidebar-search {
    padding: 0 1rem 1rem;
    border-bottom: 1px solid var(--dash-border, #e5e7eb);
    margin-bottom: 0.5rem;
}

.sidebar-search input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--dash-border, #e5e7eb);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    color: #374151;
    background: #f9fafb;
    box-sizing: border-box;
    transition: border-color .15s;
}

.sidebar-search input:focus {
    border-color: var(--dash-green, #006b3f);
    background: #fff;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 0.5rem;
}

.sb-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.18s ease;
    user-select: none;
    font-size: 14px;
    color: #374151;
    border: 1px solid transparent;
}

.sb-nav-item:hover {
    background: #f3f5f6;
    border-color: rgba(18, 67, 109, 0.08);
}

.sb-nav-item.sb-nav-active {
    background: linear-gradient(90deg, rgba(18, 67, 109, 0.07), rgba(0, 107, 63, 0.06));
    color: var(--primary, #12436D);
    font-weight: 600;
    border-color: rgba(18, 67, 109, 0.12);
    box-shadow: 0 2px 8px rgba(18, 67, 109, 0.05);
}

.sb-nav-item.sb-nav-empty {
    opacity: .55;
    cursor: default;
}

.sb-nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary, #12436D);
}
.sb-nav-label { flex: 1; }

.sb-nav-count {
    color: #999;
    font-size: 14px;
    font-weight: 500;
    flex-shrink: 0;
}

.sb-nav-item.sb-nav-active .sb-nav-count {
    color: var(--primary, #12436D);
    font-weight: 600;
}

.sb-nav-soon {
    font-size: 12px;
    color: #adb5bd;
    font-style: italic;
}

/* ── Main content area ── */
.hub-main {
    padding: 2rem 2rem 3rem;
    min-width: 0;
}

/* Category header */
.hub-cat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1.2rem;
    padding-bottom: 0.25rem;
}

.hub-cat-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: transparent;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    color: var(--primary, #12436D);
    opacity: 0.9;
}

.hub-cat-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--dark, #212529);
    margin-bottom: 0;
    letter-spacing: -0.02em;
}

.hub-cat-desc {
    font-size: 0.8rem;
    color: #6b7280;
    line-height: 1.5;
    margin-top: 0.1rem;
}

/* Analysis cards grid */
.analysis-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.analysis-card {
    background: #ffffff;
    padding: 1.1rem 1rem 0.9rem;
    border-radius: 12px;
    box-shadow: none;
    border: 1px solid rgba(148, 163, 184, 0.14);
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    transition: all 0.18s ease;
    min-height: 210px;
}

.analysis-card:hover {
    box-shadow: none;
    border-color: rgba(18, 67, 109, 0.18);
    transform: translateY(-1px);
    text-decoration: none;
    color: inherit;
}

.ac-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    margin-bottom: 0.7rem;
}

.ac-cat {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7280;
}

.ac-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary, #12436D);
    opacity: 0.9;
}

.ac-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.45rem;
    line-height: 1.35;
}

.ac-desc {
    color: #4b5563;
    line-height: 1.55;
    font-size: 0.88rem;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ac-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.6rem;
}

.ac-tag {
    padding: 0.18rem 0.5rem;
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 999px;
    font-size: 12px;
    color: #6b7280;
}

.ac-footer {
    margin-top: auto;
    padding-top: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.ac-source {
    color: #9ca3af;
    font-size: 12px;
    line-height: 1.4;
}

.ac-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    padding: 0.5rem 0.8rem;
    background: transparent;
    color: var(--primary);
    border-radius: 999px;
    border: 1px solid rgba(18, 67, 109, 0.12);
    font-weight: 600;
    font-size: 0.8rem;
    text-align: center;
    transition: all 0.2s ease;
}

.analysis-card:hover .ac-arrow {
    border-color: rgba(18, 67, 109, 0.2);
    background: rgba(18, 67, 109, 0.02);
}

/* Empty state */
.cards-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: #6b7280;
    grid-column: 1 / -1;
}

.cards-empty-icon {
    width: 40px;
    height: 40px;
    margin: 0 auto 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
}
.cards-empty p { font-size: 0.9rem; line-height: 1.6; }

/* ── Breadcrumb (on dedicated analysis pages) ── */
.analysis-breadcrumb {
    background: #fff;
    border-bottom: 1px solid var(--dash-border, #e5e7eb);
    padding: 10px 0;
    font-size: 13px;
}

.analysis-breadcrumb .container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.breadcrumb-back {
    color: var(--primary, #12436D);
    text-decoration: none;
    font-weight: 600;
}

.breadcrumb-back:hover { text-decoration: underline; }
.breadcrumb-sep  { color: #d1d5db; }
.breadcrumb-current { color: #6b7280; }

/* ── Responsive ── */
@media (max-width: 860px) {
    .hub-container {
        grid-template-columns: 1fr;
    }

    .hub-sidebar {
        position: static;
        min-height: auto;
        border-right: none;
        border-bottom: 1px solid var(--dash-border, #e5e7eb);
        padding: 1rem 0;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 0 1rem;
    }

    .sb-nav-item {
        flex-direction: column;
        align-items: center;
        gap: 4px;
        padding: 8px 10px;
        font-size: 12px;
        text-align: center;
    }

    .sb-nav-soon { display: none; }

    /* Empty categories are hidden on phones so the cards fit in the first screen */
    .sb-nav-item.sb-nav-empty { display: none; }

    .hub-main { padding: 1.5rem 1rem 2rem; }
}

/* Phones: filter pills at least 40px high */
@media (max-width: 768px) {
    .fpill {
        min-height: 40px;
    }
}

/* Notes under a chart and date of the data (T24) */
.dash-note { font-size: 12px; color: var(--dash-gray, #6b7280); margin: 10px 0 0; line-height: 1.4; }
.page-header .data-date { font-size: 13px; opacity: .8; margin-top: 4px; }
