/* =============================================================================
 * cadence-fpa.css — the FP&A surface.
 * One layer, its own tokens drawn from brand-contract.md (plum authority, ledger neutrals,
 * Instrument type). The sheet is the hero: dense tabular numerics, hairline rules, plum only on
 * the header band and selection, colour only for favourable / unfavourable.
 * ============================================================================= */
.fpa-page {
  --fpa-canvas: #f6f5f1; --fpa-surface: #ffffff; --fpa-line: #e2ded6; --fpa-line-soft: #edeae4;
  --fpa-ink: #22232a; --fpa-muted: #7a756e; --fpa-faint: #a7a099;
  --fpa-plum: #302437; --fpa-plum-ink: #e9dfcd; --fpa-plum-sel: #5a3470; --fpa-plum-tint: rgba(90, 52, 112, .07);
  --fpa-agg: #f5f2eb; --fpa-closed: #f3f1f4; --fpa-slab: #f4f2ee; --fpa-total: #fbfaf7;
  --fpa-pos: #03684a; --fpa-neg: #8a2f10; --fpa-pos-bg: rgba(3, 104, 74, .08); --fpa-neg-bg: rgba(138, 47, 16, .08);
  --fpa-serif: "Instrument Serif", Georgia, serif; --fpa-sans: "Instrument Sans", Arial, sans-serif;
  font-family: var(--fpa-sans); color: var(--fpa-ink); -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; gap: 12px; min-height: 0;
}
.fpa-page * { box-sizing: border-box; }

/* ---- command bar ------------------------------------------------------------------------- */
.fpa-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fpa-bar .fpa-gap { flex: 1 1 auto; }
.fpa-ctl { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 30px 0 12px; background: var(--fpa-surface); border: 1px solid var(--fpa-line); border-radius: 6px; cursor: pointer; white-space: nowrap; }
.fpa-ctl:hover { border-color: #cfc9bf; }
.fpa-ctl .l { font-size: 9.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--fpa-faint); }
.fpa-ctl .v { font-size: 13px; font-weight: 550; color: var(--fpa-ink); }
.fpa-ctl::after { content: ""; position: absolute; right: 11px; top: 50%; width: 6px; height: 6px; border-right: 1.5px solid var(--fpa-muted); border-bottom: 1.5px solid var(--fpa-muted); transform: translateY(-70%) rotate(45deg); }
.fpa-ctl select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 14px; }
.fpa-ctl.static { padding-right: 12px; cursor: default; } .fpa-ctl.static::after { display: none; }
.fpa-bar .plan-ver { height: 34px; }
.fpa-btn { height: 34px; padding: 0 12px; border: 1px solid var(--fpa-line); background: var(--fpa-surface); border-radius: 6px; font: 550 13px var(--fpa-sans); color: var(--fpa-ink); cursor: pointer; }
.fpa-btn:hover { border-color: #cfc9bf; } .fpa-btn:disabled { color: var(--fpa-faint); cursor: default; }
.fpa-btn.on { background: var(--fpa-plum); color: #fff; border-color: var(--fpa-plum); }
.fpa-seg { display: inline-flex; border: 1px solid var(--fpa-line); border-radius: 6px; overflow: hidden; height: 34px; background: var(--fpa-surface); }
.fpa-seg button { border: 0; background: transparent; padding: 0 12px; font: 550 12.5px var(--fpa-sans); color: var(--fpa-muted); cursor: pointer; }
.fpa-seg button.on { background: var(--fpa-plum); color: #fff; }
.fpa-save { font-size: 12px; color: var(--fpa-muted); white-space: nowrap; }
.fpa-save .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--fpa-pos); margin-right: 6px; vertical-align: 1px; }
.fpa-save.dirty .dot, .fpa-save.saving .dot { background: #b9862c; } .fpa-save.err .dot { background: var(--fpa-neg); }

/* ---- cards & stats ----------------------------------------------------------------------- */
.fpa-card { background: var(--fpa-surface); border: 1px solid var(--fpa-line); border-radius: 6px; min-width: 0; }
.fpa-card-h { display: flex; align-items: baseline; gap: 12px; padding: 12px 16px 10px; border-bottom: 1px solid var(--fpa-line-soft); }
.fpa-card-h h3 { margin: 0; font: 600 14px var(--fpa-sans); color: var(--fpa-ink); }
.fpa-card-h .sub { font-size: 12px; color: var(--fpa-muted); }
.fpa-card-h .right { margin-left: auto; display: inline-flex; gap: 8px; align-items: center; }
.fpa-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.fpa-stat { background: var(--fpa-surface); border: 1px solid var(--fpa-line); border-radius: 6px; padding: 12px 16px 10px; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto auto; column-gap: 10px; min-width: 0; }
.fpa-stat .l { grid-column: 1 / -1; font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--fpa-muted); }
.fpa-stat .v { grid-column: 1; font: 400 30px/1.1 var(--fpa-serif); letter-spacing: -.02em; color: var(--fpa-ink); margin-top: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fpa-stat .d { grid-column: 1; font-size: 12px; margin-top: 4px; color: var(--fpa-muted); white-space: nowrap; }
.fpa-stat .d b { font-weight: 650; } .fpa-stat .d.up b { color: var(--fpa-pos); } .fpa-stat .d.down b { color: var(--fpa-neg); }
.fpa-stat svg { grid-column: 2; grid-row: 2 / 4; align-self: end; width: 96px; height: 36px; }

/* ---- the sheet --------------------------------------------------------------------------- */
.fpa-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
.fpa-main.with-inspector { grid-template-columns: minmax(0, 1fr) 340px; }
.fpa-sheet-wrap { overflow: auto; max-height: calc(100vh - 210px); border-radius: 6px; }
.fpa-sheet { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.fpa-sheet th { position: sticky; top: 0; z-index: 3; background: var(--fpa-plum); color: var(--fpa-plum-ink); font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; text-align: right; padding: 0 10px; height: 36px; white-space: nowrap; border-bottom: 1px solid #211a27; }
.fpa-sheet th.lab { text-align: left; left: 0; z-index: 5; }
.fpa-sheet th.agg { background: #3a2d42; } .fpa-sheet th.fy { background: #241c2b; position: sticky; right: 0; z-index: 4; box-shadow: -1px 0 0 #211a27; }
.fpa-sheet td { padding: 0 10px; height: 30px; border-bottom: 1px solid var(--fpa-line-soft); text-align: right; white-space: nowrap; background: var(--fpa-surface); color: var(--fpa-ink); }
.fpa-sheet td.lab { text-align: left; position: sticky; left: 0; z-index: 2; min-width: 250px; box-shadow: 1px 0 0 var(--fpa-line); }
.fpa-sheet td.lab .code { display: inline-block; width: 38px; color: var(--fpa-faint); font-size: 11px; }
.fpa-sheet td.lab .trend { display: inline-block; vertical-align: middle; margin-left: 10px; width: 64px; height: 16px; }
.fpa-sheet tr.ind1 td.lab { padding-left: 22px; } .fpa-sheet tr.ind2 td.lab { padding-left: 38px; } .fpa-sheet tr.ind3 td.lab { padding-left: 54px; }
.fpa-sheet tr.roll td { background: var(--fpa-slab); font-weight: 650; } .fpa-sheet tr.roll td.lab { padding-left: 10px; }
.fpa-sheet tr.total td { background: var(--fpa-total); font-weight: 700; border-top: 1.5px solid #cdc7bc; } .fpa-sheet tr.total td.lab { padding-left: 10px; }
.fpa-sheet td.agg { background: var(--fpa-agg); } .fpa-sheet tr.roll td.agg { background: #ede9e0; } .fpa-sheet tr.total td.agg { background: #f1ede4; }
.fpa-sheet td.fy { position: sticky; right: 0; z-index: 2; font-weight: 650; box-shadow: -1px 0 0 var(--fpa-line); background: #f1ede4; }
.fpa-sheet td.closed { background: var(--fpa-closed); color: #4b4650; } .fpa-sheet tr.roll td.closed, .fpa-sheet tr.total td.closed { background: #ebe8ec; }
.fpa-sheet td.closed.last { box-shadow: inset -2px 0 0 var(--fpa-plum-sel); }
.fpa-sheet td.driven { color: #5f5a63; } .fpa-sheet td.driven::after { content: "\0192"; font-family: Georgia, serif; font-style: italic; font-size: 10px; color: var(--fpa-faint); margin-left: 5px; }
.fpa-sheet td.empty { color: var(--fpa-faint); }
.fpa-sheet td.in { padding: 0 4px; }
.fpa-sheet td.in input { width: 100%; min-width: 84px; height: 26px; border: 1px solid transparent; border-radius: 4px; background: transparent; text-align: right; font: 500 12.5px var(--fpa-sans); color: var(--fpa-ink); font-variant-numeric: tabular-nums; padding: 0 6px; outline: none; }
.fpa-sheet td.in input:hover { border-color: #cfc9bf; background: #fff; }
.fpa-sheet td.in input:focus { border-color: var(--fpa-plum-sel); box-shadow: 0 0 0 2px var(--fpa-plum-tint); background: #fff; }
.fpa-sheet td.in.edited input { color: #3d2a52; font-weight: 600; }
.fpa-sheet td.sel { box-shadow: inset 0 0 0 1.5px var(--fpa-plum-sel); }
.fpa-sheet td.pos { color: var(--fpa-pos); } .fpa-sheet td.neg { color: var(--fpa-neg); }
.fpa-sheet td.pct { color: var(--fpa-muted); font-size: 11px; padding-left: 4px; width: 58px; }
.fpa-sheet td.pos.pct, .fpa-sheet td.neg.pct { color: inherit; opacity: .85; }
.fpa-sheet tr.cmp td { height: 22px; font-size: 11px; color: var(--fpa-muted); background: #fbfaf8; border-bottom: 1px solid var(--fpa-line-soft); }
.fpa-sheet tr.cmp td.lab { padding-left: 48px; font-style: italic; }
.fpa-sheet tr.cmp td.pos { color: var(--fpa-pos); } .fpa-sheet tr.cmp td.neg { color: var(--fpa-neg); }
.fpa-sheet tbody tr:hover td { background-color: #faf8f4; } .fpa-sheet tbody tr:hover td.closed { background-color: #efedf0; }
.fpa-sheet tbody tr.roll:hover td, .fpa-sheet tbody tr.total:hover td { filter: brightness(.985); }
.fpa-sheet td.flag { padding: 0 6px; width: 24px; } .fpa-sheet td.flag i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--fpa-neg); }
.fpa-sheet td.note { padding: 0 6px; min-width: 220px; }
.fpa-sheet td.note input { width: 100%; height: 24px; border: 1px solid transparent; border-radius: 4px; background: transparent; font: 400 12px var(--fpa-sans); color: var(--fpa-ink); padding: 0 6px; }
.fpa-sheet td.note input::placeholder { color: var(--fpa-faint); font-style: italic; }
.fpa-sheet td.note input:hover { border-color: #cfc9bf; } .fpa-sheet td.note input:focus { border-color: var(--fpa-plum-sel); outline: none; background: #fff; }
.fpa-sheet td.act { text-align: left; } .fpa-sheet td.act button { border: 0; background: transparent; color: var(--fpa-plum-sel); font: 550 12px var(--fpa-sans); cursor: pointer; padding: 0; }
.fpa-legend { display: flex; gap: 16px; flex-wrap: wrap; padding: 8px 16px 10px; font-size: 11.5px; color: var(--fpa-muted); border-top: 1px solid var(--fpa-line-soft); }
.fpa-legend i { display: inline-block; width: 12px; height: 12px; border: 1px solid var(--fpa-line); border-radius: 2px; vertical-align: -2px; margin-right: 6px; }
.fpa-chips { display: inline-flex; gap: 4px; }
.fpa-chip { height: 26px; padding: 0 10px; border: 1px solid var(--fpa-line); border-radius: 13px; background: var(--fpa-surface); font: 550 12px var(--fpa-sans); color: var(--fpa-muted); cursor: pointer; }
.fpa-chip.on { background: var(--fpa-plum); color: #fff; border-color: var(--fpa-plum); }
.fpa-state { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 11px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.fpa-state.need { background: #fbf1e3; color: #8a5a12; } .fpa-state.done { background: var(--fpa-pos-bg); color: var(--fpa-pos); }

/* ---- variance workbench ------------------------------------------------------------------ */
.fpa-row2 { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 12px; }
.fpa-bridge { padding: 8px 12px 6px; } .fpa-bridge svg { width: 100%; height: 250px; display: block; }
.fpa-chart-legend { display: inline-flex; gap: 14px; font-size: 11.5px; color: var(--fpa-muted); }
.fpa-chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.fpa-exc { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.fpa-exc th { text-align: right; font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--fpa-muted); padding: 8px 12px; border-bottom: 1px solid var(--fpa-line-soft); white-space: nowrap; }
.fpa-exc th:first-child, .fpa-exc td:first-child { text-align: left; }
.fpa-exc td { padding: 0 12px; height: 38px; border-bottom: 1px solid var(--fpa-line-soft); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.fpa-exc td .n { font-weight: 600; } .fpa-exc td .s { display: block; font-size: 11px; color: var(--fpa-muted); font-weight: 400; }
.fpa-exc td.pos { color: var(--fpa-pos); } .fpa-exc td.neg { color: var(--fpa-neg); }
.fpa-exc tr:hover td { background: #faf8f4; } .fpa-exc td button { border: 0; background: transparent; color: var(--fpa-plum-sel); font: 550 12px var(--fpa-sans); cursor: pointer; }

/* ---- inspector --------------------------------------------------------------------------- */
.fpa-inspector { position: sticky; top: 92px; background: var(--fpa-surface); border: 1px solid var(--fpa-line); border-radius: 6px; padding: 14px 16px 16px; max-height: calc(100vh - 110px); overflow: auto; font-size: 12.5px; }
.fpa-inspector .eyebrow { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--fpa-faint); }
.fpa-inspector h4 { margin: 4px 0 0; font: 600 15px var(--fpa-sans); color: var(--fpa-ink); }
.fpa-inspector .pov { font-size: 11.5px; color: var(--fpa-muted); margin-top: 2px; }
.fpa-inspector .val { font: 400 32px/1.1 var(--fpa-serif); letter-spacing: -.02em; margin: 12px 0 2px; font-variant-numeric: tabular-nums; }
.fpa-inspector .val.edited { color: #3d2a52; }
.fpa-inspector .seed { font-size: 12px; color: var(--fpa-muted); } .fpa-inspector .seed button { border: 0; background: transparent; color: var(--fpa-plum-sel); font: 550 12px var(--fpa-sans); cursor: pointer; padding: 0 0 0 6px; }
.fpa-inspector .sec { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--fpa-line-soft); }
.fpa-inspector .sec .eyebrow { margin-bottom: 6px; }
.fpa-inspector .formula { font-size: 12.5px; color: var(--fpa-ink); margin-bottom: 8px; }
.fpa-inspector table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.fpa-inspector td { padding: 5px 0; border-bottom: 1px solid var(--fpa-line-soft); } .fpa-inspector td:last-child { text-align: right; font-weight: 600; }
.fpa-inspector td .sign { color: var(--fpa-faint); width: 14px; display: inline-block; }
.fpa-inspector td button { border: 0; background: transparent; color: var(--fpa-plum-sel); font: 500 12px var(--fpa-sans); cursor: pointer; padding: 0; }
.fpa-inspector .mini { width: 100%; height: auto; display: block; margin-top: 6px; }
.fpa-inspector textarea { width: 100%; min-height: 64px; border: 1px solid var(--fpa-line); border-radius: 6px; padding: 8px; font: 400 12.5px var(--fpa-sans); color: var(--fpa-ink); resize: vertical; }
.fpa-inspector textarea:focus { outline: none; border-color: var(--fpa-plum-sel); box-shadow: 0 0 0 2px var(--fpa-plum-tint); }
.fpa-inspector .close { position: absolute; top: 10px; right: 10px; border: 0; background: transparent; color: var(--fpa-faint); font-size: 16px; cursor: pointer; }
.fpa-inspector .links { display: flex; gap: 12px; margin-top: 12px; } .fpa-inspector .links button { border: 0; background: transparent; color: var(--fpa-plum-sel); font: 550 12.5px var(--fpa-sans); cursor: pointer; padding: 0; }
.fpa-empty { color: var(--fpa-muted); font-size: 12.5px; padding: 24px 16px; }

/* ---- drivers ------------------------------------------------------------------------------ */
.fpa-drv-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.fpa-drv-grid .wide { grid-column: 1 / -1; }
.fpa-sheet.compact td { height: 30px; } .fpa-sheet.compact th.lab, .fpa-sheet.compact td.lab { min-width: 200px; }
.fpa-sheet td.unit { color: var(--fpa-muted); text-align: left; font-size: 11.5px; width: 70px; }

@media (max-width: 1280px) {
  .fpa-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .fpa-row2 { grid-template-columns: minmax(0, 1fr); }
  .fpa-main.with-inspector { grid-template-columns: minmax(0, 1fr); } .fpa-inspector { position: static; max-height: none; }
  .fpa-drv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.fpa-sheet td.in input::placeholder { color: var(--fpa-faint); }

/* ---- Cadence Forms 1.0 mount: the form owns the chrome; the page is content ------------------ */
body[data-cadence-ui="1.0"] #view .fpa-page.fpa-direct { padding: 0; }
body[data-cadence-ui="1.0"] #view .fpa-page.fpa-direct .fpa-stats { margin-top: 2px; }
/* The kit owns table geometry on 1.0: the page scrolls, not the wrap, and no sticky FY column. */
html body[data-cadence-ui="1.0"] #view .fpa-direct .fpa-sheet-wrap { max-height: none; overflow: auto; }
html body[data-cadence-ui="1.0"] #view .fpa-direct .fpa-sheet th.fy, html body[data-cadence-ui="1.0"] #view .fpa-direct .fpa-sheet td.fy { position: static; box-shadow: none; }
html body[data-cadence-ui="1.0"] #view .fpa-direct .fpa-sheet td.lab { position: static; box-shadow: none; min-width: 0; }
html body[data-cadence-ui="1.0"] #view .fpa-direct .fpa-inspector { top: 100px; }
html body[data-cadence-ui="1.0"] #view .fpa-direct .fpa-card { overflow-x: auto; }
html body[data-cadence-ui="1.0"] #view .fpa-direct .fpa-row2 > * { min-width: 0; }

/* ---- phase 2: rosters and asset lists ------------------------------------------------------ */
.fpa-roster input.fpa-text { width: 100%; min-width: 160px; border: 0; background: transparent; font: inherit; color: inherit; padding: 0; }
.fpa-roster input.fpa-text:focus { outline: 1px solid var(--fpa-plum-sel); outline-offset: 2px; border-radius: 3px; }
.fpa-sheet tr.fpa-new td { background: #fbf7ee; }
.fpa-sheet td.fpa-act { text-align: right; white-space: nowrap; }
.fpa-sheet td.fpa-pick { text-align: left; }
.fpa-sheet td.fpa-pick .cad-sel { width: auto; }
.fpa-legend .fpa-note { flex-basis: 100%; }
