/* AI Efficiency Budget Builder — integrated AIEA step */
.aiea-budget-builder {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem 1.25rem 1.5rem;
    background: linear-gradient(180deg, #f4f7fb 0%, #eef2f8 100%);
    min-height: 100%;
    font-family: Inter, system-ui, sans-serif;
    color: #0f172a;
    overflow-y: auto;
}

.aiea-budget-builder__header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.aiea-budget-builder__title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
}

.aiea-budget-builder__subtitle {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    color: #64748b;
}

.aiea-budget-builder__export {
    border: 1px solid #cbd5e1;
    background: #fff;
    border-radius: 8px;
    padding: 0.45rem 0.85rem;
    font-size: 0.8125rem;
    cursor: pointer;
}

.aiea-budget-builder__kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
}

@media (max-width: 900px) {
    .aiea-budget-builder__kpis { grid-template-columns: repeat(2, 1fr); }
}

.aiea-budget-builder__kpi {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.85rem 1rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.aiea-budget-builder__kpi-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    margin: 0 0 0.35rem;
}

.aiea-budget-builder__kpi-value {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

.aiea-budget-builder__kpi-value--green { color: #059669; }
.aiea-budget-builder__kpi-value--blue { color: #2563eb; }

.aiea-budget-builder__section-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
}

.aiea-budget-builder__scenarios {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

@media (max-width: 768px) {
    .aiea-budget-builder__scenarios { grid-template-columns: 1fr; }
}

.aiea-budget-builder__scenario {
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.85rem;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.aiea-budget-builder__scenario.is-active {
    border-color: #2563eb;
    box-shadow: 0 0 0 1px #2563eb;
}

.aiea-budget-builder__scenario-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    background: #dbeafe;
    color: #1d4ed8;
    border-radius: 999px;
    padding: 0.15rem 0.5rem;
    margin-bottom: 0.35rem;
}

.aiea-budget-builder__scenario-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin: 0 0 0.25rem;
}

.aiea-budget-builder__scenario-desc {
    font-size: 0.78rem;
    color: #64748b;
    margin: 0;
}

.aiea-budget-builder__budget-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1rem;
}

.aiea-budget-builder__budget-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex: 1;
    min-width: 200px;
}

.aiea-budget-builder__budget-input {
    font-size: 1.35rem;
    font-weight: 700;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0.4rem 0.65rem;
    width: 100%;
    max-width: 180px;
}

.aiea-budget-builder__budget-currency {
    font-weight: 600;
    color: #475569;
}

.aiea-budget-builder__optimize-btn {
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.55rem 1rem;
    font-weight: 600;
    cursor: pointer;
}

.aiea-budget-builder__recommendation {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 10px;
    padding: 0.85rem 1rem;
    margin-top: 0.5rem;
}

.aiea-budget-builder__recommendation-title {
    font-weight: 600;
    color: #047857;
    margin: 0 0 0.35rem;
}

.aiea-budget-builder__table-wrap {
    overflow-x: auto;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
}

.aiea-budget-builder__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.aiea-budget-builder__table th,
.aiea-budget-builder__table td {
    padding: 0.55rem 0.65rem;
    border-bottom: 1px solid #f1f5f9;
    text-align: left;
    vertical-align: top;
}

.aiea-budget-builder__table th {
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
}

.aiea-budget-builder__toggle {
    width: 36px;
    height: 20px;
    border-radius: 999px;
    background: #cbd5e1;
    border: none;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
}

.aiea-budget-builder__toggle.is-on {
    background: #2563eb;
}

.aiea-budget-builder__toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.15s;
}

.aiea-budget-builder__toggle.is-on::after {
    transform: translateX(16px);
}

.aiea-budget-builder__charts {
    display: grid;
    grid-template-columns: 1fr 1.2fr 0.9fr;
    gap: 0.75rem;
}

@media (max-width: 1024px) {
    .aiea-budget-builder__charts { grid-template-columns: 1fr; }
}

.aiea-budget-builder__chart-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.85rem;
}

.aiea-budget-builder__donut {
    display: block;
    margin: 0 auto;
    max-width: 180px;
}

.aiea-budget-builder__bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 120px;
    padding-top: 0.5rem;
}

.aiea-budget-builder__bar-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    height: 100%;
    justify-content: flex-end;
}

.aiea-budget-builder__bar {
    width: 100%;
    border-radius: 3px 3px 0 0;
    min-height: 2px;
}

.aiea-budget-builder__bar--invest { background: #3b82f6; }
.aiea-budget-builder__bar--benefit { background: #10b981; }

.aiea-budget-builder__bar-label {
    font-size: 0.6rem;
    color: #94a3b8;
}

.aiea-budget-builder__value-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.aiea-budget-builder__value-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.8rem;
}

.aiea-budget-builder__footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 0.5rem;
}

.aiea-budget-builder__btn-primary {
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.65rem 1.25rem;
    font-weight: 600;
    cursor: pointer;
}

.aiea-budget-builder__btn-secondary {
    background: #fff;
    color: #334155;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0.65rem 1.25rem;
    cursor: pointer;
}

.aiea-budget-builder__legend {
    font-size: 0.7rem;
    color: #64748b;
    margin-top: 0.35rem;
}

.advisor-fab--budget-builder .advisor-fab__progress,
.advisor-fab--budget-builder .advisor-fab__footer-shell {
    display: none;
}

.advisor-shell--budget-builder .advisor-webchat-root {
    display: none;
}

/* Tier landing: three-column bottom alignment (loads last — wins cascade) */
@media (min-width: 1280px) {
    body.aiea-app--live .advisor-fab.advisor-fab--tiers .aiea-onboarding-stage {
        align-items: stretch !important;
    }

    body.aiea-app--live .advisor-fab.advisor-fab--tiers .aiea-onboarding-stage > .aiea-marketing-rail,
    body.aiea-app--live .advisor-fab.advisor-fab--tiers .aiea-onboarding-stage > .aiea-onboarding-stage__main {
        align-self: stretch !important;
        min-height: 100%;
    }

    body.aiea-app--live .advisor-fab.advisor-fab--tiers.advisor-fab--marketing-rails-open .aiea-marketing-rail--left,
    body.aiea-app--live .advisor-fab.advisor-fab--tiers.advisor-fab--marketing-rails-open .aiea-marketing-rail--right {
        display: flex !important;
        flex-direction: column;
        min-height: 100%;
    }

    body.aiea-app--live .advisor-fab.advisor-fab--tiers .aiea-marketing-rail__fill--left {
        flex: 1 1 auto;
    }

    body.aiea-app--live .advisor-fab.advisor-fab--tiers .aiea-marketing-rail__banner--lower {
        margin-top: auto;
    }

    body.aiea-app--live .advisor-fab.advisor-fab--tiers .aiea-marketing-rail__tier-savings,
    body.aiea-app--live .advisor-fab.advisor-fab--tiers .aiea-marketing-rail__budget-preview {
        flex: 0 0 auto;
    }

    body.aiea-app--live .advisor-fab.advisor-fab--tiers .aiea-marketing-rail__fill--right {
        flex: 1 1 auto;
    }

    body.aiea-app--live .advisor-fab.advisor-fab--tiers .advisor-tier-start__benefits-panel,
    body.aiea-app--live .advisor-fab.advisor-fab--tiers .advisor-tier-start > .aiea-more-benefits {
        flex: 1 1 auto;
    }

    body.aiea-app--live .advisor-fab.advisor-fab--tiers .advisor-tier-start__framework {
        display: none !important;
    }
}

/* Collapsed marketing rails: center tier landing must stay visible (loads last in cascade) */
body.aiea-app--live .advisor-fab.advisor-fab--tiers:not(.advisor-fab--marketing-rails-open) .aiea-marketing-rail {
    display: none !important;
}

.aiea-budget-hub.aiea-customer-hub__panel {
    max-width: min(960px, 100%);
}

.aiea-budget-hub__mount {
    min-width: 0;
    width: 100%;
}

.aiea-budget-hub__loading {
    font-size: 0.85rem;
    color: #64748b;
}

.aiea-budget-hub__toast {
    margin: 0 0 0.5rem;
    padding: 0.45rem 0.65rem;
    border-radius: 8px;
    background: #ecfdf5;
    color: #065f46;
    font-size: 0.82rem;
    font-weight: 600;
}

.aiea-budget-builder__report-context {
    margin-bottom: 0.75rem;
}

.aiea-budget-builder__report-context-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 0.35rem;
}

.aiea-budget-builder__report-select {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    font: inherit;
    font-size: 0.82rem;
    padding: 0.45rem 0.55rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
}

.aiea-budget-builder__footer--hub {
    flex-wrap: wrap;
    gap: 0.65rem;
}

.aiea-budget-builder__footer-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.35rem;
    margin-left: auto;
}

.aiea-budget-builder__save-status {
    font-size: 0.72rem;
    color: #64748b;
}

.aiea-budget-builder__save-status[data-state="error"] {
    color: #b91c1c;
}

.aiea-budget-builder__init-row.is-disabled {
    opacity: 0.72;
}

.aiea-budget-builder__init-row.is-disabled .aiea-budget-builder__money {
    color: #64748b;
}

.aiea-budget-builder__init-status {
    display: inline-block;
    margin-top: 0.2rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: #334155;
}

.aiea-budget-builder__init-row.is-disabled .aiea-budget-builder__init-status {
    color: #64748b;
}

.aiea-budget-builder__source-hint {
    color: #64748b;
}

.aiea-budget-builder__overrun {
    color: #b45309;
}

.aiea-budget-builder__data-req,
.aiea-budget-builder__low-data {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.85rem 1rem;
}

.aiea-budget-builder__data-req-summary,
.aiea-budget-builder__data-req-quality {
    margin: 0.35rem 0;
    font-size: 0.85rem;
    color: #475569;
}

.aiea-budget-builder__data-req-list {
    list-style: none;
    margin: 0.5rem 0 0.75rem;
    padding: 0;
    display: grid;
    gap: 0.35rem;
}

.aiea-budget-builder__data-req-item.is-ok {
    color: #166534;
}

.aiea-budget-builder__data-req-item.is-missing {
    color: #9a3412;
}

.aiea-budget-builder__data-req-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
}

.aiea-budget-builder__hourly-label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.8rem;
    flex: 1 1 12rem;
}

.aiea-budget-builder__hourly-input {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0.4rem 0.55rem;
    font-size: 0.875rem;
}

.aiea-budget-builder__kpi-value {
    word-break: break-word;
}

.aiea-budget-builder__na {
    font-size: 0.72rem;
    color: #9a3412;
    line-height: 1.25;
}

.aiea-budget-builder__chart-unavailable {
    font-size: 0.85rem;
    color: #64748b;
    margin: 0.5rem 0;
}

@media (max-width: 480px) {
    .aiea-budget-builder__footer--hub {
        flex-direction: column;
        align-items: stretch;
    }

    .aiea-budget-builder__footer-actions {
        align-items: stretch;
        margin-left: 0;
    }

    .aiea-budget-builder__data-req-actions {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Tablet / touch: never show tier marketing rails or toggle (loads after onboardingMarketingRails.css) */
@media (max-width: 1279px), (hover: none), (pointer: coarse), (any-pointer: coarse) {
    body.aiea-app--live .advisor-fab.advisor-fab--tiers .aiea-marketing-rail,
    body.aiea-app--live .advisor-fab.advisor-fab--tiers.advisor-fab--marketing-rails-open .aiea-marketing-rail,
    body.aiea-app--live .aiea-marketing-rails-toggle-wrap,
    body.aiea-app--live #aieaMarketingRailsToggle {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }
}
