/* Layout: navy command rail on the left (bottom tab bar on phones), work surface on the right; documents render as white paper in both themes. */
:root {
  --navy: #0a1628;
  --navy-2: #12233d;
  --navy-3: #1c3254;
  --neon: #4dff2e;
  --neon-dim: #3bd61f;
  --on-neon: #06210a;
  --paper: #ffffff;
  --paper-ink: #0a1628;
  --paper-muted: #5b6b82;
  --paper-line: #dde4ee;

  --bg: #f2f5f9;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --ink: #0a1628;
  --muted: #56667d;
  --line: #dbe2ec;
  --accent-ink: #168a0c;
  --accent-soft: #e6fbe1;
  --warn: #b45f00;
  --warn-soft: #fff2df;
  --bad: #c2261f;
  --bad-soft: #fde8e7;
  --info: #1f5fbf;
  --info-soft: #e5eefc;
  --shadow: 0 1px 2px rgba(10,22,40,.06), 0 4px 16px rgba(10,22,40,.06);

  --f-display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --f-body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #07101e; --surface: #0e1b2f; --surface-2: #122340; --ink: #e9eff7; --muted: #93a3ba; --line: #22385a;
    --accent-ink: #6dff52; --accent-soft: #123a17; --warn: #ffb44d; --warn-soft: #3a2a10; --bad: #ff7a72; --bad-soft: #3d1614;
    --info: #8db8ff; --info-soft: #14284a; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #07101e; --surface: #0e1b2f; --surface-2: #122340; --ink: #e9eff7; --muted: #93a3ba; --line: #22385a;
  --accent-ink: #6dff52; --accent-soft: #123a17; --warn: #ffb44d; --warn-soft: #3a2a10; --bad: #ff7a72; --bad-soft: #3d1614;
  --info: #8db8ff; --info-soft: #14284a; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.45; }
h1, h2, h3, h4 { font-family: var(--f-display); letter-spacing: .01em; margin: 0; text-wrap: balance; line-height: 1.1; }
h1 { font-size: 30px; font-weight: 700; }
h2 { font-size: 22px; font-weight: 700; }
h3 { font-size: 18px; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent-ink); }
.num, td.num, .money { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.eyebrow { font-family: var(--f-display); font-size: 13px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--neon-dim); outline-offset: 2px; }

/* ---------- App frame ---------- */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100%; }
.side { background: var(--navy); color: #dfe8f5; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 12px; gap: 18px; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 6px; }
.brand-mark { width: 38px; height: 38px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-text b { font-family: var(--f-display); font-size: 24px; letter-spacing: .08em; color: #fff; }
.brand-text span { font-size: 11.5px; color: var(--neon); letter-spacing: .02em; margin-top: 3px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-sec { font-family: var(--f-display); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: #6f84a5; padding: 12px 10px 4px; }
.nav button { all: unset; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: #c9d6ea; font-weight: 500; }
.nav button:hover { background: var(--navy-2); color: #fff; }
.nav button.on { background: var(--navy-3); color: #fff; box-shadow: inset 3px 0 0 var(--neon); }
.nav button:focus-visible { outline: 2px solid var(--neon); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .badge { margin-left: auto; }
.side-foot { margin-top: auto; font-size: 12px; color: #8396b3; padding: 0 8px; display: grid; gap: 6px; }
.side-foot .sync { display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--neon); display: inline-block; flex: none; }
.dot.off { background: #ffb44d; }
.badge { background: var(--neon); color: var(--on-neon); font-weight: 700; font-size: 12px; border-radius: 999px; padding: 1px 8px; font-variant-numeric: tabular-nums; }
.badge.warn { background: #ffb44d; color: #2b1a00; }

.main { min-width: 0; padding-block: 24px 96px; padding-inline: clamp(16px, 3vw, 36px); outline: none; }
.boot { color: var(--muted); padding: 40px 0; }
.tabbar { display: none; }

/* ---------- Page header ---------- */
.ph { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin-bottom: 20px; }
.ph-title { display: grid; gap: 4px; min-width: 0; }
.ph-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sample-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; justify-content: space-between; background: var(--info-soft); color: var(--info); border-radius: var(--r); padding: 10px 14px; margin-bottom: 18px; font-size: 14px; }
.offline-bar { background: var(--warn-soft); color: var(--warn); border-radius: var(--r); padding: 10px 14px; margin-bottom: 18px; font-size: 14px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 8px 14px; border-radius: 8px; font-weight: 600; cursor: pointer; white-space: nowrap; min-height: 38px; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--neon); border-color: var(--neon); color: var(--on-neon); }
.btn-primary:hover { background: var(--neon-dim); border-color: var(--neon-dim); }
.btn-navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-3); border-color: var(--navy-3); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn-danger { color: var(--bad); }
.btn-sm { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn-lg { padding: 12px 20px; font-size: 17px; min-height: 48px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-block { width: 100%; }
.linkish { all: unset; cursor: pointer; color: var(--accent-ink); font-weight: 600; }
.linkish:hover { text-decoration: underline; }

/* ---------- Cards & grids ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stack { display: grid; gap: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: grid; gap: 2px; min-width: 0; }
.kpi .v { font-family: var(--f-display); font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .l { font-size: 13px; color: var(--muted); }
.kpi .d { font-size: 12.5px; font-weight: 600; }
.up { color: var(--accent-ink); } .down { color: var(--bad); }
.kpi.hero { background: var(--navy); border-color: var(--navy); color: #fff; }
.kpi.hero .l { color: #a9bad3; }
.kpi.hero .v { color: var(--neon); }

/* ---------- Pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.s-draft { }
.pill.s-estimate_sent, .pill.s-invoiced { background: var(--info-soft); color: var(--info); border-color: transparent; }
.pill.s-approved, .pill.s-scheduled, .pill.s-in_progress { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.s-work_complete { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.s-paid { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.pill.s-finalized { background: var(--navy); color: var(--neon); border-color: transparent; }
.pill.s-declined { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.plain::before { display: none; }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-family: var(--f-display); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--surface-2); }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl tfoot td { font-weight: 700; border-bottom: none; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 5px; min-width: 0; }
.field > label, .lbl { font-size: 13px; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 38px; }
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { border-color: var(--neon-dim); outline: 2px solid color-mix(in srgb, var(--neon) 35%, transparent); outline-offset: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--neon-dim); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; padding: 3px; background: var(--surface-2); gap: 2px; flex-wrap: wrap; }
.seg button { all: unset; cursor: pointer; padding: 6px 12px; border-radius: 7px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--navy); color: var(--neon); }
.seg button:focus-visible { outline: 2px solid var(--neon-dim); }
.search { max-width: 320px; }

/* ---------- Chips filter ---------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { all: unset; cursor: pointer; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 13.5px; font-weight: 600; color: var(--muted); }
.chip.on { background: var(--navy); color: var(--neon); border-color: var(--navy); }
.chip:focus-visible { outline: 2px solid var(--neon-dim); }

/* ---------- Attention list ---------- */
.alerts { display: grid; gap: 8px; }
.alert { display: grid; grid-template-columns: 6px minmax(0, 1fr) auto; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px 10px 0; overflow: hidden; }
.alert .bar { align-self: stretch; background: var(--warn); }
.alert.high .bar { background: var(--bad); }
.alert.low .bar { background: var(--info); }
.alert.good .bar { background: var(--neon-dim); }
.alert .t { font-weight: 600; }
.alert .s { font-size: 13px; color: var(--muted); }

/* ---------- Pipeline ---------- */
.pipe { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(190px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.pipe-col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; display: grid; gap: 8px; align-content: start; min-height: 120px; }
.pipe-col h4 { font-size: 14px; letter-spacing: .08em; text-transform: uppercase; display: flex; justify-content: space-between; color: var(--muted); }
.pipe-card { all: unset; cursor: pointer; display: grid; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13.5px; }
.pipe-card:hover { border-color: var(--neon-dim); }
.pipe-card b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Job page ---------- */
.steps { display: flex; gap: 0; overflow-x: auto; margin: 4px 0 18px; }
.step { flex: 1 0 auto; display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); padding: 6px 12px 6px 0; white-space: nowrap; }
.step .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line); font-size: 12px; background: var(--surface); }
.step.done { color: var(--ink); }
.step.done .n { background: var(--neon); border-color: var(--neon); color: var(--on-neon); }
.step.now .n { border-color: var(--neon-dim); color: var(--accent-ink); }
.step + .step::before { content: ""; width: 20px; height: 2px; background: var(--line); margin-right: 4px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { all: unset; cursor: pointer; padding: 10px 12px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-color: var(--neon-dim); }
.tabs button:focus-visible { outline: 2px solid var(--neon-dim); }
.action-bar { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 16px; align-items: center; }
.action-bar .next { font-size: 13px; color: var(--muted); margin-right: auto; }
.money-box { display: grid; gap: 6px; }
.money-box .line { display: flex; justify-content: space-between; gap: 8px; font-variant-numeric: tabular-nums; }
.money-box .line.big { font-family: var(--f-display); font-size: 24px; font-weight: 700; }
.lock { display: flex; gap: 10px; align-items: center; padding: 12px; border: 1px dashed var(--line); border-radius: var(--r); color: var(--muted); background: var(--surface-2); }
.timeline { display: grid; gap: 0; }
.tl { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.tl .at { color: var(--muted); font-size: 12.5px; font-family: var(--f-mono); }

/* ---------- Editor ---------- */
.ed-section { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); margin-bottom: 12px; overflow: hidden; }
.ed-section-h { display: flex; gap: 8px; align-items: center; padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ed-section-h .input { max-width: 340px; font-weight: 600; }
.li { display: grid; grid-template-columns: minmax(0, 3fr) 70px 110px 110px 34px; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); align-items: start; }
.li:last-child { border-bottom: none; }
.li .desc { margin-top: 6px; min-height: 38px; font-size: 13.5px; }
.li .amt { text-align: right; font-weight: 700; padding-top: 8px; font-variant-numeric: tabular-nums; }
.li-h { display: grid; grid-template-columns: minmax(0, 3fr) 70px 110px 110px 34px; gap: 8px; padding: 6px 12px; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.li-h span:nth-child(4) { text-align: right; }
.li .cost { font-size: 12px; color: var(--muted); margin-top: 4px; }
.iconbtn { all: unset; cursor: pointer; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); }
.iconbtn:hover { background: var(--bad-soft); color: var(--bad); }
.iconbtn svg { width: 16px; height: 16px; }
.layout-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.lp { all: unset; cursor: pointer; border: 2px solid var(--line); border-radius: var(--r); padding: 12px; display: grid; gap: 4px; background: var(--surface); }
.lp b { font-family: var(--f-display); font-size: 18px; }
.lp span { font-size: 13px; color: var(--muted); }
.lp.on { border-color: var(--neon-dim); background: var(--accent-soft); }
.lp .sug { font-size: 11.5px; font-weight: 700; color: var(--accent-ink); text-transform: uppercase; letter-spacing: .08em; }
.lp:focus-visible { outline: 2px solid var(--neon-dim); }
.tier-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.sticky-total { position: sticky; bottom: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 10px 24px; align-items: center; justify-content: space-between; box-shadow: var(--shadow); margin-top: 16px; z-index: 5; }
.sticky-total .tot { font-family: var(--f-display); font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Paper document ---------- */
.paper { background: var(--paper); color: var(--paper-ink); border-radius: 6px; box-shadow: var(--shadow); border: 1px solid var(--paper-line); padding: clamp(18px, 4vw, 44px); max-width: 860px; margin: 0 auto; font-size: 14.5px; color-scheme: light; }
.paper h1, .paper h2, .paper h3 { color: var(--paper-ink); }
.paper .muted { color: var(--paper-muted); }
.doc-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; border-bottom: 4px solid var(--navy); padding-bottom: 16px; margin-bottom: 18px; }
.doc-brand { display: flex; gap: 12px; align-items: center; }
.doc-brand .mk { width: 46px; height: 46px; border-radius: 10px; background: var(--navy); display: grid; place-items: center; }
.doc-brand .nm { font-family: var(--f-display); font-size: 24px; font-weight: 800; line-height: 1; letter-spacing: .02em; }
.doc-brand .sub { font-size: 12px; color: var(--paper-muted); }
.doc-kind { text-align: right; }
.doc-kind .k { font-family: var(--f-display); font-size: 30px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; line-height: 1; }
.doc-kind .k.neon { background: var(--navy); color: var(--neon); padding: 4px 10px; border-radius: 6px; display: inline-block; }
.doc-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.doc-meta .lbl { color: var(--paper-muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
.doc-sec-title { font-family: var(--f-display); font-size: 16px; letter-spacing: .1em; text-transform: uppercase; background: var(--navy); color: #fff; padding: 6px 10px; border-radius: 4px; margin: 18px 0 6px; display: flex; justify-content: space-between; }
.doc-sec-title span { color: var(--neon); }
.paper table { width: 100%; border-collapse: collapse; }
.paper th { text-align: left; font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--paper-muted); border-bottom: 2px solid var(--paper-line); padding: 6px 6px; }
.paper td { padding: 8px 6px; border-bottom: 1px solid var(--paper-line); vertical-align: top; }
.paper .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.paper .ldesc { font-size: 12.5px; color: var(--paper-muted); }
.doc-totals { margin-left: auto; width: min(320px, 100%); display: grid; gap: 4px; margin-top: 12px; font-variant-numeric: tabular-nums; }
.doc-totals div { display: flex; justify-content: space-between; gap: 10px; }
.doc-totals .grand { border-top: 3px solid var(--navy); padding-top: 6px; font-family: var(--f-display); font-size: 22px; font-weight: 800; }
.doc-totals .due { background: var(--navy); color: var(--neon); padding: 6px 10px; border-radius: 5px; font-weight: 700; }
.doc-block { margin-top: 18px; }
.doc-block h3 { font-size: 15px; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 4px; }
.doc-block p, .doc-block li { font-size: 13.5px; white-space: pre-wrap; }
.doc-sig { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; margin-top: 22px; }
.sigbox { border: 1px solid var(--paper-line); border-radius: 6px; padding: 10px; min-height: 90px; display: grid; gap: 4px; }
.sigbox img { max-height: 70px; width: auto; }
.sigbox .lbl { color: var(--paper-muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
.stamp { display: inline-block; border: 3px solid var(--neon-dim); color: #128a08; font-family: var(--f-display); font-weight: 800; font-size: 22px; letter-spacing: .12em; padding: 2px 12px; border-radius: 6px; transform: rotate(-4deg); }
.tiers { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 8px; }
.tier { border: 2px solid var(--paper-line); border-radius: 8px; padding: 12px; display: grid; gap: 6px; align-content: start; }
.tier.pick { border-color: var(--neon-dim); box-shadow: 0 0 0 3px rgba(77,255,46,.25); }
.tier .tn { font-family: var(--f-display); font-size: 20px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.tier .tp { font-family: var(--f-display); font-size: 26px; font-weight: 800; }
.tier ul { margin: 0; padding-left: 18px; font-size: 13px; }
.quick .doc-head { border-bottom-width: 3px; }
.doc-foot { margin-top: 24px; padding-top: 10px; border-top: 1px solid var(--paper-line); font-size: 12px; color: var(--paper-muted); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(5, 12, 24, .62); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); color: var(--ink); border-radius: 14px; width: min(620px, 100%); max-height: calc(100% - 24px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.35); display: flex; flex-direction: column; }
.modal.wide { width: min(920px, 100%); }
.modal-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-b { padding: 18px; display: grid; gap: 14px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; position: sticky; bottom: 0; background: var(--surface); }
.pay-methods { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pm { all: unset; cursor: pointer; border: 2px solid var(--line); border-radius: 10px; padding: 10px; display: grid; gap: 2px; text-align: left; }
.pm b { font-size: 14px; }
.pm span { font-size: 12px; color: var(--muted); }
.pm.on { border-color: var(--neon-dim); background: var(--accent-soft); }
.pm:focus-visible { outline: 2px solid var(--neon-dim); }
.reader { background: var(--navy); color: #fff; border-radius: 12px; padding: 22px; text-align: center; display: grid; gap: 8px; place-items: center; }
.reader .ring { width: 72px; height: 72px; border-radius: 50%; border: 4px solid var(--neon); display: grid; place-items: center; font-family: var(--f-display); font-size: 20px; color: var(--neon); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 12px rgba(77,255,46,.15); } }
@media (prefers-reduced-motion: reduce) { .reader .ring { animation: none; } }
.testnote { font-size: 12.5px; background: var(--warn-soft); color: var(--warn); padding: 8px 10px; border-radius: 8px; }
.sigpad { width: 100%; height: 180px; border: 2px dashed var(--line); border-radius: 10px; background: #fff; touch-action: none; cursor: crosshair; display: block; }

/* ---------- Customer portal ---------- */
.portal { position: fixed; inset: 0; z-index: 40; background: var(--navy); overflow-y: auto; padding-block: 0 40px; }
.portal-top { position: sticky; top: 0; z-index: 3; background: var(--navy); color: #fff; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; border-bottom: 1px solid var(--navy-3); flex-wrap: wrap; }
.portal-top .who { font-family: var(--f-display); font-size: 18px; letter-spacing: .04em; }
.portal-top .who span { color: var(--neon); }
.portal-body { max-width: 860px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.portal-card { background: #fff; color: var(--paper-ink); border-radius: 12px; padding: 18px; display: grid; gap: 12px; color-scheme: light; }
.portal-card h2 { color: var(--paper-ink); }
.portal-card .muted { color: var(--paper-muted); }
.portal-card .input { background: #fff; color: var(--paper-ink); border-color: var(--paper-line); }
.portal-card .btn { background: #fff; color: var(--paper-ink); border-color: var(--paper-line); }
.portal-card .btn-primary { background: var(--neon); color: var(--on-neon); border-color: var(--neon); }
.portal-card .btn-navy { background: var(--navy); color: #fff; border-color: var(--navy); }
.portal-card .lock { background: #f3f6fa; color: var(--paper-muted); border-color: var(--paper-line); }
.stars { display: flex; gap: 6px; }
.star { all: unset; cursor: pointer; font-size: 38px; line-height: 1; color: #c9d3e1; }
.star.on { color: #f5b301; }
.star:focus-visible { outline: 2px solid var(--neon-dim); border-radius: 4px; }
.yn { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.yn button { all: unset; cursor: pointer; text-align: center; padding: 14px; border-radius: 10px; border: 2px solid var(--paper-line); font-weight: 700; font-size: 17px; }
.yn button.on { border-color: var(--neon-dim); background: #e9fde4; }
.review-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }

/* ---------- Bars (charts) ---------- */
.hbars { display: grid; gap: 8px; }
.hb { display: grid; grid-template-columns: minmax(90px, 160px) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 13.5px; }
.hb .track { height: 14px; background: var(--surface-2); border-radius: 4px; overflow: hidden; border: 1px solid var(--line); }
.hb .fill { height: 100%; background: var(--neon-dim); border-radius: 3px; }
.hb .fill.navy { background: var(--navy-3); }
.hb .val { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.hb .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--f-body); }
.chart .lbl-v { fill: var(--ink); font-weight: 600; }
.chart .grid-l { stroke: var(--line); }
.chart .bar { fill: var(--neon-dim); }
.chart .bar.prev { fill: var(--line); }
.insight { border-left: 4px solid var(--neon-dim); background: var(--surface-2); padding: 10px 12px; border-radius: 0 8px 8px 0; font-size: 14px; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; transform: translateX(-50%); top: calc(14px + env(safe-area-inset-top, 0px)); background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.3); z-index: 80; font-weight: 600; max-width: calc(100% - 32px); border-left: 4px solid var(--neon); }

.lock svg, .card-h > svg, .empty svg { width: 22px; height: 22px; flex: none; }
.card-h > svg { color: var(--accent-ink); }
.paper { width: 100%; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.dropzone { display: grid; justify-items: center; gap: 4px; text-align: center; padding: 22px 14px; border: 2px dashed var(--line); border-radius: var(--r); background: var(--surface-2); cursor: pointer; }
.dropzone:hover, .dropzone:focus-within { border-color: var(--neon-dim); }
.dropzone svg { width: 28px; height: 28px; color: var(--accent-ink); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.thumbs.big { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.thumb { margin: 0; position: relative; display: grid; gap: 4px; }
.thumb img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; background: #fff; }
.thumbs.big .thumb img { aspect-ratio: auto; object-fit: contain; max-height: 360px; }
.thumb figcaption { font-size: 12px; color: var(--muted); }
.thumb .iconbtn { position: absolute; top: 4px; right: 4px; background: var(--surface); width: 30px; height: 30px; }
.thumb-btn { all: unset; cursor: pointer; display: block; }
.thumb-btn:focus-visible { outline: 2px solid var(--neon-dim); border-radius: 8px; }
.desc-card { all: unset; cursor: pointer; box-sizing: border-box; display: grid; gap: 6px; align-content: start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; min-width: 0; }
.desc-card:hover { border-color: var(--neon-dim); }
.desc-card:focus-visible { outline: 2px solid var(--neon-dim); }
.desc-card b { font-family: var(--f-display); font-size: 18px; }
.desc-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
@media (max-width: 480px) { .desc-row { flex-direction: column; align-items: stretch; } }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.empty b { color: var(--ink); font-size: 17px; }
hr.sep { border: none; border-top: 1px solid var(--line); margin: 4px 0; }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.code { font-family: var(--f-mono); font-size: 12.5px; background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }
.note { font-size: 13px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .main { padding-block: 16px calc(96px + env(safe-area-inset-bottom, 0px)); padding-inline: 16px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; background: var(--navy); padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px)); z-index: 30; border-top: 1px solid var(--navy-3); }
  .tabbar button { all: unset; cursor: pointer; display: grid; justify-items: center; gap: 2px; color: #a9bad3; font-size: 11px; font-weight: 600; padding: 4px 0; position: relative; }
  .tabbar button.on { color: var(--neon); }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar .plus { width: 46px; height: 46px; border-radius: 14px; background: var(--neon); color: var(--on-neon); display: grid; place-items: center; margin-top: -18px; box-shadow: 0 4px 14px rgba(77,255,46,.35); }
  .tabbar .tb-badge { position: absolute; top: 0; left: 55%; background: #ffb44d; color: #2b1a00; border-radius: 999px; font-size: 10px; padding: 0 5px; font-weight: 800; }
  .g3, .g2 { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .layout-pick { grid-template-columns: minmax(0, 1fr); }
  .pay-methods { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .li { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 34px; }
  .li > div:first-child { grid-column: 1 / -1; }
  .li-h { display: none; }
  .sticky-total { bottom: calc(74px + env(safe-area-inset-bottom, 0px)); }
  .alert { grid-template-columns: 6px minmax(0, 1fr); }
  .alert > .btn { grid-column: 2; justify-self: start; }
  .li .amt { grid-column: 1 / -1; text-align: right; padding-top: 0; }

  h1 { font-size: 26px; }
  .tl { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .modal-back { place-items: end center; padding: 0; }
  .modal { width: 100%; border-radius: 16px 16px 0 0; max-height: 92%; }
  .search { max-width: none; width: 100%; }
}
@media (max-width: 480px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .v { font-size: 24px; }
  .hb { grid-template-columns: minmax(70px, 110px) minmax(0, 1fr) auto; }
}

/* ---------- hosted version additions ---------- */
.gate { position: fixed; inset: 0; z-index: 90; background: var(--navy); display: grid; place-items: center; padding: 16px; }
.gate-card { background: var(--surface); color: var(--ink); border-radius: 16px; padding: 26px; width: min(420px, 100%); display: grid; gap: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.gate-brand .brand-text b { color: var(--ink); }
.gate-brand .brand-text span { color: var(--accent-ink); }
.install-btn { display: none; }
body.can-install .install-btn { display: inline-flex; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-h { font-family: var(--f-display); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); text-align: center; padding-bottom: 4px; }
.cal-d { min-height: 78px; border: 1px solid var(--line); border-radius: 8px; padding: 4px; display: grid; gap: 3px; align-content: start; background: var(--surface); min-width: 0; }
.cal-d.off { background: var(--surface-2); }
.cal-d.past { opacity: .55; }
.cal-d.today { border-color: var(--neon-dim); box-shadow: inset 0 0 0 1px var(--neon-dim); }
.cal-n { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.cap { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--line); display: inline-block; }
.cap.some { background: #ffb44d; border-color: #ffb44d; }
.cap.full { background: var(--bad); border-color: var(--bad); }
.cal-job { all: unset; cursor: pointer; font-size: 11.5px; font-weight: 600; background: var(--navy); color: var(--neon); border-radius: 4px; padding: 1px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-job.hold { background: var(--warn-soft); color: var(--warn); border: 1px dashed var(--warn); }
.act-row { all: unset; cursor: pointer; display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; width: 100%; box-sizing: border-box; }
.act-row.new { font-weight: 600; }
.act-row:hover { background: var(--surface-2); }
@media (max-width: 820px) { .cal-d { min-height: 56px; } .cal-job { font-size: 10px; } .act-row { grid-template-columns: minmax(0, 1fr); gap: 2px; } }
