/* Growth Informed Platform Styles */

:root {
    /* === TYPOGRAPHY === */
    --font-sans: 'Source Sans 3', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;
    --font-chart: 'Source Sans 3';  /* Single family for Plotly (no fallback chain) */

    /* === BRAND (Growth Informed — navy/teal/orange) === */
    --color-brand: #2E8B8B;           /* Teal — active states, positive metrics, links */
    --color-brand-hover: #3AA8A8;     /* Light teal — hover states, tertiary data */
    --color-brand-subtle: #E8F5F5;    /* Light teal tint — subtle backgrounds */
    --color-accent: #D4812A;          /* Orange — alerts, negative metrics, CTAs */

    /* Sidebar */
    --color-sidebar-bg: #091F36;      /* Deep navy */
    --color-sidebar-surface: #1A5276; /* Mid blue — secondary UI, user initials circle */
    --color-sidebar-border: #153D5E;  /* Navy mid-tone */
    --color-sidebar-hover: #0F2A44;   /* Navy between bg and surface */
    --color-sidebar-active: #2E8B8B;  /* Teal */

    /* === SURFACES === */
    --color-surface-page: #F3F3F1;    /* Warm neutral gray */
    --color-surface-card: #ffffff;
    --color-surface-muted: #F2F2F0;

    /* === TEXT === */
    --color-text-primary: #0C2E4E;    /* Navy — headings, primary text */
    --color-text-secondary: #4A6580;  /* Navy-gray — body secondary */
    --color-text-muted: #647590;      /* Muted gray — labels, timestamps (4.69:1 on white, AA-safe) */
    --color-text-on-dark: #FFFFFF;    /* White — sidebar nav text */
    --color-text-muted-on-dark: #5A8A9E; /* Section header gray — sidebar headers, client name */

    /* === BORDERS === */
    --color-border: #E2E4E8;          /* Neutral gray — card borders, dividers */
    --color-border-strong: #D1D9E4;   /* Slightly darker — emphasis borders */

    /* === SEMANTIC (independent of brand) === */
    --color-success: #16a34a;
    --color-warning: #b45309;
    --color-error: #dc2626;
    --color-info: #0369a1;

    /* === MOTION === */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease-out;

    /* === SHADOWS === */
    --shadow-xs: 0 1px 2px rgba(12, 46, 78, 0.05);
    --shadow-sm: 0 2px 4px rgba(12, 46, 78, 0.08);
    --shadow-md: 0 4px 8px rgba(12, 46, 78, 0.08);
    --shadow-lg: 0 8px 16px rgba(12, 46, 78, 0.08);
    --shadow-xl: 0 12px 24px rgba(12, 46, 78, 0.10);
    --shadow-focus: 0 0 0 3px rgba(46, 139, 139, 0.15);  /* Teal-based focus ring */

    /* === BORDER RADIUS === */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 10px;  /* Cards — up from 8px */

    /* === LEGACY ALIASES (for backward compatibility) === */
    --primary-color: var(--color-brand);
    --primary-light: var(--color-brand-hover);
    --background-color: var(--color-surface-page);
    --content-bg: var(--color-surface-page);
    --text-color: var(--color-text-primary);
    --text-muted: var(--color-text-secondary);
    --border-color: var(--color-border);
    --hover-bg: var(--color-surface-muted);

    /* Legacy header */
    --header-bg: var(--color-sidebar-bg);
    --header-text: var(--color-text-on-dark);

    /* Sidebar aliases */
    --sidebar-bg: var(--color-sidebar-bg);
    --sidebar-text: var(--color-text-on-dark);
    --sidebar-border: var(--color-sidebar-border);
    --sidebar-muted: var(--color-text-muted-on-dark);
    --sidebar-link: var(--color-text-on-dark);
    --sidebar-hover: var(--color-sidebar-hover);
    --sidebar-active: var(--color-sidebar-active);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    overflow-x: hidden;
}

body {
    font-family: var(--font-sans);
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--color-text-primary);
    background-color: var(--color-surface-page);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
}

/* Modern focus states */
:focus-visible {
    outline: 2px solid var(--color-brand);
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* Link transitions */
a {
    transition: color var(--transition-fast);
}

/* Header */
header {
    background-color: var(--header-bg);
    color: var(--header-text);
    padding: 1rem 2rem;
}

header nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

header ul {
    list-style: none;
    display: flex;
    gap: 1.5rem;
}

header a {
    color: var(--header-text);
    text-decoration: none;
    opacity: 0.9;
    transition: opacity 0.2s;
}

header a:hover {
    opacity: 1;
}

/* Main Content */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Report Content Container */
.report-content {
    max-width: 1400px;
    margin: 0 auto;
    min-width: 0;
}

/* Page Header */
.page-header {
    margin-bottom: 2rem;
}

.page-header h2 {
    color: var(--color-text-primary);
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.page-header p {
    color: var(--color-text-secondary);
}

/* Segment narrative list (bulleted) */
.segment-narrative {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0 0;
    color: var(--color-text-secondary);
}

.segment-narrative li {
    padding-left: 1rem;
    position: relative;
    margin-bottom: 0.25rem;
}

.segment-narrative li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--color-text-muted);
}

/* KPI Cards */
.kpi-cards {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.kpi-card {
    flex: 1;
    min-width: 120px;
    background: var(--color-surface-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1rem;
    text-align: center;
    overflow: hidden;
}

.kpi-value {
    font-size: 1.625rem;  /* 26px */
    font-weight: 700;
    color: var(--color-text-primary);
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.kpi-label {
    font-size: 0.8125rem;  /* 13px */
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 0.375rem;
}

.kpi-sublabel {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

.kpi-positive {
    color: var(--color-brand);
}

.kpi-negative {
    color: var(--color-accent);
}

/* KPI YoY (embedded within card, secondary styling) */
.kpi-yoy {
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.kpi-yoy-positive {
    color: var(--color-brand);
}

.kpi-yoy-negative {
    color: var(--color-accent);
}

/* Filter Controls block wrapper (adds spacing below) */
.filter-controls-block {
    margin-bottom: 1.5rem;
}

.filter-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.toggle-control {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--color-text-primary);
    background: var(--color-surface-card);
    padding: 0.625rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    transition: border-color var(--transition-fast);
}

.toggle-control:hover {
    border-color: var(--color-brand);
}

.toggle-control input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
    accent-color: var(--color-brand);
}

/* Filter Panel */
.filter-panel {
    background: var(--color-surface-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.5rem;
    margin-bottom: 2rem;
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-group--toggles {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
}

.filter-group--toggles .filter-title {
    margin-bottom: 0.25rem;
}

.filter-group--toggles .toggle-label {
    margin-left: 0;
}

.filter-group label {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    font-weight: 500;
}

.filter-group select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background-color: var(--color-surface-card);
    cursor: pointer;
    transition: border-color var(--transition-fast),
                box-shadow var(--transition-fast);
}

.filter-group select:hover {
    border-color: var(--color-border-strong);
}

.filter-group select:focus {
    outline: none;
    border-color: var(--color-brand);
    box-shadow: var(--shadow-focus);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.toggle-label input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
    accent-color: var(--color-brand);
}

/* Table year filter checkboxes */
.table-year-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    align-items: center;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
    accent-color: var(--color-brand);
}

/* Form utility classes */
.form-input,
.form-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--color-text-primary);
    background: var(--color-surface-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-fast),
                box-shadow var(--transition-fast);
}

.form-input:hover,
.form-select:hover {
    border-color: var(--color-border-strong);
}

.form-input:focus,
.form-select:focus,
.form-input:focus-visible,
.form-select:focus-visible {
    outline: none;
    border-color: var(--color-brand);
    box-shadow: var(--shadow-focus);
}

.form-input::placeholder {
    color: var(--color-text-muted);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234A6580' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    padding-right: 2rem;
}

.form-checkbox {
    width: 1rem;
    height: 1rem;
    accent-color: var(--color-brand);
    cursor: pointer;
}

.form-label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-primary);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.form-check .form-label {
    margin-bottom: 0;
    font-weight: 400;
    cursor: pointer;
}

/* Narrative section */
.narrative {
    background: var(--color-surface-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.narrative h3 {
    color: var(--color-brand);
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.narrative p {
    color: var(--color-text-secondary);
    margin: 0;
}

/* Chart Container */
.chart-container {
    background: var(--color-surface-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

/* Chart loading state — shows on empty chart divs, removed when Plotly renders */
.chart-container > div:empty,
.chart-half > div:empty {
    position: relative;
    overflow: hidden;
    background: var(--color-surface-muted);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-container > div:empty {
    min-height: 400px;
}

.chart-half > div:empty {
    min-height: 300px;
}

/* Spinning ring + "Loading" label */
.chart-container > div:empty::before,
.chart-half > div:empty::before {
    content: '';
    width: 28px;
    height: 28px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-brand);
    border-radius: 50%;
    animation: chart-spin 0.8s linear infinite;
}

.chart-container > div:empty::after,
.chart-half > div:empty::after {
    content: 'Loading chart\2026';
    position: absolute;
    margin-top: 56px;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    letter-spacing: 0.02em;
}

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

#giving-chart,
#avg-chart,
#butterfly-chart,
#concentration-chart,
#composition-chart,
#revenue-composition-chart {
    width: 100%;
    height: 400px;
}

/* Side-by-side charts */
.chart-row {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-half {
    flex: 1;
    background: var(--color-surface-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    min-width: 0;
}

.chart-half > div {
    width: 100%;
    height: 300px;
}

/* Data Table */
.data-table {
    background: var(--color-surface-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
}

.table-wrapper {
    overflow-x: auto;
    position: relative; /* helps sticky header rendering in scrolling context */
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.table-header-left h3,
.table-header h3 {
    color: var(--color-brand);
    font-size: 1.25rem;
    margin: 0;
}

.table-subtitle {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    margin: 0.25rem 0 0 0;
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-controls label {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

.filter-controls select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background-color: var(--color-surface-card);
    cursor: pointer;
    transition: border-color var(--transition-fast),
                box-shadow var(--transition-fast);
}

.filter-controls select:hover {
    border-color: var(--color-border-strong);
}

.filter-controls select:focus {
    outline: none;
    border-color: var(--color-brand);
    box-shadow: var(--shadow-focus);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
    font-size: 0.875rem;
}

/* Per-page table min-widths (removed global 800px — caused mobile overflow) */

/* Sticky headers - opt-in via .sticky-header class or table-specific rules */

th, td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

th {
    background-color: var(--color-surface-muted);
    font-weight: 600;
    color: var(--color-text-primary);
}

/* Column group headers */
th.column-group {
    text-align: center;
    border-bottom: 2px solid var(--color-border);
    background-color: var(--color-surface-muted);
}

/* Sub-header row */
thead tr:nth-child(2) th {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

/* Row hover scoped to data tables (not global to avoid affecting tables in cards) */
.data-table tbody tr {
    transition: background-color var(--transition-fast);
}

.data-table tbody tr:hover {
    background-color: var(--color-surface-muted);
}

/* Numeric column alignment utility */
.col-numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Right-align numeric columns for specific report tables */
#band-table td:nth-child(n+3),
#band-table thead tr:nth-child(2) th,
#band-matrix td:nth-child(n+2),
#band-matrix th:nth-child(n+2),
.giving-table td:nth-child(n+2) {
    text-align: right;
}

/* Combined total column emphasis */
td.combined-total {
    font-weight: 600;
    background-color: var(--color-surface-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    text-decoration: none;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color var(--transition-fast),
                border-color var(--transition-fast),
                color var(--transition-fast);
}

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Primary button — darker teal for AA contrast with white text (5.20:1 base, 5.71:1 hover) */
.btn-primary,
.btn--primary {
    background-color: #267878;
    color: #fff;
    border-color: #267878;
}

.btn-primary:hover:not(:disabled),
.btn--primary:hover:not(:disabled) {
    background-color: #217070;
    border-color: #217070;
}

/* Secondary button - outlined */
.btn-secondary,
.btn--secondary {
    background-color: var(--color-surface-card);
    color: var(--color-text-primary);
    border-color: var(--color-border);
}

.btn-secondary:hover:not(:disabled),
.btn--secondary:hover:not(:disabled) {
    background-color: var(--color-surface-muted);
    border-color: var(--color-border-strong);
}

/* Ghost button - minimal */
.btn--ghost {
    background: transparent;
    color: var(--color-text-secondary);
    border-color: transparent;
}

.btn--ghost:hover:not(:disabled) {
    background: var(--color-surface-muted);
    color: var(--color-text-primary);
}

/* Size variants */
.btn-sm,
.btn--sm {
    padding: 0.25rem 0.625rem;
    font-size: 0.8125rem;
}

.btn--lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.4;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

/* Semantic badge variants */
.badge--success { background: #ecfdf5; color: #047857; }
.badge--warning { background: #fffbeb; color: #b45309; }
.badge--error   { background: #fef2f2; color: #b91c1c; }
.badge--info    { background: #f0f9ff; color: #0369a1; }
.badge--neutral { background: var(--color-surface-muted); color: var(--color-text-secondary); }

/* Priority band badges */
.badge--high { background: #fef2f2; color: #dc2626; }
.badge--medium { background: #fffbeb; color: #d97706; }
.badge--low { background: #f0fdf4; color: #16a34a; }

/* Segment badges (MECE taxonomy) */
.badge--champions { background: #d1fae5; color: #059669; }
.badge--loyal { background: #dbeafe; color: #2563eb; }
.badge--potential_loyalists { background: #ede9fe; color: #7c3aed; }
.badge--recent_one_time { background: #cffafe; color: #0891b2; }
.badge--at_risk { background: #fef3c7; color: #d97706; }
.badge--dormant_high_value { background: #fee2e2; color: #dc2626; }
.badge--dormant { background: #f3f4f6; color: #4b5563; }
.badge--dormant_limited_giving { background: #f9fafb; color: #9ca3af; }

/* Suppression status badges */
.badge--deceased { background: #6b7280; color: #fff; }
.badge--hard-optout { background: #dc2626; color: #fff; }
.badge--bounce { background: #f97316; color: #fff; }
.badge--data-quality { background: #eab308; color: #1f2937; }
.badge--internal-policy { background: #3b82f6; color: #fff; }
.badge--unknown { background: #e5e7eb; color: #6b7280; }
.badge--anonymous { background: #8b5cf6; color: #fff; }

/* Donor flags container (below location in donor cell) */
.donor-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.donor-flags .badge {
    font-size: 0.75rem;
    padding: 0.0625rem 0.375rem;
}

/* ==========================================================================
   Prioritization Table - Fixed Layout with Semantic Column Classes
   ========================================================================== */

/* Fixed table layout for predictable column widths */
.prioritization-table {
    table-layout: fixed;
    width: 100%;
    min-width: 1300px;
    border-collapse: separate;
    border-spacing: 0;
}

/* Column widths via colgroup */
.prioritization-table col.col-priority { width: 110px; }
.prioritization-table col.col-segment { width: 120px; }
.prioritization-table col.col-donor { width: 280px; }
.prioritization-table col.col-last-gift { width: 100px; }
.prioritization-table col.col-days-ago { width: 65px; }
.prioritization-table col.col-giving-2yr { width: 95px; }
.prioritization-table col.col-lifetime { width: 95px; }
.prioritization-table col.col-relationship-state { width: 190px; }
.prioritization-table col.col-observed-signals { width: 210px; }

/* Row dividers via box-shadow (reliable across browsers) */
.prioritization-table tbody td {
    border-bottom: none;
}

.prioritization-table tbody tr {
    box-shadow: inset 0 -1px 0 var(--color-border);
}

.prioritization-table tbody tr:last-child {
    box-shadow: none;
}

/* Sticky header with proper background and shadow */
.prioritization-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--color-surface-muted);
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
}

/* Typography classes */
.col-num {
    text-align: center;
}

.col-nowrap {
    white-space: nowrap;
    text-align: center;
}

.text-muted {
    color: var(--color-text-muted);
}

/* Priority cell - inner wrapper for flex layout */
.cell-priority__inner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.priority-score-muted {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    cursor: help;
}

/* Donor cell - left-aligned, stacked layout */
.cell-donor {
    text-align: left;
}

.cell-donor__inner {
    display: block;
    min-width: 0; /* Allow truncation */
}

.donor-name {
    display: block;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.donor-location {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.donor-stream {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* Salesforce deep-link (EN-016) */
.donor-sf-link {
    display: inline-block;
    margin-top: 0.0625rem;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    text-decoration: none;
}

.donor-sf-link:hover {
    color: var(--color-brand);
    text-decoration: underline;
}

.donor-sf-link:focus-visible {
    outline: 2px solid var(--color-brand);
    outline-offset: 2px;
    border-radius: 3px;
}

/* Segment cell - centered, allow badge to wrap */
.cell-segment {
    text-align: center;
}

.cell-segment .badge {
    white-space: normal;
    line-height: 1.3;
    text-align: center;
    display: inline-block;
}

/* Relationship State cell */
.cell-relationship-state {
    text-align: left;
}

/* Left-justified header for Relationship State column */
.prioritization-table .th-relationship-state {
    text-align: left;
}

/* Observed Signals cell - left-aligned */
.cell-observed-signals {
    text-align: left;
}

/* Observed Signals list */
.signals-list {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
}

.signals-list li {
    position: relative;
    padding-left: 0.9rem;
    line-height: 1.35;
    margin-bottom: 0.2rem;
    text-align: left;
}

.signals-list li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.72em;
    width: 0.45rem;
    height: 1px;
    background: currentColor;
    opacity: 0.6;
}

/* Score-based color gradient: 1 (red) → 5 (green), 0 = warning (gray) */
/* ::before uses currentColor so inherits automatically */
.signals-list li.signal-score-0 { color: #6b7280; }  /* gray - data quality issue */
.signals-list li.signal-score-1 { color: #dc2626; }  /* red */
.signals-list li.signal-score-2 { color: #ea580c; }  /* orange */
.signals-list li.signal-score-3 { color: #ca8a04; }  /* yellow/amber */
.signals-list li.signal-score-4 { color: #65a30d; }  /* lime */
.signals-list li.signal-score-5 { color: #16a34a; }  /* green */

.signals-more {
    color: var(--color-text-secondary);
    font-style: italic;
}

.signals-more::before {
    content: none;
}

/* Segment checkboxes */
.segment-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    align-items: center;
}

/* Row hover */
.prioritization-table tbody tr:hover {
    background-color: var(--color-surface-muted);
}

/* Pagination Controls */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 0;
    border-top: 1px solid var(--color-border);
    margin-top: 1rem;
    flex-wrap: wrap;
}

.pagination__info {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.pagination__controls {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.pagination__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem 0.625rem;
    font-size: 0.8125rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface-card);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: background-color var(--transition-fast),
                border-color var(--transition-fast),
                color var(--transition-fast);
    min-width: 2rem;
}

.pagination__btn:hover:not(:disabled) {
    background: var(--color-surface-muted);
    border-color: var(--color-border-strong);
    color: var(--color-text-primary);
}

.pagination__btn:disabled,
.pagination__btn--disabled {
    opacity: 0.4;
    color: var(--color-text-muted);
    cursor: not-allowed;
    user-select: none;
}

.pagination__btn--disabled:hover {
    background: var(--color-surface-card);
    border-color: var(--color-border);
}

.pagination__page {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    padding: 0 0.5rem;
}

.pagination__size {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.pagination__size-label {
    color: var(--color-text-muted);
}

.pagination__size-select {
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    background: var(--color-surface-card);
    cursor: pointer;
    transition: border-color var(--transition-fast),
                box-shadow var(--transition-fast);
}

.pagination__size-select:hover {
    border-color: var(--color-border-strong);
}

.pagination__size-select:focus {
    outline: none;
    border-color: var(--color-brand);
    box-shadow: var(--shadow-focus);
}

/* Table Toolbar (title left, controls right) */
.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

.table-toolbar__header {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.table-toolbar__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-brand);
    margin: 0;
}

.table-toolbar__subtitle {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    margin: 0;
}

.table-toolbar__controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.table-toolbar__info {
    color: var(--color-text-muted);
}

.table-toolbar__pagination {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.table-toolbar__pagination .pagination__btn {
    padding: 0.25rem 0.5rem;
    min-width: 1.5rem;
    font-size: 0.875rem;
}

.table-toolbar__pagination .pagination__page {
    padding: 0 0.375rem;
    font-size: 0.8125rem;
}

.table-toolbar__size {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.table-toolbar__size-label {
    color: var(--color-text-muted);
    font-size: 0.8125rem;
}

.table-toolbar__export {
    white-space: nowrap;
}

/* Sortable Table Headers */
th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 1.25rem;
}

th.sortable:hover {
    background-color: var(--color-surface-muted);
}

th.sortable .sort-indicator {
    position: absolute;
    right: 0.375rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.625rem;
    color: var(--color-text-muted);
}

th.sortable .sort-indicator::after {
    content: "▲▼";
    font-size: 0.55rem;
    opacity: 0.35;
    display: inline-block;
    transform: translateY(-1px);
}

th.sortable.sorted .sort-indicator::after {
    opacity: 1;
    color: var(--color-brand);
}

th.sortable.sorted--asc .sort-indicator::after {
    content: '\25B2';
}

th.sortable.sorted--desc .sort-indicator::after {
    content: '\25BC';
}

/* ==========================================================================
   Revenue Intelligence Components
   ========================================================================== */

/* Stream Summary Cards (Individual, Grant, Special Account) */
.stream-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stream-card {
    background: var(--color-surface-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.25rem;
    border-top: 3px solid var(--color-border);
}

/* Stream-specific accent colors (top border) */
.stream-card--individual { border-top-color: #0d9488; }  /* Teal 600 */
.stream-card--grant { border-top-color: #d97706; }       /* Amber 600 */
.stream-card--special_account,
.stream-card--special-account,
.stream-card--special { border-top-color: #7c3aed; }  /* Violet 600 */

.stream-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.stream-card__title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
}

.stream-card__change {
    font-size: 0.75rem;
    font-weight: 500;
}

.stream-card__revenue {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text-primary);
    line-height: 1.2;
    margin-bottom: 0.75rem;
    font-variant-numeric: tabular-nums;
}

.stream-card__metrics {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

.stream-card__metric {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.stream-card__metric-label {
    color: var(--color-text-muted);
    font-size: 0.8125rem;
}

.stream-card__metric-value {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--color-text-primary);
    font-variant-numeric: tabular-nums;
}

/* Analysis Grid (Bridge left, Concentration right) */
.analysis-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.analysis-grid__left,
.analysis-grid__right {
    background: var(--color-surface-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem;
    min-width: 0; /* Prevent overflow in grid */
}

.analysis-section__title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0 0 1rem 0;
}

/* Bridge Waterfall Chart Container */
.bridge-chart {
    width: 100%;
    height: 280px;
}

/* Bridge Formula Row */
.bridge-formula {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem;
    margin-top: 1rem;
    background: var(--color-surface-muted);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}

.bridge-formula__item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.bridge-formula__label {
    color: var(--color-text-secondary);
}

.bridge-formula__value {
    font-weight: 600;
    color: var(--color-text-primary);
}

.bridge-formula__operator {
    color: var(--color-text-muted);
    font-weight: 500;
    padding: 0 0.25rem;
}

.bridge-formula__equals {
    color: var(--color-text-muted);
    font-weight: 600;
    padding: 0 0.5rem;
}

/* Concentration Bars (CSS-based, no chart library) */
.concentration-bars {
    margin-bottom: 1.5rem;
}

.concentration-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.625rem;
}

.concentration-bar:last-child {
    margin-bottom: 0;
}

.concentration-bar__label {
    flex-shrink: 0;
    width: 50px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    text-align: right;
}

.concentration-bar__track {
    flex: 1;
    height: 20px;
    background: var(--color-surface-muted);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.concentration-bar__fill {
    height: 100%;
    background: var(--color-brand);
    border-radius: var(--radius-sm);
    transition: width var(--transition-base);
}

.concentration-bar__value {
    flex-shrink: 0;
    width: 45px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text-primary);
    font-variant-numeric: tabular-nums;
}

/* Stream Mix Chart */
.stream-mix-chart {
    width: 100%;
    height: 200px;
    margin-top: 1rem;
}

/* Trend Cards (Sparklines) */
.trend-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.trend-card {
    background: var(--color-surface-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1rem;
}

.trend-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.trend-card__title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin: 0;
}

.trend-card__delta {
    font-size: 0.8125rem;
    font-weight: 500;
}

.trend-card__value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text-primary);
    line-height: 1.2;
    margin-bottom: 0.5rem;
    font-variant-numeric: tabular-nums;
}

.trend-card__sparkline {
    width: 100%;
    height: 80px;
}

/* Footer Stats */
.footer-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding: 1rem;
    margin-top: 1rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
}

.footer-stat {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.footer-stat__label {
    color: var(--color-text-muted);
}

.footer-stat__value {
    font-weight: 600;
    color: var(--color-text-primary);
    font-variant-numeric: tabular-nums;
}

/* Revenue Page Header with Period Selector */
.revenue-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.revenue-header__title {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
}

.revenue-header__subtitle {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin-top: 0.25rem;
}

.revenue-header__title,
.revenue-header__subtitle {
    min-width: 0; /* Prevent overflow with long text */
}

.revenue-header__controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Stream Filter Dropdown (HTMX) */
.stream-filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stream-filter__label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

/* Section Header with Filter */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.section-header__title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
}

/* ================================================================
   Login / Pending Approval Pages
   ================================================================ */

.login-page {
    background-color: var(--color-surface-page);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-container {
    width: 100%;
    max-width: 440px;
    padding: 1rem;
}

.login-card {
    background: var(--color-surface-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.login-logo {
    max-width: 280px;
    width: 100%;
    height: auto;
    margin-bottom: 1.5rem;
}

.login-subtitle {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin-bottom: 1.5rem;
}

.btn-login {
    display: inline-block;
    width: 100%;
    padding: 0.75rem 1.5rem;
    background-color: var(--color-brand);
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.btn-login:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

@media (hover: hover) {
    .btn-login:hover {
        background-color: var(--color-brand-hover);
    }
}

/* Logout form in header dropdown — matches .user-menu-dropdown a in app.css */
.logout-form {
    margin: 0;
    padding: 0;
}

.logout-form button {
    background: none;
    border: none;
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--color-text-primary);
    text-decoration: none;
    cursor: pointer;
}

.logout-form button:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

@media (hover: hover) {
    .logout-form button:hover {
        background-color: var(--color-surface-muted);
    }
}

/* Revenue Intelligence Responsive */
@media (max-width: 1100px) {
    .stream-cards {
        grid-template-columns: 1fr;
    }

    .analysis-grid {
        grid-template-columns: 1fr;
    }

    .trend-cards {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 850px) {
    .stream-card__revenue {
        font-size: 1.25rem;
    }

    .trend-card__value {
        font-size: 1.1rem;
    }

    .footer-stats {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .bridge-formula {
        font-size: 0.75rem;
    }
}

@media (max-width: 600px) {
    .revenue-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .footer-stats {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }

    .bridge-formula {
        flex-direction: column;
        gap: 0.25rem;
    }

    .bridge-formula__operator,
    .bridge-formula__equals {
        display: none;
    }
}

/* Responsive */
@media (max-width: 1400px) {
    .kpi-value {
        font-size: 1.25rem;
    }
}

@media (max-width: 1100px) {
    .kpi-value {
        font-size: 1.1rem;
    }
}

@media (max-width: 900px) {
    .kpi-value {
        font-size: 1rem;
    }
}

@media (max-width: 850px) {
    header nav {
        flex-direction: column;
        gap: 1rem;
    }

    main {
        padding: 1rem;
    }

    .kpi-cards {
        gap: 0.75rem;
    }

    .kpi-card {
        min-width: calc(50% - 0.5rem);
        padding: 0.75rem;
    }

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

    .chart-container,
    .data-table,
    .chart-half {
        padding: 1rem;
    }

    .chart-row {
        flex-direction: column;
    }

    #giving-chart,
    #avg-chart,
    #butterfly-chart,
    #concentration-chart,
    #composition-chart,
    #revenue-composition-chart,
    .chart-half > div {
        height: 300px;
    }

    table {
        font-size: 0.75rem;
    }

    th, td {
        padding: 0.35rem 0.5rem;
    }

    th.column-group {
        font-size: 0.75rem;
    }

    thead tr:nth-child(2) th {
        font-size: 0.7rem;
    }

    .table-toolbar,
    .pagination,
    .table-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .table-toolbar__controls,
    .table-toolbar__pagination,
    .table-toolbar__size,
    .pagination__controls,
    .table-header-right {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
        min-width: 0;
        gap: 0.5rem;
        justify-content: flex-start;
    }

    .table-toolbar__export,
    .pagination__page,
    .table-header__info {
        white-space: normal;
    }
}

@media (max-width: 600px) {
    .kpi-card {
        min-width: 100%;
    }

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

    #giving-chart,
    #avg-chart,
    #butterfly-chart,
    #concentration-chart,
    #composition-chart,
    #revenue-composition-chart,
    .chart-half > div {
        height: 250px;
    }

    table {
        font-size: 0.65rem;
    }

    th, td {
        padding: 0.25rem 0.35rem;
    }
}

/* Prioritization table responsive - tighter padding, keep horizontal scroll */
@media (max-width: 1400px) {
    .prioritization-table th,
    .prioritization-table td {
        padding: 0.375rem 0.5rem;
    }

    .table-subtitle,
    .table-toolbar__subtitle {
        display: none;
    }
}

/* Accessibility: Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ==========================================================================
   Giving Scorecard (015-board-report) — above-the-fold board view
   Scoped under .scorecard so the component classes (kpi-card, kpi-cards,
   analysis-grid, filter-group) override the globals within this page only
   and never affect other report pages. Reuses global .form-select,
   .kpi-positive, .kpi-negative for app consistency.
   ========================================================================== */

:root {
    /* Revenue-stream swatches — mirror getStreamColors() in plotly_theme.js so
       the mix legend matches the donut chart colors. */
    --color-stream-individual: #0d9488;
    --color-stream-grant: #d97706;
    --color-stream-special: #7c3aed;
}

/* --- Header + period selector --- */
.scorecard .report-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 2rem; margin-bottom: 1.5rem; padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--color-border);
}
.scorecard .report-header__eyebrow {
    font-size: 0.8125rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--color-brand); margin-bottom: 0.25rem;
}
.scorecard .report-header__title {
    margin: 0 0 0.375rem; font-size: 1.875rem; font-weight: 700; letter-spacing: -0.01em;
}
.scorecard .report-header__subtitle {
    margin: 0; font-size: 0.9375rem; color: var(--color-text-muted);
}
.scorecard .report-controls { flex-shrink: 0; display: flex; gap: 0.75rem; align-items: flex-end; }
.scorecard .filter-group { display: flex; flex-direction: column; gap: 0.375rem; }
.scorecard .filter-group > label {
    font-size: 0.6875rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--color-text-muted);
}
.scorecard .segmented {
    display: inline-flex; border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md); overflow: hidden; background: white;
}
.scorecard .segmented button {
    font-family: var(--font-sans); font-size: 0.875rem; font-weight: 500;
    padding: 0.45rem 0.85rem; border: none; background: white;
    color: var(--color-text-secondary); cursor: pointer; border-right: 1px solid var(--color-border);
}
.scorecard .segmented button:last-child { border-right: none; }
.scorecard .segmented button.is-active { background: var(--color-brand); color: white; font-weight: 600; }
/* A touch more right padding than the global .form-select (2rem) so the longest
   option — "… (current)" — clears the dropdown caret. */
.scorecard .form-select { padding-right: 2.5rem; }
.scorecard .scorecard-loading { align-self: center; font-size: 0.8125rem; color: var(--color-text-muted); }

/* --- Hero pair --- */
.scorecard .hero-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: 1.25rem; }
.scorecard .hero-card {
    background: var(--color-surface-card); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); padding: 1.5rem 1.75rem; box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column;
}
.scorecard .hero-card__eyebrow {
    font-size: 1.25rem; font-weight: 600; color: var(--color-brand); margin-bottom: 0.25rem;
}
.scorecard .hero-card__label {
    font-size: 1rem; color: var(--color-text-secondary);
    letter-spacing: 0; margin-bottom: 0.15rem;
}
.scorecard .hero-card__value {
    font-size: 2.75rem; font-weight: 700; line-height: 1; letter-spacing: -0.02em; margin: 0.1rem 0 0.4rem;
}
.scorecard .hero-card__value-suffix {
    font-size: 1rem; font-weight: 500; color: var(--color-text-muted); letter-spacing: 0;
}
.scorecard .hero-card__delta {
    display: inline-flex; align-items: center; gap: 0.375rem; font-size: 0.9375rem; font-weight: 600;
}
.scorecard .hero-card__context {
    font-size: 0.8125rem; color: var(--color-text-secondary);
    margin-top: 0.75rem; padding-top: 0.7rem; border-top: 1px solid var(--color-border);
}
.scorecard .hero-card__chart { height: 185px; margin-top: 1rem; }

/* --- KPI strip --- */
.scorecard .kpi-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.scorecard .kpi-card {
    background: var(--color-surface-card); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); padding: 1.2rem 1.375rem; box-shadow: var(--shadow-sm); text-align: left;
    display: flex; flex-direction: column;
}
.scorecard .kpi-card__label {
    font-size: 1.25rem; font-weight: 600; color: var(--color-brand); margin-bottom: 0.25rem;
}
.scorecard .kpi-card__desc {
    font-size: 1rem; color: var(--color-text-secondary); margin-bottom: 0.7rem;
}
.scorecard .kpi-card__primary { display: flex; align-items: baseline; gap: 0.4rem; }
.scorecard .kpi-card__value { font-size: 2rem; font-weight: 700; line-height: 1; letter-spacing: -0.01em; }
.scorecard .kpi-card__period { font-size: 0.8125rem; color: var(--color-text-muted); font-weight: 500; }
.scorecard .kpi-card__delta { font-size: 0.8125rem; font-weight: 600; margin-top: 0.35rem; }
.scorecard .kpi-card__secondary {
    margin-top: auto; padding-top: 0.55rem; border-top: 1px solid var(--color-border);
    font-size: 0.9375rem; font-variant-numeric: tabular-nums;
}
.scorecard .kpi-card__secondary strong { font-weight: 700; }
.scorecard .kpi-card__secondary span { color: var(--color-text-muted); font-size: 0.8125rem; }
.scorecard .kpi-muted { color: var(--color-text-muted); }

/* Average-gift mini grid */
.scorecard .avg-grid { display: grid; grid-template-columns: auto 1fr 1fr; gap: 0.5rem 0.9rem; align-items: baseline; }
.scorecard .avg-grid__head {
    font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--color-text-muted); text-align: right;
}
.scorecard .avg-grid__rowlabel { font-size: 0.875rem; color: var(--color-text-secondary); }
.scorecard .avg-grid__v { font-size: 1.2rem; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.scorecard .avg-grid__v--muted { color: var(--color-text-muted); font-weight: 600; font-size: 1rem; }

/* --- Analysis cards (mix + net donor change) --- */
.scorecard .analysis-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: 1.25rem; }
.scorecard .analysis-card {
    background: var(--color-surface-card); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); padding: 1.4rem 1.6rem; box-shadow: var(--shadow-sm);
}
.scorecard .section-title { font-size: 1.25rem; font-weight: 600; color: var(--color-brand); margin: 0; }
.scorecard .card-head { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 1rem; }
.scorecard .card-head__meta { font-size: 1rem; color: var(--color-text-secondary); }

/* Revenue mix — two comparison pills (current FY vs prior FY) + legend table */
.scorecard .mix-pills { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1.1rem; }
.scorecard .mix-pill-row { display: grid; grid-template-columns: 3rem 1fr; gap: 0.75rem; align-items: center; }
.scorecard .mix-pill-year {
    font-size: 0.875rem; font-weight: 700; color: var(--color-text-primary);
    text-align: right; font-variant-numeric: tabular-nums;
}
.scorecard .mix-pill-year--prior { color: var(--color-text-muted); font-weight: 600; }
.scorecard .mix-pill {
    display: flex; height: 34px; border-radius: 999px;
    background: var(--color-surface-muted); box-shadow: inset 0 0 0 1px var(--color-border);
}
/* No overflow:hidden on the pill — segments round their own outer corners so the
   hover tooltip can escape upward instead of being clipped. */
.scorecard .mix-pill-seg {
    position: relative; display: flex; align-items: center; justify-content: center; min-width: 0;
}
.scorecard .mix-pill-seg:first-child { border-top-left-radius: 999px; border-bottom-left-radius: 999px; }
.scorecard .mix-pill-seg:last-child { border-top-right-radius: 999px; border-bottom-right-radius: 999px; }
/* In-segment % label; the template only renders it when the sliver is wide enough
   (server-side width threshold) so it never overflows its segment. */
.scorecard .mix-pill-seg__label {
    font-size: 0.75rem; font-weight: 700; color: #fff; white-space: nowrap;
    letter-spacing: 0.01em; text-shadow: 0 1px 1px rgba(12, 46, 78, 0.35);
}
/* Instant styled hovertip (no JS) — content from data-tip on the segment. */
.scorecard .mix-pill-seg[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute; left: 50%; bottom: calc(100% + 7px); transform: translateX(-50%);
    background: var(--color-text-primary); color: #fff;
    font-size: 0.75rem; font-weight: 600; white-space: nowrap;
    padding: 0.35rem 0.6rem; border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md); z-index: 20; pointer-events: none;
}
.scorecard .mix-pill-seg[data-tip]:hover::before {
    content: ''; position: absolute; left: 50%; bottom: calc(100% + 2px); transform: translateX(-50%);
    border: 5px solid transparent; border-top-color: var(--color-text-primary);
    z-index: 20; pointer-events: none;
}

.scorecard .mix-table { width: 100%; border-collapse: collapse; }
.scorecard .mix-table th {
    font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--color-text-secondary); padding: 0.5rem 0.5rem 0.55rem; background: var(--color-surface-muted);
    border-bottom: 1px solid var(--color-border-strong);
}
.scorecard .mix-table td { font-size: 0.95rem; padding: 0.75rem 0.5rem; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.scorecard .mix-table tr:last-child td { border-bottom: none; }
.scorecard .mix-table th.mix-table__num,
.scorecard .mix-table td.mix-table__num { text-align: right; font-variant-numeric: tabular-nums; }
.scorecard .mix-table th.mix-table__stream,
.scorecard .mix-table td.mix-table__stream { text-align: left; }
.scorecard .mix-table td.mix-table__stream { font-weight: 500; white-space: nowrap; }
.scorecard .mix-table__swatch {
    display: inline-block; width: 11px; height: 11px; border-radius: 3px;
    margin-right: 0.5rem; vertical-align: baseline;
}
/* Make the Revenue mix card fill the row height next to Net donor change:
   stack as a column, give the pills breathing room, and let the legend table
   grow to absorb the remaining height (its rows distribute the extra space). */
.scorecard .analysis-card--mix { display: flex; flex-direction: column; }
.scorecard .analysis-card--mix .mix-pills { margin: 0.5rem 0 1.5rem; }
.scorecard .analysis-card--mix .mix-table { flex: 1; }

/* Net donor change (leaky bucket) */
.scorecard .flow-list { display: flex; flex-direction: column; gap: 0.5rem; }
.scorecard .flow-row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.scorecard .flow-row__label { font-size: 0.9rem; color: var(--color-text-secondary); }
.scorecard .flow-row__op { font-weight: 700; margin-right: 0.3rem; color: var(--color-text-muted); }
.scorecard .flow-row__op--minus { color: var(--color-error); }
.scorecard .flow-row__value { font-size: 1.05rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.scorecard .flow-row--total { border-top: 1px solid var(--color-border); padding-top: 0.5rem; margin-top: 0.1rem; }
.scorecard .flow-row--total .flow-row__label,
.scorecard .flow-row--total .flow-row__value { font-weight: 700; }
.scorecard .leaky-net {
    margin-top: 0.9rem; padding: 0.7rem 1rem; border-radius: var(--radius-md);
    background: var(--color-brand-subtle); display: flex; justify-content: space-between; align-items: baseline;
}
.scorecard .leaky-net__label { font-size: 0.8125rem; font-weight: 600; color: var(--color-text-secondary); }
.scorecard .leaky-net__value {
    font-size: 1.375rem; font-weight: 700; color: var(--color-brand); font-variant-numeric: tabular-nums;
}
.scorecard .leaky-note { font-size: 0.75rem; color: var(--color-text-muted); margin-top: 0.45rem; }

/* ==========================================================================
   Below the fold — Top Gifts only (donor_viewer-gated, screen-only). The rest of
   the drill-in (retention-by-value / concentration / detail stats / lapsed) was
   removed to keep this a board deck; the snapshot mart that backed it stays in
   place for future use. .belowfold wraps Top Gifts for Track 5's print hide.
   ========================================================================== */

/* Top Gifts — ONE unified card; the 3 streams are columns inside it, divided by
   thin rules and tagged by a stream-colored underline on each column header.
   (donor_viewer-gated — names render through normal escaping) */
.scorecard .top-gifts {
    background: var(--color-surface-card); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); padding: 1.4rem 1.6rem; box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}
.scorecard .top-gifts__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; }
.scorecard .top-gifts__col {
    display: flex; flex-direction: column;
    padding: 0 1.5rem; border-left: 1px solid var(--color-border);
}
.scorecard .top-gifts__col:first-child { padding-left: 0; border-left: none; }
.scorecard .top-gifts__col:last-child { padding-right: 0; }
/* Shaded column-header row — mirrors the Revenue Mix legend treatment: a muted
   fill bar with a stream-colored swatch + the stream label. */
.scorecard .top-gifts__col-header {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--color-surface-muted); border-radius: var(--radius-md);
    padding: 0.5rem 0.75rem; margin-bottom: 0.9rem;
}
.scorecard .top-gifts__col-title {
    display: inline-flex; align-items: center; gap: 0.45rem;
    font-size: 0.9375rem; font-weight: 700; color: var(--color-text-primary);
}
.scorecard .top-gifts__swatch { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }
.scorecard .top-gifts__col-count { font-size: 0.8125rem; color: var(--color-text-muted); }
.scorecard .top-gifts__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.8rem; flex: 1; }
.scorecard .top-gifts__row { display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem; }
.scorecard .top-gifts__name { font-size: 0.95rem; font-weight: 500; line-height: 1.3; }
.scorecard .top-gifts__date { font-size: 0.8125rem; color: var(--color-text-muted); margin-top: 0.15rem; }
.scorecard .top-gifts__amount { font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.scorecard .top-gifts__empty { font-size: 0.9rem; color: var(--color-text-muted); font-style: italic; }
.scorecard .top-gifts__footer {
    margin-top: 1rem; padding-top: 0.7rem; border-top: 1px dashed var(--color-border);
    font-size: 0.8125rem; color: var(--color-text-muted); text-align: center;
}
.scorecard .top-gifts__footer strong { color: var(--color-text-secondary); font-weight: 600; }

/* --- Responsive --- */
@media (max-width: 1100px) {
    .scorecard .report-header { flex-direction: column; }
    .scorecard .hero-grid,
    .scorecard .analysis-grid { grid-template-columns: 1fr; }
    .scorecard .kpi-cards { grid-template-columns: repeat(2, 1fr); }
    .scorecard .top-gifts__grid { grid-template-columns: 1fr; }
    .scorecard .top-gifts__col { border-left: none; padding: 0; }
    .scorecard .top-gifts__col + .top-gifts__col { border-top: 1px solid var(--color-border); margin-top: 1rem; padding-top: 1rem; }
}
