@font-face { font-family: "Plex"; src: url(fonts/ibm-plex-sans-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex"; src: url(fonts/ibm-plex-sans-latin-500-normal.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex"; src: url(fonts/ibm-plex-sans-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plex"; src: url(fonts/ibm-plex-sans-latin-700-normal.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url(fonts/ibm-plex-mono-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }

/* The page borrows the workbook's own colours: navy header, blue section bands, yellow input cells,
   so users recognise what's editable. Light follows the workbook; dark is the redesign's palette.
   The page follows the device's light or dark setting. */
:root {
  --navy: #1f3864; --navy-ink: #ffffff; --primary: #2f57a0; --primary-hover: #284b8a;
  --bar: #d9e1f2; --input: #fff2cc; --input-line: #e8d48a; --input-ink: #1e2430;
  --paper: #ffffff; --card-alt: #f7f8fb; --page: #eef1f6; --ink: #1e2430; --ink-soft: #3d4a60; --muted: #5d6676;
  --grid: #d5dae3; --grid-strong: #b9c1ce; --divider: #e3e7ee; --hover: #f5f7fb;
  --link: #2f57a0; --link-hover: #1f3864; --gold: #8a6a12; --handle: #9aa3b2;
  --ok: #1e7a46; --ok-bg: #e7f4ec; --warn-bg: #fff7e0; --warn-line: #ecd07a;
  --bad: #b42318; --bad-bg: #fdecea; --bad-line: #f1b0a9;
  --tab-active: var(--ink); --radius: 12px; --radius-sm: 8px;
  --sans: "Plex", "Segoe UI", system-ui, sans-serif;
  --mono: "Plex Mono", Consolas, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --navy: #2c4e86; --primary: #2f57a0; --primary-hover: #3764b3;
    --bar: #22314b; --input: #3b331f; --input-line: #7d6a35; --input-ink: #f1e9d2;
    --paper: #1b2029; --card-alt: #161a22; --page: #12161d; --ink: #e7eaee; --ink-soft: #b7c4d8; --muted: #9ba4b0;
    --grid: #2b323d; --grid-strong: #3a4250; --divider: #252b35; --hover: #1f2530;
    --link: #8db3f2; --link-hover: #b5cef7; --gold: #f1d58a; --handle: #4e5765; --tab-active: #ffffff;
    --ok: #6bcb8f; --ok-bg: #15281d; --warn-bg: #2b2513; --warn-line: #6d5a24;
    --bad: #f2a29a; --bad-bg: #2e1a19; --bad-line: #713630;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 15px/1.5 var(--sans);
  font-variant-numeric: tabular-nums; }
a { color: var(--link); } a:hover { color: var(--link-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 8px; }
.note { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

/* top bar */
.bar { background: var(--navy); color: var(--navy-ink); }
.bar-inner { max-width: 1376px; margin: 0 auto; padding: 0 32px; min-height: 56px; display: flex; align-items: center;
  justify-content: space-between; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 17px; text-decoration: none; }
.brand:hover { color: #fff; }
.who { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.account-wrap { position: relative; }
.account { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 12px 4px 4px; cursor: pointer;
  border-radius: 999px; background: rgb(255 255 255 / .1); border: 1px solid rgb(255 255 255 / .2); color: #fff; }
.account:hover { background: rgb(255 255 255 / .16); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #fff; color: var(--navy); font-weight: 700;
  font-size: 12px; display: grid; place-items: center; }
.account-email { font-size: 13px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* small menus: the account menu and the ⋯ menus */
.menu { display: grid; min-width: 200px; padding: 6px; background: var(--paper); color: var(--ink); z-index: 20;
  border: 1px solid var(--grid-strong); border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgb(0 0 0 / .22); }
.account-wrap .menu { position: absolute; right: 0; top: calc(100% + 6px); }
.menu.pop { position: absolute; }
.menu-item { appearance: none; border: 0; background: none; text-align: left; padding: 9px 12px; border-radius: 6px;
  cursor: pointer; font-size: 14px; color: var(--ink); min-height: 36px; }
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); }
a.menu-item { display: flex; align-items: center; text-decoration: none; }
.menu-account { display: grid; padding-bottom: 6px; margin-bottom: 6px; border-bottom: 1px solid var(--divider); }
.menu-info { padding: 9px 12px; max-width: 260px; font-size: 13px; color: var(--muted); }
.menu-item.danger { color: var(--bad); }

.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 28px;
  max-width: 1376px; margin: 28px auto 32px; padding: 0 32px; align-items: start; }
.side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.block { background: var(--paper); border: 1px solid var(--grid); border-radius: var(--radius); padding: 16px; }
.main { min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.small { font-size: 12px; }
.eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* "open now": the current workbook */
.current { display: grid; gap: 12px; }
.current-head { display: flex; align-items: center; gap: 12px; }
.icon-tile { width: 40px; height: 40px; border-radius: 10px; background: var(--bar); color: var(--link); flex: none;
  display: grid; place-items: center; }
.current-text { min-width: 0; flex: 1; }
.current-text .note { margin: 0; }
.current-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.save-state .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.save-state.ok { color: var(--ok); } .save-state.warn { color: var(--gold); }
.btn-pair { display: flex; gap: 8px; }
.btn-pair > * { flex: 1 1 auto; white-space: nowrap; }
.btn-outline { position: relative; min-height: 40px; padding: 0 4px; border: 1px solid var(--grid-strong);
  border-radius: var(--radius-sm); background: transparent; color: var(--ink); cursor: pointer; text-decoration: none;
  display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; font-weight: 500; }
.btn-outline:hover, .btn-outline.over { background: var(--hover); color: var(--ink); }
.btn-outline:disabled { opacity: .55; cursor: wait; }
label.btn { position: relative; }
.btn-outline:focus-within, label.btn:focus-within { outline: 2px solid var(--link); outline-offset: 2px; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.tip { margin: 0; font-size: 12px; line-height: 1.5; }
#mine-save-new { justify-self: start; }

/* a workbook dragged over the page */
.drop-overlay { display: none; position: fixed; inset: 12px; z-index: 30; border: 2px dashed var(--link);
  border-radius: var(--radius); background: rgb(18 22 29 / .55); color: #fff; font-size: 18px; font-weight: 600;
  place-items: center; pointer-events: none; }
body.drop-over .drop-overlay { display: grid; }
body.drop-over .drop-overlay span { background: var(--navy); padding: 12px 20px; border-radius: var(--radius-sm); }

/* template lists */
.list-card { padding: 14px 8px 8px; }
.list-card > .eyebrow, .list-head { padding: 0 8px 8px; }
.list-head { display: flex; align-items: center; justify-content: space-between; }
.tpl-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.tpl { width: 100%; display: flex; align-items: center; gap: 12px; padding: 8px; min-height: 52px; text-align: left;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer; color: var(--ink); }
.tpl:hover { background: var(--hover); }
.tpl.is-active { background: var(--hover); border-color: var(--input-line); }
.tpl-icon { width: 36px; height: 36px; flex: none; border-radius: var(--radius-sm); display: grid; place-items: center;
  background: var(--bar); color: var(--link); }
.tpl.is-active .tpl-icon { background: var(--input); color: var(--gold); }
.tpl-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.tpl-name { font-weight: 600; font-size: 14px; }
.tpl-desc { font-size: 12px; color: var(--muted); }
.pill { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.pill.in-use { display: none; color: var(--gold); border: 1px solid var(--input-line); background: var(--input); }
.tpl.is-active .pill.in-use { display: inline; }
.list-foot { border-top: 1px solid var(--divider); margin: 6px -8px -8px; padding: 6px 16px; }
.arrow-link { appearance: none; border: 0; background: none; padding: 0; cursor: pointer; color: var(--link);
  font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; min-height: 32px; }
a.arrow-link { text-decoration: none; }
.arrow-link:hover { color: var(--link-hover); }

/* change list */
.changes { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.changes li { display: grid; grid-template-columns: 18px 1fr; gap: 4px; }
.changes li::before { content: attr(data-mark); font-weight: 600; text-align: center; }
.changes li.add::before { color: var(--ok); } .changes li.del::before { color: var(--bad); }
.changes li.none { display: block; color: var(--muted); }
.changes li.none::before { content: none; }

/* buttons */
.btn { appearance: none; border: 1px solid var(--grid-strong); background: var(--paper); border-radius: var(--radius-sm);
  padding: 7px 14px; cursor: pointer; }
.btn:hover { border-color: var(--link); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: wait; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

.status { font-size: 13px; margin-top: 8px; color: var(--muted); min-height: 20px; }
.status.ok { color: var(--ok); } .status.bad { color: var(--bad); }
.panel { margin-top: 10px; padding: 10px 12px; border-radius: 5px; font-size: 13px; }
.panel.ok { background: var(--ok-bg); border: 1px solid var(--ok); }
.panel.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); }
.panel.bad { background: var(--bad-bg); border: 1px solid var(--bad-line); white-space: pre-wrap; }
.panel p { margin: 0 0 6px; } .panel ul { margin: 0 0 8px; padding-left: 18px; max-height: 180px; overflow: auto; }
.panel a { color: inherit; font-weight: 600; }

/* title row: template type, title, check status, build */
.title-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; }
.title-block { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.template-label { font-size: 12px; color: var(--muted); }
.title-input { width: 100%; margin-left: -9px; padding: 2px 8px; font-size: 28px; font-weight: 600; color: var(--tab-active);
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm); }
.title-input:hover, .title-input:focus { border-color: var(--grid-strong); }
.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.actions .status { margin: 0; display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.actions svg { flex: none; }
.build-btn { min-height: 44px; padding: 0 20px; font-size: 15px; display: inline-flex; align-items: center; gap: 8px; }
.main > .panel { margin: 0; }

/* tabs as numbered steps */
.steps { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; border-bottom: 1px solid var(--grid); }
.steps button { appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; }
.step { display: flex; align-items: center; gap: 10px; padding: 10px 14px 12px 4px; text-align: left; color: var(--ink-soft); }
.step:hover, .step[aria-selected="true"] { color: var(--tab-active); }
.steps button[aria-selected="true"] { border-bottom-color: var(--link); }
.step-num { width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 12px;
  font-weight: 700; background: var(--divider); color: var(--muted); }
.step[aria-selected="true"] .step-num { background: var(--primary); color: #fff; }
.step-text { display: flex; flex-direction: column; gap: 1px; }
.step-label { font-weight: 600; font-size: 14px; line-height: 1.4; }
.step-hint { font-size: 12px; line-height: 1.4; color: var(--muted); }
.yaml-link { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; padding: 0 4px; min-height: 44px;
  font-size: 13px; color: var(--muted); }
.yaml-link:hover, .yaml-link[aria-selected="true"] { color: var(--tab-active); }

/* inputs styled as the workbook's input cells */
.cell { background: var(--input); color: var(--input-ink); border: 1px solid var(--input-line); border-radius: 6px;
  padding: 4px 8px; min-width: 0; width: 100%; }
.cell::placeholder { color: var(--muted); opacity: .8; }
.cell.invalid { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
select.cell { padding-right: 4px; }
.pct { display: flex; align-items: center; gap: 4px; }
.pct .cell { text-align: right; }
.pct span { color: var(--muted); font-size: 13px; }

.general { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; padding: 18px;
  background: var(--paper); border: 1px solid var(--grid); border-radius: var(--radius); }
.general .field { gap: 6px; }
.general .cell { height: 40px; }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.field .cell { color: var(--input-ink); font-size: 15px; }

/* the sheet: section bars + line rows */
.sheet { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.section-card { background: var(--paper); border: 1px solid var(--grid); border-radius: var(--radius); overflow: hidden; }
.section-card .row:first-child { border-top: 0; }
.count { font-size: 12px; color: var(--ink-soft); background: rgb(128 128 128 / .16); padding: 2px 8px; border-radius: 999px;
  white-space: nowrap; margin-right: auto; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) 180px 104px 224px; gap: 10px;
  align-items: center; padding: 6px 10px; border-top: 1px solid var(--grid); }
.row.head { margin-bottom: -16px; color: var(--muted); font-size: 12px; border-top: 0; padding-top: 8px; padding-bottom: 8px; }
.row.section { background: var(--bar); border-top-color: transparent; }
.row.section .cell.label { font-weight: 700; letter-spacing: .03em; }
.row.line:hover { background: var(--hover); }
.row.line .name { padding-left: 18px; }
/* a line with sub-lines (a group): it shows their subtotal, the sub-lines are indented */
.row.group .name { padding-left: 18px; }
.row.group .cell.label { font-weight: 600; }
.row.line.in-group .name { padding-left: 40px; }
.row.adder.in-group { padding-left: 50px; }
.row.adder { display: flex; gap: 16px; }
.row.adder { padding: 4px 10px 8px 28px; border-top: 0; }
.row.adder .link { justify-self: start; grid-column: 1 / -1; }
/* drag and drop: a grip left of each name, a line where the row will land */
.sheet { position: relative; }
.row .name { position: relative; }
.grip { position: absolute; left: 0; top: 4px; width: 16px; height: 26px; display: grid; place-items: center;
  color: var(--handle); cursor: grab; touch-action: none; opacity: .55; border-radius: 3px; }
.grip svg { width: 8px; height: 14px; }
.row:hover .grip { opacity: 1; }
.grip:hover { background: var(--grid); }
.row.line.in-group .grip { left: 22px; }
.row.section.draggable { position: relative; padding-left: 28px; }
.row.section .grip { left: 6px; top: 50%; transform: translateY(-50%); }
.drag-on, .drag-on * { cursor: grabbing !important; user-select: none; }
.row.dragging { opacity: .4; }
.drop-marker { position: absolute; left: 8px; right: 8px; height: 3px; border-radius: 2px; background: var(--link);
  pointer-events: none; z-index: 2; }
.drop-marker.in-group { left: 48px; }
@media (hover: none) { .grip { opacity: 1; } }
.acts { display: flex; gap: 2px; justify-content: flex-end; align-items: center; }
.acts .move { width: 112px; margin-right: 6px; font-size: 13px; padding: 3px 4px; background: var(--paper); border-color: var(--grid); }
.icon { appearance: none; border: 0; background: none; width: 26px; height: 26px; border-radius: 4px;
  cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.icon:hover { background: var(--grid); color: var(--ink); }
.icon.del:hover { color: var(--bad); }
.icon svg { width: 15px; height: 15px; }
.icon:disabled { opacity: .3; cursor: default; background: none; }
.link { appearance: none; border: 0; background: none; color: var(--link); cursor: pointer; padding: 2px 0; font-size: 13px; font-weight: 500; }
.link:hover { color: var(--link-hover); }
.tag { font-size: 11px; color: var(--muted); margin-left: 6px; }
.renamed { font-size: 12px; color: var(--muted); padding-left: 18px; margin-top: 2px; }
.add-section { width: 100%; min-height: 50px; margin-top: 20px; cursor: pointer; border: 1.5px dashed var(--grid-strong);
  border-radius: var(--radius); background: transparent; color: var(--ink-soft); font-weight: 500; display: flex;
  align-items: center; justify-content: center; gap: 8px; }
.add-section:hover { background: var(--paper); }
.next { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 4px 0; }
.next-text { font-size: 13px; color: var(--muted); }
.next-text strong { color: var(--ink); font-weight: 600; }
.btn-secondary { min-height: 44px; display: inline-flex; align-items: center; gap: 6px; padding: 0 16px; cursor: pointer;
  border: 1px solid var(--grid-strong); border-radius: var(--radius-sm); background: var(--paper); color: var(--ink); font-weight: 500; }
.btn-secondary:hover { background: var(--hover); }

details.more { margin-top: 16px; border-top: 1px solid var(--grid); padding-top: 12px; }
details.more summary { cursor: pointer; font-weight: 500; }
.mini { display: grid; grid-template-columns: minmax(0, 1fr) 150px 110px; gap: 8px 12px; align-items: center;
  margin-top: 10px; font-size: 14px; }
.mini .h { color: var(--muted); font-size: 12px; }

.problems { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.problems:empty { display: none; }
.problems li { padding: 8px 10px; border-radius: 5px; font-size: 13px; white-space: pre-wrap; }
.problems li.bad { background: var(--bad-bg); border: 1px solid var(--bad-line); }
.problems li.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); }
.problems li[data-line] { cursor: pointer; }

/* advanced */
.yaml-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.yaml-tools .note { margin: 0; }
.editor { display: flex; border: 1px solid var(--grid); border-radius: 4px; overflow: hidden; height: 560px; }
.gutter, #yaml { font: 13px/20px var(--mono); margin: 0; padding: 10px; }
.gutter { color: var(--muted); text-align: right; user-select: none; min-width: 48px; overflow: hidden;
  background: var(--page); border-right: 1px solid var(--grid); }
#yaml { flex: 1; border: 0; resize: none; outline: none; background: var(--paper); white-space: pre; overflow: auto; tab-size: 2; }

.sheet.no-pl .catcol { visibility: hidden; }

/* live results (DuckDB-WASM) */
.live { margin-top: 6px; }
.live-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.live-head .note { font-size: 12px; }
.live-grid td.strong { font-weight: 600; }
.live-facts { display: grid; grid-template-columns: max-content auto; gap: 4px 16px; font-size: 13px; margin: 0 0 12px; }
.live-facts dt { color: var(--muted); } .live-facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.live-facts dd.bad { color: var(--bad); font-weight: 600; }

/* sign in */
.login { display: flex; justify-content: center; padding: 48px 16px; }
.login-card { width: 100%; max-width: 400px; background: var(--paper); border: 1px solid var(--grid); border-radius: 8px;
  padding: 28px 24px; display: grid; gap: 14px; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card .lead { margin: 0; color: var(--muted); font-size: 14px; }
.login-providers { display: grid; gap: 8px; }
.login-providers .btn { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px; }
.login-providers svg { width: 18px; height: 18px; flex: none; }
.login-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.login-or::before, .login-or::after { content: ""; flex: 1; border-top: 1px solid var(--grid); }
.login-form { display: grid; gap: 12px; }
.login-form .cell { padding: 9px 10px; }
.login-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin: 0; }
.verify { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--warn-bg); border-bottom: 1px solid var(--warn-line); padding: 10px 24px; font-size: 14px; }
.verify-acts { display: flex; gap: 12px; align-items: center; }
.signin-btn { background: #fff; color: var(--navy); border-color: #fff; font-weight: 600; min-height: 36px; }
.login-reason { margin: 0; padding: 10px 12px; border-radius: 5px; background: var(--warn-bg); border: 1px solid var(--warn-line); font-size: 14px; }
.login-skip { margin: 0; text-align: center; border-top: 1px solid var(--grid); padding-top: 12px; }
.locked { opacity: .85; }

/* my templates */
.mine-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: 14px; }
.mine-list li.none { color: var(--muted); font-size: 13px; padding: 4px 8px 8px; }
.saved { display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 10px; border-radius: var(--radius-sm); }
.saved:hover, .saved.current { background: var(--hover); }
.swatch { width: 8px; height: 8px; border-radius: 2px; flex: none; background: var(--muted); }
.swatch.t-budget { background: #8db3f2; } .swatch.t-hourly_rate { background: #6bcb8f; }
.swatch.t-cost_price { background: #e0b84a; } .swatch.t-rental_return { background: #e7a0c4; }
.swatch.t-project_budget { background: #b9a3f0; } .swatch.t-license_model { background: #7fd3d8; }
.saved-link { flex: 1; min-width: 0; min-height: 40px; display: grid; align-content: center; gap: 1px; text-align: left;
  appearance: none; border: 0; background: none; padding: 0; cursor: pointer; color: var(--ink); }
.saved-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved.current .saved-name::after { content: " · open"; color: var(--muted); font-weight: 400; }
.saved .meta { color: var(--muted); font-size: 12px; }
.icon-btn { appearance: none; width: 36px; height: 36px; flex: none; border: 0; background: none; border-radius: var(--radius-sm);
  display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.icon-btn:hover, .icon-btn[aria-expanded="true"] { background: var(--grid); color: var(--ink); }

/* template requests: a dashed row, with the user's own requests below it */
.request { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px 16px; text-align: left; cursor: pointer;
  border: 1px dashed var(--grid-strong); border-radius: var(--radius); background: transparent; color: var(--ink); }
.request:hover { background: var(--paper); }
.request:disabled { cursor: default; opacity: .7; }
.request svg { flex: none; color: var(--gold); }
.request-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.request-title { font-weight: 600; }
.request-note { font-size: 12px; color: var(--muted); }
.req-list { list-style: none; margin: 10px 0 0; padding: 0; font-size: 13px; }
.req-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 6px 0; border-top: 1px solid var(--grid); }
.req-list a { color: var(--ink); font-weight: 600; text-decoration: none; }
.req-list a:hover { text-decoration: underline; }
.req-list .st { color: var(--muted); font-size: 12px; white-space: nowrap; }
.req-list .st.done { color: var(--ok); }
.req-list .sum { grid-column: 1 / -1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#req-dialog { border: 1px solid var(--grid); border-radius: 8px; padding: 0; width: min(560px, calc(100vw - 32px));
  background: var(--paper); color: var(--ink); }
#req-dialog::backdrop { background: rgb(0 0 0 / .35); }
.req-form { display: grid; gap: 12px; padding: 20px; }
.req-form h2 { margin: 0; font-size: 18px; }
.req-form .note { margin: 0; }
.req-form textarea.cell { resize: vertical; font: inherit; font-size: 14px; }
.req-form .opt { color: var(--muted); font-size: 12px; font-weight: 400; }
.req-actions { display: flex; justify-content: flex-end; gap: 8px; }
.req-done { font-size: 14px; }
.req-done a { color: var(--link); font-weight: 600; }

/* cover page editor */
details.cover-block { margin: 0 0 20px; padding: 12px 18px; background: var(--paper); border: 1px solid var(--grid); border-radius: var(--radius); }
.cover-edit { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; margin-top: 12px; }
.logo-preview { height: 96px; border: 1px dashed var(--grid); border-radius: 6px; display: grid; place-items: center;
  color: var(--muted); font-size: 13px; background: var(--paper); overflow: hidden; }
.logo-preview img { max-width: 100%; max-height: 88px; object-fit: contain; }
.logo-actions { display: flex; gap: 12px; align-items: center; margin-top: 8px; }
.doc-fields { display: grid; gap: 10px; }
.doc-fields textarea.cell { min-height: 64px; resize: vertical; font: inherit; }
.doc-fields .link { justify-self: start; }
.kv { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) 28px; gap: 8px; align-items: center; }
.results-logo { max-height: 70px; max-width: 280px; margin: 4px 0 12px; display: block; }
@media (max-width: 640px) { .cover-edit { grid-template-columns: 1fr; } }

/* numbers + results */
.num-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.num-tools .note { margin: 0; max-width: 60ch; }
.gridwrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--grid); border-radius: 4px; margin-bottom: 22px; }
.ngrid { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.ngrid th, .ngrid td { padding: 3px 4px; border-top: 1px solid var(--grid); white-space: nowrap; text-align: right; }
.ngrid th:first-child, .ngrid td:first-child { text-align: left; position: sticky; left: 0; background: var(--paper);
  min-width: 170px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; padding-left: 10px; z-index: 1; }
.ngrid thead th { background: var(--navy); color: var(--navy-ink); font-weight: 600; text-align: center; border-top: 0; padding: 7px 4px; }
.ngrid thead th:first-child { background: var(--navy); color: var(--navy-ink); }
.ngrid tr.sec td { background: var(--bar); font-weight: 600; }
.ngrid tr.sec td:first-child { background: var(--bar); }
.ngrid tr.tot td { font-weight: 600; border-top: 1px solid var(--muted); }
.ngrid tr.grp td { font-weight: 600; }
.ngrid tr.in-group td:first-child { padding-left: 24px; }
.ngrid tr.res td { font-weight: 600; border-top: 1px solid var(--muted); border-bottom: 3px double var(--muted); }
.ngrid td.sum { color: var(--ink); min-width: 92px; padding-right: 10px; }
.ncell { width: 88px; text-align: right; background: var(--input); border: 1px solid var(--input-line); border-radius: 2px;
  padding: 3px 6px; font: inherit; color: var(--input-ink); font-variant-numeric: tabular-nums; }
.ncell.pct { width: 64px; display: inline-block; }
#numbers td:not(:first-child) { text-align: right; }
.ncell.changed { border-color: var(--link); box-shadow: inset 0 -2px 0 var(--link); }
.ncell.invalid { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
.ncell::placeholder { color: var(--muted); }
h3.gtitle { font-size: 15px; margin: 4px 0 8px; }
.seg { display: inline-flex; border: 1px solid var(--grid); border-radius: 5px; overflow: hidden; }
.seg button { appearance: none; border: 0; background: var(--paper); padding: 6px 12px; cursor: pointer; font-size: 13px; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--grid); }
.seg button[aria-pressed="true"] { background: var(--navy); color: var(--navy-ink); }
.rgrid td { padding: 4px 8px; }
.rgrid tr.head td { background: var(--navy); color: var(--navy-ink); font-weight: 600; text-align: center; }
.rgrid tr.head td:not(:first-child) { white-space: normal; min-width: 64px; max-width: 96px; vertical-align: bottom; line-height: 1.25; }
.rgrid tr.head td:first-child { background: var(--navy); }
.rgrid tr.section td, .rgrid tr.section td:first-child { background: var(--bar); font-weight: 600; }
.rgrid tr.total td { font-weight: 600; border-top: 1px solid var(--muted); }
.rgrid tr.result td { font-weight: 600; border-top: 1px solid var(--muted); border-bottom: 3px double var(--muted); }
.rgrid tr.bold td:first-child { font-weight: 600; }
.rgrid tr.note td { color: var(--muted); font-style: italic; font-size: 12px; white-space: normal; text-align: left; }
.rgrid tr.gap td { border: 0; height: 10px; }
.answers { display: grid; grid-template-columns: max-content auto; gap: 6px 24px; margin: 4px 0 18px; font-size: 15px; }
.answers b { font-size: 17px; }

/* paywall */
.paywall { max-width: 760px; margin: 48px auto; padding: 0 16px; }
.paywall h1 { font-size: 30px; line-height: 1.2; font-weight: 600; margin: 0 0 12px; letter-spacing: -0.01em; }
.paywall .lead { font-size: 17px; color: var(--muted); max-width: 62ch; margin: 0 0 28px; }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.plan { background: var(--paper); border: 1px solid var(--grid); border-radius: 6px; padding: 20px;
  display: grid; gap: 6px; align-content: start; }
.plan.best { border: 2px solid var(--navy); padding: 19px; }
.plan h2 { margin: 0; font-size: 15px; color: var(--muted); font-weight: 500; }
.plan .price { font-size: 32px; font-weight: 600; }
.plan .price small { font-size: 15px; font-weight: 400; color: var(--muted); }
.plan .sub { font-size: 13px; color: var(--muted); min-height: 20px; }
.plan .btn { margin-top: 10px; }
.save { display: inline-block; background: var(--input); border: 1px solid var(--input-line); border-radius: 3px;
  font-size: 12px; padding: 1px 6px; color: var(--ink); }
.paywall .note { margin-top: 18px; }
@media (max-width: 640px) { .plans { grid-template-columns: 1fr; } .paywall { margin: 28px auto; } .paywall h1 { font-size: 24px; } }

/* Same footer as the landing page (web/index.html) */
.site-footer { border-top: 1px solid var(--grid); padding: 32px 24px; margin-top: 24px; }
.site-footer-inner { max-width: 1180px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 16px 32px;
  justify-content: space-between; align-items: center; font-size: 14px; color: var(--muted); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 4px 24px; }
.site-footer a { color: var(--muted); padding: 12px 0; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 0 16px; margin-top: 16px; }
  .bar-inner { padding: 0 16px; }
}
@media (max-width: 640px) {
  .account-email, .step-hint { display: none; }
  .actions, .build-btn { width: 100%; justify-content: center; }
  .row { grid-template-columns: minmax(0, 1fr) 96px; }
  .row .catcol { grid-column: 1 / -1; order: 3; }
  .row.head .catcol, .row.head .actcol, .sheet.no-pl .catcol { display: none; }
  .row .acts { grid-column: 1 / -1; order: 4; justify-content: flex-start; }
  .row.line .name { padding-left: 18px; }
  .mini { grid-template-columns: 1fr 1fr; }
  .mini .lbl { grid-column: 1 / -1; margin-bottom: -4px; }
  .mini > span:empty { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
