/**
 * Shared command-header compaction.
 * Content-sized sticky chrome: title/actions + one tab row.
 * Large KPI cards stay in the scrolling main, not this band.
 * Do not apply viewport-relative heights here.
 */

.fo-command-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 0 0 auto;
    height: auto;
    min-height: 0;
    max-height: none;
    padding: 8px 12px 0;
    position: static;
    background: var(--fo-page-bg, #f7f8fa);
    z-index: 25;
}

@media (min-width: 768px) {
    .fo-command-header {
        position: sticky;
        top: 0;
    }

    .fo-command-header .fo-payments-header,
    .fo-command-header .fo-finance-header,
    .fo-command-header .fo-sales-header,
    .fo-command-header .fo-projects-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 8px 12px;
        padding: 0;
    }

    .fo-command-header .fo-payments-header-icon,
    .fo-command-header .fo-finance-header-icon,
    .fo-command-header .fo-sales-header-icon,
    .fo-command-header .fo-projects-header-icon {
        width: 32px;
        height: 32px;
        font-size: 1rem;
        border-radius: 8px;
    }

    .fo-command-header .fo-payments-title,
    .fo-command-header .fo-finance-title,
    .fo-command-header .fo-sales-title,
    .fo-command-header .fo-projects-title,
    .fo-command-header .ops-toolbar-title {
        font-size: 1.35rem;
        line-height: 1.2;
    }

    .fo-command-header .fo-payments-subtitle,
    .fo-command-header .fo-finance-subtitle,
    .fo-command-header .fo-sales-subtitle,
    .fo-command-header .fo-projects-subtitle {
        margin: 2px 0 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .fo-command-header .fo-payments-header-metrics,
    .fo-command-header .fo-finance-header-metrics,
    .fo-command-header .fo-sales-header-metrics,
    .fo-command-header .fo-projects-header-metrics {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        margin-top: 4px;
        max-height: 28px;
        gap: 8px;
        scrollbar-width: thin;
    }

    .fo-command-header .fo-payments-header-metrics > span,
    .fo-command-header .fo-finance-header-metrics > span,
    .fo-command-header .fo-sales-header-metrics > span,
    .fo-command-header .fo-projects-header-metrics > span {
        white-space: nowrap;
        flex: 0 0 auto;
    }

    .fo-command-header .fo-finance-copilot,
    .fo-command-header .fo-sales-copilot,
    .fo-command-header .fo-projects-copilot {
        margin-top: 4px;
        padding: 4px 8px;
        max-height: 32px;
        min-width: 0;
    }

    .fo-command-header .fo-finance-copilot span,
    .fo-command-header .fo-sales-copilot span,
    .fo-command-header .fo-projects-copilot span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .fo-command-header .fo-action-bar {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        align-items: center;
        gap: 8px;
        padding: 0;
        margin: 0;
        border: none;
        background: transparent;
        align-self: center;
    }

    .fo-command-header .fo-payments-tab,
    .fo-command-header .fo-finance-tab,
    .fo-command-header .fo-sales-tab,
    .fo-command-header .fo-projects-tab {
        flex-direction: row;
        align-items: center;
        gap: 6px;
        min-height: 36px;
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .fo-command-header .fo-payments-tabbar,
    .fo-command-header .fo-finance-tabbar,
    .fo-command-header .fo-sales-tabbar,
    .fo-command-header .fo-projects-tabbar {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        min-height: 36px;
        max-height: 48px;
    }
}

.fo-command-header .fo-payments-tab:focus-visible,
.fo-command-header .fo-finance-tab:focus-visible,
.fo-command-header .fo-sales-tab:focus-visible,
.fo-command-header .fo-projects-tab:focus-visible,
.ops-tab:focus-visible,
.ops-icon-btn:focus-visible {
    outline: 2px solid var(--fo-brand-600, #2563eb);
    outline-offset: 2px;
}

/* KPI rails live in scrolling content — not a second sticky band. */
.fo-payments-main > .fo-payments-pinned,
.fo-finance-main > .fo-finance-pinned,
.fo-sales-main > .fo-sales-pinned,
.fo-projects-main > .fo-projects-pinned,
.fo-payments-main > .fo-action-bar.fo-payments-pinned,
.fo-finance-main > .fo-action-bar.fo-finance-pinned,
.fo-sales-main > .fo-action-bar.fo-sales-pinned,
.fo-projects-main > .fo-action-bar.fo-projects-pinned {
    flex-shrink: 0;
    margin-bottom: 8px;
}

@media (max-width: 767px) {
    .fo-command-header {
        position: static;
        height: auto;
        max-height: none;
        padding: 8px 12px 0;
    }
}

/*
 * Desktop density (~20% tighter upper chrome). Content-sized only.
 * Does not apply below 992px. Does not add a vertical scroll owner.
 */
@media (min-width: 992px) {
    .fo-command-header {
        gap: 4px;
        padding: 4px 12px 0;
    }

    .fo-command-header .fo-payments-header,
    .fo-command-header .fo-finance-header,
    .fo-command-header .fo-sales-header,
    .fo-command-header .fo-projects-header {
        gap: 4px 10px;
    }

    .fo-command-header .fo-payments-header-icon,
    .fo-command-header .fo-finance-header-icon,
    .fo-command-header .fo-sales-header-icon,
    .fo-command-header .fo-projects-header-icon {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }

    .fo-command-header .fo-payments-title,
    .fo-command-header .fo-finance-title,
    .fo-command-header .fo-sales-title,
    .fo-command-header .fo-projects-title {
        font-size: 1.15rem;
        line-height: 1.15;
    }

    .fo-command-header .fo-payments-subtitle,
    .fo-command-header .fo-finance-subtitle,
    .fo-command-header .fo-sales-subtitle,
    .fo-command-header .fo-projects-subtitle {
        margin: 0;
        font-size: 0.75rem;
        line-height: 1.2;
    }

    .fo-command-header .fo-payments-header-metrics,
    .fo-command-header .fo-finance-header-metrics,
    .fo-command-header .fo-sales-header-metrics,
    .fo-command-header .fo-projects-header-metrics {
        margin-top: 2px;
        gap: 6px;
        max-height: 22px;
    }

    .fo-command-header .fo-finance-copilot,
    .fo-command-header .fo-sales-copilot,
    .fo-command-header .fo-projects-copilot {
        margin-top: 2px;
        padding: 2px 8px;
    }

    .fo-command-header .fo-action-bar {
        gap: 6px;
    }

    .fo-command-header .fo-btn.fo-btn--sm {
        padding: 0.2rem 0.55rem;
        min-height: 1.625rem;
    }

    .fo-command-header .fo-payments-tab,
    .fo-command-header .fo-finance-tab,
    .fo-command-header .fo-sales-tab,
    .fo-command-header .fo-projects-tab {
        min-height: 32px;
        padding: 4px 8px;
        gap: 4px;
    }

    .fo-command-header .fo-payments-tabbar,
    .fo-command-header .fo-finance-tabbar,
    .fo-command-header .fo-sales-tabbar,
    .fo-command-header .fo-projects-tabbar {
        min-height: 32px;
        max-height: 40px;
        gap: 2px;
    }

    .fo-payments-main > .fo-action-bar.fo-payments-pinned,
    .fo-finance-main > .fo-action-bar.fo-finance-pinned,
    .fo-sales-main > .fo-action-bar.fo-sales-pinned,
    .fo-projects-main > .fo-action-bar.fo-projects-pinned {
        margin-bottom: 4px;
        padding: 0;
        gap: 6px;
        background: transparent;
        border-bottom: none;
    }

    .fo-payments-pinned .fo-kpi-card--compact,
    .fo-finance-pinned .fo-kpi-card--compact,
    .fo-sales-pinned .fo-kpi-card--compact,
    .fo-projects-pinned .fo-kpi-card--compact {
        min-width: 108px;
        padding: 6px 10px;
    }

    .fo-payments-pinned .fo-kpi-card--compact .fo-kpi-value,
    .fo-finance-pinned .fo-kpi-card--compact .fo-kpi-value,
    .fo-sales-pinned .fo-kpi-card--compact .fo-kpi-value,
    .fo-projects-pinned .fo-kpi-card--compact .fo-kpi-value {
        font-size: 1.05rem;
        line-height: 1.1;
    }
}
