/**
 * Financial Overview – feature-specific styles.
 * Total Invoiced detail modal (expand-from-card, compact on mobile).
 */

/* Total Invoiced detail modal */
.total-invoiced-modal {
    align-items: flex-start;
    justify-content: flex-start;
    padding: 0;
}
.total-invoiced-modal .modal-content.total-invoiced-modal-content {
    position: fixed;
    margin: 0;
    width: fit-content;
    min-width: 240px;
    max-width: min(420px, calc(100vw - 2rem));
    height: auto;
    max-height: min(80vh, 520px);
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    padding: 0;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    -webkit-transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.05), opacity 0.25s ease-out;
    transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.05), opacity 0.25s ease-out;
    -webkit-transform: translateY(20px) scale(0.95);
    box-shadow: 0 20px 40px rgba(0,0,0,0.35);
    will-change: transform, opacity;
    /* Keep filter menus from expanding this box / creating a scrollbar */
    overflow: visible !important;
}
body.platform-ios .total-invoiced-modal.modal.active .modal-content.total-invoiced-modal-content {
    contain: none;
}
.total-invoiced-modal .modal-content.total-invoiced-modal-content.total-invoiced-expanded {
    -webkit-transform: translateY(0) scale(1);
    transform: translateY(0) scale(1);
    opacity: 1;
}
.total-invoiced-modal .modal-content.total-invoiced-modal-content.total-invoiced-closing {
    -webkit-transform: translateY(10px) scale(0.97);
    transform: translateY(10px) scale(0.97);
    opacity: 0;
    -webkit-transition: transform 0.2s cubic-bezier(0.4, 0, 1, 1), opacity 0.18s ease-in;
    transition: transform 0.2s cubic-bezier(0.4, 0, 1, 1), opacity 0.18s ease-in;
}
.total-invoiced-modal .total-invoiced-modal-header {
    padding: 0.2rem 1rem;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.total-invoiced-modal .total-invoiced-modal-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}
.total-invoiced-modal .total-invoiced-modal-close {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    line-height: 1;
    border-radius: 50%;
    background: transparent !important;
    background-color: transparent !important;
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    box-shadow: none !important;
}
@media (hover: hover) and (pointer: fine) {
.total-invoiced-modal .total-invoiced-modal-close:hover {
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
}
}

.total-invoiced-modal .total-invoiced-modal-close:active,
.total-invoiced-modal .total-invoiced-modal-close:focus {
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
}
.total-invoiced-modal .total-invoiced-modal-body {
    padding: 0.5rem 0.75rem 0.75rem;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 0 1 auto;
    max-height: min(75vh, 500px);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
}
.total-invoiced-list {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    width: fit-content;
    max-width: 100%;
}
/* Beat global .invoice-item flex-wrap + > div:last-child { flex-direction: column } (single child matches both). */
.total-invoiced-list .invoice-item {
    padding: 0.4375rem 0.625rem;
    min-height: 34px;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    border-radius: 8px;
    margin-bottom: 0;
    width: fit-content;
    max-width: 100%;
    box-sizing: border-box;
}
.total-invoiced-list .invoice-item-left,
.total-invoiced-list .invoice-item > div:first-child,
.total-invoiced-list .invoice-item > div:last-child {
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.5rem;
    width: auto !important;
    max-width: 100% !important;
    min-width: 0 !important;
    flex: 0 1 auto !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    text-align: left !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
    border-top: none !important;
}
.total-invoiced-list .invoice-item-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    flex: 0 1 auto;
    min-width: 0;
    flex-wrap: nowrap !important;
    white-space: nowrap;
}
.total-invoiced-list .invoice-item-money {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-shrink: 0;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.total-invoiced-list .invoice-project-num {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 1;
    min-width: 0;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.total-invoiced-list .invoice-num {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    flex-shrink: 0;
    white-space: nowrap;
}
.total-invoiced-list .invoice-stat {
    font-size: 0.625rem;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    flex-shrink: 0;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.2;
    white-space: nowrap;
}
.total-invoiced-list .invoice-stat.status-open {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-primary);
}
.total-invoiced-list .invoice-stat.status-paid {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}
.total-invoiced-list .invoice-stat.status-overdue {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}
.total-invoiced-list .invoice-stat.status-draft {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-secondary);
}
.total-invoiced-list .invoice-due-compact {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--accent-red);
}
.total-invoiced-list .invoice-total-compact {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-muted);
}
.total-invoiced-list .invoice-total-compact::before {
    content: '/';
    margin-right: 0.375rem;
    opacity: 0.55;
}
.total-invoiced-list .payment-date-compact {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-muted);
    flex-shrink: 0;
    white-space: nowrap;
}
.total-invoiced-list .payment-method-compact {
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    background: rgba(148, 163, 184, 0.12);
    flex-shrink: 0;
    white-space: nowrap;
    text-transform: capitalize;
}
.total-invoiced-list .invoice-amt-collected {
    color: var(--accent-primary);
}
.spending-detail-modal-body {
    display: flex;
    flex-direction: column;
    overflow: visible !important;
    max-height: min(75vh, 500px);
}

.spending-detail-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin: 0 0 12px;
    flex: 0 0 auto;
    overflow: visible;
    position: relative;
    z-index: 5;
}

.spending-detail-toolbar[hidden] {
    display: none !important;
}

.spending-detail-toolbar-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
    position: relative;
}

.spending-detail-toolbar-group[hidden] {
    display: none !important;
}

.spending-detail-toolbar-label {
    font-size: 10px;
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.spending-detail-picker {
    position: relative;
    z-index: 6;
}

.spending-detail-picker.is-open {
    z-index: 20;
}

.spending-detail-picker .filter-dropdown-btn {
    min-width: 148px;
}

.spending-detail-picker .filter-dropdown-menu {
    z-index: 40;
    max-height: none;
    overflow: visible;
    overflow-y: visible;
}

.spending-detail-picker.opens-up .filter-dropdown-menu {
    top: auto;
    bottom: calc(100% + 4px);
}

.spending-detail-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.spending-detail-donut {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 16px 24px;
    margin: 4px 0 8px;
}

.spending-detail-donut[hidden],
#spendingDetailList[hidden],
#collectedDetailList[hidden] {
    display: none !important;
}

.spending-detail-donut-chart {
    position: relative;
    width: 180px;
    height: 180px;
    flex: 0 0 auto;
}

.spending-detail-donut-chart svg {
    display: block;
    transform: rotate(-90deg);
}

.spending-detail-donut-chart .donut-segment {
    transition: stroke-dasharray 0.45s cubic-bezier(0.4, 0, 0.2, 1), stroke-dashoffset 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.spending-detail-donut-chart .donut-bg {
    stroke: var(--finance-track, var(--border-color));
}

.spending-detail-donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    text-align: center;
    padding: 24px;
}

.spending-detail-donut-total {
    font-size: 1.05rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.spending-detail-donut-sub {
    margin-top: 2px;
    font-size: 11px;
    color: var(--text-muted);
}

.spending-detail-donut-legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: min(100%, 220px);
    flex: 1 1 180px;
}

.spending-detail-legend-row {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 8px;
    width: 100%;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary, transparent);
    color: var(--text-primary);
    border-radius: 2px;
    padding: 8px 10px;
    text-align: left;
    cursor: pointer;
}

.spending-detail-legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.spending-detail-legend-label {
    font-size: 12px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.spending-detail-legend-pct,
.spending-detail-legend-amt {
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

.spending-detail-legend-amt {
    color: var(--text-primary);
    font-weight: var(--font-weight-semibold);
}

.total-invoiced-list .spending-cat-compact {
    font-size: 10px;
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: 2px;
    padding: 1px 5px;
}

.total-invoiced-list .spending-cat-labor {
    color: var(--finance-bar-spent-labor, var(--text-muted));
    border-color: color-mix(in srgb, var(--finance-bar-spent-labor, var(--border-color)) 45%, var(--border-color));
}

.total-invoiced-list .spending-cat-materials {
    color: var(--finance-bar-spent-materials, var(--text-muted));
    border-color: color-mix(in srgb, var(--finance-bar-spent-materials, var(--border-color)) 45%, var(--border-color));
}

.total-invoiced-list .spending-cat-equipment {
    color: var(--finance-bar-spent-equipment, var(--text-muted));
    border-color: color-mix(in srgb, var(--finance-bar-spent-equipment, var(--border-color)) 45%, var(--border-color));
}

.total-invoiced-list .spending-memo-compact {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-secondary);
    flex: 0 1 auto;
    min-width: 0;
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.total-invoiced-list .invoice-amt-compact {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #22c55e;
}
.total-invoiced-list .empty-invoice-state {
    text-align: center;
    padding: 1.25rem 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

@media (max-width: 480px) {
    .total-invoiced-modal .modal-content.total-invoiced-modal-content {
        width: fit-content;
        max-width: calc(100vw - 2rem);
        min-width: 240px;
        max-height: min(88vh, 600px);
        margin: 0;
        border-radius: 14px;
    }
    .total-invoiced-modal .total-invoiced-modal-header {
        padding: 0.2rem 1rem;
    }
    .total-invoiced-modal .total-invoiced-modal-close {
        width: 44px;
        height: 44px;
    }
    .total-invoiced-list .invoice-item {
        min-height: 36px;
        padding: 0.5rem 0.625rem;
        flex-direction: row !important;
    }
    .total-invoiced-list .invoice-item-left,
    .total-invoiced-list .invoice-item > div:first-child,
    .total-invoiced-list .invoice-item > div:last-child {
        flex-direction: row !important;
        border-top: none !important;
        margin-top: 0 !important;
        padding-top: 0 !important;
    }
    .total-invoiced-modal .total-invoiced-modal-body {
        max-height: min(82vh, 520px);
    }
}

@media (max-width: 380px) {
    .total-invoiced-list .invoice-item {
        flex-direction: row !important;
        align-items: center !important;
    }
    .total-invoiced-list .invoice-item-left,
    .total-invoiced-list .invoice-item > div:first-child,
    .total-invoiced-list .invoice-item > div:last-child {
        display: inline-flex !important;
        flex-direction: row !important;
        border-top: none !important;
        margin-top: 0 !important;
        padding-top: 0 !important;
    }
}

/* Overview display: Cards | List (project table) | Chart (horizontal bars) | Compare (months) */
/* Summary cards: wrap to fit the screen on phone / tablet / desktop (no sideways scroll). */
#financialView .overview-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    overflow: visible;
    flex-wrap: unset;
    scroll-snap-type: none;
    padding-bottom: 0;
}

#financialView .overview-grid .big-stat-card {
    width: auto;
    min-width: 0;
    max-width: none;
    flex: unset;
    scroll-snap-align: unset;
    padding: 0.5rem 0.45rem;
    box-sizing: border-box;
}

#financialView .overview-grid .big-stat-label {
    font-size: 10px;
    letter-spacing: 0.04em;
    margin-bottom: 0.15rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#financialView .overview-grid .big-stat-value {
    font-size: 1.05rem;
    min-height: 0;
}

#financialView .overview-grid .big-stat-compare {
    font-size: 0.7rem;
}

#financialView .overview-grid .big-stat-value-row {
    gap: 0.25rem;
    min-height: 0;
}

@media (min-width: 480px) {
    #financialView .overview-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.625rem;
    }

    #financialView .overview-grid .big-stat-value {
        font-size: 1.15rem;
    }
}

@media (min-width: 768px) {
    #financialView .overview-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0.75rem;
    }

    #financialView .overview-grid .big-stat-card {
        padding: 0.625rem 0.75rem;
    }

    #financialView .overview-grid .big-stat-label {
        font-size: var(--font-size-tertiary);
    }

    #financialView .overview-grid .big-stat-value {
        font-size: var(--font-size-special);
    }

    #financialView .overview-grid .big-stat-compare {
        font-size: 0.78rem;
    }
}

@media (min-width: 1024px) {
    #financialView .overview-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 1rem;
    }
}

#financialView .overview-grid[hidden],
#financialView .overview-chart[hidden],
#financialView .overview-compare[hidden],
#financialView .overview-compare [hidden],
#financialView .big-stat-card[hidden],
#financialFilterGroupMenu .control-group[hidden] {
    display: none !important;
}

/* ===== Compare view: month-by-month ===== */
#financialView .overview-compare {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 1rem;
}

.overview-compare-insights {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

@media (min-width: 768px) {
    .overview-compare-insights {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.compare-insight {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 2px;
    padding: 8px 10px;
    min-width: 0;
}

.compare-insight-title,
.compare-metric-label {
    font-size: 11px;
    font-weight: var(--font-weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.2;
}

.compare-insight-value {
    margin-top: 4px;
    font-size: 1.15rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.compare-insight-month {
    margin-right: 6px;
    color: var(--text-secondary);
    font-weight: var(--font-weight-normal, 400);
}

.compare-insight-sub {
    margin-top: 2px;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.3;
}

.overview-compare .is-pos { color: var(--accent-green, #68d391); }
.overview-compare .is-neg { color: var(--accent-red, #fc8181); }

.compare-change {
    font-size: 11px;
    font-weight: var(--font-weight-semibold);
    white-space: nowrap;
}

.compare-change.up { color: var(--accent-green, #68d391); }
.compare-change.down { color: var(--accent-red, #fc8181); }
.compare-change.up.is-inverse { color: var(--accent-red, #fc8181); }
.compare-change.down.is-inverse { color: var(--accent-green, #68d391); }
.compare-change.flat,
.compare-change.na { color: var(--text-muted); }

.overview-compare-metrics {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
}

@media (min-width: 768px) {
    .overview-compare-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    .overview-compare-metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.compare-metric {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 2px;
    padding: 8px 10px 6px;
    min-width: 0;
}

.compare-metric-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.compare-metric-now {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
}

.compare-metric-value {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.compare-cols {
    display: flex;
    align-items: stretch;
    gap: 4px;
    height: 110px;
}

.compare-col {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
}

.compare-col-value {
    font-size: 10px;
    line-height: 12px;
    height: 12px;
    color: var(--text-muted);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    font-variant-numeric: tabular-nums;
}

.compare-col-track {
    flex: 1 1 auto;
    display: flex;
    align-items: flex-end;
    background: var(--finance-track);
    border-radius: 2px;
    overflow: hidden;
}

.compare-col-bar {
    width: 100%;
    border-radius: 2px 2px 0 0;
    opacity: 0.6;
    transition: height 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.compare-col.is-current .compare-col-bar {
    opacity: 1;
}

.compare-col-label {
    font-size: 10px;
    line-height: 12px;
    color: var(--text-muted);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.compare-cols.is-dense {
    gap: 2px;
}

.compare-cols.is-dense .compare-col-label {
    font-size: 9px;
    text-overflow: clip;
}

.compare-col.is-current .compare-col-label,
.compare-col.is-current .compare-col-value {
    color: var(--text-primary);
    font-weight: var(--font-weight-semibold);
}

.compare-empty {
    margin: 0;
    padding: 16px 10px;
    text-align: center;
    color: var(--text-muted);
    font-size: var(--font-size-tertiary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 2px;
}

/* Monthly empty state: message overlays ghost insights / charts. */
#financialView .overview-compare-empty {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    grid-column: 1 / -1;
}

#financialView .overview-compare-ghost-insights,
#financialView .overview-compare-ghost-metrics,
#financialView .overview-compare-ghost-table,
#financialView .overview-compare-ghost-insight,
#financialView .overview-compare-ghost-metric {
    pointer-events: none;
    cursor: default;
}

#financialView .overview-compare-ghost-insights,
#financialView .overview-compare-ghost-metrics,
#financialView .overview-compare-ghost-table {
    opacity: 0.1;
}

#financialView .overview-compare-ghost-insights {
    margin: 0;
}

#financialView .overview-compare-ghost-metrics {
    margin: 0;
}

#financialView .overview-compare-ghost-bar {
    opacity: 1;
    background: var(--text-muted, var(--border-color));
}

#financialView .overview-compare-ghost-insight .compare-insight-title,
#financialView .overview-compare-ghost-metric .compare-metric-label {
    display: flex;
    align-items: center;
    min-height: 12px;
}

#financialView .overview-compare-ghost-insight .compare-insight-value,
#financialView .overview-compare-ghost-insight .compare-insight-sub,
#financialView .overview-compare-ghost-metric .compare-metric-now {
    display: flex;
    align-items: center;
}

#financialView .overview-compare-ghost-table {
    overflow-x: auto;
}

.overview-compare-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    background: var(--bg-secondary);
}

.overview-compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-tertiary);
    font-variant-numeric: tabular-nums;
}

.overview-compare-table th,
.overview-compare-table td {
    padding: 6px 10px;
    text-align: right;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color);
}

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

.overview-compare-table thead th {
    font-size: 11px;
    font-weight: var(--font-weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.overview-compare-table thead th:first-child,
.overview-compare-table tbody th {
    position: sticky;
    left: 0;
    z-index: 1;
    text-align: left;
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    background: var(--bg-secondary);
}

.overview-compare-table td {
    color: var(--text-primary);
}

.overview-compare-table .is-current {
    background: rgba(104, 211, 145, 0.08);
}

.overview-compare-table thead th.is-current {
    color: var(--text-primary);
}

.overview-compare-table .is-total {
    font-weight: var(--font-weight-semibold);
    border-left: 1px solid var(--border-color);
}

.overview-compare-table td.is-neg {
    color: var(--accent-red, #fc8181);
}

.overview-compare-note,
.overview-summary-note {
    margin: 0;
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-muted);
}

.overview-summary-note {
    margin-top: 12px;
    max-width: 52rem;
}

#financialView .overview-display-dropdown {
    position: relative;
    flex: 0 0 auto;
}

#financialView .overview-display-menu {
    left: 0;
    right: auto;
    top: calc(100% + 4px);
    min-width: 140px;
}

#financialView .overview-display-menu .filter-dropdown-item {
    font-size: var(--font-size-tertiary);
}

#financialView .overview-chart {
    background: transparent;
    border: none;
    padding: 0;
    margin-bottom: 1rem;
}

#financialView .big-stat-card--static {
    cursor: default;
}

@media (hover: hover) and (pointer: fine) {
    #financialView .big-stat-card--static:hover {
        transform: none;
    }
}

/* This period: independent cash-flow stats (no funnel bars / connectors). */
#financialView .overview-chart.is-period-stats .ov-sections {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-items: stretch;
}

@media (min-width: 720px) {
    #financialView .overview-chart.is-period-stats .ov-sections {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1100px) {
    #financialView .overview-chart.is-period-stats .ov-sections {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

#financialView .ov-stat {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 2px;
    padding: 12px 14px;
    min-width: 0;
    box-shadow: inset 3px 0 0 var(--ov-accent, transparent);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.2s ease;
}

#financialView .ov-stat:focus-visible {
    outline: 2px solid var(--accent-green);
    outline-offset: -2px;
}

@media (hover: hover) and (pointer: fine) {
    #financialView .ov-stat:hover {
        background: var(--finance-track);
    }
}

#financialView .ov-stat-label {
    font-size: 11px;
    font-weight: var(--font-weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.2;
    margin-bottom: 6px;
}

#financialView .ov-stat-value-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
}

#financialView .ov-stat-value {
    font-size: var(--font-size-secondary, 1.05rem);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1.25;
    word-break: break-word;
}

#financialView .ov-stat-value.is-pos { color: var(--accent-green, #68d391); }
#financialView .ov-stat-value.is-neg { color: var(--accent-red, #fc8181); }

#financialView .ov-stat-meta {
    margin-top: 6px;
    font-size: 11px;
    line-height: 1.35;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
}

#financialView .overview-chart.loading .ov-stat-value,
#financialView .overview-chart.loading .ov-stat-meta {
    visibility: hidden;
}

/* Legacy pipeline layout helpers (unused when is-period-stats). */
#financialView .ov-sections {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

#financialView .ov-flow-link {
    flex: 0 0 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#financialView .ov-flow-node {
    position: relative;
    width: 22px;
    height: 22px;
    border-radius: 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    background: color-mix(in srgb, var(--ov-to) 30%, var(--bg-secondary));
    color: var(--ov-to);
    font-size: 10px;
}

@media (min-width: 1280px) {
    #financialView .ov-sections {
        flex-direction: row;
        align-items: center;
    }

    #financialView .ov-sections > .ov-section {
        flex: 1 1 0;
        align-self: stretch;
        box-shadow: inset 0 3px 0 var(--ov-accent, transparent);
    }

    #financialView .ov-flow-link {
        flex: 0 0 34px;
        height: 34px;
    }

    #financialView .ov-flow-node i {
        transform: rotate(-90deg);
    }

    #financialView .ov-section-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    #financialView .ov-section-hint {
        max-width: 100%;
    }
}

#financialView .ov-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 2px;
    padding: 10px 12px 8px;
    min-width: 0;
    box-shadow: inset 3px 0 0 var(--ov-accent, transparent);
}

#financialView .ov-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
    min-width: 0;
}

#financialView .ov-section-title {
    font-size: 11px;
    font-weight: var(--font-weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.2;
}

#financialView .ov-section-hint {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

#financialView .ov-rows {
    display: flex;
    flex-direction: column;
}

#financialView .ov-row {
    padding: 6px 6px;
    margin: 0 -6px;
    border-radius: 2px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.2s ease;
}

#financialView .ov-row.is-static {
    cursor: default;
}

#financialView .ov-row:focus-visible {
    outline: 2px solid var(--accent-green);
    outline-offset: -2px;
}

@media (hover: hover) and (pointer: fine) {
    #financialView .ov-row:not(.is-static):hover {
        background: var(--finance-track);
    }
}

#financialView .ov-row:not(.is-static):active {
    background: var(--finance-track);
}

#financialView .ov-row-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 2px 8px;
    min-width: 0;
}

#financialView .ov-row-label {
    font-size: var(--font-size-tertiary);
    color: var(--text-secondary, var(--text-muted));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

#financialView .ov-row-values {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    flex-shrink: 0;
}

#financialView .ov-row-value {
    font-size: var(--font-size-tertiary);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

#financialView .ov-row-value.is-pos { color: var(--accent-green, #68d391); }
#financialView .ov-row-value.is-neg { color: var(--accent-red, #fc8181); }

#financialView .ov-row-compare {
    font-size: 10px;
}

#financialView .ov-row-track {
    height: 8px;
    margin-top: 5px;
    background: var(--finance-track);
    border-radius: 2px;
    overflow: hidden;
}

#financialView .ov-row-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.finance-bar-fill--due { background: var(--finance-bar-spent-labor); }
.finance-bar-fill--spending { background: var(--finance-bar-profit-neg); }

#financialView .overview-chart.loading .ov-row-value,
#financialView .overview-chart.loading .big-stat-compare {
    visibility: hidden;
}

#financialView .overview-chart.loading .ov-row-bar {
    width: 0 !important;
}

@supports (padding: max(0px)) {
    .total-invoiced-modal .modal-content.total-invoiced-modal-content {
        max-height: min(75vh, 520px);
    }
    @media (max-width: 480px) {
        .total-invoiced-modal .modal-content.total-invoiced-modal-content {
            max-height: min(90vh, 650px);
        }
    }
}

/* Detail popups (Estimated / Invoiced / Balance Due / Collected / Spending / Profit):
   same flat, low-radius surface as the Filter menu (#financialFilterGroupMenu). */
.total-invoiced-modal .modal-content.total-invoiced-modal-content,
.total-invoiced-modal .modal-content.total-invoiced-modal-content.total-invoiced-expanded {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 2px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
}

.total-invoiced-modal .total-invoiced-modal-header {
    padding: 6px 6px 6px 10px;
    min-height: 0;
}

.total-invoiced-modal .total-invoiced-modal-title {
    font-size: 11px;
    font-weight: var(--font-weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.2;
}

.total-invoiced-modal .total-invoiced-modal-close {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    font-size: 1.1rem;
    border-radius: 2px;
}

.total-invoiced-modal .total-invoiced-modal-body {
    padding: 10px;
}

.total-invoiced-list {
    gap: 4px;
}

.total-invoiced-list .invoice-item {
    min-height: 32px;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 2px;
    transition: border-color 0.15s ease, background 0.15s ease;
}

@media (hover: hover) and (pointer: fine) {
    .total-invoiced-list .invoice-item:hover {
        transform: none;
        background: var(--bg-tertiary);
        border-color: var(--accent-green);
    }
}

.total-invoiced-list .invoice-item.is-unassigned {
    cursor: default;
}

@media (hover: hover) and (pointer: fine) {
    .total-invoiced-list .invoice-item.is-unassigned:hover {
        border-color: var(--border-color);
    }
}

.total-invoiced-list .invoice-stat,
.total-invoiced-list .payment-method-compact {
    border-radius: 2px;
}

.total-invoiced-list .invoice-stat.status-sent {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-primary);
}

.total-invoiced-list .invoice-stat.status-accepted,
.total-invoiced-list .invoice-stat.status-approved {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.total-invoiced-list .invoice-stat.status-declined,
.total-invoiced-list .invoice-stat.status-rejected,
.total-invoiced-list .invoice-stat.status-expired {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.total-invoiced-list .invoice-amt-estimated {
    color: var(--text-primary);
}

.total-invoiced-list .empty-invoice-state {
    padding: 12px 8px;
    font-size: var(--font-size-tertiary);
}

@media (max-width: 480px) {
    .total-invoiced-modal .modal-content.total-invoiced-modal-content {
        border-radius: 2px;
    }
    .total-invoiced-modal .total-invoiced-modal-header {
        padding: 6px 6px 6px 10px;
    }
    .total-invoiced-modal .total-invoiced-modal-close {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
    }
    .total-invoiced-list .invoice-item {
        min-height: 34px;
        padding: 6px 10px;
    }
}

#financialView .section-title[hidden] {
    display: none !important;
}

/* By project sheet: match Monthly compare table look; keep sort / resize / reorder / row click. */
#financialView #needsCollectionSection > .section-title {
    display: none !important;
}

#financialView #needsCollectionList {
    margin: 0;
}

#financialView #needsCollectionList .needs-collection-sheet {
    border: 1px solid var(--border-color);
    border-radius: 2px;
    background: var(--bg-secondary);
    backdrop-filter: none;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: none;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) var(--bg-secondary);
}

/* Dark scrollbar track (handrail) for By project + Monthly tables. */
#financialView #needsCollectionList .needs-collection-sheet::-webkit-scrollbar,
#financialView .overview-compare-table-wrap::-webkit-scrollbar {
    height: 10px;
    width: 10px;
}

#financialView #needsCollectionList .needs-collection-sheet::-webkit-scrollbar-track,
#financialView .overview-compare-table-wrap::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 0 0 2px 2px;
}

#financialView #needsCollectionList .needs-collection-sheet::-webkit-scrollbar-thumb,
#financialView .overview-compare-table-wrap::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
    border: 2px solid var(--bg-secondary);
}

#financialView #needsCollectionList .needs-collection-sheet::-webkit-scrollbar-thumb:hover,
#financialView .overview-compare-table-wrap::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

#financialView .overview-compare-table-wrap {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) var(--bg-secondary);
}

#financialView #needsCollectionList .needs-collection-sheet-inner {
    position: relative;
    width: max-content;
    min-width: 100%;
}

#financialView #needsCollectionList .needs-collection-sheet-header,
#financialView #needsCollectionList .needs-collection-sheet-row {
    min-height: 0;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

#financialView #needsCollectionList .needs-collection-sheet-guides {
    position: absolute;
    inset: 0;
    width: auto !important; /* fill the full inner table, not only the visible viewport */
    pointer-events: none;
    z-index: 4;
}

#financialView #needsCollectionList .needs-collection-sheet-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    color: var(--text-muted);
}

#financialView #needsCollectionList .needs-collection-sheet-header > div,
#financialView #needsCollectionList .needs-collection-sheet-row > div {
    min-height: 0;
    padding: 6px 10px;
    justify-content: flex-end;
    text-align: right;
}

#financialView #needsCollectionList .needs-collection-sheet-header > div:first-child,
#financialView #needsCollectionList .needs-collection-sheet-row > div:first-child,
#financialView #needsCollectionList .sheet-col-name,
#financialView #needsCollectionList .sheet-col-project,
#financialView #needsCollectionList .sheet-col-status {
    justify-content: flex-start;
    text-align: left;
}

#financialView #needsCollectionList .needs-collection-sheet .sheet-col-label {
    font-size: 11px;
    font-weight: var(--font-weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

#financialView #needsCollectionList .needs-collection-sheet .sheet-cell-value {
    font-size: var(--font-size-tertiary);
    font-weight: var(--font-weight-regular, 400);
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

#financialView #needsCollectionList .needs-collection-sheet-row {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    transition: background-color 0.15s ease;
}

#financialView #needsCollectionList .needs-collection-sheet-row:nth-child(even) {
    background: transparent;
}

#financialView #needsCollectionList .needs-collection-sheet-row:last-child {
    border-bottom: none;
    border-radius: 0;
}

#financialView #needsCollectionList .needs-collection-sheet-row:hover {
    background: rgba(104, 211, 145, 0.08);
    transform: none;
}

#financialView #needsCollectionList .needs-collection-sheet-row:focus-visible {
    outline: 2px solid var(--accent-green);
    outline-offset: -2px;
}

#financialView #needsCollectionList .sheet-status-badge {
    border-radius: 2px;
    padding: 0.15rem 0.4rem;
    font-size: 10px;
    letter-spacing: 0.04em;
    background: transparent;
}

#financialView #needsCollectionList .sheet-resize-handle {
    right: -10px;
    width: 20px;
}

#financialView #needsCollectionList .needs-collection-sheet-guide {
    background: var(--border-color);
}

#financialView #needsCollectionList .needs-collection-sheet-guide.active {
    background: var(--text-muted);
}

/* By project / Monthly empty: copy overlays whisper ghost chrome. */
#financialView .overview-projects-empty {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0.5rem 0 1rem;
}

#financialView .overview-projects-empty-copy {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.35rem;
    padding: 1.5rem 1.25rem;
    pointer-events: none;
    box-sizing: border-box;
}

#financialView .overview-projects-empty-copy h4 {
    margin: 0;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    color: var(--text-muted);
}

#financialView .overview-projects-empty-copy p {
    margin: 0;
    max-width: 28rem;
    font-size: var(--font-size-tertiary);
    color: var(--text-muted);
    line-height: 1.4;
}

/* Empty-state skeleton: same sheet chrome as the real By project table, no animation.
   Keep scrollbar usable; only disable row / header interaction. Whisper opacity matches dashboard. */
#financialView .overview-projects-ghost-sheet {
    opacity: 0.1;
}

#financialView .overview-projects-ghost-sheet .needs-collection-sheet-header,
#financialView .overview-projects-ghost-sheet .needs-collection-sheet-row {
    pointer-events: none;
    cursor: default;
}

#financialView .overview-projects-ghost-sheet .needs-collection-sheet-row:hover {
    background: transparent;
}

#financialView .overview-projects-ghost-bar {
    display: block;
    height: 10px;
    max-width: 100%;
    border-radius: 2px;
    background: var(--finance-track, var(--border-color));
    opacity: 1;
}

#financialView .overview-projects-ghost-sheet .sheet-col-money .overview-projects-ghost-bar {
    margin-left: auto;
}

/* Loading skeleton cards (Projects list / financial job cards) */
#financialView .skeleton-card {
    opacity: 0.1;
}
