/* ===== Home overview ===== */
.pbstats-home-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 4px;
}

.pbstats-home-title {
    margin: 0;
    font-family: var(--pbstats-serif);
    font-size: clamp(2rem, 3vw, 2.5rem);
    font-weight: 600;
    letter-spacing: -0.035em;
    line-height: 1.1;
    color: var(--pbstats-text-main);
}

.pbstats-home-lead {
    margin: 0;
    max-width: 40rem;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--pbstats-text-muted);
}

.pbstats-overview-card {
    display: flex;
    flex-direction: column;
    gap: 22px;
    min-width: 0;
    max-width: 100%;
    padding: 24px 24px 20px;
    border: 1px solid var(--pbstats-border-subtle);
    border-radius: var(--pbstats-radius-lg);
    background: var(--pbstats-surface-bg);
    box-shadow: var(--pbstats-shadow-subtle);
}

.pbstats-overview-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding-bottom: 2px;
}

.pbstats-overview-card-header > div {
    min-width: 0;
    flex: 1 1 16rem;
}

.pbstats-overview-title {
    margin: 0 0 6px;
    font-family: var(--pbstats-serif);
    font-size: 1.28rem;
    font-weight: 600;
    letter-spacing: -0.025em;
    line-height: 1.25;
    color: var(--pbstats-text-main);
    overflow-wrap: break-word;
}

.pbstats-overview-subtitle {
    margin: 0;
    max-width: 46rem;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--pbstats-text-muted);
}

.pbstats-chart-context {
    margin: 0;
    max-width: 52rem;
    padding: 12px 14px;
    border-left: 3px solid #1d4ed8;
    border-radius: 0 10px 10px 0;
    background: var(--pbstats-surface-muted);
    font-size: 0.88rem;
    line-height: 1.55;
    color: var(--pbstats-text-main);
    white-space: pre-line;
}

.pbstats-overview-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: var(--pbstats-radius-pill);
    border: 1px solid var(--pbstats-border-subtle);
    background: var(--pbstats-surface-muted);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--pbstats-text-muted);
    white-space: nowrap;
}

.pbstats-overview-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #1d4ed8;
    flex-shrink: 0;
}

.pbstats-kpi-grid,
.pbstats-kpi-grid-compact,
.pbstats-kpi-grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
    gap: 12px;
}

.pbstats-kpi-grid-compact:has(> :only-child) {
    grid-template-columns: minmax(190px, 280px);
}

.pbstats-kpi-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 16px 14px;
    border: 1px solid var(--pbstats-border-subtle);
    border-radius: var(--pbstats-radius-md);
    background: #ffffff;
    overflow: hidden;
}

.pbstats-kpi-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: #1d4ed8;
}

.pbstats-kpi-card:nth-child(2)::before {
    background: #0f766e;
}

.pbstats-kpi-card:nth-child(3)::before {
    background: #6d28d9;
}

.pbstats-kpi-card:nth-child(4)::before {
    background: #0369a1;
}

.pbstats-kpi-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--pbstats-text-muted);
    line-height: 1.35;
}

.pbstats-kpi-value {
    font-size: clamp(1.45rem, 2vw, 1.85rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
    color: var(--pbstats-text-main);
}

.pbstats-kpi-meta {
    font-size: 0.78rem;
    color: var(--pbstats-text-faint);
}

.pbstats-table-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pbstats-table-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.pbstats-table-toggle {
    flex-shrink: 0;
    padding: 7px 12px;
    border: 1px solid var(--pbstats-border-subtle);
    border-radius: var(--pbstats-radius-sm);
    background: #ffffff;
    color: var(--pbstats-text-main);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background var(--pbstats-transition-fast), border-color var(--pbstats-transition-fast);
}

.pbstats-table-toggle:hover {
    background: var(--pbstats-surface-muted);
    border-color: #d1d5db;
}

.pbstats-table-toggle:focus-visible,
.pbstats-section-tab:focus-visible,
.pbstats-tax-chapter-link:focus-visible,
.pbstats-tax-graph:focus-visible,
.pbstats-nav-link:focus-visible,
.pbstats-dropdown-link:focus-visible,
.pbstats-chart-select:focus-visible {
    outline: 2px solid var(--pbstats-accent);
    outline-offset: 2px;
}

.pbstats-table-scroll.is-collapsed {
    display: none;
}

.pbstats-table-title {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--pbstats-text-main);
}

.pbstats-table-scroll {
    overflow: auto;
    max-height: 480px;
    border: 1px solid var(--pbstats-border-subtle);
    border-radius: var(--pbstats-radius-md);
    background: #ffffff;
}

.pbstats-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}

.pbstats-data-table th,
.pbstats-data-table td {
    padding: 11px 14px;
    border-bottom: 1px solid #f3f4f6;
    text-align: left;
    vertical-align: middle;
}

.pbstats-data-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f8fafc;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--pbstats-text-muted);
    box-shadow: inset 0 -1px 0 var(--pbstats-border-subtle);
}

.pbstats-data-table tbody tr:last-child th,
.pbstats-data-table tbody tr:last-child td {
    border-bottom: none;
}

.pbstats-data-table tbody tr:hover {
    background: #f8fafc;
}

.pbstats-data-table .pbstats-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--pbstats-text-main);
}

.pbstats-overview-footer {
    margin-top: -4px;
    padding-top: 14px;
    border-top: 1px solid #f3f4f6;
}

.pbstats-source-note {
    margin: 0;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--pbstats-text-faint);
}

.pbstats-empty-state {
    padding: 40px 24px;
    border: 1px dashed #d1d5db;
    border-radius: var(--pbstats-radius-lg);
    background: rgba(255, 255, 255, 0.7);
    text-align: center;
    color: var(--pbstats-text-muted);
}

.pbstats-empty-state p {
    margin: 0;
    font-size: 0.92rem;
}

.pbstats-home-stack {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.pbstats-section-tabs {
    display: inline-flex;
    flex-wrap: wrap;
    align-self: flex-start;
    gap: 2px;
    margin: 0;
    padding: 4px;
    border: 1px solid var(--pbstats-border-subtle);
    border-radius: 12px;
    background: #ffffff;
    box-shadow: var(--pbstats-shadow-subtle);
}

.pbstats-section-tab {
    appearance: none;
    margin: 0;
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font: inherit;
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--pbstats-text-muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.pbstats-section-tab:hover {
    color: var(--pbstats-text-main);
    background: #f3f4f6;
}

.pbstats-section-tab.is-active {
    background: var(--pbstats-accent);
    color: #ffffff;
}

.pbstats-section-tab.is-active:hover {
    background: #000000;
    color: #ffffff;
}

.pbstats-section-tabpanel {
    display: none;
}

.pbstats-section-tabpanel.is-active {
    display: block;
}

.pbstats-tax-browser {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.pbstats-tax-layout {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.pbstats-tax-chapters {
    position: sticky;
    top: 84px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.pbstats-tax-chapters-label {
    margin: 0;
    padding: 0 4px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--pbstats-text-faint);
}

.pbstats-tax-chapter-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: calc(100vh - 140px);
    overflow: auto;
    padding: 6px;
    border: 1px solid var(--pbstats-border-subtle);
    border-radius: var(--pbstats-radius-lg);
    background: #ffffff;
    box-shadow: var(--pbstats-shadow-subtle);
}

.pbstats-tax-chapter-link {
    appearance: none;
    margin: 0;
    padding: 9px 12px;
    border: none;
    border-radius: 10px;
    background: transparent;
    text-align: left;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 500;
    line-height: 1.35;
    color: var(--pbstats-text-muted);
    cursor: pointer;
}

.pbstats-tax-chapter-link:hover {
    color: var(--pbstats-text-main);
    background: #f3f4f6;
}

.pbstats-tax-chapter-link.is-active,
.pbstats-tax-chapter-link.is-active:hover {
    background: var(--pbstats-accent);
    color: #ffffff;
}

.pbstats-tax-chapter-select-wrap {
    display: none;
}

.pbstats-tax-stage,
.pbstats-tax-chapter,
.pbstats-tax-category {
    min-width: 0;
}

.pbstats-tax-chapter[hidden],
.pbstats-tax-category[hidden],
.pbstats-chart-panel[hidden] {
    display: none !important;
}

.pbstats-tax-graphs {
    display: flex;
    flex-wrap: wrap;
    align-self: flex-start;
    gap: 2px;
    padding: 4px;
    border-radius: 12px;
    background: #f3f4f6;
}

.pbstats-tax-graphs:has(> :only-child) {
    display: none;
}

.pbstats-tax-graph {
    appearance: none;
    margin: 0;
    padding: 7px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--pbstats-text-muted);
    cursor: pointer;
}

.pbstats-tax-graph:hover {
    color: var(--pbstats-text-main);
}

.pbstats-tax-graph.is-active {
    background: #ffffff;
    color: var(--pbstats-text-main);
    box-shadow: var(--pbstats-shadow-subtle);
}

@media (max-width: 800px) {
    .pbstats-tax-layout {
        grid-template-columns: 1fr;
    }

    .pbstats-tax-chapters {
        position: static;
    }

    .pbstats-tax-chapters-label {
        display: none;
    }

    .pbstats-tax-chapter-list {
        display: none;
    }

    .pbstats-tax-chapter-select-wrap {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .pbstats-tax-chapter-select {
        max-width: none;
    }
}

.pbstats-data-table-sex .pbstats-meta-cell {
    font-size: 0.8rem;
    color: var(--pbstats-text-muted);
    min-width: 120px;
}

.pbstats-formal-table {
    margin-bottom: 0;
    border-bottom: 12px solid #ffffff;
}

.pbstats-formal-table:last-child {
    margin-bottom: 0;
    border-bottom: none;
}

.pbstats-table-caption {
    margin: 0;
    padding: 14px 14px 8px;
    font-size: 0.88rem;
    font-weight: 600;
    text-align: left;
    caption-side: top;
    color: var(--pbstats-text-main);
}

.pbstats-chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.pbstats-share-table thead tr:first-child th[colspan] {
    text-align: center;
}

.pbstats-share-table thead tr:nth-child(2) th {
    top: 36px;
}

.pbstats-data-table tr.pbstats-tax-total th,
.pbstats-data-table tr.pbstats-tax-total td {
    font-weight: 700;
    background: #f8fafc;
    color: var(--pbstats-text-main);
}

.pbstats-data-table tr.pbstats-tax-child th {
    padding-left: 28px;
}

.pbstats-data-table .pbstats-table-section th {
    background: #f8fafc;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--pbstats-text-muted);
}

.pbstats-fee-table .pbstats-table-section th {
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    color: var(--pbstats-text-main);
}

.pbstats-fee-table .pbstats-table-subsection th {
    background: #ffffff;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: var(--pbstats-text-main);
    padding-left: 18px;
}

.pbstats-fee-note {
    display: block;
    margin-top: 2px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--pbstats-text-muted);
}

@media (max-width: 900px) {
    .pbstats-chart-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .pbstats-overview-card {
        padding: 18px 16px;
    }

    .pbstats-home-title {
        font-size: 1.75rem;
    }

    .pbstats-kpi-grid,
    .pbstats-kpi-grid-compact,
    .pbstats-kpi-grid-4 {
        grid-template-columns: 1fr;
    }

    .pbstats-main {
        overflow-x: clip;
    }

    .pbstats-overview-card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .pbstats-overview-card-header > div {
        flex: 0 1 auto;
    }
}
