/* Rock Solid Financing - the office, the application and the customer portal.
 * Direction: "Achromatic ledger" (.taste-skill/app-sheet.txt). The chrome holds no colour: ink on the
 * brand's paper ground (the face), white cards, a near-black primary and a grey secondary. The one chart
 * hue (#9c6a17, the brand gold darkened to 4.7:1 on white) marks a screen's main data element only.
 * Type: General Sans 24 / 16 / 30 (figures) / 14 / 13. Radii: 8 (cards), 6 (controls), 999 (pills).
 * Bodies: .office (admin shell), .flow (application, portal, setup, sign-in).
 */

@font-face { font-family: "General Sans"; src: url("../fonts/GeneralSans-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "General Sans"; src: url("../fonts/GeneralSans-Medium.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "General Sans"; src: url("../fonts/GeneralSans-Semibold.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }

:root {
  --ground: #f3f2ef;          /* the brand's paper: the face of every screen */
  --surface: #ffffff;
  --raised: #f6f5f3;          /* a filled well inside a card */
  --well: #fafafa;            /* settings panels */
  --active: #e7e7e5;          /* the active nav pill */
  --border: #e6e6e6;
  --rule: #f0f0f0;
  --control: #d4d4d4;
  --text: #111111;
  --muted: #5f6368;
  --faint: #6b6b6b;
  --primary: #141414;
  --primary-hover: #2e2e2e;
  --primary-ink: #ffffff;
  --secondary: #e5e5e5;
  --secondary-hover: #d9d9d9;
  --chart: #9c6a17;
  --positive: #247b50;
  --negative: #c4242a;
  --warning: #92400e;
  --pill-pos-bg: #dcfae5; --pill-pos-ink: #04250e;
  --pill-neg-bg: #ffedea; --pill-neg-ink: #831c1e;
  --pill-warn-bg: #fffbeb; --pill-warn-ink: #92400e; --pill-warn-line: #fde68a;
  --pill-neutral-bg: #eeeeee; --pill-neutral-ink: #3d3d3d;

  --font: "General Sans", "Helvetica Neue", Arial, system-ui, sans-serif;
  --fs-title: 24px; --fs-section: 16px; --fs-kpi: 30px; --fs-body: 14px; --fs-small: 13px;
  --lh-body: 20px;

  --sidebar: 240px;
  --pad: 32px;
  --gap: 16px;
  --card-pad: 20px;
  --r-card: 8px;
  --r-control: 6px;
  --r-pill: 999px;
  --control-h: 36px;
  --input-h: 40px;
  --row-h: 44px;
  --nav-row: 32px;

  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M4.5 2.5 8 6l-3.5 3.5' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5l3-3' fill='none' stroke='%23111' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --t-press: 120ms; --t-hover: 150ms; --t-ui: 200ms;
}
/* The customer's screens read a size larger; inputs stay at 16px so phones do not zoom. */
.flow { --fs-body: 15px; --lh-body: 22px; }

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; min-height: 100svh; background: var(--ground); color: var(--text); font: 400 var(--fs-body)/var(--lh-body) var(--font); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
h1, h2, h3, h4, p, figure, ul, ol, dl, dd, blockquote { margin: 0; }
ul[class], ol[class] { padding: 0; list-style: none; }
fieldset { margin: 0; border: 0; padding: 0; min-width: 0; }
legend { padding: 0; }
img, svg, video { display: block; max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
table { border-collapse: collapse; }
strong, b { font-weight: 500; }
a { color: inherit; text-decoration: none; }
p a:not(.btn), li > a:not([class]), dd a:not([class]), .hint a, .link {
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
}
@media (hover: hover) and (pointer: fine) { p a:not(.btn):hover, li > a:not([class]):hover, dd a:not([class]):hover, .link:hover { text-decoration-color: currentColor; } }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
::selection { background: var(--text); color: var(--surface); }

.vh { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* The form trap (FormToken): out of sight and out of the tab order; people never see it. */
.hp { position: absolute !important; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -100px; z-index: 100; padding: 10px 16px; border-radius: var(--r-control); background: var(--primary); color: var(--primary-ink); }
.skip:focus { top: 12px; }
.num, .ref, table, .kpi-value, .money { font-variant-numeric: tabular-nums lining-nums; }
.ref { letter-spacing: 0.02em; white-space: nowrap; }
.muted { color: var(--muted); }
.break { overflow-wrap: anywhere; }
.small { font-size: var(--fs-small); line-height: 18px; }
.nowrap { white-space: nowrap; }
a[href^="tel:"] { white-space: nowrap; }
.zero { color: var(--faint); }
.up { color: var(--positive); }
.down { color: var(--negative); }
.js .nojs { display: none !important; }
[hidden] { display: none !important; }
.stack { display: grid; gap: var(--gap); align-content: start; }
.stack-lg { display: grid; gap: 24px; align-content: start; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

/* ---------- office shell: sidebar on the ground, no top bar ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100svh; }
.sidebar { position: sticky; top: 0; height: 100svh; display: flex; flex-direction: column; gap: 2px; padding: 20px 12px 16px; overflow: auto; overscroll-behavior: contain; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 8px 16px; }
.brand { display: grid; gap: 4px; }
.brand img { width: 150px; height: auto; }
.brand small { font-size: var(--fs-small); color: var(--muted); }
.side-search { padding: 0 0 12px; }
.side-search .input { width: 100%; height: var(--control-h); }
.group-label { margin: 22px 8px 6px; font-size: var(--fs-small); color: var(--faint); }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: var(--nav-row); margin: 0; padding: 0 8px;
  border: 0; border-radius: var(--r-control); background: transparent; color: var(--muted); text-align: left;
  transition: background-color var(--t-hover) ease, color var(--t-hover) ease;
}
.nav-item svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.nav-item .count { margin-left: auto; font-size: var(--fs-small); color: var(--muted); font-variant-numeric: tabular-nums; }
@media (hover: hover) and (pointer: fine) { .nav-item:hover { background: var(--active); color: var(--text); } }
.nav-item[aria-current="page"] { background: var(--active); color: var(--text); }
.nav-item[aria-current="page"] .count { color: var(--text); }
.side-foot { margin-top: auto; padding-top: 16px; display: grid; gap: 2px; }
.side-user { padding: 8px 8px 6px; }
.side-user b { display: block; font-weight: 500; }
.side-user span { font-size: var(--fs-small); color: var(--muted); }
.canvas { min-width: 0; padding: 32px var(--pad) 64px 8px; }
.canvas-inner { max-width: 1360px; }
.phone-bar, .btn.menu-close { display: none; }

/* ---------- page head ---------- */
.title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.title-row h1 { font-size: var(--fs-title); line-height: 30px; font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
.title-row .sub { margin-top: 4px; color: var(--muted); max-width: 72ch; }
.title-row .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.title-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 6px; color: var(--muted); }
.crumb { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 10px; color: var(--muted); }
.crumb::before { content: ""; width: 12px; height: 12px; background: currentColor; -webkit-mask: var(--chevron) center / 12px no-repeat; mask: var(--chevron) center / 12px no-repeat; transform: scaleX(-1); }
@media (hover: hover) and (pointer: fine) { .crumb:hover { color: var(--text); } }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: var(--gap); }
.filters .input { height: var(--control-h); }
.filters .grow { flex: 1 1 220px; max-width: 320px; }
.filters .spacer { flex: 1; }

/* ---------- grid and panels ---------- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: 1 / -1; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: var(--card-pad); min-width: 0; }
.panel > header { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 16px; }
.panel h2 { font-size: var(--fs-section); line-height: 22px; font-weight: 500; }
.panel h3 { font-size: var(--fs-body); line-height: var(--lh-body); font-weight: 500; }
.panel .meta { color: var(--muted); font-size: var(--fs-small); }
.panel .lede { color: var(--muted); margin-top: -8px; margin-bottom: 16px; max-width: 68ch; }
.panel-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 16px; }
.panel-flush { padding: 0; }
.panel-flush > header { padding: var(--card-pad) var(--card-pad) 0; }
.panel-flush > .empty { margin: 0 var(--card-pad) var(--card-pad); }
.panel-flush > .empty:first-child { margin-top: var(--card-pad); }
.attn { color: var(--text); font-weight: 500; }
.narrow-panel { max-width: 560px; }
.section { scroll-margin-top: 16px; }
.divide > * + * { border-top: 1px solid var(--rule); }
.card-link { display: inline-flex; align-items: center; gap: 2px; padding: 0; border: 0; background: none; color: var(--text); font-weight: 500; text-underline-offset: 3px; white-space: nowrap; }
.card-link::after { content: ""; width: 12px; height: 12px; flex: none; background: currentColor; -webkit-mask: var(--chevron) center / 12px no-repeat; mask: var(--chevron) center / 12px no-repeat; }
@media (hover: hover) and (pointer: fine) { .card-link:hover { text-decoration: underline; } }

/* list rows: a rule between rows and none above the first */
.rows { display: grid; }
.row { display: flex; align-items: center; gap: 12px; min-height: var(--row-h); padding: 10px 0; }
.row + .row { border-top: 1px solid var(--rule); }
.row .grow { flex: 1; min-width: 0; }
.row .end { margin-left: auto; text-align: right; }
.row-t { font-weight: 500; }
.row-x { color: var(--muted); font-size: var(--fs-small); line-height: 18px; }

/* ---------- figures: balances in one divided strip ---------- */
.kpis { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); margin-bottom: var(--gap); }
.kpi { padding: 16px var(--card-pad) 18px; min-width: 0; }
.kpi + .kpi { border-left: 1px solid var(--border); }
.kpi-label { color: var(--muted); }
.kpi-value { margin-top: 6px; font-size: var(--fs-kpi); line-height: 36px; font-weight: 500; letter-spacing: -0.01em; white-space: nowrap; }
.kpi-value.zero { color: var(--faint); font-weight: 400; }
.kpi-note { margin-top: 4px; font-size: var(--fs-small); line-height: 18px; color: var(--muted); }
.kpi-note a { color: var(--text); }

/* ---------- a bar chart in HTML: ink bars, the current period in the chart hue ---------- */
.bars { --plot-h: 200px; position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 12px; margin-top: 8px; }
.bars-y { position: relative; height: var(--plot-h); width: var(--y-w, 28px); }
.bars-y span { position: absolute; right: 0; bottom: var(--y); transform: translateY(50%); font-size: var(--fs-small); color: var(--muted); font-variant-numeric: tabular-nums; }
.bars-grid { position: absolute; left: calc(var(--y-w, 28px) + 12px); right: 0; top: 0; height: var(--plot-h); pointer-events: none; }
.bars-grid i { position: absolute; left: 0; right: 0; bottom: var(--y); border-top: 1px solid var(--rule); }
.bars-grid i.base { border-top-color: var(--border); }
.bars-plot { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; height: calc(var(--plot-h) + 26px); align-items: end; }
.bars-plot li { position: relative; display: grid; grid-template-rows: var(--plot-h) 26px; align-items: end; min-width: 0; }
.bars-plot .bar { display: block; height: var(--h); min-height: 1px; max-width: 36px; width: 100%; justify-self: center; background: var(--text); border-radius: 2px 2px 0 0; }
.bars-plot .is-now .bar { background: var(--chart); }
.bars-plot .bar-v { position: absolute; left: 0; right: 0; bottom: calc(var(--h) + 26px + 4px); text-align: center; font-size: var(--fs-small); color: var(--muted); font-variant-numeric: tabular-nums; }
.bars-plot .bar-x { align-self: end; text-align: center; font-size: var(--fs-small); line-height: 18px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.bars-plot .is-now .bar-x { color: var(--text); }
.chart-key { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: var(--fs-small); color: var(--muted); }
.chart-key i { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 2px; background: var(--text); }
.chart-key .now i { background: var(--chart); }

/* a stage meter: the pipeline as proportional ink lines */
.meter { height: 6px; border-radius: var(--r-pill); background: var(--rule); overflow: hidden; }
.meter > i { display: block; height: 100%; width: var(--p, 0%); background: var(--text); border-radius: var(--r-pill); transition: width var(--t-ui) var(--ease-out); }
.meter.is-main > i { background: var(--chart); }
.stage { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: baseline; gap: 4px 16px; padding: 10px 0; }
.stage + .stage { border-top: 1px solid var(--rule); }
.stage .meter { grid-column: 1 / -1; }
.stage .n { min-width: 2ch; text-align: right; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; }
table.data th { height: 36px; padding: 0 12px; text-align: left; font-weight: 400; font-size: var(--fs-small); color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
table.data td { padding: 12px; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
table.data th:first-child, table.data td:first-child { padding-left: var(--card-pad); }
table.data th:last-child, table.data td:last-child { padding-right: var(--card-pad); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data th.n, table.data td.n { text-align: right; }
table.data td .sub { display: block; margin-top: 2px; font-size: var(--fs-small); line-height: 18px; color: var(--muted); }
table.data .t-main { font-weight: 500; }
table.data a.t-main { text-underline-offset: 3px; }
@media (hover: hover) and (pointer: fine) { table.data a.t-main:hover { text-decoration: underline; } }
table.data tr.is-quiet td { color: var(--muted); }
.truncate { display: block; max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 12px var(--card-pad); border-top: 1px solid var(--border); color: var(--muted); }
.pager .actions { display: flex; gap: 8px; }

/* ---------- status pills: a pale tint with dark ink of the same hue ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: var(--r-pill); font-size: var(--fs-small); line-height: 1; font-weight: 500; background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); white-space: nowrap; vertical-align: baseline; }
.pill.pos { background: var(--pill-pos-bg); color: var(--pill-pos-ink); }
.pill.neg { background: var(--pill-neg-bg); color: var(--pill-neg-ink); }
.pill.warn { background: var(--pill-warn-bg); color: var(--pill-warn-ink); box-shadow: inset 0 0 0 1px var(--pill-warn-line); }
.pill.ink { background: var(--primary); color: var(--primary-ink); }
.pill.line { background: transparent; box-shadow: inset 0 0 0 1px var(--control); color: var(--muted); }

/* ---------- buttons: one near-black primary per screen, a grey secondary ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--control-h); padding: 0 14px;
  border: 1px solid var(--control); border-radius: var(--r-control); background: var(--surface); color: var(--text);
  font-weight: 500; line-height: 18px; text-align: center; white-space: nowrap; cursor: pointer;
  transition: background-color var(--t-hover) ease, border-color var(--t-hover) ease, transform var(--t-press) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) { .btn:hover { background: var(--raised); } }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
@media (hover: hover) and (pointer: fine) { .btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); } }
.btn.secondary { background: var(--secondary); border-color: var(--secondary); }
@media (hover: hover) and (pointer: fine) { .btn.secondary:hover { background: var(--secondary-hover); border-color: var(--secondary-hover); } }
.btn.ghost { border-color: transparent; background: transparent; }
@media (hover: hover) and (pointer: fine) { .btn.ghost:hover { background: var(--active); } }
.btn.danger { color: var(--negative); }
.btn.sm { min-height: 30px; padding: 0 10px; }
.btn.lg { min-height: 44px; padding: 0 20px; }
.btn.wide { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after { content: ""; position: absolute; width: 14px; height: 14px; border-radius: var(--r-pill); border: 2px solid var(--primary-ink); border-right-color: transparent; animation: spin 700ms linear infinite; }
.btn:not(.primary).is-busy::after { border-color: var(--text); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inline-form { display: inline; }

/* ---------- fields ---------- */
.form { display: grid; gap: 20px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.fields > .full, .fields > fieldset, .fields > .group-h { grid-column: 1 / -1; }
.fields.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.field > label, .field > legend, .label { font-weight: 500; }
.field > legend { margin-bottom: 6px; }
.opt { font-weight: 400; color: var(--muted); }
.hint { color: var(--muted); font-size: var(--fs-small); line-height: 18px; max-width: 72ch; }
.err { color: var(--negative); font-size: var(--fs-small); line-height: 18px; font-weight: 500; }
.input {
  width: 100%; min-height: var(--input-h); padding: 8px 12px; border: 1px solid var(--control); border-radius: var(--r-control);
  background: var(--surface); line-height: 22px; transition: border-color var(--t-hover) ease, box-shadow var(--t-hover) ease;
}
.input:focus { outline: none; border-color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.input::placeholder { color: var(--faint); }
.input[readonly] { background: var(--raised); }
textarea.input { min-height: 104px; resize: vertical; }
select.input { appearance: none; padding-right: 34px; background: var(--surface) var(--caret) right 12px center / 12px no-repeat; }
.flow .input, .flow select.input { font-size: 16px; }
.has-error .input, .input[aria-invalid="true"] { border-color: var(--negative); }
.has-error .input:focus { box-shadow: 0 0 0 1px var(--negative); }
.affix { display: flex; align-items: stretch; }
.affix > span { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--control); background: var(--raised); color: var(--muted); }
.affix > span:first-child { border-right: 0; border-radius: var(--r-control) 0 0 var(--r-control); }
.affix > span:last-child { border-left: 0; border-radius: 0 var(--r-control) var(--r-control) 0; }
.affix > .input { flex: 1; min-width: 0; }
.affix > span:first-child + .input { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.affix > .input:has(+ span) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input.n { text-align: right; font-variant-numeric: tabular-nums; }
.w-s { max-width: 160px; }
.w-m { max-width: 280px; }
.w-l { max-width: 420px; }

.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.check input { flex: none; width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--primary); cursor: pointer; }
.flow .check input { margin-top: 2px; }
.check > span { display: grid; gap: 2px; }
.check .hint { font-weight: 400; }
.checks { display: grid; gap: 12px; }
.checks.inline { display: flex; flex-wrap: wrap; gap: 12px 24px; }

/* choice cards: a radio with a title and a line */
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choice { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; padding: 14px 16px; border: 1px solid var(--control); border-radius: var(--r-card); background: var(--surface); cursor: pointer; transition: border-color var(--t-hover) ease, box-shadow var(--t-hover) ease; }
.choice input { grid-row: span 2; width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--primary); cursor: pointer; }
.choice-t { font-weight: 500; }
.choice-x { color: var(--muted); font-size: var(--fs-small); line-height: 18px; }
.choice:has(input:checked) { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.choice:has(input:focus-visible) { outline: 2px solid var(--text); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) { .choice:hover { border-color: var(--faint); } }

/* segmented radios */
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; border-radius: var(--r-card); background: var(--secondary); max-width: 100%; }
.seg label { position: relative; display: block; }
.seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 34px; padding: 0 14px; border-radius: var(--r-control); color: var(--muted); font-weight: 500; white-space: nowrap; transition: background-color var(--t-hover) ease, color var(--t-hover) ease; }
.seg input:checked + span { background: var(--surface); color: var(--text); }
.seg input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 1px; }

.switch { appearance: none; flex: none; width: 32px; height: 20px; margin: 0; border-radius: var(--r-pill); background: var(--control); position: relative; cursor: pointer; transition: background-color var(--t-ui) ease; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: var(--r-pill); background: var(--surface); transition: transform var(--t-ui) var(--ease-out); }
.switch:checked { background: var(--text); }
.switch:checked::after { transform: translateX(12px); }

.form-act { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-top: 4px; }
.form-act .end { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-left: auto; }
.form-act .alt { order: -1; }
.form-note { color: var(--muted); font-size: var(--fs-small); line-height: 18px; }

/* repeated groups (owners, equipment) */
.group { display: grid; gap: 16px; padding: 20px var(--card-pad); border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); }
.group-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.group-h { font-size: var(--fs-section); line-height: 22px; font-weight: 500; }
.group + .group { margin-top: 0; }

/* ---------- messages ---------- */
.flashes { display: grid; gap: 8px; margin-bottom: 20px; }
.flash { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--border); }
.flash::before { content: ""; flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: var(--r-pill); background: var(--text); }
.flash.is-ok::before { background: var(--positive); }
.flash.is-error { border-color: #f3c4c0; background: var(--pill-neg-bg); color: var(--pill-neg-ink); }
.flash.is-error::before { background: var(--negative); }
.flash.is-warn { border-color: var(--pill-warn-line); background: var(--pill-warn-bg); color: var(--pill-warn-ink); }
.flash.is-warn::before { background: var(--warning); }
.errors { padding: 16px var(--card-pad); border: 1px solid #f3c4c0; border-radius: var(--r-card); background: var(--pill-neg-bg); color: var(--pill-neg-ink); }
.errors:focus { outline: 2px solid var(--negative); outline-offset: 2px; }
.errors-h { font-weight: 500; }
.errors ul { margin-top: 6px; padding-left: 18px; }
.errors a { color: inherit; }
.notice { display: grid; gap: 4px; padding: 12px 16px; border-radius: var(--r-card); background: var(--raised); border: 1px solid var(--border); }
.notice.warn { background: var(--pill-warn-bg); border-color: var(--pill-warn-line); color: var(--pill-warn-ink); }
.notice.ok { background: var(--pill-pos-bg); border-color: #b9ecc8; color: var(--pill-pos-ink); }
.notice-h { font-weight: 500; }
p.notice { display: block; }
.empty { display: grid; place-items: center; gap: 8px; min-height: 96px; padding: 20px 16px; border: 1px dashed var(--border); border-radius: var(--r-control); color: var(--muted); text-align: center; }
.empty .btn { margin-top: 4px; }
.rows .empty, .grid > .empty, li > .empty { grid-column: 1 / -1; width: 100%; }

/* key and value pairs */
.kv { display: grid; }
.kv > div { display: grid; grid-template-columns: minmax(120px, 38%) minmax(0, 1fr); gap: 4px 16px; padding: 9px 0; border-top: 1px solid var(--rule); }
.kv > div:first-child { border-top: 0; padding-top: 0; }
.kv dt { color: var(--muted); }
.kv dd { min-width: 0; overflow-wrap: anywhere; }
.kv dd.n { font-variant-numeric: tabular-nums; }
.kv.tight > div { padding: 6px 0; }
.kv.stacked > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
.figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 14px 24px; }
.figs dt { color: var(--muted); font-size: var(--fs-small); line-height: 18px; }
.figs dd { margin-top: 2px; font-weight: 500; font-variant-numeric: tabular-nums; }
.figs .key dd { font-size: 22px; line-height: 28px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--border); margin-bottom: var(--gap); overflow-x: auto; scrollbar-width: none; }
.tabs a { position: relative; flex: none; padding: 10px 0; color: var(--muted); transition: color var(--t-hover) ease; }
.tabs a .count { margin-left: 4px; font-variant-numeric: tabular-nums; }
@media (hover: hover) and (pointer: fine) { .tabs a:hover { color: var(--text); } }
.tabs a[aria-current="page"], .tabs a[aria-selected="true"] { color: var(--text); }
.tabs a[aria-current="page"]::after, .tabs a[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--text); }

/* ---------- application detail ---------- */
.timeline { display: grid; }
.timeline li { display: grid; grid-template-columns: 8px minmax(0, 1fr); gap: 0 12px; padding: 8px 0; position: relative; }
.timeline li::before { content: ""; width: 8px; height: 8px; margin-top: 6px; border-radius: var(--r-pill); background: var(--control); }
.timeline li.is-key::before { background: var(--chart); }
.timeline li:not(:last-child)::after { content: ""; position: absolute; left: 3.5px; top: 22px; bottom: -6px; width: 1px; background: var(--rule); }
.timeline .when { display: block; font-size: var(--fs-small); line-height: 18px; color: var(--muted); }
.note-item { padding: 12px 0; }
.note-item + .note-item { border-top: 1px solid var(--rule); }
.note-item p { white-space: pre-wrap; overflow-wrap: anywhere; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 72ch; }
.note-item .by { margin-top: 4px; font-size: var(--fs-small); color: var(--muted); }
.task { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; }
.task + .task { border-top: 1px solid var(--rule); }
.task form { display: contents; }
.task .tick { flex: none; width: 20px; height: 20px; margin-top: 0; padding: 0; border: 1.5px solid var(--control); border-radius: var(--r-pill); background: var(--surface); }
@media (hover: hover) and (pointer: fine) { .task .tick:hover { border-color: var(--text); } }
.task.is-done .tick { background: var(--text); border-color: var(--text); }
.task.is-done .task-t { color: var(--muted); text-decoration: line-through; }
.task-x { font-size: var(--fs-small); line-height: 18px; color: var(--muted); }
.task-x .late { color: var(--negative); font-weight: 500; }
.secret { display: inline-flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.secret .num { letter-spacing: 0.04em; }
.offer { padding: 16px; border: 1px solid var(--border); border-radius: var(--r-card); }
.offer + .offer { margin-top: 12px; }
.offer.is-old { background: var(--raised); color: var(--muted); }
.offer-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.offer-conds { margin-top: 16px; }
.offer-conds ul { margin-top: 6px; padding-left: 18px; list-style: disc; }
.offer-conds li + li { margin-top: 4px; }
.offer-foot { margin-top: 14px; font-size: var(--fs-small); line-height: 18px; color: var(--muted); }
.doc { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 12px; padding: 10px 0; }
.doc + .doc { border-top: 1px solid var(--rule); }
.doc-name { font-weight: 500; overflow-wrap: anywhere; }
.doc-meta { font-size: var(--fs-small); line-height: 18px; color: var(--muted); }
.doc .actions { justify-content: flex-end; }
.req { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 12px 0; }
.req + .req { border-top: 1px solid var(--rule); }
.req-t { font-weight: 500; }
.req-x { font-size: var(--fs-small); line-height: 18px; color: var(--muted); }
.upload + .req, .files + .req, .req-act + .req { margin-top: 16px; border-top: 1px solid var(--rule); }
/* the office: what staff can do with a request or a file */
.req-act { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; margin: 4px 0 12px; }
.req-act details[open] { flex-basis: 100%; }
.req-act summary { list-style: none; }
.req-act summary::-webkit-details-marker { display: none; }
.req-act details > form { margin-top: 10px; }
.file > .req-act { grid-column: 1 / -1; margin: 0; }
.panel-flush > .pad { padding: 0 var(--card-pad) var(--card-pad); }
.lender-status { display: flex; gap: 8px; align-items: center; }
.lender-status .input { min-width: 150px; }
table.data tr.has-more td { border-bottom: 0; }
table.data tr.share-row td { padding-top: 0; }
tr.share-row details.more { border-top: 0; margin-top: 0; padding-top: 0; }
tr.share-row .checks { gap: 10px; }
.lender-answer .pill { margin: 0 2px; }
.firm-thread + .firm-thread { border-top: 1px solid var(--rule); padding-top: 20px; }
.firm-thread > h3 { margin-bottom: 12px; }
.firm-thread > h3 .muted { font-weight: 400; }
.firm-thread > p.small { margin: -4px 0 12px; }
html:not(.js) [data-show-if][hidden] { display: block !important; }
.kv dd .sub { display: block; font-size: var(--fs-small); line-height: 18px; color: var(--muted); }
details.more { border-top: 1px solid var(--rule); margin-top: 16px; padding-top: 12px; }
details.more > summary { cursor: pointer; font-weight: 500; list-style: none; display: inline-flex; align-items: center; gap: 6px; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: ""; width: 12px; height: 12px; background: currentColor; -webkit-mask: var(--caret) center / 12px no-repeat; mask: var(--caret) center / 12px no-repeat; transition: transform var(--t-ui) var(--ease-out); }
details.more[open] > summary::after { transform: rotate(180deg); }
details.row-more { display: inline-block; vertical-align: middle; }
details.row-more[open] { display: block; margin-top: 8px; }
details.row-more > summary { list-style: none; }
details.row-more > summary::-webkit-details-marker { display: none; }
details.more > summary + * { margin-top: 14px; }

/* messages thread */
.thread { display: grid; gap: 12px; }
.bubble { max-width: 80%; padding: 10px 14px; border-radius: var(--r-card); background: var(--raised); border: 1px solid var(--border); }
.bubble.me { justify-self: end; background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.bubble p { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .by { margin-top: 4px; font-size: var(--fs-small); opacity: 0.75; }

/* ---------- uploads ---------- */
.drop { position: relative; }
.drop-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.drop-face { display: grid; justify-items: center; gap: 4px; padding: 22px 16px; border: 1px dashed var(--faint); border-radius: var(--r-card); background: var(--raised); text-align: center; transition: border-color var(--t-hover) ease, background-color var(--t-hover) ease; }
.drop-t { font-weight: 500; }
.drop-t u { text-underline-offset: 3px; }
.drop-x { font-size: var(--fs-small); line-height: 18px; color: var(--muted); }
.drop.is-over .drop-face, .drop:focus-within .drop-face { border-color: var(--text); border-style: solid; background: var(--surface); }
.drop.is-over .drop-face { box-shadow: inset 0 0 0 1px var(--text); }
html:not(.js) .drop-input { position: static; opacity: 1; height: auto; margin-bottom: 8px; }
html:not(.js) .drop-face { display: none; }
.upload-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.files { display: grid; margin-top: 8px; }
.file { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 12px; padding: 10px 0; }
.file + .file { border-top: 1px solid var(--rule); }
.file-name { font-weight: 500; overflow-wrap: anywhere; }
.file-meta { font-size: var(--fs-small); line-height: 18px; color: var(--muted); }
.file .meter { grid-column: 1 / -1; }
.file.is-error .file-meta { color: var(--negative); font-weight: 500; }
.file.is-done .meter { display: none; }

/* ---------- the customer's screens: header, column, footer ---------- */
.flow { display: flex; flex-direction: column; }
.flow-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; padding: 12px 32px; border-bottom: 1px solid var(--border); background: var(--ground); }
.flow-brand { flex: none; }
.flow-brand img { width: 172px; height: auto; }
.flow-aside { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px 16px; color: var(--muted); }
.flow-aside a:not(.btn) { color: var(--text); font-weight: 500; }
.flow-main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 40px 32px 72px; }
.flow-main.narrow { max-width: 520px; }
.flow-main.mid { max-width: 800px; }
.flow-foot { padding: 24px 32px 32px; border-top: 1px solid var(--border); color: var(--muted); font-size: var(--fs-small); line-height: 18px; }
.flow-foot-in { max-width: 1120px; margin: 0 auto; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }
.flow-foot nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.flow-foot a { color: var(--text); }
.lead { font-size: 17px; line-height: 26px; color: var(--muted); max-width: 60ch; text-wrap: pretty; }
.page-h { font-size: var(--fs-title); line-height: 30px; font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }

/* the application: a step rail beside the form */
.apply { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 48px; align-items: start; }
.rail { position: sticky; top: 24px; display: grid; gap: 20px; }
.rail-ref { display: grid; gap: 2px; }
.rail-ref span { font-size: var(--fs-small); color: var(--muted); }
.rail-ref b { font-weight: 500; }
.steps { display: grid; gap: 2px; counter-reset: step; }
.step > a, .step > span { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 8px; border-radius: var(--r-control); color: var(--muted); }
.step-n { display: grid; place-items: center; flex: none; width: 22px; height: 22px; border-radius: var(--r-pill); border: 1px solid var(--control); font-size: var(--fs-small); line-height: 1; font-variant-numeric: tabular-nums; background: var(--surface); }
.step.is-done .step-n { border-color: var(--text); background: var(--text); color: var(--primary-ink); }
.step.is-done > a { color: var(--text); }
@media (hover: hover) and (pointer: fine) { .step.is-done > a:hover { background: var(--active); } }
.step[aria-current="step"] > span, .step[aria-current="step"] > a { background: var(--active); color: var(--text); font-weight: 500; }
.step[aria-current="step"] .step-n { border-color: var(--text); }
.rail-note { display: grid; gap: 8px; padding-top: 16px; border-top: 1px solid var(--border); font-size: var(--fs-small); line-height: 18px; color: var(--muted); }
.apply-main { display: grid; gap: 24px; min-width: 0; max-width: 760px; }
.apply-head { display: grid; gap: 8px; }
.apply-head .count { color: var(--muted); font-weight: 500; }
.phone-steps { display: none; }
.step-n svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; }
.apply-later { display: none; }
.choices.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.group > .upload + .field { padding-top: 4px; }
.lock-note { display: flex; gap: 8px; align-items: flex-start; font-size: var(--fs-small); line-height: 18px; color: var(--muted); }
.lock-note svg { flex: none; width: 14px; height: 14px; margin-top: 2px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.consent-text { max-height: 220px; overflow: auto; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r-control); background: var(--raised); font-size: var(--fs-small); line-height: 19px; }
.consent-text p + p { margin-top: 8px; }
.sign { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.estimate { display: grid; gap: 4px; padding: 16px; border-radius: var(--r-card); background: var(--raised); }
.estimate .big { font-size: var(--fs-kpi); line-height: 36px; font-weight: 500; font-variant-numeric: tabular-nums; }

/* the one-page application (partners/nextlevel/apply): the whole form, and on a wide screen a column
 * beside it with what is being financed, the estimate and the parts of the page */
.op { display: grid; gap: 24px; }
.op-main { display: grid; gap: 24px; min-width: 0; max-width: 760px; }
.op-side, .op-stick { display: grid; gap: 20px; align-content: start; min-width: 0; }
.op [id^="op-"] { scroll-margin-top: 24px; }
.op-sum { display: grid; gap: 14px; padding: 18px var(--card-pad) var(--card-pad); border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); }
.op-side-h { font-size: var(--fs-section); line-height: 22px; font-weight: 500; }
.op-kv > div { grid-template-columns: 112px minmax(0, 1fr); }
.op .seg span, .op .estimate { font-variant-numeric: tabular-nums; }
.op-kv dd.is-empty { color: var(--muted); }
.estimate:not([hidden]) + .op-est-none { display: none; }
.op-nav { display: grid; gap: 6px; }
.op-nav .op-side-h { padding: 0 8px; }
.op-nav ul { display: grid; gap: 2px; padding: 0; list-style: none; }
.op-nav li > a { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 34px; padding: 0 8px; border-radius: var(--r-control); color: var(--muted); text-decoration: none; transition: background-color var(--t-hover) ease, color var(--t-hover) ease; }
@media (hover: hover) and (pointer: fine) { .op-nav a:hover { background: var(--active); color: var(--text); } }
.op-nav a[aria-current] { background: var(--active); color: var(--text); font-weight: 500; }
.op-fix { flex: none; color: var(--negative); font-size: var(--fs-small); line-height: 18px; font-weight: 500; }
.op-help { font-size: var(--fs-small); line-height: 18px; color: var(--muted); }
.op-help a { color: var(--text); font-weight: 500; }
.op-rows { display: grid; gap: 16px; }
.op-rows:not(:has([data-row])) { display: none; }
.op-owner, .op-sub { display: grid; gap: 16px; padding-top: 16px; border-top: 1px solid var(--rule); }
.op-owner .group-h, .op-sub-h { font-size: var(--fs-body); line-height: var(--lh-body); font-weight: 500; }
.op .files:empty { display: none; }
.op .has-error .drop-face { border-color: var(--negative); border-style: solid; }
@media (min-width: 1024px) {
  .op { grid-template-columns: minmax(0, 1fr) 300px; gap: 48px; align-items: start; }
  .op-side { align-self: stretch; }
  .op-stick { position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow: auto; overscroll-behavior: contain; padding: 2px; margin: -2px; }
  .op-main .estimate { display: none; }
  .op-help { padding: 0 8px; }
}
@media (max-width: 1023px) { .op-sum, .op-nav { display: none; } }

/* the confirmation and the portal */
.done { display: grid; gap: 24px; max-width: 760px; }
.done-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-pill); background: var(--text); }
.done-mark svg { width: 20px; height: 20px; fill: none; stroke: var(--primary-ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.next-steps { display: grid; counter-reset: next; }
.next-steps li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 2px 12px; padding: 14px 0; counter-increment: next; }
.next-steps li + li { border-top: 1px solid var(--rule); }
.next-steps li::before { content: counter(next); grid-row: span 2; display: grid; place-items: center; width: 24px; height: 24px; border-radius: var(--r-pill); border: 1px solid var(--control); font-size: var(--fs-small); font-variant-numeric: tabular-nums; }
.next-steps b { font-weight: 500; }
.next-steps span { color: var(--muted); }
.track { display: grid; grid-template-columns: repeat(var(--n, 5), minmax(0, 1fr)); gap: 6px; }
.track li { display: grid; gap: 8px; align-content: start; color: var(--muted); font-size: var(--fs-small); line-height: 18px; }
.track li::before { content: ""; height: 4px; border-radius: var(--r-pill); background: var(--border); }
.track li.is-done { color: var(--text); }
.track li.is-done::before { background: var(--text); }
.track li.is-now { color: var(--text); font-weight: 500; }
.track li.is-now::before { background: var(--chart); }
.app-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; align-items: center; padding: 16px var(--card-pad); }
.app-card + .app-card { border-top: 1px solid var(--rule); }
.app-card .t { font-weight: 500; }
.app-card .x { color: var(--muted); font-size: var(--fs-small); }

/* sign-in, setup and two-step cards */
.auth { display: grid; gap: 20px; }
.auth .panel { padding: 24px; }
.auth-head { display: grid; gap: 6px; }
.qr { width: 196px; padding: 10px; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); }
.qr svg { width: 100%; height: auto; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; padding: 14px 16px; border-radius: var(--r-card); background: var(--raised); font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.secret-key { display: inline-block; padding: 4px 8px; border-radius: var(--r-control); background: var(--raised); font-variant-numeric: tabular-nums; letter-spacing: 0.06em; overflow-wrap: anywhere; }
.checklist { display: grid; }
.checklist li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline; padding: 10px 0; }
.checklist li + li { border-top: 1px solid var(--rule); }
.checklist .ok::before, .checklist .bad::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: var(--r-pill); }
.checklist .ok::before { background: var(--positive); }
.checklist .bad::before { background: var(--negative); }
.checklist + .notice { margin-top: 16px; }
.pair { display: grid; grid-template-columns: 196px minmax(0, 1fr); gap: 16px 24px; align-items: start; }
.pair-text { display: grid; gap: 10px; align-content: start; }
.key-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
@media (max-width: 560px) { .pair { grid-template-columns: minmax(0, 1fr); } }

/* ---------- settings: label column beside a panel ---------- */
.settings { max-width: 1152px; }
.set-row { display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 700px); gap: 16px 48px; padding: 32px 0; }
.set-row + .set-row { border-top: 1px solid var(--border); }
.set-row:first-of-type { padding-top: 8px; }
.set-label h2 { font-size: var(--fs-section); line-height: 22px; font-weight: 500; }
.set-label p { margin-top: 4px; color: var(--muted); max-width: 46ch; }
.set-label p + p { margin-top: 10px; }
.set-panel { display: grid; gap: 16px; padding: 16px; border-radius: var(--r-card); background: var(--well); box-shadow: inset 0 0 0 1px var(--rule); }
.set-panel .input { background: var(--surface); }
.set-panel .form-act { padding-top: 0; justify-content: flex-start; }
.switch-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.switch-row .switch { margin-top: 1px; }

/* ---------- staff list, settings extras, email log preview ---------- */
.members { display: grid; }
.member { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 4px 24px; padding: 16px var(--card-pad); scroll-margin-top: 16px; }
.member + .member { border-top: 1px solid var(--rule); }
.member-who, .member-state { display: grid; gap: 2px; align-content: start; min-width: 0; }
.member-who .row-x { overflow-wrap: anywhere; }
.member-role { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-weight: 500; }
.member > .req-act { grid-column: 1 / -1; margin: 8px 0 0; }
.member.is-off .row-t { color: var(--muted); }
.member:target { background: var(--well); }
.link-input { flex: 1 1 280px; min-width: 0; }
.choices.one { grid-template-columns: minmax(0, 1fr); }
.gate { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 12px 14px; border-radius: var(--r-control); background: var(--well); }
.gate p { flex: 1 1 220px; color: var(--muted); }
.req-act details > .gate { margin-top: 10px; }
.set-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding-top: 16px; border-top: 1px solid var(--rule); }
details.peek > summary { display: block; cursor: pointer; list-style: none; }
details.peek > summary::-webkit-details-marker { display: none; }
details.peek > summary .t-main { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); }
@media (hover: hover) and (pointer: fine) { details.peek > summary:hover .t-main { text-decoration-color: currentColor; } }
.peek-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; max-width: 64ch; overflow-wrap: anywhere; margin-top: 10px; padding: 12px 14px; border-radius: var(--r-control); background: var(--well); }
.peek-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-small); line-height: 20px; }

/* ---------- error page ---------- */
.error-page { display: grid; gap: 16px; max-width: 560px; padding: 24px 0; }
.error-code { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- agreements: packages sent for signature (office) ---------- */
.pkg > .notice { margin-bottom: 12px; }
.pkg-docs { color: var(--muted); font-size: var(--fs-small); line-height: 18px; }
.pkg-people { display: grid; margin-top: 10px; }
.pkg-person { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 16px; align-items: start; padding: 10px 0; }
.pkg-person + .pkg-person { border-top: 1px solid var(--rule); }
.pkg-person > .req-act { grid-column: 1 / -1; margin: 6px 0 0; }
.pkg-name { font-weight: 500; }
.pkg-meta { color: var(--muted); font-size: var(--fs-small); line-height: 18px; overflow-wrap: anywhere; }
.pkg-state { color: var(--muted); font-size: var(--fs-small); line-height: 20px; text-align: right; white-space: nowrap; }
.pkg-state.is-pos { color: var(--positive); font-weight: 500; }
.pkg-state.is-neg { color: var(--negative); font-weight: 500; }
.offer-foot + .offer-foot { margin-top: 6px; }
.req-act.pkg-act { margin: 14px 0 0; }
.notice-list { display: grid; gap: 4px; margin-top: 2px; padding-left: 18px; list-style: disc; }
.pkg-guar { display: grid; margin-top: 8px; }
.pkg-guar-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 24px; align-items: start; padding: 12px 0; }
.pkg-guar-row + .pkg-guar-row { border-top: 1px solid var(--rule); }
.pkg-plan { display: grid; gap: 6px; padding: 14px 16px; border-radius: var(--r-control); background: var(--raised); }
.pkg-plan ul { display: grid; }
.pkg-plan li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 16px; padding: 7px 0; }
.pkg-plan li + li { border-top: 1px solid var(--border); }
.pkg-plan li > .muted { font-size: var(--fs-small); }
#send-contract .form-act > .hint { flex: 1 1 240px; }

/* ---------- contracts: the templates and counsel's approval ---------- */
.ctpl-notice { max-width: 1152px; margin-bottom: 16px; }
.set-label .ctpl-state { margin-top: 12px; }
.ctpl-now { display: grid; gap: 4px; }
.ctpl-now .prewrap { margin-top: 4px; }
.set-panel > details.more { margin-top: 0; }
.ctpl-list { display: grid; gap: 8px; max-width: 68ch; padding-left: 18px; list-style: disc; }
.ctpl-act { display: flex; flex-wrap: wrap; gap: 8px; }
.ctpl-act form { display: contents; }
.ctpl-act > form:first-child > .btn.ghost { margin-left: -10px; }
table.data.ctpl-history th:first-child, table.data.ctpl-history td:first-child { padding-left: 0; }
table.data.ctpl-history th:last-child, table.data.ctpl-history td:last-child { padding-right: 0; }

/* ---------- settings: the GoHighLevel CRM connection ---------- */
.crm-test { display: grid; gap: 12px; }
.crm-test > .small { color: var(--muted); }
table.data.crm-table th:first-child, table.data.crm-table td:first-child { padding-left: 0; }
table.data.crm-table th:last-child, table.data.crm-table td:last-child { padding-right: 0; }
table.data.crm-table td .sub { overflow-wrap: anywhere; }
.crm-act { display: flex; flex-wrap: wrap; gap: 8px; }
.crm-act form { display: contents; }

/* ---------- the portal: documents waiting for this customer's signature ---------- */
.sign-due-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 24px; align-items: center; }
.sign-due-item + .sign-due-item { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--rule); }
.sign-due-docs { margin-top: 2px; }
.sign-due-item .small { margin-top: 6px; color: var(--muted); }
.sign-due-x { max-width: 36ch; color: var(--pill-neg-ink); font-size: var(--fs-small); line-height: 18px; }
.sign-due > .small { margin-top: 16px; color: var(--muted); }

/* ---------- the signing page ---------- */
.sign-parts { display: grid; }
.sign-parts li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; align-items: center; padding: 12px 0; }
.sign-parts li:first-child { padding-top: 0; }
.sign-parts li:last-child { padding-bottom: 0; }
.sign-parts li + li { border-top: 1px solid var(--rule); }
.sign-part-t { font-weight: 500; }
.sign-parts li > .pill { justify-self: start; }
.sign-terms dd { overflow-wrap: anywhere; }
.sign-docs { display: grid; gap: 16px; }
.sign-docs-top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.sign-docs-top + .hint { margin-top: -10px; }
.sign-skip { font-weight: 500; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); }
@media (hover: hover) and (pointer: fine) { .sign-skip:hover { text-decoration-color: currentColor; } }
.sign-ref { padding: 14px 16px; border-radius: var(--r-card); background: var(--raised); }
.sign-ref > summary { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; cursor: pointer; list-style: none; }
.sign-ref > summary::-webkit-details-marker { display: none; }
.sign-ref > summary::after { content: ""; flex: none; width: 12px; height: 12px; background: currentColor; -webkit-mask: var(--caret) center / 12px no-repeat; mask: var(--caret) center / 12px no-repeat; transition: transform var(--t-ui) var(--ease-out); }
.sign-ref[open] > summary::after { transform: rotate(180deg); }
.sign-ref-in { display: grid; gap: 16px; margin-top: 14px; }
.sign-form { display: grid; gap: 16px; scroll-margin-top: 16px; }
.sign-as { display: grid; gap: 6px; align-content: start; min-width: 0; }
.sign-as p:last-child { display: flex; align-items: center; min-height: var(--input-h); padding: 0 12px; border-radius: var(--r-control); background: var(--raised); }
.sign-status { max-width: 60ch; font-size: 17px; line-height: 26px; text-wrap: pretty; }

/* ---------- a contract document, read on screen before signing ---------- */
.cdoc { display: grid; gap: 12px; padding: 32px 36px 36px; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); font-size: 15px; line-height: 24px; scroll-margin-top: 16px; }
.cdoc p { max-width: 74ch; text-wrap: pretty; }
.cdoc-head { display: grid; gap: 8px; margin-bottom: 4px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.cdoc-top { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px 16px; }
.cdoc .cdoc-title { font-size: 20px; line-height: 26px; font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
.cdoc-meta { display: flex; flex-wrap: wrap; column-gap: 6px; color: var(--muted); font-size: var(--fs-small); line-height: 18px; }
.cdoc-meta b { color: var(--text); }
.cdoc-h { margin-top: 12px; font-size: var(--fs-section); line-height: 22px; font-weight: 600; }
.cdoc-clause { display: grid; gap: 6px; }
.cdoc-clause strong { font-weight: 600; }
.cdoc-sub { display: grid; grid-template-columns: 34px minmax(0, 1fr); padding-left: 8px; }
.cdoc-hang { color: var(--muted); font-variant-numeric: tabular-nums; }
.cdoc-note { color: var(--muted); font-size: var(--fs-small); line-height: 20px; }
.cdoc-box { display: grid; gap: 8px; padding: 14px 16px; border: 1px solid var(--text); border-radius: var(--r-control); font-weight: 500; }
.cdoc-kv { font-size: var(--fs-body); line-height: var(--lh-body); }
.cdoc-table { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-control); }
.cdoc-table table { width: 100%; font-size: var(--fs-small); line-height: 18px; }
.cdoc-table th { padding: 8px 12px; text-align: left; font-weight: 500; color: var(--muted); white-space: nowrap; background: var(--raised); border-bottom: 1px solid var(--border); }
.cdoc-table td { padding: 8px 12px; vertical-align: top; border-top: 1px solid var(--rule); }
.cdoc-table tbody tr:first-child td { border-top: 0; }
.cdoc-table th.n, .cdoc-table td.n { text-align: right; white-space: nowrap; }
.cdoc-table th.c, .cdoc-table td.c { text-align: center; }
.cdoc-table tfoot td { font-weight: 500; background: var(--raised); border-top: 1px solid var(--border); }
.cdoc-table.is-long { max-height: 360px; overflow-y: auto; }
.cdoc-table.is-long thead th { position: sticky; top: 0; z-index: 1; }
.cdoc-sigs { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 28px 40px; margin-top: 16px; }
.cdoc-sig { display: grid; gap: 2px; align-content: start; min-width: 0; }
.cdoc-sig-label { font-weight: 600; }
.cdoc-sig-entity { color: var(--muted); }
.cdoc-sig-line { display: flex; align-items: flex-end; min-height: 48px; margin-top: 6px; padding-bottom: 4px; border-bottom: 1px solid var(--text); font-size: 20px; line-height: 28px; font-weight: 500; overflow-wrap: anywhere; }
.cdoc-sig-line span { color: var(--faint); font-size: var(--fs-small); line-height: 18px; font-weight: 400; }
.cdoc-sig-who, .cdoc-sig-date { color: var(--muted); font-size: var(--fs-small); line-height: 18px; }
.cdoc-sig-who { margin-top: 4px; }
.cdoc-sig.is-signed .cdoc-sig-date { color: var(--positive); }

/* ---------- phone: the navigation folds into a top bar and a full-screen sheet ---------- */
@media (max-width: 1100px) {
  .grid > .span-3, .grid > .span-4, .grid > .span-5 { grid-column: span 6; }
  .grid > .span-7, .grid > .span-8 { grid-column: 1 / -1; }
  .set-row { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .phone-bar { position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: 12px; height: 48px; padding: 0 8px 0 16px; background: var(--ground); border-bottom: 1px solid var(--border); }
  .phone-bar img { width: 24px; height: auto; }
  .phone-title { flex: 1; min-width: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sidebar { position: fixed; inset: 0; z-index: 30; width: 100%; height: 100%; padding: 12px 16px 24px; background: var(--ground); visibility: hidden; transform: translateX(-100%); transition: transform var(--t-ui) var(--ease-out), visibility 0s linear var(--t-ui); }
  .sidebar.is-open { visibility: visible; transform: none; transition: transform var(--t-ui) var(--ease-out), visibility 0s; }
  .sidebar:target { visibility: visible; transform: none; }
  .btn.menu-close { display: inline-flex; }
  .nav-item { min-height: 44px; font-size: 16px; }
  html.nav-open { overflow: hidden; }
  .canvas { padding: 20px 16px 48px; }
  .title-row { flex-wrap: wrap; align-items: flex-start; }
  .grid > * { grid-column: 1 / -1 !important; }
  .kpis { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi + .kpi { border-left: 0; }
  .kpi:nth-child(n + 3) { border-top: 1px solid var(--border); }
  .kpi:nth-child(2n) { border-left: 1px solid var(--border); }
  .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kpi-value { font-size: min(var(--fs-kpi), 6.6vw); }
  .app-card { grid-template-columns: minmax(0, 1fr); justify-items: start; gap: 8px; }
  .input { font-size: 16px; }
  .flow-top { padding: 10px 16px; min-height: 56px; }
  .flow-brand img { width: 140px; }
  .flow-main { padding: 24px 16px 56px; }
  .flow-foot { padding: 20px 16px 28px; }
  .apply { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .rail { display: none; }
  .phone-steps { display: grid; gap: 8px; margin-bottom: 4px; }
  .phone-steps p { display: flex; justify-content: space-between; gap: 12px; font-size: var(--fs-small); color: var(--muted); }
  .phone-steps b { color: var(--text); font-weight: 500; }
  .apply-later { display: grid; gap: 8px; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--border); font-size: var(--fs-small); line-height: 18px; color: var(--muted); }
  .bars { --plot-h: 160px; }
  .member, .set-row, #invite { scroll-margin-top: 48px; }
}
@media (max-width: 640px) {
  .fields, .fields.three, .choices, .choices.three, .sign { grid-template-columns: minmax(0, 1fr); }
  .form-act { flex-direction: column-reverse; align-items: stretch; }
  .form-act .btn, .form-act .end { width: 100%; }
  .form-act .end { flex-direction: column-reverse; align-items: stretch; margin-left: 0; }
  .seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); width: 100%; }
  .seg span { padding: 0 4px; }
  .kv > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .flow-aside > .small { display: none; }
  .track { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .track li { grid-template-columns: 4px minmax(0, 1fr); gap: 12px; padding: 6px 0; }
  .track li::before { height: auto; min-height: 18px; }
  .bubble { max-width: 92%; }
  .codes { grid-template-columns: minmax(0, 1fr); }
  .tabs { gap: 16px; }
  .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .input { width: 100%; max-width: none; }
  .filters .grow, .filters .btn { grid-column: 1 / -1; }
  /* tables become two-line lists */
  table.data.s-list thead { display: none; }
  table.data.s-list, table.data.s-list tbody, table.data.s-list tr, table.data.s-list td { display: block; }
  table.data.s-list tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 12px var(--card-pad); border-bottom: 1px solid var(--rule); }
  table.data.s-list tbody tr:last-child { border-bottom: 0; }
  table.data.s-list td, table.data.s-list td:first-child, table.data.s-list td:last-child { padding: 0; border: 0; }
  table.data.s-list td.n { text-align: right; }
  table.data.s-list td.hide-s { display: none; }
  table.data.s-list td.s-full { grid-column: 1 / -1; }
  table.data.s-list td.s-end { justify-self: end; text-align: right; }
  table.data.s-list td.s-meta { color: var(--muted); font-size: var(--fs-small); line-height: 18px; }
  table.data.s-list td[data-label]::before { content: attr(data-label) " "; color: var(--muted); }
  table.data.s-list .sub.hide-s { display: none; }
  /* email log: an opened email uses the whole row; the status stays top right */
  table.data.s-list.mail-list tr { position: relative; }
  table.data.s-list.mail-list td:first-child { grid-column: 1 / -1; }
  table.data.s-list.mail-list td.mail-state { position: absolute; top: 12px; right: var(--card-pad); }
  table.data.s-list.mail-list details.peek > summary { padding-right: 112px; }
  .member { grid-template-columns: minmax(0, 1fr); }
  .set-foot .btn { width: 100%; }
  .pkg-person, .pkg-guar-row, .sign-parts li { grid-template-columns: minmax(0, 1fr); }
  .pkg-state { text-align: left; white-space: normal; }
  .sign-due-item { grid-template-columns: minmax(0, 1fr); }
  .sign-due-item > .btn { width: 100%; }
  .cdoc { padding: 20px 16px 24px; }
  .cdoc-sub { grid-template-columns: 30px minmax(0, 1fr); padding-left: 0; }
  .cdoc-sigs { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; } }
@media print {
  .sidebar, .phone-bar, .flow-top, .flow-foot, .rail, .form-act, .btn, .skip { display: none !important; }
  body, .panel { background: #fff; }
  .app { display: block; }
  .canvas { padding: 0; }
  .sign-form, .sign-skip, .sign-docs-top + .hint { display: none !important; }
  .cdoc { padding: 0; border: 0; }
  .cdoc + .cdoc { break-before: page; }
  .cdoc-sig, .cdoc-box, .cdoc-table tr { break-inside: avoid; }
  .cdoc-table.is-long { max-height: none; overflow: visible; }
}
