/* ==========================================================================
   POWERHOUSE JANITORIAL — P&L by building
   The founder's "Industry" design system (claude.ai/design, 2026-08-16):
   Barlow body / Barlow Condensed headings, a steel-blue accent ramp, square
   corners, hairline dividers, and blueprint cards with corner registration
   marks. One light theme, committed.

   CSP: style-src 'self'. Everything visual lives here — no inline styles
   anywhere in the app. Fonts are self-hosted (font-src 'self').
   ========================================================================== */

/* ------------------------------- fonts ---------------------------------- */

@font-face {
  font-family: "Barlow";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/barlow-400.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/fonts/barlow-500.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/fonts/barlow-700.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/barlow-condensed-400.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/fonts/barlow-condensed-600.woff2") format("woff2");
}

/* ------------------------------- tokens ---------------------------------- */

:root {
  --color-bg: #f2f2f3;
  --color-surface: #e9e9ea;
  --color-text: #1d1f20;
  --color-accent: #5980a6;
  --color-divider: color-mix(in srgb, #1d1f20 16%, transparent);
  --color-hairline: color-mix(in srgb, #1d1f20 8%, transparent);
  --color-muted: color-mix(in srgb, #1d1f20 55%, transparent);

  --color-neutral-100: #f5f5f8;
  --color-neutral-300: #d4d4d7;
  --color-neutral-400: #b7b7ba;
  --color-neutral-600: #7a7a7d;
  --color-neutral-800: #424244;
  --color-neutral-900: #2b2b2d;

  --color-accent-100: #eef6ff;
  --color-accent-200: #d6ebff;
  --color-accent-400: #94bce3;
  --color-accent-600: #597ea3;
  --color-accent-700: #416180;
  --color-accent-800: #2c455d;

  /* The one warm signal in an otherwise cool system: something wrong. */
  --color-bad: #8a3b2e;
  --color-bad-100: #f7e9e4;

  --font-heading: "Barlow Condensed", system-ui, sans-serif;
  --font-body: "Barlow", system-ui, sans-serif;

  --shadow-sm: 0 1px 2px color-mix(in srgb, #2b2b2d 14%, transparent);
  --shadow-md: 0 3px 10px color-mix(in srgb, #2b2b2d 16%, transparent);
  --shadow-lg: 0 12px 32px color-mix(in srgb, #2b2b2d 22%, transparent);
}

/* -------------------------------- base ----------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
/* The [hidden] attribute must always win — .app and .login-screen set display
   values that would otherwise override it and leak the hidden surface. */
[hidden] { display: none !important; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
}
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0 0 6px;
}
h1 { font-size: 34px; }
h2 { font-size: 28px; }
h3 { font-size: 22px; }
h4 { font-size: 18px; }
p { margin: 0 0 10px; }
a { color: var(--color-accent-700); text-underline-offset: 3px; }
a:hover { color: var(--color-accent-800); }
img { display: block; max-width: 100%; }
.text-muted, .faint { color: var(--color-muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.neg { color: var(--color-bad); }
.muted { color: var(--color-muted); }
.small { font-size: 12.5px; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 60;
  background: var(--color-accent); color: var(--color-bg); padding: 8px 14px;
}
.skip-link:focus { left: 8px; }

/* ------------------------ blueprint registration -------------------------- */

.blueprint { position: relative; border: 1px solid var(--color-divider); border-radius: 0; }
.blueprint > .corner {
  position: absolute; width: 11px; height: 11px;
  color: color-mix(in srgb, var(--color-text) 55%, transparent);
  pointer-events: none;
}
.blueprint > .corner::before, .blueprint > .corner::after {
  content: ""; position: absolute; background: currentColor;
}
.blueprint > .corner::before { left: 5px; top: 0; width: 1px; height: 100%; }
.blueprint > .corner::after  { top: 5px; left: 0; width: 100%; height: 1px; }
.blueprint > .corner.tl { top: -6px; left: -6px; }
.blueprint > .corner.tr { top: -6px; right: -6px; }
.blueprint > .corner.bl { bottom: -6px; left: -6px; }
.blueprint > .corner.br { bottom: -6px; right: -6px; }

/* -------------------------------- cards ----------------------------------- */

.card {
  display: flex; flex-direction: column; gap: 7px;
  padding: 14px 16px; border-radius: 0;
  background: transparent; border: 1px solid var(--color-divider);
}
.card-kicker {
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--color-accent);
}
.card-title { font-family: var(--font-heading); font-weight: 600; font-size: 21px; line-height: 1.2; }
.card-body { margin: 0; font-size: 13.5px; opacity: 0.85; }
.elev-sm { box-shadow: var(--shadow-sm); background: var(--color-bg); }
.elev-md { box-shadow: var(--shadow-md); background: var(--color-bg); }

/* -------------------------------- tags ------------------------------------ */

.tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px;
  letter-spacing: 0.02em; padding: 3px 10px; border-radius: 0; white-space: nowrap;
}
.tag-accent { background: var(--color-accent-100); color: var(--color-accent-800); }
.tag-neutral { background: var(--color-neutral-100); color: var(--color-neutral-800); border: 1px solid var(--color-hairline); }
.tag-outline { border: 1px solid var(--color-accent); color: var(--color-accent-700); }
.tag-bad { background: var(--color-bad-100); color: var(--color-bad); }

/* ------------------------------- buttons ---------------------------------- */

.btn, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none;
  font-family: var(--font-heading); font-weight: 600; letter-spacing: 0.02em;
  font-size: 14px; line-height: 1.2; color: var(--color-text);
  background: transparent; border: 1px solid var(--color-divider);
  padding: 8px 14px; border-radius: 0;
}
.btn:disabled, .button:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:hover:not(:disabled), .button:hover:not(:disabled) { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.btn-primary, .button.primary {
  background: var(--color-accent); border-color: var(--color-accent); color: var(--color-bg);
}
.btn-primary:hover:not(:disabled), .button.primary:hover:not(:disabled) { background: var(--color-accent-600); }
.btn-primary:active:not(:disabled), .button.primary:active:not(:disabled) { background: var(--color-accent-700); }
.btn-block { width: 100%; }
.button.small { padding: 4px 10px; font-size: 12.5px; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.icon-button {
  width: 32px; height: 32px; display: inline-grid; place-items: center;
  background: transparent; border: 1px solid var(--color-divider); border-radius: 0;
  cursor: pointer; color: var(--color-text); font-size: 15px;
}
.icon-button:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.avatar {
  width: 32px; height: 32px; display: inline-grid; place-items: center;
  background: var(--color-accent); color: var(--color-bg); border: none; border-radius: 0;
  font-family: var(--font-heading); font-weight: 600; font-size: 13px; cursor: pointer;
}

/* -------------------------------- forms ----------------------------------- */

.input, input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="number"], input[type="date"], select, textarea {
  width: 100%; min-height: 36px; padding: 6px 10px; font: inherit;
  font-size: 14px; color: var(--color-text); caret-color: var(--color-accent);
  background: var(--color-surface);
  border: 1px solid var(--color-divider); border-radius: 0;
}
.input:hover, input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.input:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  border-color: var(--color-accent); outline-offset: 0;
}
.field > label, .field label {
  display: block; font-size: 12px; margin-bottom: 5px;
  color: color-mix(in srgb, var(--color-text) 70%, transparent);
}
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.field-grid .field.wide, .field-grid label.wide { grid-column: 1 / -1; }
.field-grid > label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: color-mix(in srgb, var(--color-text) 70%, transparent); }
.field-help { display: block; font-size: 11.5px; color: var(--color-muted); margin-top: 3px; }
.field-check { display: flex; gap: 8px; align-items: flex-start; }
.field-check input { width: auto; min-height: 0; margin-top: 3px; }
.check-copy { font-size: 13px; }
.req { color: var(--color-bad); }
.form-note { font-size: 12.5px; color: var(--color-muted); margin: 8px 0 0; }
.form-note.warn { color: var(--color-bad); }

/* ------------------------------ app chrome -------------------------------- */

.app { min-height: 100vh; display: flex; flex-direction: column; }

.nav {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-bg);
  position: sticky; top: 0; z-index: 20;
  flex-wrap: wrap;
}
.nav-brand {
  font-family: var(--font-heading); font-weight: 600; font-size: 18px;
  letter-spacing: 0.02em; white-space: nowrap;
}
.nav-context { font-size: 13px; white-space: nowrap; }
.nav-links { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; }
.nav-item {
  color: inherit; text-decoration: none; font-size: 14px;
  padding: 5px 10px; border: 1px solid transparent;
  display: inline-flex; align-items: center; gap: 6px;
}
.nav-item:hover { color: var(--color-accent-700); }
.nav-item.active { color: var(--color-accent-800); border-color: var(--color-divider); background: var(--color-accent-100); }
.nav-count {
  min-width: 16px; height: 16px; padding: 0 4px;
  display: inline-grid; place-items: center;
  background: var(--color-accent-200); color: var(--color-accent-800);
  font-size: 10.5px; font-variant-numeric: tabular-nums;
}
.nav-count:empty { display: none; }
.nav-count.warn { background: var(--color-bad-100); color: var(--color-bad); }
.nav-right { display: flex; align-items: center; gap: 10px; }
.period-box select { min-height: 32px; padding: 3px 8px; font-size: 13px; width: auto; background: var(--color-bg); }

.main { flex: 1; display: flex; flex-direction: column; }
.page { flex: 1; }
.page[hidden] { display: none; }
.page-scroll { max-width: 1180px; margin: 0 auto; padding: 22px 28px 56px; width: 100%; }

.app-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 20px; border-top: 1px solid var(--color-hairline);
  font-size: 12px; flex-wrap: wrap;
}
.powered-by { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--color-muted); }
.powered-by img { height: 14px; width: auto; opacity: 0.75; }

/* ------------------------------- banners ---------------------------------- */

.banners { max-width: 1180px; margin: 0 auto; width: 100%; padding: 0 28px; }
.banners:empty { display: none; }
.banner {
  display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap;
  border: 1px solid var(--color-accent-400); background: var(--color-accent-100);
  padding: 9px 14px; margin: 12px 0 0; font-size: 13px;
}
.banner strong { font-family: var(--font-heading); font-weight: 600; letter-spacing: 0.02em; }
.banner.warn, .banner.bad { border-color: color-mix(in srgb, var(--color-bad) 45%, transparent); background: var(--color-bad-100); }
.banner.ok { border-color: var(--color-accent); }
.banner.demo, .banner.example, .banner.info { border-color: var(--color-divider); background: var(--color-neutral-100); }

/* -------------------------------- toast ----------------------------------- */

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translate(-50%, 12px);
  background: var(--color-neutral-900); color: var(--color-bg);
  padding: 9px 16px; font-size: 13px; opacity: 0; pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease; z-index: 70; max-width: 80vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error, .toast.bad { background: var(--color-bad); }

/* -------------------------------- login ----------------------------------- */

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(420px, 100%); background: var(--color-bg);
  padding: 26px 28px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow-md);
}
.login-card img { height: 40px; width: auto; align-self: flex-start; }
.login-eyebrow { font-size: 10px; letter-spacing: 0.12em; color: var(--color-accent); }
.login-card p { font-size: 13px; color: var(--color-muted); }
.login-card form { display: flex; flex-direction: column; gap: 10px; }
.login-card form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--color-muted); }
.login-error { color: var(--color-bad); font-size: 12.5px; min-height: 1em; margin: 0; }
.login-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 6px; }
.login-mode { font-size: 11px; color: var(--color-muted); }

/* -------------------------------- dialog ---------------------------------- */

dialog.dialog {
  width: min(560px, calc(100vw - 32px)); border: 1px solid var(--color-divider);
  border-radius: 0; background: var(--color-bg); color: var(--color-text);
  padding: 20px 22px; box-shadow: var(--shadow-lg);
}
dialog.dialog::backdrop { background: color-mix(in srgb, var(--color-neutral-900) 50%, transparent); }
.dialog-close-form { position: absolute; top: 10px; right: 10px; margin: 0; }
.dialog-close { border: none; font-size: 18px; }
.dialog-lede { font-size: 13px; color: var(--color-muted); }
.dialog-form { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.dialog-error { color: var(--color-bad); font-size: 12.5px; min-height: 1em; margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ------------------------------- tooltips --------------------------------- */

.tip { position: relative; cursor: help; border-bottom: 1px dotted var(--color-neutral-400); }
/*
 * ONE floating tooltip node (#tip-pop, lib/ui.js initTooltips), position:fixed
 * so no overflow container can clip it. The old ::after tooltip was clipped by
 * every scrolling ancestor (.table-wrap { overflow-x: auto } forces overflow-y
 * to auto too) and ran off the right edge of the viewport from `left: 0` —
 * long provenance tips were unreadable. Geometry arrives as CSS custom
 * properties set with CSSOM, which the CSP's style-src 'self' permits where a
 * style="" attribute would not.
 */
.tip-pop {
  position: fixed; left: var(--tip-x, 0px); top: var(--tip-y, 0px); z-index: 80;
  width: max-content; max-width: min(340px, calc(100vw - 16px));
  white-space: pre-line;
  background: var(--color-neutral-900); color: var(--color-bg);
  font-size: 12px; line-height: 1.45; padding: 8px 10px;
  font-family: var(--font-body); font-weight: 400; text-transform: none; letter-spacing: 0;
  box-shadow: var(--shadow-md);
  pointer-events: none;
}

/* ------------------------------ shared bits -------------------------------- */

.loading { padding: 28px 0; color: var(--color-muted); font-size: 13.5px; }
.empty { padding: 18px 0; font-size: 13.5px; color: var(--color-muted); display: flex; flex-direction: column; gap: 4px; }
.empty strong { color: var(--color-text); font-family: var(--font-heading); font-weight: 600; letter-spacing: 0.02em; }
.table-wrap { overflow-x: auto; }
.clickable { cursor: pointer; }
.greyed { opacity: 0.55; }

.chip-row { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-flex; align-items: center; font-size: 10.5px; letter-spacing: 0.02em;
  padding: 2px 8px; background: var(--color-neutral-100); color: var(--color-neutral-800);
  border: 1px solid var(--color-hairline); white-space: nowrap;
}
.chip.good { background: var(--color-accent-100); color: var(--color-accent-800); border-color: transparent; }
.chip.warn { background: var(--color-neutral-100); color: var(--color-neutral-800); border-color: var(--color-neutral-400); }
.chip.bad, .chip.strong-bad { background: var(--color-bad-100); color: var(--color-bad); border-color: transparent; }
.chip.tip { cursor: help; }

/* Sparkline (SVG attributes carry the geometry; colors live here). */
.spark { display: inline-block; vertical-align: middle; }
.spark-line { fill: none; stroke: var(--color-accent-600); stroke-width: 1.5; }
.spark-zero { stroke: var(--color-neutral-300); stroke-width: 1; stroke-dasharray: 2 3; }
.spark-dot { fill: var(--color-accent-700); }
.spark-dot.neg { fill: var(--color-bad); }

/* ------------------------------ panels (ops) ------------------------------- */

.panel {
  border: 1px solid var(--color-divider); background: var(--color-bg);
  box-shadow: var(--shadow-sm); margin: 0 0 22px;
}
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 14px 16px 0; flex-wrap: wrap;
}
.panel-head h2 { font-size: 21px; margin: 0; }
.panel-sub { font-size: 12.5px; color: var(--color-muted); margin-top: 2px; max-width: 72ch; }
.panel-body { padding: 12px 16px 16px; }
.panel-body.tight { padding: 6px 0 10px; }
.panel-foot { padding: 10px 16px; border-top: 1px solid var(--color-hairline); font-size: 12px; color: var(--color-muted); }

/* -------------------------------- tables ---------------------------------- */

.table, .grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .grid th {
  text-align: left; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: color-mix(in srgb, var(--color-text) 60%, transparent);
  padding: 8px 10px; border-bottom: 1px solid var(--color-divider);
  font-family: var(--font-body); font-weight: 500; white-space: nowrap;
}
.table td, .grid td { padding: 8px 10px; border-bottom: 1px solid var(--color-hairline); }
.table tbody tr:hover, .grid tbody tr:hover { background: color-mix(in srgb, var(--color-text) 4%, transparent); }
th.num, td.num { text-align: right; }
.sortable { cursor: pointer; user-select: none; }
.sort-caret { font-size: 9px; }
.table-note { font-size: 12px; padding: 10px 16px; margin: 0; }

/* ==========================================================================
   THE MONTHLY REVIEW
   ========================================================================== */

.review-foot { font-size: 12px; margin: 18px 2px 0; }

.stat-strip {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 6px 0 24px;
}
.stat-card { padding: 14px 16px; gap: 2px; }
.stat-value {
  font-family: var(--font-heading); font-size: 26px; font-weight: 600;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.stat-card.warn .stat-value { color: var(--color-bad); }
.stat-sub { font-size: 12px; }

.decisions-card { padding: 18px 20px; margin-bottom: 24px; }
.decisions-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.decisions-head h3 { margin: 0; font-size: 22px; }
.decisions-head .text-muted { font-size: 12px; }
.decisions-list { margin-top: 6px; }
.decision-row {
  display: flex; align-items: baseline; gap: 14px; padding: 9px 2px;
  border-top: 1px solid var(--color-hairline); cursor: pointer;
}
.decision-row:hover { background: color-mix(in srgb, var(--color-text) 4%, transparent); }
.decision-tag { width: 118px; justify-content: center; flex: none; }
.decision-building { font-weight: 600; font-size: 13.5px; width: 170px; flex: none; }
.decision-text { font-size: 13.5px; flex: 1; min-width: 200px; }
.decision-impact {
  font-family: var(--font-heading); font-weight: 600; font-size: 15px;
  font-variant-numeric: tabular-nums; flex: none;
}

.review-grid {
  display: grid; grid-template-columns: minmax(400px, 6fr) minmax(360px, 5fr);
  gap: 24px; align-items: start;
}

.buildings-card { padding: 0; }
.buildings-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 14px 16px 0; gap: 12px;
}
.buildings-head h3 { margin: 0; font-size: 20px; }
.buildings-head .text-muted { font-size: 12px; }
.buildings-table { margin-top: 6px; }
.buildings-table th:first-child, .buildings-table td:first-child { padding-left: 16px; }
.buildings-table th:last-child, .buildings-table td:last-child { padding-right: 16px; }
.b-row { cursor: pointer; }
.b-row.selected { background: var(--color-accent-100); }
.b-row.selected:hover { background: var(--color-accent-100); }
.b-row:focus-visible { outline-offset: -2px; }
.b-title { font-weight: 500; }
.b-sub { font-size: 12px; }
.b-keeps { font-weight: 600; }
.b-keeps.pos { color: var(--color-accent-800); }
.b-keeps.neg { color: var(--color-text); }
.b-spark, .b-spark-h { text-align: center; }
.b-flag { text-align: right; }
.b-open { text-align: right; color: var(--color-neutral-400); width: 28px; font-size: 15px; }
.b-row:hover .b-open { color: var(--color-accent-700); }

/* ==========================================================================
   THE STATEMENT PANEL (review + demo stage 4)
   ========================================================================== */

.statement-panel { padding: 20px 22px; }
.sp-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.sp-head.sp-head-link { cursor: pointer; margin: -6px -8px 0; padding: 6px 8px; }
.sp-head.sp-head-link:hover { background: color-mix(in srgb, var(--color-text) 4%, transparent); }
.sp-head.sp-head-link:hover .sp-name { color: var(--color-accent-700); }
.sp-open-hint { color: var(--color-accent-700); font-size: 14px; margin-left: 6px; }
.sp-name { margin: 2px 0 0; font-size: 22px; }
.sp-banner {
  border: 1px solid var(--color-accent-400); background: var(--color-accent-100);
  padding: 8px 12px; font-size: 12.5px; margin-top: 8px;
}
.sp-rows { margin-top: 8px; }
.sp-row { display: flex; align-items: baseline; gap: 10px; padding: 6px 0; }
.sp-chev { width: 16px; flex: none; color: var(--color-accent-700); font-size: 12px; }
.sp-code { width: 34px; flex: none; font-size: 11px; color: var(--color-muted); font-variant-numeric: tabular-nums; }
.sp-label { flex: 1; font-size: 13.5px; }
.sp-note { font-size: 12px; color: var(--color-muted); text-align: right; }
.sp-amt { font-variant-numeric: tabular-nums; font-size: 13.5px; min-width: 86px; text-align: right; }
.sp-rev .sp-label { font-weight: 500; font-size: 14px; }
.sp-rev .sp-amt { font-size: 14px; }
.sp-line .sp-label { padding-left: 10px; }
.stmt-ref .stmt-label, .stmt-ref .stmt-amount { font-size: 12.5px; color: var(--color-neutral-800); }
.field-inline { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--color-neutral-800); }
.field-inline .input { width: 96px; }
.whatif-result p { margin: 10px 0 0; font-size: 13.5px; max-width: 70ch; }
.sp-ref { padding: 3px 0; }
.sp-ref .sp-label { padding-left: 10px; font-size: 12.5px; color: var(--color-neutral-800); white-space: nowrap; flex: none; }
.sp-ref .sp-amt { font-size: 12.5px; color: var(--color-neutral-800); }
.sp-ref .sp-note.sp-over { color: var(--color-bad); font-weight: 600; }
.sp-zero .sp-label, .sp-zero .sp-amt { color: var(--color-muted); }
.sp-group {
  border-top: 1px solid var(--color-divider); cursor: pointer; padding: 8px 0;
}
.sp-group .sp-label { font-family: var(--font-heading); font-weight: 600; font-size: 14.5px; letter-spacing: 0.02em; }
.sp-group .sp-amt { font-weight: 600; font-size: 14.5px; }
.sp-group:hover { background: color-mix(in srgb, var(--color-text) 4%, transparent); }
.sp-total {
  border-top: 1px solid var(--color-divider); padding: 8px 0;
}
.sp-total .sp-label, .sp-total .sp-amt {
  font-family: var(--font-heading); font-weight: 600; font-size: 14.5px; letter-spacing: 0.02em;
}
.sp-final {
  border-top: 2px solid var(--color-text); background: var(--color-accent-100);
  padding: 10px 0; margin-top: 2px;
}
.sp-final .sp-label, .sp-final .sp-amt {
  font-family: var(--font-heading); font-weight: 600; font-size: 16px; letter-spacing: 0.03em;
}
.sp-total.sp-pos .sp-amt, .sp-final.sp-pos .sp-amt { color: var(--color-accent-800); }
.sp-solver { border-top: 1px solid var(--color-divider); margin-top: 10px; padding-top: 10px; }
.sp-solver p { font-size: 13.5px; margin: 4px 0 0; }
.sp-actions { margin-top: 14px; }
.sp-memo { font-size: 12px; margin: 12px 0 0; }

/* ==========================================================================
   THE ONBOARDING ARC
   ========================================================================== */

.stepper { display: flex; flex-wrap: wrap; padding: 6px 0 10px; }
.step {
  display: flex; align-items: center; gap: 10px; padding: 8px 22px 8px 0;
  opacity: 0.45;
}
.step.can { opacity: 1; cursor: pointer; }
.step.current { opacity: 1; }
.step-box {
  width: 26px; height: 26px; flex: none;
  border: 1px solid var(--color-divider); background: transparent;
  color: var(--color-neutral-600);
  display: grid; place-items: center;
  font-family: var(--font-heading); font-size: 14px; font-weight: 600;
}
.step.done .step-box { border-color: var(--color-accent); background: var(--color-accent-100); color: var(--color-accent-800); }
.step.current .step-box { border-color: var(--color-accent); background: var(--color-accent); color: var(--color-bg); }
.step-label {
  font-family: var(--font-heading); font-size: 16px; font-weight: 600;
  letter-spacing: 0.02em; color: var(--color-neutral-600);
}
.step.current .step-label { color: var(--color-text); }
.step-arrow { color: var(--color-neutral-400); margin-left: 12px; }

.stage { padding-top: 8px; }
.stage h2 { margin: 18px 0 4px; }
.stage-lede { max-width: 64ch; margin-bottom: 24px; font-size: 14px; }
.stage-actions { margin-top: 28px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.stage-actions .text-muted { font-size: 13px; }

.connect-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; max-width: 860px; }
.connect-card { padding: 22px; gap: 12px; }
.connect-state { display: flex; align-items: center; gap: 10px; }
.connect-state .text-muted { font-size: 13px; }
.connect-note { font-size: 12px; margin: 4px 0 0; }
.connect-spacer { flex: 1; }
.connect-card .btn { align-self: flex-start; }

.sync-card { max-width: 560px; padding: 22px; gap: 0; }
.sync-list { list-style: none; margin: 0; padding: 0; }
.sync-item {
  display: flex; align-items: baseline; gap: 12px; padding: 10px 2px;
  border-bottom: 1px solid var(--color-hairline); font-size: 14px;
}
.sync-item.wait { opacity: 0.4; }
.sync-mark { width: 20px; text-align: center; flex: none; color: var(--color-neutral-400); font-size: 14px; }
.sync-item.done .sync-mark { color: var(--color-accent-700); }
.sync-label { flex: 1; }
.sync-count { font-size: 13px; font-variant-numeric: tabular-nums; }
.sync-done { padding-top: 14px; }

.match-card { max-width: 860px; padding: 0; }
.match-table th:first-child, .match-table td:first-child { padding-left: 18px; }
.match-table th:last-child, .match-table td:last-child { padding-right: 18px; }
.match-cs { font-weight: 500; }
.match-arrow { color: var(--color-neutral-400); width: 24px; }
.match-tag { text-align: right; }
.match-foot { display: flex; align-items: center; gap: 14px; padding: 14px 18px; flex-wrap: wrap; }
.match-foot .text-muted { font-size: 13px; }

.pnl-grid {
  display: grid; grid-template-columns: minmax(340px, 5fr) minmax(380px, 6fr);
  gap: 24px; align-items: start;
}

.tie-card { max-width: 640px; padding: 22px 24px; gap: 0; }
.tie-row { display: flex; align-items: baseline; gap: 12px; padding: 5px 0; font-size: 13.5px; }
.tie-label { flex: 1; }
.tie-note { font-size: 12px; }
.tie-amt { font-variant-numeric: tabular-nums; min-width: 90px; text-align: right; }
.tie-sub { border-top: 1px solid var(--color-divider); padding: 8px 0; }
.tie-sub .tie-label, .tie-sub .tie-amt {
  font-family: var(--font-heading); font-weight: 600; font-size: 14.5px; letter-spacing: 0.02em;
}
.tie-final { border-top: 2px solid var(--color-text); padding: 10px 0; }
.tie-final .tie-label, .tie-final .tie-amt {
  font-family: var(--font-heading); font-weight: 600; font-size: 16px; letter-spacing: 0.02em;
}
.tie-verdict { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.tie-verdict .tag { font-size: 13px; padding: 6px 14px; }
.tie-verdict .text-muted { font-size: 13px; }

/* ==========================================================================
   THE FULL STATEMENT (operator deep-dive)
   ========================================================================== */

.statement-grid {
  display: grid; grid-template-columns: minmax(480px, 7fr) minmax(300px, 4fr);
  gap: 22px; align-items: start;
}

.stmt-header { margin-bottom: 18px; }
.stmt-back { font-size: 13px; text-decoration: none; display: inline-block; margin-bottom: 4px; }
.stmt-header-main { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-top: 8px; }
.stmt-title h2 { margin-bottom: 2px; }
.stmt-scope { font-size: 12.5px; color: var(--color-muted); margin-bottom: 8px; }
.stmt-provenance {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 18px;
  border: 1px solid var(--color-divider); background: var(--color-neutral-100);
  padding: 12px 14px; margin-top: 12px;
}
.prov { font-size: 12px; display: flex; flex-direction: column; gap: 1px; }
.prov-label { font-size: 9.5px; letter-spacing: 0.1em; color: var(--color-accent); }
.prov-value { color: var(--color-text); }

table.stmt { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.stmt th {
  text-align: left; font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--color-muted); padding: 6px 10px; border-bottom: 1px solid var(--color-divider);
  font-weight: 500;
}
table.stmt td { padding: 4px 10px; }
.stmt-code { width: 44px; color: var(--color-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.stmt-qty { text-align: right; color: var(--color-muted); font-size: 12px; white-space: nowrap; }
.stmt-amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stmt-pct { text-align: right; color: var(--color-muted); font-size: 12px; width: 64px; }
.stmt-section td {
  font-family: var(--font-heading); font-weight: 600; letter-spacing: 0.05em; font-size: 12.5px;
  padding-top: 14px; border-bottom: 1px solid var(--color-divider); color: var(--color-neutral-800);
}
.stmt-subtotal td { border-top: 1px solid var(--color-divider); font-weight: 600; padding: 6px 10px; }
.stmt-subtotal.major td { font-family: var(--font-heading); letter-spacing: 0.02em; font-size: 14px; }
.stmt-subtotal.major.headline td { border-top: 2px solid var(--color-text); background: var(--color-accent-100); font-size: 15px; }
.stmt-line.zero td { color: var(--color-muted); }
/* The Frantz-density columns: prior month sits on a faint tint so the four
   figure groups read as groups; the change column stays quiet until nonzero. */
table.stmt.stmt-wide { font-size: 13px; }
table.stmt.stmt-wide td, table.stmt.stmt-wide th { padding-left: 8px; padding-right: 8px; }
.stmt-colgroups th {
  font-family: var(--font-heading); font-size: 12px; letter-spacing: 0.05em;
  text-transform: none; color: var(--color-neutral-800); border-bottom: none;
  padding-bottom: 0; text-align: right;
}
.stmt-colgroups th:nth-child(-n+2) { text-align: left; }
td.stmt-compare, th.stmt-compare { background: color-mix(in srgb, var(--color-text) 3%, transparent); }
td.stmt-delta { color: var(--color-muted); font-size: 12px; }
.stmt-subtotal td.stmt-delta { color: var(--color-text); font-size: inherit; }

.stmt-flag {
  display: inline-block; font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 1px 5px; margin-left: 4px; border: 1px solid var(--color-hairline); color: var(--color-muted);
}
.stmt-flag.est { border-color: var(--color-neutral-400); }
.stmt-flag.confirm { background: var(--color-accent-100); color: var(--color-accent-800); border-color: transparent; }
.stmt-toggle { padding: 10px 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 12px; }

.memo-list { display: flex; flex-direction: column; }
.memo-row {
  display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
  padding: 5px 0; border-bottom: 1px solid var(--color-hairline); font-size: 13px;
}
.memo-row.headline { font-size: 14px; }
.memo-row.headline .memo-value { font-family: var(--font-heading); font-weight: 600; font-size: 16px; }
.memo-label { color: var(--color-muted); }
.memo-value { font-variant-numeric: tabular-nums; text-align: right; }
.memo-more { margin-top: 10px; font-size: 13px; }
.memo-more summary { cursor: pointer; color: var(--color-accent-700); }

.bridge-row {
  display: grid; grid-template-columns: 26px 1fr auto auto; gap: 10px; align-items: baseline;
  padding: 8px 0; border-bottom: 1px solid var(--color-hairline); font-size: 13px;
}
.bridge-sign { text-align: center; color: var(--color-muted); }
.bridge-label { font-weight: 500; }
.bridge-note { font-size: 12px; color: var(--color-muted); }
.bridge-amount { font-variant-numeric: tabular-nums; text-align: right; }
.bridge-verdict { text-align: right; }

/* ------------------------- monthly run and rates --------------------------- */

.run-grid, .rates-grid {
  display: grid; grid-template-columns: minmax(420px, 3fr) minmax(300px, 2fr);
  gap: 22px; align-items: start;
}
.run-col { display: flex; flex-direction: column; }

.checklist { display: flex; flex-direction: column; }
.check-step {
  display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: baseline;
  padding: 8px 0; border-bottom: 1px solid var(--color-hairline);
}
.check-state { text-align: center; color: var(--color-muted); }
.check-step.done .check-state { color: var(--color-accent-700); }
.check-step.attention .check-state { color: var(--color-bad); }
.check-label { font-weight: 500; font-size: 13.5px; }
.check-detail, .check-copy { font-size: 12.5px; color: var(--color-muted); }
.check-budget { font-size: 11.5px; color: var(--color-muted); font-variant-numeric: tabular-nums; }

.exception-row { border-bottom: 1px solid var(--color-hairline); padding: 10px 0; }
.exception-top { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.exception-summary { font-size: 13.5px; font-weight: 500; flex: 1; }
.exception-meta { font-size: 11.5px; color: var(--color-muted); }
.exception-detail { font-size: 12.5px; color: var(--color-muted); margin-top: 3px; }
.exception-actions { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }

.je-group { border: 1px solid var(--color-hairline); padding: 10px 12px; margin: 0 0 10px; }
.je-memo { font-size: 12.5px; color: var(--color-muted); margin-bottom: 6px; }

.editor-tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--color-divider); margin-bottom: 12px; }
.editor-tab {
  padding: 6px 12px; font-size: 13px; cursor: pointer;
  border: 1px solid transparent; border-bottom: none; background: transparent;
  font-family: var(--font-heading); font-weight: 600; letter-spacing: 0.02em; color: var(--color-muted);
}
.editor-tab.active { border-color: var(--color-divider); background: var(--color-bg); color: var(--color-text); }

.tile { border: 1px solid var(--color-divider); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.tile-label { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-accent); }
.tile-value { font-family: var(--font-heading); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile-note { font-size: 11.5px; color: var(--color-muted); }
.metric-label { font-size: 11px; color: var(--color-muted); }
.metric-value { font-family: var(--font-heading); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ------------------------------ responsive --------------------------------- */

@media (max-width: 1000px) {
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
  .review-grid, .pnl-grid, .statement-grid, .run-grid, .rates-grid { grid-template-columns: 1fr; }
  .connect-grid { grid-template-columns: 1fr; }
  .decision-building { width: auto; }
  .decision-tag { width: auto; }
}

@media (max-width: 640px) {
  .page-scroll { padding: 16px 14px 40px; }
  .nav { gap: 10px; padding: 8px 14px; }
  .nav-context { display: none; }
  .stat-strip { grid-template-columns: 1fr; }
}

/* --------------------------------- print ----------------------------------- */

@media print {
  .nav, .app-foot, .banners, .stage-actions, .stmt-toggle, .button-row, .toast { display: none !important; }
  .page-scroll { padding: 0; max-width: none; }
  body { background: #fff; }
  .panel, .card { box-shadow: none; }
}
