/* =========================================================================
   Revenue Forecast — the second tab on the TIS page.

   Flexbox and relative units throughout, so the panel reflows on a laptop
   the same way the rest of the page does.
   ========================================================================= */

.tis-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(206, 186, 76, 0.25);
}
.tis-tab {
    flex: 0 1 auto;
    padding: 0.7rem 1.4rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: #9fb0c4;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}
.tis-tab:hover { color: rgb(206, 186, 76); }
.tis-tab.active {
    color: rgb(206, 186, 76);
    border-bottom-color: rgb(206, 186, 76);
}
.tis-tab:focus-visible {
    outline: 2px solid rgb(206, 186, 76);
    outline-offset: 2px;
}

.forecast-hint {
    color: #9fb0c4;
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.forecast-file-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0;
}
.forecast-file-list:empty { display: none; }
.forecast-file-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.9rem;
    background: rgba(206, 186, 76, 0.08);
    border: 1px solid rgba(206, 186, 76, 0.3);
    border-radius: 6px;
    font-size: 0.85rem;
    color: #e8e8e8;
}
.forecast-file-list .file-meta {
    margin-left: auto;
    color: #9fb0c4;
    font-size: 0.78rem;
}
.forecast-file-list .remove-btn {
    background: none;
    border: none;
    color: #9fb0c4;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.25rem;
}
.forecast-file-list .remove-btn:hover { color: #e06c6c; }

/* =========================================================================
   Focus mode — the setup folds away and the card goes wide for the table.

   Collapsed, not removed: every file and field is still there on the way
   back, so "Change files" returns to a form that is exactly as it was.
   ========================================================================= */
.main-content,
.main-content .upload-section {
    transition: max-width 0.3s ease;
}

/* The width is shared by every panel that has a focus mode, so the forecast
   and the estimate widen to exactly the same measure rather than to two
   values that were once the same. panel-focus.ts sets this whenever any
   panel is both asking for focus and on screen. */
body.tis-focus .main-content,
body.tis-focus .main-content .upload-section {
    max-width: min(100%, 95vw);
}

/* max-height rather than height: flexbox cannot interpolate an auto
   height, so the fold is animated on a bound the content never reaches. */
#forecastForm {
    overflow: hidden;
    max-height: 200rem;
    opacity: 1;
    transition: max-height 0.35s ease, opacity 0.2s ease;
}

body.forecast-focus #forecastForm {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
}

/* A line of prose should not stretch to 95vw even when the card does. */
body.forecast-focus #panelForecast > .section-header {
    max-width: 50rem;
}

body.forecast-focus .forecast-chart { height: 19rem; }

.forecast-results { margin-top: 1.5rem; }

/* ===== Toolbar: which view, and how wide ================================ */
.forecast-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(206, 186, 76, 0.2);
}

.forecast-views {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.forecast-view-btn,
.forecast-width-btn {
    padding: 0.45rem 0.9rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: #cfd8e3;
    background: rgba(13, 40, 73, 0.6);
    border: 1px solid rgba(206, 186, 76, 0.3);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.forecast-view-btn:hover,
.forecast-width-btn:hover {
    border-color: rgb(206, 186, 76);
    color: rgb(206, 186, 76);
}

.forecast-view-btn.is-on,
.forecast-width-btn.is-on {
    color: #0D2849;
    background: rgb(206, 186, 76);
    border-color: rgb(206, 186, 76);
}

.forecast-view-btn:focus-visible,
.forecast-width-btn:focus-visible {
    outline: 2px solid rgb(206, 186, 76);
    outline-offset: 3px;
}

.forecast-width {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-left: auto;
}

.forecast-width-label {
    font-size: 0.78rem;
    color: #9fb0c4;
}

.forecast-warnings {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.forecast-warnings:empty { display: none; }
.forecast-warning {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border: 1px solid rgba(206, 186, 76, 0.35);
    background: rgba(206, 186, 76, 0.1);
    color: rgb(206, 186, 76);
    font-size: 0.85rem;
    line-height: 1.5;
}

.forecast-headline {
    margin: 1.25rem 0;
    padding: 1.1rem 1.25rem;
    border-radius: 8px;
    border-left: 3px solid rgb(206, 186, 76);
    background: rgba(13, 40, 73, 0.6);
    color: #e8e8e8;
    font-size: 1rem;
    line-height: 1.6;
}
.forecast-headline strong { color: rgb(206, 186, 76); }
.forecast-headline .loss { color: #ff8080; }

.forecast-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.forecast-card {
    flex: 1 1 11rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 1rem 1.1rem;
    background: rgba(13, 40, 73, 0.6);
    border: 1px solid rgba(206, 186, 76, 0.3);
    border-radius: 8px;
}
.forecast-card .card-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: rgb(206, 186, 76);
}
.forecast-card .card-value.loss { color: #ff8080; }
.forecast-card .card-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #9fb0c4;
}
.forecast-card .card-sub {
    font-size: 0.78rem;
    color: #9fb0c4;
}

.forecast-block {
    margin-bottom: 2rem;
    padding: 1.25rem;
    background: rgba(13, 40, 73, 0.45);
    border: 1px solid rgba(206, 186, 76, 0.22);
    border-radius: 8px;
}
.forecast-block h3 {
    color: rgb(206, 186, 76);
    font-size: 1rem;
    margin-bottom: 0.4rem;
}
.forecast-note {
    color: #9fb0c4;
    font-size: 0.8rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

/* Chart — one flex column per month, each bar sized as a percentage of the
   tallest month, so it stays honest at any width without a canvas. */
.forecast-chart {
    display: flex;
    align-items: flex-end;
    gap: 0.4rem;
    height: 15rem;
    padding-top: 1rem;
    overflow-x: auto;
}
.chart-month {
    flex: 1 1 0;
    min-width: 2.4rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    height: 100%;
}
.chart-bars {
    flex: 1 1 auto;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 0.15rem;
    width: 100%;
}
.chart-bar {
    flex: 1 1 0;
    max-width: 0.9rem;
    border-radius: 2px 2px 0 0;
    min-height: 1px;
    transition: opacity 0.2s;
}
.chart-bar.revenue { background: rgb(206, 186, 76); }
.chart-bar.cost { background: #4a6fa5; }
.chart-month.projected .chart-bar { opacity: 0.42; }
.chart-month.projected .chart-label { font-style: italic; }
.chart-label {
    font-size: 0.7rem;
    color: #9fb0c4;
}
.chart-net {
    font-size: 0.68rem;
    font-weight: 600;
    color: #7fd18a;
}
.chart-net.loss { color: #ff8080; }

.forecast-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1.2rem;
    margin-top: 1rem;
    font-size: 0.78rem;
    color: #9fb0c4;
}
.forecast-legend span {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.swatch {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 2px;
    display: inline-block;
}
.swatch-revenue { background: rgb(206, 186, 76); }
.swatch-cost { background: #4a6fa5; }
.swatch-net { background: #7fd18a; }

.forecast-table-wrap { overflow-x: auto; }
.forecast-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    color: #e8e8e8;
}
.forecast-table th {
    text-align: right;
    padding: 0.55rem 0.7rem;
    color: rgb(206, 186, 76);
    font-weight: 600;
    border-bottom: 1px solid rgba(206, 186, 76, 0.3);
    white-space: nowrap;
}
.forecast-table th:first-child,
.forecast-table td:first-child { text-align: left; }
.forecast-table td {
    text-align: right;
    padding: 0.5rem 0.7rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    white-space: nowrap;
}
/* Banded headers over the two years, so the pairs of columns being
   compared read as pairs rather than as one long row of numbers. */
.forecast-table th.band {
    text-align: center;
    font-size: 0.8rem;
    letter-spacing: 0.03em;
    border-bottom: 2px solid transparent;
}
.forecast-table th.band-current { border-bottom-color: rgb(206, 186, 76); }
.forecast-table th.band-prior {
    border-bottom-color: #4a6fa5;
    color: #8ba7c9;
}
.forecast-table th.band-change {
    border-bottom-color: rgba(255, 255, 255, 0.25);
    color: #9fb0c4;
}
.forecast-table tr.band-row th[rowspan] {
    vertical-align: bottom;
    border-bottom: none;
}

.forecast-table tr.projected td {
    color: #9fb0c4;
    font-style: italic;
}
.forecast-table td.loss {
    color: #ff8080;
    font-weight: 600;
}
.forecast-table td.gain { color: #7fd18a; }
.forecast-table tr.total-row td {
    border-top: 1px solid rgba(206, 186, 76, 0.4);
    border-bottom: none;
    font-weight: 700;
    padding-top: 0.7rem;
}
.forecast-table .basis {
    text-align: left;
    color: #9fb0c4;
    font-size: 0.75rem;
    font-style: italic;
    white-space: normal;
}

/* The clean sheet. Green rather than gold: this is the one panel on the
   page reporting that nothing is wrong, and it should not look like every
   other card. */
.forecast-clean {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    padding: 2rem 1.5rem;
    text-align: center;
    border-radius: 8px;
    background: rgba(127, 209, 138, 0.08);
    border: 1px solid rgba(127, 209, 138, 0.3);
}
.forecast-clean .clean-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    font-size: 1.6rem;
    font-weight: 700;
    color: #0D2849;
    background: #7fd18a;
}
.forecast-clean h4 {
    color: #7fd18a;
    font-size: 1.15rem;
    margin: 0;
}
.forecast-clean .clean-line {
    max-width: 34rem;
    margin: 0;
    color: #cfd8e3;
    font-size: 0.9rem;
    line-height: 1.6;
}

/* A view button whose news is good wears it. */
.forecast-view-btn.is-good {
    border-color: rgba(127, 209, 138, 0.55);
    color: #7fd18a;
}
.forecast-view-btn.is-good.is-on {
    color: #0D2849;
    background: #7fd18a;
    border-color: #7fd18a;
}

.losing-month {
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.losing-month:last-child {
    border-bottom: none;
    margin-bottom: 0;
}
.losing-month-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
}
.losing-month-head .month-name {
    font-weight: 700;
    color: #e8e8e8;
}
.losing-month-head .month-net {
    color: #ff8080;
    font-weight: 600;
}
.driver-block { border-bottom: 1px solid rgba(255, 255, 255, 0.04); }
.driver-block:last-child { border-bottom: none; }

.driver-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
    width: 100%;
    padding: 0.45rem 0.5rem;
    font-size: 0.83rem;
    font-family: inherit;
    color: #cfd8e3;
    text-align: left;
    background: none;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.15s;
}
.driver-row:hover { background: rgba(206, 186, 76, 0.08); }
.driver-row.is-open { background: rgba(206, 186, 76, 0.1); }
.driver-row:focus-visible {
    outline: 2px solid rgb(206, 186, 76);
    outline-offset: 2px;
}
.driver-row.is-static {
    cursor: default;
    background: none;
    opacity: 1;
}
.driver-caret {
    flex: none;
    width: 0.9rem;
    color: rgba(206, 186, 76, 0.8);
    font-size: 0.7rem;
}
.driver-row .driver-category { flex: 1 1 11rem; }
.driver-row .driver-amount {
    color: #e8e8e8;
    font-weight: 600;
}
.driver-row .driver-delta {
    color: #ff9c6e;
    font-size: 0.78rem;
}
.driver-row .driver-count {
    flex: none;
    min-width: 4.5rem;
    text-align: right;
    color: #9fb0c4;
    font-size: 0.75rem;
}

/* The transactions behind one category. Indented under their driver so it
   stays obvious which line they explain. */
.driver-detail {
    margin: 0 0 0.75rem 1.4rem;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.22);
    border-left: 2px solid rgba(206, 186, 76, 0.4);
    border-radius: 0 5px 5px 0;
    overflow-x: auto;
}
.driver-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    color: #cfd8e3;
}
.driver-table th {
    text-align: left;
    padding: 0.3rem 0.6rem;
    color: rgba(206, 186, 76, 0.85);
    font-weight: 600;
    border-bottom: 1px solid rgba(206, 186, 76, 0.2);
    white-space: nowrap;
}
.driver-table td {
    padding: 0.3rem 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: top;
}
.driver-table tr:last-child td { border-bottom: none; }
.driver-table td.txn-amount {
    text-align: right;
    color: #e8e8e8;
    font-weight: 600;
    white-space: nowrap;
}
.driver-table th:nth-child(3) { text-align: right; }
.driver-detail .forecast-note { margin: 0.5rem 0 0; }

.survival-figures {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.survival-figure {
    flex: 1 1 12rem;
    padding: 0.9rem 1rem;
    border-radius: 6px;
    background: rgba(206, 186, 76, 0.08);
    border: 1px solid rgba(206, 186, 76, 0.25);
}
.survival-figure .figure-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: rgb(206, 186, 76);
}
.survival-figure .figure-label {
    font-size: 0.78rem;
    color: #9fb0c4;
    margin-top: 0.2rem;
}
.survival-list {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.survival-list li {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    font-size: 0.83rem;
    color: #cfd8e3;
}
.survival-list .cost-name { flex: 1 1 auto; }
.survival-list .cost-value {
    font-weight: 600;
    color: #e8e8e8;
}
.survival-list .cost-months {
    color: #9fb0c4;
    font-size: 0.76rem;
}

body.theme-gold .forecast-block,
body.theme-gold .forecast-headline,
body.theme-gold .forecast-card {
    background: rgba(206, 186, 76, 0.1);
    border-color: rgba(206, 186, 76, 0.35);
}
body.theme-gold .forecast-hint,
body.theme-gold .forecast-note,
body.theme-gold .card-label {
    color: rgba(206, 186, 76, 0.75);
}

@media (max-width: 700px) {
    .forecast-chart { height: 11rem; }
    .chart-net { display: none; }
}

@media (max-width: 700px) {
    .forecast-width { margin-left: 0; }
    body.forecast-focus .forecast-chart { height: 13rem; }
}

@media (prefers-reduced-motion: reduce) {
    .tis-tab,
    .chart-bar,
    .driver-row,
    .forecast-view-btn,
    .forecast-width-btn,
    .main-content,
    .main-content .upload-section,
    #forecastForm { transition: none; }
}
