* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --navy: #1F4E79;
    --navy-light: #D6E4F0;
    --green: #2E7D32;
    --green-light: #D5F5E3;
    --green-fill: #E2EFDA;
    --yellow: #FFF2CC;
    --yellow-input: #FFFFCC;
    --red: #C62828;
    --red-light: #FFC7CE;
    --orange: #E65100;
    --gray: #808080;
    --gray-light: #F5F5F5;
    --border: #D9D9D9;
    --actual-bg: #E8F0FE;
    --forecast-bg: #FFF8E1;
    --font: 'Segoe UI', Arial, sans-serif;
}

body {
    font-family: var(--font);
    background: #f0f2f5;
    color: #333;
    min-height: 100vh;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--navy) 0%, #2d6da3 100%);
    color: white;
    padding: 24px 32px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.header-content h1 { font-size: 22px; font-weight: 700; letter-spacing: 0.5px; }
.subtitle { font-size: 13px; opacity: 0.8; margin-top: 4px; }

/* Tabs */
.tabs {
    display: flex;
    background: white;
    border-bottom: 2px solid var(--border);
    padding: 0 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    position: sticky;
    top: 0;
    z-index: 100;
}
.tab {
    padding: 14px 24px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}
.tab:hover { color: var(--navy); }
.tab.active { color: var(--navy); border-bottom-color: var(--navy); }

/* Tab content */
.tab-content { display: none; padding: 24px; max-width: 1400px; margin: 0 auto; }
.tab-content.active { display: block; }

/* Tab introductions */
.tab-intro {
    background: white;
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    border-left: 4px solid var(--navy);
}
.tab-intro h2 {
    font-size: 19px;
    font-weight: 700;
    color: var(--red);
    margin-bottom: 8px;
}
.tab-intro p {
    font-size: 14px;
    color: #555;
    line-height: 1.6;
    font-weight: 600;
}

/* Section titles */
.section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--navy);
    margin: 24px 0 12px 0;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--navy);
}

/* Charts */
.chart-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}
.chart-container {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.chart-container.full-width { grid-column: 1 / -1; }
.chart-container h3 { font-size: 13px; color: var(--navy); margin-bottom: 12px; font-weight: 600; }

/* Tables */
.table-wrapper {
    overflow-x: auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 8px 12px; text-align: right; border: 1px solid var(--border); white-space: nowrap; }
th { background: var(--navy); color: white; font-weight: 600; font-size: 11px; }
td:first-child, th:first-child { text-align: left; position: sticky; left: 0; z-index: 2; min-width: 200px; }
td:first-child { background: white; }
th:first-child { background: var(--navy); }
.row-header td:first-child, .row-total td:first-child, .row-ebitda td:first-child { background: #F0F4F8; }
.row-impact td:first-child { background: #FFF3E0; }

/* Row types */
tr.row-header td { background: var(--navy-light); font-weight: 700; }
tr.row-total td { background: var(--green-fill); font-weight: 700; }
tr.row-ebitda td { background: var(--yellow); font-weight: 700; color: var(--navy); font-size: 13px; }
tr.row-fcf td { background: var(--green-light); font-weight: 700; color: #006100; font-size: 13px; }
tr.row-input td { background: var(--yellow-input); color: #0000FF; }
tr.row-memo td { color: var(--gray); font-style: italic; }
tr.row-pct td { color: var(--gray); font-style: italic; font-size: 11px; }
tr.row-impact td { font-weight: 700; color: var(--orange); }
tr.row-negative td { color: var(--red); }

/* Actual vs Forecast column highlights */
td.actual { background-color: rgba(232, 240, 254, 0.3); }
td.forecast { background-color: rgba(255, 248, 225, 0.3); }
th.actual-header { background: #1a6bb5; }
th.forecast-header { background: #5a8db5; }
th.fy-total { background: #0d3d5e; }

/* Stress test controls */
.instructions { font-size: 13px; color: var(--gray); margin-bottom: 16px; font-style: italic; }

.stress-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}
.stress-section {
    background: white;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.stress-section.full-width { grid-column: 1 / -1; }
.stress-section h3 { font-size: 13px; color: var(--navy); margin-bottom: 12px; font-weight: 600; }

.entity-slider {
    display: grid;
    grid-template-columns: 160px auto 50px 40px;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 12px;
}
.entity-slider label { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.entity-slider input[type="range"] { width: 100%; accent-color: var(--navy); }
.entity-slider .slider-val { text-align: right; font-weight: 600; color: var(--navy); min-width: 45px; }
.entity-slider .toggle { cursor: pointer; }

.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    display: inline-block;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #ccc;
    border-radius: 20px;
    transition: 0.3s;
}
.toggle-slider:before {
    content: "";
    position: absolute;
    height: 14px; width: 14px;
    left: 3px; bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--green); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(16px); }

/* Debt & Interest info grid */
.debt-info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.debt-info-card {
    background: #F8F9FA;
    border-radius: 6px;
    padding: 12px 16px;
    border: 1px solid var(--border);
}
.debt-info-card.highlight {
    background: var(--navy-light);
    border-color: var(--navy);
}
.debt-info-label {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.debt-info-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--navy);
}
.debt-info-value.stressed {
    color: var(--orange);
}
.debt-info-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.debt-info-row input[type="range"] {
    flex: 1;
    accent-color: var(--orange);
}
.debt-info-base {
    font-size: 12px;
    color: #888;
    min-width: 90px;
}
.debt-input {
    width: 140px;
    padding: 6px 8px;
    border: 1px solid var(--navy);
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    text-align: right;
    background: var(--yellow-input);
    color: #0000FF;
}
.slider-val-lg {
    min-width: 50px;
    text-align: right;
    font-weight: 700;
    font-size: 16px;
    color: var(--orange);
}
.rate-input {
    width: 90px;
    padding: 6px 8px;
    border: 1px solid var(--navy);
    border-radius: 4px;
    font-size: 18px;
    font-weight: 700;
    text-align: right;
    background: var(--yellow-input);
    color: #0000FF;
}
.rate-unit {
    font-size: 18px;
    font-weight: 700;
    color: var(--navy);
}
.debt-info-hint {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
    font-style: italic;
}

/* Bridge overrides */
.bridge-inputs { display: flex; flex-direction: column; gap: 12px; }

.bridge-override-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.bridge-override-table table { font-size: 11px; position: relative; z-index: 0; border-collapse: collapse; }
.bridge-override-table td, .bridge-override-table th { padding: 6px 4px; border: 1px solid var(--border); }
.bridge-override-table th { background: var(--navy); color: white; font-weight: 600; text-align: center; }
.bridge-override-table td:first-child { background: #F0F4F8; font-weight: 600; position: static; min-width: 140px; }
.bridge-override-table input[type="number"] {
    width: 80px; padding: 4px 6px; border: 1px solid var(--navy);
    border-radius: 4px; font-size: 11px; text-align: right;
    background: var(--yellow-input); color: #0000FF; font-weight: 600;
}

/* Scenario bar */
.scenario-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: white;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    flex-wrap: wrap;
    font-size: 13px;
}
.scenario-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: white;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.scenario-btn:hover { background: var(--navy-light); }
.scenario-btn.active { background: var(--navy); color: white; border-color: var(--navy); }
.save-btn { background: var(--green-light); border-color: var(--green); color: var(--green); }
.save-btn:hover { background: var(--green); color: white; }
.actual-btn { background: var(--navy-light); border-color: var(--navy); color: var(--navy); font-weight: 700; }
.actual-btn:hover { background: var(--navy); color: white; }
.export-scenarios-btn { background: #FFF3E0; border-color: var(--orange); color: var(--orange); }
.export-scenarios-btn:hover { background: var(--orange); color: white; }

/* Result cards */
.result-cards {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}
.result-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    border-top: 4px solid var(--border);
}
.ebitda-card { border-top-color: var(--navy); }
.fcf-card { border-top-color: var(--green); }
.breakeven-card { border-top-color: var(--orange); }
.result-card h4 { font-size: 12px; color: var(--gray); margin-bottom: 8px; text-transform: uppercase; }
.result-value { font-size: 28px; font-weight: 700; }
.ebitda-card .result-value { color: var(--navy); }
.fcf-card .result-value { color: var(--green); }
.breakeven-card .result-value { color: var(--orange); }
.result-delta { font-size: 13px; margin-top: 4px; }
.result-delta.positive { color: var(--green); }
.result-delta.negative { color: var(--red); }
.result-subtitle { font-size: 11px; color: var(--gray); margin-top: 4px; }

/* Export bar */
.export-bar {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}
.export-btn {
    padding: 10px 24px;
    border: 2px solid var(--navy);
    border-radius: 6px;
    background: white;
    color: var(--navy);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}
.export-btn:hover { background: var(--navy); color: white; }

/* Footer */
footer {
    text-align: center;
    padding: 16px;
    font-size: 11px;
    color: var(--gray);
    border-top: 1px solid var(--border);
    margin-top: 40px;
}

/* Print styles */
@media print {
    .tabs, .scenario-bar, .export-bar, .stress-controls, footer { display: none; }
    .tab-content { display: block !important; padding: 0; }
    .chart-row { grid-template-columns: 1fr; }
    body { background: white; }
    header { background: white; color: var(--navy); box-shadow: none; border-bottom: 2px solid var(--navy); }
}

/* Responsive */
@media (max-width: 900px) {
    .chart-row { grid-template-columns: 1fr; }
    .stress-controls { grid-template-columns: 1fr; }
    .result-cards { grid-template-columns: 1fr; }
    .tabs { overflow-x: auto; }
}
