/* Financial Analysis page (finance.html).
   Self-contained: it shares the map page's "Glacier" look (slate neutrals, one glacier-blue accent,
   white cards with hairline borders and soft shadows, Inter) without loading the map's stylesheets.
   Chart series use the validated categorical slots 1-3 (blue #2a78d6, orange #eb6834, aqua #1baf7a -
   checked against the white card surface; aqua is below 3:1, so every chart has a table view); DSCR state uses the fixed status palette, always with an icon
   and a label; chart chrome uses the page's slate neutrals. */

:root {
    color-scheme: light;
    --bg:        #f4f7fb;
    --wash:      #e6f0fa;   /* sky tint at the top of the page */
    --panel:     #ffffff;
    --panel-2:   #f8fafc;
    --ink:       #0f172a;
    --text:      #1e293b;
    --text-2:    #5b6b80;
    --text-3:    #94a3b8;
    --border:    rgba(15, 23, 42, 0.08);
    --border-2:  rgba(15, 23, 42, 0.14);
    --hover:     #f1f5f9;
    --tint:      #f2f7fd;   /* light blue fill for chips, table header, row hover */
    --tint-line: rgba(14, 107, 168, 0.16);
    --brand-grad: linear-gradient(90deg, #0e6ba8, #1597b5);
    --accent:    #0e6ba8;
    --accent-h:  #0a5687;
    --accent-dim: rgba(14, 107, 168, 0.09);
    --r:         14px;
    --r-sm:      9px;
    --sh-sm:     0 1px 2px rgba(15, 23, 42, 0.04), 0 6px 18px -10px rgba(15, 35, 70, 0.16);
    --sh-md:     0 2px 6px rgba(15, 23, 42, 0.05), 0 10px 28px rgba(15, 23, 42, 0.08);
    --sh-lg:     0 6px 16px rgba(15, 23, 42, 0.08), 0 22px 54px rgba(15, 23, 42, 0.16);
    --font:      'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

    /* charts */
    --fc-s1:     #2a78d6;
    --fc-s2:     #eb6834;
    --fc-s3:     #1baf7a;
    --fc-grid:   #edf1f6;
    --fc-axis:   #c3ccd8;
    --fc-muted:  #64748b;
    --fc-ink:    #0f172a;
    --fc-ink-2:  #475569;

    /* status (fixed) and deltas */
    --st-good:   #0ca30c;
    --st-warn:   #fab219;
    --st-crit:   #d03b3b;
    --good-text: #006300;
    --warn-text: #8a5300;
    --crit-text: #b42318;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: linear-gradient(180deg, var(--wash) 0, #eef4fb 260px, var(--bg) 620px) no-repeat, var(--bg);
    color: var(--text);
    font: 400 14px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

[hidden] { display: none !important; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.num, .tnum { font-variant-numeric: tabular-nums; }

/* ── Header: the map page's blue ribbon ── */
.fa-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: linear-gradient(110deg, #083b63 0%, #0e6ba8 55%, #1597b5 100%);
    border-bottom: 1px solid rgba(8, 44, 70, 0.6);
    box-shadow: 0 2px 0 rgba(255, 255, 255, 0.08) inset, 0 10px 26px -14px rgba(8, 44, 70, 0.55);
    color: #fff;
}

.fa-header-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 7px 16px;
    min-height: 48px;
}

.fa-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    flex: 1 1 auto;
    color: #fff;
    font-size: 1.05rem;
    font-weight: 650;
    letter-spacing: -0.012em;
    text-shadow: 0 1px 2px rgba(5, 25, 45, 0.25);
}

.fa-brand:hover { color: #fff; text-decoration: none; }

.fa-brand svg {
    flex: none;
    height: 1.55em;
    width: auto;
    border-radius: 7px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5), 0 1px 3px rgba(5, 25, 45, 0.35);
}

.fa-brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Page tabs: the same segmented control as the map-style buttons */
.fa-tabs {
    display: inline-flex;
    flex: none;
    gap: 2px;
    padding: 3px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 10px;
}

.fa-tabs a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px;
    border-radius: 7px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.78rem;
    font-weight: 550;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}

.fa-tabs a:hover { background: rgba(255, 255, 255, 0.16); color: #fff; text-decoration: none; }

.fa-tabs a.active {
    background: #fff;
    color: var(--accent);
    box-shadow: 0 1px 3px rgba(5, 25, 45, 0.3);
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 13px;
    border: 1px solid var(--border-2);
    border-radius: var(--r-sm);
    background: var(--panel);
    color: var(--text);
    font-size: 0.84rem;
    font-weight: 550;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover:not(:disabled) { background: var(--hover); border-color: rgba(15, 23, 42, 0.22); text-decoration: none; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-h); border-color: var(--accent-h); color: #fff; }
.btn-danger { color: var(--crit-text); }
.btn-danger:hover:not(:disabled) { background: #fdf0ef; border-color: rgba(180, 35, 24, 0.35); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--hover); border-color: transparent; color: var(--text); }
.btn-icon { padding: 5px 8px; }

/* ── Page frame ── */
.fa-main {
    flex: 1 0 auto;
    width: 100%;
    max-width: 1360px;
    margin: 0 auto;
    padding: 20px 16px 36px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    outline: none;
}

.fa-loading, .fa-error {
    padding: 48px 20px;
    text-align: center;
    color: var(--text-2);
}

.fa-error { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--sh-sm); }
.fa-error h2 { color: var(--ink); font-size: 1.05rem; margin: 0 0 6px; }
.fa-error code { background: var(--hover); padding: 2px 6px; border-radius: 5px; font-size: 0.85em; }

.fa-pagehead {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 24px;
}

.fa-title {
    margin: 0;
    color: var(--ink);
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

/* Project title followed by the bracketed estimates disclaimer. The h1 carries the small text size so the
   disclaimer's wrapped lines sit close together; only the name is set large. */
.fa-title.has-note { font-size: 0.82rem; line-height: 1.5; }
.title-name { font-size: 1.55rem; line-height: 1.2; }

.title-note {
    margin-left: 0.3em;
    color: var(--crit-text);
    font-weight: 500;
    letter-spacing: 0;
    animation: title-note-in 0.8s ease-out both, title-note-pulse 2.6s ease-in-out 0.8s infinite;
}

@keyframes title-note-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Both reds keep at least 4.5:1 contrast on the page background, so the text stays readable mid-pulse. */
@keyframes title-note-pulse {
    0%, 100% { color: var(--crit-text); text-shadow: none; }
    50%      { color: #dc2626; text-shadow: 0 0 8px rgba(220, 38, 38, 0.35); }
}

@media (prefers-reduced-motion: reduce) {
    .title-note { animation: none; }
}

.fa-lede { margin: 6px 0 0; color: var(--text-2); max-width: 760px; }
.fa-basis { margin-top: 10px; padding: 8px 12px; max-width: 760px; border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; background: var(--tint); }
.fa-basis p { margin: 0; color: var(--text-2); font-size: 0.82rem; }
.fa-basis p + p { margin-top: 2px; }

.crumbs { font-size: 0.85rem; margin-bottom: -8px; }
.crumbs a { display: inline-flex; align-items: center; gap: 6px; font-weight: 550; }

/* ── Cards ── */
.card {
    background: var(--panel);
    border: 1px solid rgba(15, 23, 42, 0.07);
    border-radius: var(--r);
    box-shadow: var(--sh-sm);
    padding: 16px 18px;
    min-width: 0;
}

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin-bottom: 12px;
}

.card-head > div:first-child { flex: 1 1 260px; min-width: 0; }
.card-head > .btn { flex: none; }
.card-head > .card-tools { flex: 0 1 auto; min-width: 0; }
.chart-card .card-head { flex-wrap: nowrap; }
.chart-card .card-head > div:first-child { flex-basis: auto; }

/* An odd last chart spans the full row instead of leaving a gap */
.chart-grid > .chart-card:last-child:nth-child(odd) { grid-column: 1 / -1; }

.mobile-sort { display: none; align-items: center; gap: 8px; color: var(--text-2); font-size: 0.8rem; font-weight: 550; }

.card-head h2, .card-head h3 { margin: 0; color: var(--ink); font-size: 0.98rem; font-weight: 650; letter-spacing: -0.01em; }
.card-head h2::before, .card-head h3::before { content: ''; display: inline-block; width: 4px; height: 0.95em; margin-right: 9px; border-radius: 2px; background: linear-gradient(180deg, #0e6ba8, #1597b5); vertical-align: -0.12em; }
.card-head h3 { font-size: 0.92rem; }
.card-sub { margin: 3px 0 0; color: var(--text-2); font-size: 0.8rem; max-width: 640px; }
.card-tools { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 8px; }

/* ── KPI tiles ── */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpis.kpis-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

.kpi {
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #ffffff 0%, #fafcff 100%);
    border: 1px solid rgba(15, 23, 42, 0.07);
    border-radius: var(--r);
    box-shadow: var(--sh-sm);
    padding: 16px 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.kpi::before { content: ''; position: absolute; inset: 0 0 auto; height: 3px; background: var(--brand-grad); opacity: 0.85; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--sh-md); }

@media (prefers-reduced-motion: reduce) {
    .kpi { transition: none; }
    .kpi:hover { transform: none; }
}

.kpi-label { color: var(--text-2); font-size: 0.78rem; font-weight: 550; }
.kpi-value { color: var(--ink); font-size: 1.6rem; font-weight: 650; letter-spacing: -0.02em; line-height: 1.25; overflow-wrap: anywhere; }
.kpi-value small { font-size: 0.55em; font-weight: 550; color: var(--text-2); letter-spacing: 0; margin-left: 3px; }
.kpi-sub { color: var(--text-2); font-size: 0.78rem; overflow-wrap: anywhere; }
.kpi .pill { margin-top: 4px; }


.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    width: fit-content;
    padding: 2px 9px 2px 7px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 650;
    white-space: nowrap;
}

.pill.good { color: var(--good-text); background: rgba(12, 163, 12, 0.11); }
.pill.good i { color: var(--st-good); }
.pill.warn { color: var(--warn-text); background: rgba(250, 178, 25, 0.18); }
.pill.warn i { color: #d48f00; }
.pill.crit { color: var(--crit-text); background: rgba(208, 59, 59, 0.1); }
.pill.crit i { color: var(--st-crit); }
.pill.neutral { color: var(--text-2); background: var(--hover); }

.st-icon { font-size: 0.8em; margin-left: 4px; vertical-align: 0.02em; }
.st-icon.good { color: var(--st-good); }
.st-icon.warn { color: #d48f00; }
.st-icon.crit { color: var(--st-crit); }

/* ── Filter row ── */
.fa-filters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 12px;
}

.search-box {
    position: relative;
    flex: 0 1 300px;
    min-width: 200px;
}

.search-box i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 0.85rem; pointer-events: none; }

.search-box input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    background: var(--panel);
    border: 1px solid var(--border-2);
    border-radius: var(--r-sm);
    font-size: 0.86rem;
}

.search-box input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow, rgba(14, 107, 168, 0.18)); }

.seg {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 3px;
    background: #e7eef7;
    border-radius: 10px;
}

.seg button {
    padding: 5px 11px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text-2);
    font-size: 0.8rem;
    font-weight: 550;
    cursor: pointer;
    white-space: nowrap;
}

.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--accent-h); font-weight: 650; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 2px 6px -2px rgba(14, 107, 168, 0.25); }

.check {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.84rem;
    color: var(--text);
    cursor: pointer;
    user-select: none;
}

.check input { width: 15px; height: 15px; accent-color: var(--accent); margin: 0; }
.filter-count { color: var(--text-2); font-size: 0.82rem; margin-left: auto; }

/* ── Tables ── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -18px; padding: 0 18px; }

.fa-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.84rem;
}

.fa-table th, .fa-table td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
}

.fa-table thead th {
    position: sticky;
    top: 0;
    background: var(--tint);
    color: var(--text-2);
    font-size: 0.74rem;
    font-weight: 600;
    border-bottom: 1px solid var(--tint-line);
    vertical-align: bottom;
    white-space: normal;
    min-width: 72px;
}

#ovTable thead th .sort-btn { white-space: normal; display: inline; }
#ovTable thead th .sort-btn i { margin-left: 3px; }
#ovTable thead th .th-line { white-space: nowrap; }
#ovTable thead th .th-line:first-child { display: block; }
#ovTable .adj-cell { white-space: normal; min-width: 120px; }
#ovTable .adj-cell .chip { margin: 0 4px 3px 0; }
#ovTable .adj-cell .chip + .chip { margin-left: 0; }

.fa-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.fa-table tbody tr { cursor: pointer; transition: background 0.12s ease; }
.fa-table tbody tr:hover { background: #f5f9fe; }
.fa-table tbody tr:last-child td, .fa-table tbody tr:last-child th { border-bottom: 0; }
.fa-table .cell-sub { display: block; color: var(--text-2); font-size: 0.74rem; font-weight: 450; margin-top: 1px; }
.fa-table .proj-cell { white-space: normal; min-width: 190px; }
.fa-table .proj-cell a { color: var(--ink); font-weight: 600; }
.fa-table .proj-cell a:hover { color: var(--accent); }

.sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
    text-align: inherit;
    white-space: nowrap;
}

.sort-btn:hover { color: var(--ink); }
.sort-btn i { font-size: 0.7rem; opacity: 0.35; }
th[aria-sort] .sort-btn { color: var(--accent-h); }
th[aria-sort] .sort-btn i { opacity: 1; }

.status-dot { display: inline-flex; align-items: center; gap: 6px; }
.status-dot::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.status-dot.operating::before { background: var(--fc-s1); }
.status-dot.construction::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--fc-ink-2); }
.status-dot.transferred::before { background: var(--text-3); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--accent-dim);
    color: var(--accent-h);
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.chip + .chip { margin-left: 4px; }
.chip.muted { background: var(--hover); color: var(--text-2); }
.chip.bonus { background: #eaf2fc; color: #1c5cab; }
.chip.right, .chip.ipo { background: #fdf0ea; color: #9a3a12; }
.chip.wb { background: #f1f5f9; color: #475569; }


.empty-row td { text-align: center; color: var(--text-2); padding: 28px 10px; cursor: default; }

/* ── Detail page ── */
.detail-head .facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.fact {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    background: var(--tint);
    border: 1px solid var(--tint-line);
    border-radius: 999px;
    color: var(--text-2);
    font-size: 0.78rem;
}

.fact b { color: var(--ink); font-weight: 600; }
.remarks { margin: 10px 0 0; color: var(--text-2); font-size: 0.84rem; max-width: 820px; }
.remarks i { color: var(--text-3); margin-right: 4px; }

.picker { display: flex; align-items: center; gap: 8px; }
.picker label { color: var(--text-2); font-size: 0.8rem; font-weight: 550; }

.picker select, .fa-select {
    padding: 7px 30px 7px 11px;
    background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='%235b6b80' d='M8 11.5 2.5 6h11z'/%3E%3C/svg%3E") no-repeat right 10px center;
    border: 1px solid var(--border-2);
    border-radius: var(--r-sm);
    font-size: 0.86rem;
    font-weight: 550;
    max-width: 280px;
    appearance: none;
    cursor: pointer;
}

.content { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
#dNotes:empty { display: none; }

/* Model inputs: read-only values, collapsed until opened */
details.inputs > summary {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 2px 12px;
    list-style: none;
    cursor: pointer;
}

details.inputs > summary::-webkit-details-marker { display: none; }
details.inputs > summary h2 { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--ink); font-size: 0.98rem; font-weight: 650; letter-spacing: -0.01em; }
details.inputs > summary h2::before { content: '\F285'; font-family: 'bootstrap-icons'; font-size: 0.75rem; color: var(--text-3); transition: transform 0.15s ease; }
details.inputs[open] > summary h2::before { transform: rotate(90deg); }
details.inputs[open] > summary { margin-bottom: 10px; }
.inputs-note { color: var(--text-2); font-size: 0.78rem; }
.inputs-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0 28px; align-items: start; }

details.fgroup { border-top: 1px solid var(--border); }

details.fgroup > summary {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 0;
    color: var(--text);
    font-size: 0.84rem;
    font-weight: 600;
    list-style: none;
    cursor: pointer;
}

details.fgroup > summary::-webkit-details-marker { display: none; }
details.fgroup > summary::before { content: '\F285'; font-family: 'bootstrap-icons'; font-size: 0.7rem; color: var(--text-3); transition: transform 0.15s ease; }
details.fgroup[open] > summary::before { transform: rotate(90deg); }

.fvals { margin: 0 0 10px; }
.fval { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 5px 0 5px 17px; border-bottom: 1px dashed var(--border); font-size: 0.8rem; }
.fval:last-child { border-bottom: 0; }
.fval dt { color: var(--text-2); }
.fval dd { margin: 0; color: var(--ink); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.fval dd .fsub { display: block; color: var(--text-2); font-size: 0.72rem; font-weight: 500; }
.fval.editable { align-items: center; }
.fval.editable dt label { color: var(--ink); font-weight: 600; cursor: pointer; }
.fval.editable dd { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.fedit { display: inline-flex; align-items: center; gap: 5px; }
.fedit input {
    width: 78px;
    padding: 4px 8px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--accent);
    border-radius: 7px;
    font: inherit;
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.fedit input:focus { outline: none; box-shadow: 0 0 0 3px rgba(14, 107, 168, 0.18); }
.fedit input.is-invalid { border-color: var(--st-crit); background: #fff5f5; }
.fedit-note { display: inline-flex; white-space: nowrap; }
.fedit-note[hidden] { display: none; }

/* Adjustment banner */
.adj-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 16px;
    padding: 12px 16px;
    background: linear-gradient(180deg, #f2f8fd, #edf5fc);
    border: 1px solid rgba(14, 107, 168, 0.18);
    border-radius: var(--r);
    font-size: 0.84rem;
}

.adj-banner p { margin: 0; color: var(--text); }
.adj-banner p + p { margin-top: 3px; color: var(--text-2); font-size: 0.78rem; }

.switch { display: inline-flex; align-items: center; gap: 9px; font-weight: 600; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 36px; height: 20px; border-radius: 999px; background: #cbd5e1; transition: background 0.15s ease; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.3); transition: transform 0.15s ease; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Year navigator */
.yearnav { display: flex; flex-direction: column; gap: 10px; }
.yearnav .row1 { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; }
.yearnav input[type=range] { flex: 1 1 180px; accent-color: var(--accent); min-width: 120px; }
.year-label { color: var(--ink); font-weight: 700; font-size: 1rem; font-variant-numeric: tabular-nums; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--tint);
    border: 1px solid var(--tint-line);
    color: var(--text-2);
    font-size: 0.74rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.badge.event { background: #fdf0ea; border-color: rgba(235, 104, 52, 0.25); color: #9a3a12; }
.badge.event.bonus { background: #eaf2fc; border-color: rgba(42, 120, 214, 0.25); color: #1c5cab; }

.yd-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 28px; }
.yd-sec h4 { margin: 0 0 6px; padding-bottom: 6px; border-bottom: 1px solid var(--border-2); color: var(--accent-h); font-size: 0.74rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.yd-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 3.5px 0; font-size: 0.82rem; }
.yd-row .lbl { color: var(--text-2); }
.yd-row .val { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 500; white-space: nowrap; }
.yd-row.strong .lbl, .yd-row.strong .val { color: var(--ink); font-weight: 650; }
.yd-row.neg .val { color: var(--crit-text); }
.yd-row.pos .val { color: var(--good-text); }
.yd-row.new .lbl::after { content: 'adjusted'; margin-left: 6px; padding: 0 5px; border-radius: 4px; background: #fdf0ea; color: #9a3a12; font-size: 0.66rem; font-weight: 650; }

/* Charts */
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.chart-host { position: relative; min-height: 120px; }

.fc { position: relative; }
.fc-svg { display: block; max-width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.fc-grid { stroke: var(--fc-grid); stroke-width: 1; shape-rendering: crispEdges; }
.fc-axis { stroke: var(--fc-axis); stroke-width: 1; shape-rendering: crispEdges; }
.fc-tick { fill: var(--fc-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.fc-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fc-dot, .fc-hover-dot { stroke: var(--panel); stroke-width: 2; }
.fc-bar { transition: opacity 0.12s ease; }
.fc-bar.is-hover { opacity: 0.78; }
.fc-hit { fill: transparent; outline: none; }
.fc-cross { stroke: var(--fc-ink-2); stroke-width: 1; shape-rendering: crispEdges; pointer-events: none; }
.fc-selected { stroke: var(--fc-axis); stroke-width: 1; shape-rendering: crispEdges; }
.fc-marker { stroke: var(--fc-ink-2); stroke-width: 1; stroke-opacity: 0.55; shape-rendering: crispEdges; }
.fc-ref { stroke: var(--fc-ink); stroke-width: 1; stroke-opacity: 0.6; shape-rendering: crispEdges; }
.fc-ref-label { fill: var(--fc-ink-2); font-size: 10.5px; font-weight: 550; paint-order: stroke; stroke: var(--panel); stroke-width: 3px; }
.fc-end-label { fill: var(--fc-ink-2); font-size: 11px; font-weight: 550; }
.fc-svg:focus { outline: none; }
.fc-svg:focus-visible, .fc-hit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.fc-tooltip {
    position: absolute;
    z-index: 5;
    visibility: hidden;
    pointer-events: none;
    min-width: 120px;
    max-width: 260px;
    padding: 7px 10px;
    background: var(--panel);
    border: 1px solid var(--border-2);
    border-radius: 8px;
    box-shadow: var(--sh-md);
    font-size: 0.76rem;
    line-height: 1.45;
}

.fc-tt-head { color: var(--text-2); font-weight: 550; margin-bottom: 3px; white-space: nowrap; }
.fc-tt-row { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.fc-tt-row b { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.fc-tt-label { color: var(--text-2); }

.fc-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; color: var(--text-2); font-size: 0.76rem; }
.fc-legend-item { display: inline-flex; align-items: center; gap: 6px; }

.fc-key { display: inline-block; flex: none; background: var(--k); }
.fc-key-line { width: 14px; height: 2px; border-radius: 1px; }
.fc-key-rect { width: 10px; height: 10px; border-radius: 2px; }
.fc-key-dot { width: 9px; height: 9px; border-radius: 50%; }
.fc-key-tick { width: 2px; height: 12px; border-radius: 1px; }
.fc-key-marker { width: 1px; height: 12px; opacity: 0.7; }

/* Horizontal ranking */
.fc-rank { --label-w: 190px; --value-w: 64px; position: relative; padding-bottom: 22px; }
.fc-rank-grid { position: absolute; top: 0; bottom: 22px; left: calc(var(--label-w) + 12px); right: calc(var(--value-w) + 12px); pointer-events: none; }
.fc-rank-gridline { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--fc-grid); }
.fc-rank-gridline.is-zero { background: var(--fc-axis); }
.fc-rank-list { position: relative; display: flex; flex-direction: column; }

.fc-rank-row {
    display: grid;
    grid-template-columns: var(--label-w) minmax(0, 1fr) var(--value-w);
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 4px 0;
    border: 0;
    background: transparent;
    text-align: left;
    font: inherit;
    cursor: pointer;
    border-radius: 6px;
}

.fc-rank-row:hover { background: rgba(14, 107, 168, 0.045); }
.fc-rank-label { color: var(--text); font-size: 0.8rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 4px; }
.fc-rank-track { position: relative; height: 22px; }
.fc-rank-bar { position: absolute; top: 4px; height: 14px; border-radius: 0 4px 4px 0; transition: opacity 0.12s ease; }
.fc-rank-bar.is-neg { border-radius: 4px 0 0 4px; }
.fc-rank-row:hover .fc-rank-bar { opacity: 0.8; }
.fc-rank-ref { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--fc-ink); border-radius: 1px; }
.fc-rank-value { color: var(--ink); font-size: 0.8rem; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; padding-right: 4px; }
.fc-rank-axis { position: absolute; bottom: 0; height: 18px; left: calc(var(--label-w) + 12px); right: calc(var(--value-w) + 12px); }
.fc-rank-tick { position: absolute; transform: translateX(-50%); color: var(--fc-muted); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Chart table view */
.fc-table-wrap { max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: var(--r-sm); }
.fc-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.fc-table caption { text-align: left; padding: 6px 10px; color: var(--text-2); }
.fc-table th, .fc-table td { padding: 5px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.fc-table thead th { position: sticky; top: 0; background: var(--panel-2); color: var(--text-2); font-weight: 600; }
.fc-table tbody th { font-weight: 500; color: var(--text); }
.fc-table .num { text-align: right; font-variant-numeric: tabular-nums; }

.adj-empty { margin: 0; padding: 18px; text-align: center; color: var(--text-2); font-size: 0.84rem; background: var(--panel-2); border: 1px dashed var(--border-2); border-radius: 11px; }


/* Year-by-year table */
details.yearly > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    list-style: none;
    cursor: pointer;
}

details.yearly > summary::-webkit-details-marker { display: none; }
details.yearly > summary h2 { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--ink); font-size: 0.98rem; font-weight: 650; letter-spacing: -0.01em; }
details.yearly > summary h2::before { content: '\F285'; font-family: 'bootstrap-icons'; font-size: 0.75rem; color: var(--text-3); transition: transform 0.15s ease; }
details.yearly[open] > summary h2::before { transform: rotate(90deg); }
details.yearly[open] > summary { margin-bottom: 12px; }
.yearly-scroll { max-height: 560px; overflow: auto; border: 1px solid var(--border); border-radius: var(--r-sm); }
.yearly-scroll .fa-table tbody tr { cursor: default; }
.yearly-scroll .fa-table th:first-child, .yearly-scroll .fa-table td:first-child { position: sticky; left: 0; background: var(--panel); z-index: 1; }
.yearly-scroll .fa-table thead th:first-child { z-index: 2; }
.yearly-scroll .fa-table tr.is-cod td, .yearly-scroll .fa-table tr.is-cod th { box-shadow: inset 0 2px 0 rgba(14, 107, 168, 0.35); }
.yearly-scroll .fa-table tr.is-now { background: #f2f8fd; }
.yearly-scroll .fa-table tr.is-now td:first-child { background: #f2f8fd; }

/* ── Footer ── */
.fa-foot {
    width: 100%;
    max-width: 1360px;
    margin: 0 auto;
    padding: 4px 16px 28px;
    color: var(--text-2);
    font-size: 0.76rem;
    line-height: 1.55;
}

.fa-foot p { margin: 0 0 4px; max-width: 900px; }

/* ── Responsive ── */
@media (max-width: 1240px) {
    .kpis.kpis-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .yd-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
    .chart-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .fa-header-inner { padding: 6px 8px; gap: 8px; }
    .fa-brand { font-size: 13px; gap: 8px; }
    .fa-brand span { white-space: normal; line-height: 1.25; }
    .fa-tabs a { padding: 4px 8px; font-size: 0.72rem; }
    .fa-tabs a .tab-long { display: none; }
    .fa-main { padding: 14px 12px 28px; gap: 14px; }
    .fa-title { font-size: 1.3rem; }
    .title-name { font-size: 1.3rem; }
    .card { padding: 14px; }
    .table-scroll { margin: 0 -14px; padding: 0 14px; }
    .kpis.kpis-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpi { padding: 12px 13px; }
    .kpi-value { font-size: 1.3rem; }
    .yd-grid { grid-template-columns: 1fr; }
    .fc-rank { --label-w: 112px; --value-w: 54px; }
    .fc-rank-row { gap: 8px; }
    .fc-rank-grid, .fc-rank-axis { left: calc(var(--label-w) + 8px); right: calc(var(--value-w) + 8px); }
    .filter-count { margin-left: 0; width: 100%; }
    .search-box { flex: 1 1 100%; }
    .fa-table .proj-cell { min-width: 150px; }
}

@media (max-width: 640px) {
    .mobile-sort { display: inline-flex; }
    .mobile-sort .fa-select { max-width: 200px; padding-top: 5px; padding-bottom: 5px; font-size: 0.8rem; }
    #ovTable, #ovTable tbody { display: block; }
    #ovTable thead { display: none; }
    #ovTable tbody tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px 14px;
        padding: 12px 2px 14px;
        border-bottom: 1px solid var(--border);
    }
    #ovTable tbody tr:last-child { border-bottom: 0; }
    #ovTable tbody th, #ovTable tbody td { display: block; padding: 0; border: 0; white-space: normal; text-align: left; min-width: 0; }
    #ovTable tbody th.proj-cell { grid-column: 1 / -1; }
    #ovTable tbody td::before { content: attr(data-label); display: block; color: var(--text-2); font-size: 0.68rem; font-weight: 600; margin-bottom: 1px; }
    #ovTable tbody td.adj-cell { grid-column: 1 / -1; }
    #ovTable tbody td.adj-cell:not(:has(.chip)) { display: none; }
    #ovTable .empty-row td { grid-column: 1 / -1; text-align: center; }
    #ovTable .empty-row td::before { content: none; }
    .table-scroll { overflow: visible; }
}

@media (max-width: 420px) {
    .fa-tabs a i { display: none; }
    .kpi-value { font-size: 1.15rem; }
}

@media print {
    .fa-header, .fa-foot, .inputs, .btn { display: none !important; }
    .card, .kpi { box-shadow: none; break-inside: avoid; }
}

/* Wet season dispatch what-if, under the estimates disclaimer */
.dispatch-whatif { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 8px; }
.dispatch-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.dispatch-panel[hidden] { display: none; }
.dispatch-label { color: var(--text-2); font-size: 0.8rem; font-weight: 600; }
.dispatch-caret { transition: transform 0.2s ease; }
#dDispatchBtn[aria-expanded="true"] .dispatch-caret { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .dispatch-caret { transition: none; } }
