/* ============================================================
   tracker.css — Fiducia Giving Global Styles
   ============================================================
   Mobile-first design. All base styles target mobile;
   larger breakpoints are added via min-width media queries.

   TABLE OF CONTENTS
   -----------------
   1. Design Tokens (CSS Custom Properties)
   2. Base & Typography
   3. Layout — Sticky Headers, Scroll Behavior
   4. Components — Badges & Tags
   5. Components — Buttons & CTA
   6. Components — Tooltips & Popovers
   7. Components — Tabs (Expense, Org Card, Detail View)
   8. Components — Cards (Org Cards, Detail Cards)
   9. Components — Forms & Filters (Multi-Select, Filter Bar)
   10. Components — Carousel
   11. Components — Callouts & Legends
   12. Components — Collapsible Sections
   13. Tracker — Donation Selector, Map, Receipt
   14. Page — Search (AG Grid, Detail Views)
   15. Page — Nonprofit (Org Selector, Sticky Header)
   16. Site Footer
   ============================================================ */

/* ============================================================
   1. Design Tokens (CSS Custom Properties)
   ============================================================ */
:root {
    /* Layout heights - single source of truth */
    --header-height: 64px;           /* h-16 in Tailwind = 64px */
    --header-height-mobile: 56px;    /* h-14 in Tailwind = 56px */
    --selector-bar-height: 48px;     /* Height of nonprofit selector bar */
    --footer-height: 52px;           /* Sticky footer calculator bar */
    --footer-height-mobile: 44px;
    --combined-nav-height: 112px;    /* header + selector bar */

    /* Sticky offsets with padding */
    --sticky-offset: calc(var(--header-height) + 16px);
    --sticky-offset-with-selector: calc(var(--combined-nav-height) + 16px);

    /* Widget spacing - tighter gaps between cards */
    --widget-gap: 1rem;
    --widget-gap-sm: 1.5rem;
}

/* Mobile-specific tokens */
@media (max-width: 768px) {
    :root {
        --header-height: var(--header-height-mobile);
        --combined-nav-height: calc(var(--header-height-mobile) + var(--selector-bar-height));
    }
}

/* ============================================================
   2. Base & Typography
   ============================================================ */
body {
    font-family: 'Merriweather', serif;
    color: #1a1a1a;
    background-color: #f8f9fa;
}
.sans {
    font-family: 'Inter', sans-serif;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* === Layout: Sticky graphic on right === */
.sticky-graphic {
    overflow: hidden;
}

/* === Card sections (new layout) === */
.card-section {
    z-index: 10;
    position: relative;
}

/* Legacy step-content support */
.step-content {
    display: flex;
    align-items: center;
    padding: 1rem 0;
    z-index: 10;
    position: relative;
}

.step-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid #e2e8f0;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    max-width: 100%;
}

/* === Sticky panel on desktop === */
@media (min-width: 1024px) {
    /* Default: Account for header + selector bar (explore page) */
    .sticky-graphic {
        position: sticky;
        top: var(--sticky-offset-with-selector);
        height: calc(100vh - var(--combined-nav-height) - 16px);
        min-height: 500px;
        z-index: 51;
    }

    /* Landing page: Only account for header (no selector bar) */
    body.page-landing .sticky-graphic {
        top: var(--sticky-offset);
        height: calc(100vh - var(--header-height) - 16px);
        min-height: 500px;
    }

    /* Map container should expand to fill available space */
    .sticky-graphic .map-container {
        flex: 1;
        min-height: 250px;
    }
}

/* === Map markers === */
.map-marker {
    transition: all 0.5s ease;
    opacity: 0;
    transform: scale(0);
}
.map-marker.active {
    opacity: 1;
    transform: scale(1);
}

/* === Donation selector === */
.amount-btn {
    transition: all 0.2s ease;
    border: 2px solid #e2e8f0;
    background: white;
    cursor: pointer;
}
.amount-btn:hover {
    border-color: #10b981;
    background: #ecfdf5;
}
.amount-btn.active {
    border-color: #059669;
    background: #059669;
    color: white;
    box-shadow: 0 4px 6px -1px rgba(5, 150, 105, 0.3);
}

.custom-input:focus {
    outline: none;
    border-color: #059669;
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.2);
}

/* === Amount transitions === */
.amount-value {
    transition: all 0.3s ease;
}

/* === Pulse hint on donation selector === */
@keyframes gentle-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); }
    50% { box-shadow: 0 0 0 8px rgba(5, 150, 105, 0.1); }
}
.pulse-hint {
    animation: gentle-pulse 2s ease-in-out 3;
}

/* === MapLibre Map Markers === */
.maplibre-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    transform: scale(0);
    transition: all 0.4s ease;
    pointer-events: none;
}

.maplibre-marker.active {
    opacity: 1;
    transform: scale(1);
}

.maplibre-marker .marker-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.maplibre-marker .marker-dot.pulse {
    animation: marker-pulse 1.5s ease-in-out infinite;
}

@keyframes marker-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3); }
    50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0), 0 2px 8px rgba(0, 0, 0, 0.3); }
}

.maplibre-marker .marker-label {
    margin-top: 4px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 10px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

/* Map reset button */
.map-reset-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 10;
    padding: 6px 12px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    color: #334155;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.map-reset-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

/* === Receipt Accordion === */
.receipt-header {
    cursor: pointer;
}

.receipt-header:hover {
    background-color: rgba(5, 150, 105, 0.05);
}

.receipt-chevron {
    transition: transform 0.2s ease;
}

.receipt-details {
    animation: slideDown 0.25s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === Calculation Note Badge === */
.calc-note {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-family: 'Inter', sans-serif;
    color: #64748b;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 4px;
}

.calc-note i {
    width: 10px;
    height: 10px;
}

/* ============================================================
   3. Layout — Responsive Adjustments
   ============================================================ */

/* Mobile adjustments (< 640px) */
@media (max-width: 640px) {
    /* Amount selector: 2 columns on tiny screens */
    .amount-selector-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Cards: Reduce padding */
    .card-section > .bg-white {
        padding: 1rem;
    }

    /* Receipt: Smaller text */
    .receipt-details {
        font-size: 0.75rem;
    }

    /* Impact areas: Tighter spacing */
    .impact-area-badge {
        display: block;
        margin-top: 0.5rem;
    }
}

/* Tablet adjustments (641px - 1023px) */
@media (min-width: 641px) and (max-width: 1023px) {
    .card-section {
        max-width: 100%;
        margin-left: auto;
        margin-right: auto;
    }
}

/* Desktop content - no max-width restriction for full-width layout */
@media (min-width: 1024px) {
    .card-section {
        max-width: 100%;
    }
}

/* ============================================================
   14. Page — Search & Nonprofit Base
   ============================================================ */

/* Search and nonprofit pages — no extra padding */
body.page-search,
body.page-nonprofit {
    padding-bottom: 0;
}

/* Scroll padding accounts for fixed + sticky headers on nonprofit page */
body.page-nonprofit {
    scroll-padding-top: calc(var(--header-height) + 120px);
}

/* ---- AG Grid Column Group Styling ---- */

/* Group header backgrounds */
.ag-header-group-cell.ag-header-group-revenue { background-color: #ecfdf5; }
.ag-header-group-cell.ag-header-group-expenses { background-color: #fffbeb; }
.ag-header-group-cell.ag-header-group-assets { background-color: #eff6ff; }

/* Group header text colors */
.ag-header-group-revenue .ag-header-group-text { color: #047857; font-weight: 600; }
.ag-header-group-expenses .ag-header-group-text { color: #b45309; font-weight: 600; }
.ag-header-group-assets .ag-header-group-text { color: #1d4ed8; font-weight: 600; }

/* Left border on first column of each group — separates groups visually */
.ag-header-cell.col-group-start,
.ag-cell.col-group-start { border-left: 2px solid #e2e8f0 !important; }

/* Total value cells — subtle emphasis */
.ag-cell.cell-total { background-color: #f8fafc; font-weight: 600; }

/* ---- Multi-Select Dropdown ---- */

.ms-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    margin-top: 4px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    overflow: hidden;
}

.ms-options {
    max-height: 280px;
    overflow-y: auto;
}

.ms-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: background-color 0.1s;
}

.ms-option:hover { background-color: #f8fafc; }
.ms-option.selected { background-color: #ecfdf5; }

.ms-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    font-size: 0.6875rem;
    background: #ecfdf5;
    color: #047857;
    border-radius: 9999px;
    white-space: nowrap;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ms-tag-remove {
    cursor: pointer;
    font-size: 0.875rem;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.1s;
}

.ms-tag-remove:hover { opacity: 1; }

/* ============================================================
   6. Components — Tooltips & Popovers
   ============================================================
   All .tooltip-trigger elements open a fixed-position popover
   on click, managed by JS in base.html. The inline .tooltip-content
   is kept hidden and used only as a data source.
   ============================================================ */

.tooltip-trigger {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

/* The inline .tooltip-content is always hidden — JS reads its innerHTML */
.tooltip-content {
    display: none !important;
}

/* ---- Global tooltip popover (appended to <body> by JS) ---- */

.tooltip-popover-backdrop {
    position: fixed;
    inset: 0;
    z-index: 99998;
}

.tooltip-popover {
    position: fixed;
    z-index: 99999;
    width: 300px;
    max-width: calc(100vw - 32px);
    background: #ffffff;
    color: #334155;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.6;
    text-align: left;
    font-family: 'Inter', sans-serif;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.18),
                0 8px 16px -6px rgba(0, 0, 0, 0.1);
    animation: tooltipPopIn 0.15s ease-out;
}

@keyframes tooltipPopIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

.tooltip-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 8px;
    border-bottom: 1px solid #f1f5f9;
}

.tooltip-popover-title {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
}

.tooltip-popover-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    border-radius: 4px;
    font-size: 18px;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}

.tooltip-popover-close:hover {
    color: #475569;
    background: #f1f5f9;
}

.tooltip-popover-body {
    padding: 10px 14px 14px;
    color: #475569;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.tooltip-popover-body strong {
    color: #1e293b;
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}

.tooltip-popover-body em {
    color: #64748b;
    font-style: italic;
    font-size: 11px;
}

.tooltip-popover-body br {
    display: block;
    content: '';
    margin-top: 2px;
}

.tooltip-popover-body .text-emerald-600 {
    color: #059669;
}

/* Arrow for popover */
.tooltip-popover-arrow {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    transform: rotate(45deg);
}

.tooltip-popover-arrow.arrow-top {
    top: -7px;
    border-right: none;
    border-bottom: none;
}

.tooltip-popover-arrow.arrow-bottom {
    bottom: -7px;
    border-left: none;
    border-top: none;
}

@media (max-width: 768px) {
    .tooltip-popover {
        width: calc(100vw - 32px);
        max-width: 340px;
    }
}

/* ============================================================
   7. Components — Tabs (Expense Tabs)
   ============================================================ */

.expense-tabs {
    display: flex;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 1rem;
    gap: 0.5rem;
}

.expense-tab {
    padding: 0.5rem 1rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    color: #64748b;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    border-top: none;
    border-left: none;
    border-right: none;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.expense-tab:hover {
    color: #334155;
}

.expense-tab.active {
    color: #059669;
    border-bottom-color: #059669;
}

.expense-tab-content {
    display: none;
}

.expense-tab-content.active {
    display: block;
}

/* ============================================================
   8a. Components — Org Card Grid (Search Page)
   ============================================================ */

.org-cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

/* 2 columns on medium+ screens */
@media (min-width: 768px) {
    .org-cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Ensure cards fill height in grid rows for alignment */
.org-cards-grid .org-card {
    display: flex;
    flex-direction: column;
    overflow: visible;
}

.org-cards-grid .org-card .org-card-body {
    flex: 1;
}

/* ---- Card header hover & chevron ---- */

.org-card-header:hover {
    background-color: #f8fafc; /* slate-50 */
}

.org-card-chevron {
    transition: transform 0.2s ease;
}

/* rotate-180 utility for open state */
.rotate-180 {
    transform: rotate(180deg);
}

/* ============================================================
   7b. Components — Org Card Tabs
   ============================================================ */

.org-card-tabs {
    display: flex;
    border-bottom: 2px solid #e2e8f0;
    gap: 0;
}

.org-card-tab {
    padding: 0.5rem 0.75rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    color: #64748b;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: transparent;
    border-top: none;
    border-left: none;
    border-right: none;
    white-space: nowrap;
}

.org-card-tab:hover {
    color: #334155;
}

.org-card-tab.active {
    color: #059669;
    border-bottom-color: #059669;
}

.org-card-tab-content {
    display: none;
}

.org-card-tab-content.active {
    display: block;
}

/* ---- KPI Badges ---- */

.org-card-kpi {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    background: #f0fdf4;
    border: 1px solid #d1fae5;
    border-radius: 9999px;
    font-family: 'Inter', sans-serif;
    font-size: 0.6875rem;
    white-space: nowrap;
}

.org-card-kpi-label {
    color: #64748b;
    font-weight: 400;
}

.org-card-kpi-value {
    color: #047857;
    font-weight: 600;
}

/* Neutral badge for N/A or missing data */
.org-card-kpi.kpi-neutral {
    background: #f8fafc;
    border-color: #e2e8f0;
}

.org-card-kpi.kpi-neutral .org-card-kpi-value {
    color: #94a3b8;
}

/* ---- Compare Checkbox ---- */

.compare-card-check {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    user-select: none;
    padding: 0.125rem 0;
}

.compare-card-check .compare-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 0.875rem;
    height: 0.875rem;
    border: 1.5px solid #cbd5e1;
    border-radius: 0.1875rem;
    background: #fff;
    cursor: pointer;
    position: relative;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.compare-card-check .compare-checkbox:checked {
    background: #059669;
    border-color: #059669;
}

.compare-card-check .compare-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 2px;
    top: 0px;
    width: 5px;
    height: 8px;
    border: solid #fff;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}

.compare-card-check .compare-checkbox:hover {
    border-color: #059669;
}

.compare-card-check .compare-check-label {
    font-family: 'Inter', sans-serif;
    font-size: 0.625rem;
    font-weight: 500;
    color: #94a3b8;
    transition: color 0.15s ease;
}

.compare-card-check:hover .compare-check-label {
    color: #059669;
}

.compare-card-check .compare-checkbox:checked ~ .compare-check-label {
    color: #059669;
}

/* KPI tooltip triggers — popover handled globally by JS */

/* ---- Card Body Collapse ---- */

.org-card-body {
    transition: max-height 0.3s ease, opacity 0.2s ease;
    overflow: hidden;
}

.org-card-body.collapsed {
    max-height: 0 !important;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-top-color: transparent;
}

/* ---- Pagination ---- */

.org-cards-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-top: 1px solid #e2e8f0;
    background: white;
    border-radius: 0 0 0.75rem 0.75rem;
    font-family: 'Inter', sans-serif;
    margin-top: 0.75rem;
}

.org-cards-pagination button {
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    background: white;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s ease;
}

.org-cards-pagination button:hover:not(:disabled) {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.org-cards-pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.org-cards-pagination button.page-active {
    background: #059669;
    color: white;
    border-color: #059669;
}

.org-cards-pagination select {
    padding: 0.375rem 1.5rem 0.375rem 0.5rem;
    font-size: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    background: white;
    color: #475569;
    cursor: pointer;
}

/* ---- Mobile adjustments ---- */

@media (max-width: 640px) {
    .org-card-kpi {
        font-size: 0.625rem;
        padding: 0.125rem 0.5rem;
    }
    .org-card-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .org-cards-pagination {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
        text-align: center;
    }
}

/* ============================================================
   5. Components — Buttons & CTA
   ============================================================ */

.btn-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background-color: #059669;
    color: white;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: 0.5rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-cta:hover {
    background-color: #047857;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(5, 150, 105, 0.3);
}

.btn-cta-secondary {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: #059669;
    color: white;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.875rem;
    text-align: center;
    border-radius: 0.5rem;
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
    z-index: 60; /* Above footer (z-50) */
}

.btn-cta-secondary:hover {
    background-color: #047857;
}

/* Hide element until JS reveals it — overrides sm:block during loading.
   JS removes this class, leaving `hidden sm:block` which hides on mobile, shows on desktop. */
.hidden-until-loaded {
    display: none !important;
}

/* ============================================================
   9a. Components — Sticky Filter Bar (Search Page)
   ============================================================ */

.sticky-filter-bar {
    position: sticky;
    top: var(--header-height);
    z-index: 30;
    background: #f8f9fa;
    padding-top: 0.5rem;
    padding-bottom: 0;
}

.sticky-filter-bar::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    right: 0;
    height: 8px;
    background: linear-gradient(to bottom, rgba(248, 249, 250, 0.8), transparent);
    pointer-events: none;
}

@media (max-width: 640px) {
    .sticky-filter-bar {
        top: var(--header-height-mobile);
    }
}

/* ============================================================
   9b. Components — Mobile Filter Bottom Sheet
   ============================================================ */

.filter-panel-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: none;
}

.filter-panel-overlay.open {
    display: block;
}

.filter-panel-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.filter-panel-overlay.open .filter-panel-backdrop {
    opacity: 1;
}

.filter-panel-sheet {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 1rem 1rem 0 0;
    box-shadow: 0 -10px 25px -5px rgba(0, 0, 0, 0.15);
    max-height: 80vh;
    overflow-y: auto;
    padding: 1.5rem;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.filter-panel-overlay.open .filter-panel-sheet {
    transform: translateY(0);
}

.filter-panel-sheet .ms-dropdown {
    position: relative;
    top: auto;
    margin-top: 4px;
    box-shadow: none;
    border: 1px solid #e2e8f0;
}

/* ============================================================
   14a. Page — 990 Detail View Pills
   ============================================================ */

.detail-view-tab {
    transition: all 0.15s ease;
}

.detail-view-tab.active {
    background-color: #ecfdf5;
    color: #047857;
    border-color: #a7f3d0;
}

/* ============================================================
   8b. Components — 990 Detail Card Rows
   ============================================================ */

.detail-card-row {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    overflow: hidden;
    transition: box-shadow 0.15s ease;
}

.detail-card-row:hover {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Primary columns row — always visible */
.detail-card-primary {
    display: grid;
    width: 100%;
    padding: 0.75rem 1rem;
    gap: 0.5rem;
    align-items: center;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
}

.detail-card-primary .detail-col {
    min-width: 0;
    overflow: hidden;
}

/* Label above each primary value (except org name) */
.detail-col-label {
    display: block;
    font-size: 0.625rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.2;
    margin-bottom: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Value inside a labeled cell */
.detail-col-val {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Tax year badge next to org name */
.detail-col-year {
    display: inline-block;
    margin-left: 0.25rem;
    padding: 0 0.375rem;
    font-size: 0.625rem;
    font-weight: 500;
    color: #64748b;
    background: #f1f5f9;
    border-radius: 0.25rem;
    vertical-align: baseline;
}

.detail-card-primary .detail-col-text {
    color: #334155;
}

.detail-card-primary .detail-col-text .detail-col-val {
    color: #334155;
}

.detail-card-primary .detail-col-currency {
    text-align: right;
}

.detail-card-primary .detail-col-currency .detail-col-val {
    color: #0f766e;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.detail-card-primary .detail-col-currency .detail-col-label {
    text-align: right;
}

.detail-card-primary .detail-col-name {
    color: #047857;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-card-primary .detail-col-number {
    text-align: right;
}

.detail-card-primary .detail-col-number .detail-col-val {
    color: #334155;
    font-variant-numeric: tabular-nums;
}

.detail-card-primary .detail-col-number .detail-col-label {
    text-align: right;
}

/* Source badge */
.detail-source-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.375rem;
    font-size: 0.625rem;
    font-family: 'Inter', sans-serif;
    color: #94a3b8;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.25rem;
    white-space: nowrap;
}

/* Expand chevron */
.detail-expand-icon {
    transition: transform 0.2s ease;
    color: #94a3b8;
}

.detail-card-row.expanded .detail-expand-icon {
    transform: rotate(180deg);
}

/* Detail (expanded) section */
.detail-card-detail {
    width: 100%;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.2s ease;
    border-top: none;
    padding: 0 1rem;
    background: #fafbfc;
}

.detail-card-row.expanded .detail-card-detail {
    max-height: 500px;
    opacity: 1;
    padding: 0.75rem 1rem;
    border-top: 1px solid #f1f5f9;
}

/* Detail grid inside expanded section */
.detail-card-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.5rem 1.5rem;
}

.detail-field {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.detail-field-label {
    font-size: 0.6875rem;
    color: #94a3b8;
    font-family: 'Inter', sans-serif;
}

.detail-field-value {
    font-size: 0.8125rem;
    color: #334155;
    font-family: 'Inter', sans-serif;
}

/* Desktop: table-like aligned grid */
@media (min-width: 640px) {
    .detail-card-primary {
        padding: 0.625rem 1rem;
    }
}

/* Mobile: stack primary columns */
@media (max-width: 639px) {
    .detail-card-primary {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }

    .detail-card-primary .detail-col-name {
        grid-column: 1 / -1;
    }

    .detail-card-primary .detail-col-currency {
        text-align: left;
    }

    .detail-card-primary .detail-col-currency .detail-col-val {
        text-align: left;
    }

    .detail-card-primary .detail-col-currency .detail-col-label,
    .detail-card-primary .detail-col-number .detail-col-label {
        text-align: left;
    }

    .detail-card-detail-grid {
        grid-template-columns: 1fr;
    }
}

/* Sort header row (desktop only) */
.detail-header-row {
    display: none;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem 0.5rem 0 0;
    padding: 0.5rem 1rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: -1px;
}

@media (min-width: 640px) {
    .detail-header-row {
        display: grid;
        align-items: center;
    }

    .detail-header-col {
        cursor: pointer;
        user-select: none;
        display: flex;
        align-items: center;
        gap: 0.25rem;
    }

    .detail-header-col:hover {
        color: #334155;
    }

    .detail-header-col .sort-icon {
        opacity: 0.3;
        transition: opacity 0.15s;
    }

    .detail-header-col.sort-active .sort-icon {
        opacity: 1;
        color: #059669;
    }

    .detail-header-col.text-right {
        justify-content: flex-end;
    }
}

/* ============================================================
   4. Components — Data Source Badges (990 / FC)
   ============================================================ */

/* Shared badge base */
.data-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px;
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.03em;
    border-radius: 3px;
    vertical-align: middle;
    cursor: help;
    position: relative;
    line-height: 1.4;
    white-space: nowrap;
}

/* Blue 990 badge — raw IRS data */
.data-badge-990 {
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #93c5fd;
}

/* Amber FC badge — Fiducia-calculated */
.data-badge-fc {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fcd34d;
}

/* Badge tooltips — inline content hidden, popover handled by global JS */
.data-badge .badge-tooltip {
    display: none !important;
}

.data-badge {
    cursor: pointer;
}

/* Filing year tag */
.filing-year-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: #f0fdf4;
    color: #047857;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    border: 1px solid #a7f3d0;
}

/* Callout box: gold-bordered educational */
.callout-insight {
    border: 1px solid #fcd34d;
    border-left: 4px solid #f59e0b;
    background: #fffbeb;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
    line-height: 1.6;
    color: #78350f;
}

.callout-insight strong {
    color: #92400e;
}

/* Callout box: gray-bordered limitation */
.callout-limitation {
    border: 1px solid #e2e8f0;
    border-left: 4px solid #94a3b8;
    background: #f8fafc;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
    line-height: 1.6;
    color: #475569;
}

/* Data source legend */
.data-source-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    padding: 12px 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: #64748b;
}

.data-source-legend .legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ============================================================
   10. Components — Carousel
   ============================================================ */

.carousel-container {
    position: relative;
    overflow: hidden;
}

.carousel-track {
    display: flex;
    transition: transform 0.5s ease;
}

.carousel-slide {
    min-width: 100%;
    padding: 0 4px;
}

@media (min-width: 768px) {
    .carousel-slide {
        min-width: 50%;
    }
}

@media (min-width: 1024px) {
    .carousel-slide {
        min-width: 33.333%;
    }
}

.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
}

.carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e1;
    cursor: pointer;
    transition: background 0.2s;
    border: none;
    padding: 0;
}

.carousel-dot.active {
    background: #059669;
}

.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: white;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #475569;
    transition: all 0.2s;
}

.carousel-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.carousel-btn-prev { left: 4px; }
.carousel-btn-next { right: 4px; }

/* ============================================================
   16. Site Footer
   ============================================================ */

.site-footer {
    background: #1e293b;
    color: #cbd5e1;
    padding: 2rem 1rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
}

.site-footer a {
    color: #a7f3d0;
    text-decoration: none;
    transition: color 0.15s;
}

.site-footer a:hover {
    color: #6ee7b7;
    text-decoration: underline;
}

/* ============================================================
   12. Components — Collapsible Section Labels
   ============================================================ */

.section-label-header {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s;
}

.section-label-header:hover {
    background-color: #f1f5f9;
}

.section-label-content {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.2s ease;
    padding: 0 1rem;
}

.section-label-header.expanded + .section-label-content {
    max-height: 500px;
    opacity: 1;
    padding: 0.75rem 1rem 1rem;
}

.section-label-chevron {
    transition: transform 0.2s ease;
}

.section-label-header.expanded .section-label-chevron {
    transform: rotate(180deg);
}

/* ============================================================
   15. Page — Nonprofit (Org Selector, Sticky Header)
   ============================================================ */

/* Org selector trigger button — looks like a dropdown select */
.org-selector-trigger {
    cursor: pointer;
    background: white;
}

.org-selector-trigger:hover {
    border-color: #6ee7b7 !important; /* emerald-300 */
    background: rgba(236, 253, 245, 0.5) !important;
}

.org-selector-trigger:focus,
.org-selector-trigger:active {
    outline: none;
    border-color: #10b981 !important;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

/* Org selector dropdown panel */
#org-selector-dropdown {
    font-family: 'Inter', sans-serif;
}

#org-selector-dropdown a {
    text-decoration: none;
}

#org-selector-dropdown a:hover {
    background-color: #f8fafc;
}

/* Sticky header */
#org-sticky-header {
    transition: box-shadow 0.2s ease;
}

/* Tab bar inside sticky header — tighter spacing */
#org-sticky-header .tab-btn {
    font-size: 0.8125rem;
}

/* On small screens, stack the header items */
@media (max-width: 640px) {
    #org-sticky-header .flex-shrink-0 {
        padding-left: 1.75rem; /* align with name after back arrow */
    }

    .org-selector-trigger {
        padding: 0.25rem 0.5rem !important;
    }

    .org-selector-trigger h1 {
        font-size: 1rem !important;
    }

    #org-sticky-header .tab-btn {
        font-size: 0.75rem;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

/* ============================================================
   17. Page — Compare (E-Commerce Tabular Comparison)
   ============================================================ */

body.page-compare {
    padding-bottom: 0;
}

/* Compare table — scrollable wrapper */
.compare-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.compare-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.8125rem;
    table-layout: fixed;
}

/* Header row: org names */
.compare-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8fafc;
    padding: 0.625rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: #334155;
    border-bottom: 2px solid #e2e8f0;
}

.compare-th-label {
    position: sticky;
    left: 0;
    z-index: 3;
    background: #f8fafc;
    width: 180px;
    min-width: 180px;
}

.compare-th-org {
    width: 200px;
    min-width: 160px;
}

.compare-th-org-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
}

/* Data rows */
.compare-row td {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: top;
}

.compare-row:last-child td {
    border-bottom: none;
}

.compare-row:nth-child(even) td {
    background: #fafbfc;
}
.compare-row:nth-child(even) .compare-td-label {
    background: #f5f6f8;
}

/* Sticky metric label column */
.compare-td-label {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #ffffff;
    font-size: 0.75rem;
    font-weight: 500;
    color: #64748b;
    width: 180px;
    min-width: 180px;
    border-right: 1px solid #e2e8f0;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
}

/* Value cells — wrap text */
.compare-td-val {
    font-size: 0.75rem;
    min-width: 160px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

/* Context table banding — applied by JS based on logical factor index */
.context-band td {
    background: #fafbfc;
}
.context-band .compare-td-label {
    background: #f5f6f8;
}

/* Context detail sub-rows */
.context-detail-row td {
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
}
.context-detail-row:not(.context-band) td {
    background: #ffffff;
}
.context-detail-row:not(.context-band) .compare-td-label {
    background: #ffffff;
}

/* Sub-header rows */
.compare-row-subheader td {
    padding: 0.5rem 1rem 0.25rem;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    border-bottom: 1px solid #e2e8f0;
}

.compare-td-subheader {
    background: #f8fafc;
}

/* Mobile */
@media (max-width: 639px) {
    .compare-th-label,
    .compare-td-label {
        width: 110px;
        min-width: 110px;
        font-size: 0.6875rem;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .compare-th-org {
        width: 150px;
        min-width: 140px;
        font-size: 0.6875rem;
    }

    .compare-td-val {
        min-width: 140px;
        font-size: 0.6875rem;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

/* Silver accordion sections */
.silver-accordion-body {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.2s ease;
}

.silver-accordion.expanded .silver-accordion-body {
    max-height: 2000px;
    opacity: 1;
}

.silver-accordion.expanded .silver-accordion-chevron {
    transform: rotate(180deg);
}

/* Guide accordion sections (giving guide page) */
.guide-accordion-body {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.2s ease;
}

.guide-accordion.expanded .guide-accordion-body {
    max-height: 4000px;
    opacity: 1;
}

.guide-accordion.expanded .guide-accordion-chevron {
    transform: rotate(180deg);
}

/* Card bar chart rows */
.card-bar-row {
    padding: 0;
}

/* ============================================================
   Comparison Tray (bottom bar)
   ============================================================ */
#comparison-tray {
    transition: transform 0.25s ease;
}

/* Comparison tray — consistent across all pages */
#comparison-tray {
    font-family: 'Inter', sans-serif;
    box-shadow: 0 -4px 6px -1px rgba(0,0,0,0.05), 0 -2px 4px -2px rgba(0,0,0,0.05);
}

.tray-org-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    max-height: 5.5rem;
    overflow-y: auto;
}

.tray-org-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.625rem;
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
    border-radius: 9999px;
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    max-width: 280px;
}

.tray-org-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 240px;
}

.tray-remove-btn {
    flex-shrink: 0;
    font-size: 1rem;
    line-height: 1;
    color: #6ee7b7;
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
}

.tray-remove-btn:hover {
    color: #ef4444;
}

/* Line clamp utility */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Sticky compare header */
#compare-sticky-header {
    transition: box-shadow 0.2s ease;
}
