/* Digital Designs Billing - app + portal + public document styles */

@font-face { font-family: 'Space Grotesk'; src: url('/assets/fonts/space-grotesk-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Space Grotesk'; src: url('/assets/fonts/space-grotesk-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans'; src: url('/assets/fonts/ibm-plex-sans-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans'; src: url('/assets/fonts/ibm-plex-sans-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans'; src: url('/assets/fonts/ibm-plex-sans-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }

:root {
  --ink: #101728;
  --ink-2: #1c2740;
  --body: #3d475c;
  --mute: #6b7691;
  --line: #dfe4ee;
  --line-soft: #eceff5;
  --soft: #f4f6fa;
  --bg: #eef1f6;
  --card: #ffffff;
  --accent: #3d3a80;
  --accent-2: #2c2a62;
  --accent-soft: #ebeaf6;
  --brand-red: #b63338;
  --ok: #0f8a4d;
  --ok-soft: #e2f4ea;
  --warn: #b96d00;
  --warn-soft: #fdf1dd;
  --bad: #c0392b;
  --bad-soft: #fbe9e7;
  --head: 'Space Grotesk', 'Segoe UI', sans-serif;
  --sans: 'IBM Plex Sans', 'Segoe UI', sans-serif;
  --r: 12px;
  --shadow: 0 1px 2px rgba(16,23,40,.05), 0 4px 14px rgba(16,23,40,.06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* Pasted URLs or runs of characters must never push past a container: every
   document surface, editor and table cell breaks long words. */
.doc-page, .inv-paper, .rte-area, .tbl td, .doc-rich, .doc-items td, .ip-items td,
.ip-notes, .doc-callout, .ie-desc, .cov-band, .cov-ledger, .cov-atlas {
  overflow-wrap: anywhere; word-break: normal; min-width: 0;
}
.rte-area { overflow-x: hidden; }
body {
  margin: 0; font-family: var(--sans); font-size: 15px; line-height: 1.5;
  color: var(--body); background: var(--bg);
}
h1,h2,h3,h4 { font-family: var(--head); color: var(--ink); line-height: 1.2; margin: 0 0 .5em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex: 0 0 232px; background: var(--ink); color: #c6cede;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
/* Brand lockups are the dark-background wordmark (logo-dark.webp) everywhere
   they appear: the sidebar, the auth screens and the public document bar are
   all dark. The PDF letterhead is the one light placement and keeps the
   Settings logo (storage/branding). */
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; padding: 22px 18px 16px; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-logo { display: block; width: 100%; height: auto; }
.brand-sub { font-family: var(--head); font-weight: 500; font-size: 11.5px; color: #8b97b5; letter-spacing: .14em; text-transform: uppercase; }
.nav { flex: 1; padding: 8px 10px; overflow-y: auto; }
.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; margin: 2px 0;
  border-radius: 9px; color: #c6cede; font-weight: 500; font-size: 14px;
}
.nav-link svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: .85; }
.nav-link:hover { background: var(--ink-2); color: #fff; text-decoration: none; }
.nav-link.on { background: var(--accent); color: #fff; }
.sidebar-foot { padding: 14px 18px 18px; border-top: 1px solid rgba(255,255,255,.08); }
.who { font-size: 12.5px; color: #8b97b5; margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signout {
  display: flex; align-items: center; gap: 9px; background: none; border: 0; color: #c6cede;
  font: inherit; font-size: 13.5px; cursor: pointer; padding: 0;
}
.signout svg { width: 16px; height: 16px; }
.signout:hover { color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 14px 26px;
  background: var(--card); border-bottom: 1px solid var(--line-soft); position: sticky; top: 0; z-index: 40;
}
.nav-toggle { display: none; background: none; border: 0; font-size: 20px; cursor: pointer; color: var(--ink); }
.page-title { font-size: 19px; margin: 0; flex-shrink: 0; }
.topbar-actions { margin-left: auto; display: flex; gap: 9px; align-items: center; }
.content { padding: 24px 26px 60px; max-width: 1180px; width: 100%; }
.content.wide { max-width: none; }

/* global search */
.global-search { position: relative; display: flex; align-items: center; gap: 8px; background: var(--soft); border: 1px solid var(--line-soft); border-radius: 9px; padding: 7px 12px; width: 320px; }
.global-search svg { width: 15px; height: 15px; color: var(--mute); flex: 0 0 15px; }
.global-search input { border: 0; background: none; font: inherit; font-size: 13.5px; width: 100%; outline: none; color: var(--ink); }
.gs-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); max-height: 340px; overflow-y: auto; z-index: 60; }
.gs-item { display: block; padding: 9px 13px; font-size: 13.5px; color: var(--body); border-bottom: 1px solid var(--line-soft); }
.gs-item:last-child { border-bottom: 0; }
.gs-item:hover { background: var(--soft); text-decoration: none; }
.gs-item .t { color: var(--ink); font-weight: 600; }
.gs-item .s { color: var(--mute); font-size: 12px; }

/* ---------- cards, KPIs ---------- */
.card { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 18px; }
.card h2 { font-size: 16px; margin-bottom: 14px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-head .spacer { flex: 1; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px 18px; display: block; }
a.kpi:hover { text-decoration: none; border-color: var(--accent); }
.kpi .k { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--mute); }
.kpi .v { font-family: var(--head); font-weight: 700; font-size: 24px; color: var(--ink); margin-top: 4px; }
.kpi .v.bad { color: var(--bad); }
.kpi .v.ok { color: var(--ok); }
.kpi .s { font-size: 12.5px; color: var(--mute); margin-top: 2px; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--mute); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.rowlink { cursor: pointer; }
.tbl tr.rowlink:hover td { background: var(--soft); }
.tbl .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl th.num { text-align: right; }
.tbl .strong { color: var(--ink); font-weight: 600; }
.tbl .mute { color: var(--mute); font-size: 13px; }
.th-sort { color: inherit; }
.th-sort:hover { color: var(--accent); text-decoration: none; }
.th-sort.on { color: var(--ink); }
.th-sort .dir { font-size: 9px; }
.empty { text-align: center; color: var(--mute); padding: 34px 10px; }
.empty h3 { color: var(--body); margin-bottom: 4px; }

/* ---------- pills ---------- */
.pill { display: inline-block; padding: 2.5px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill-draft { background: var(--line-soft); color: var(--mute); }
.pill-open { background: var(--accent-soft); color: var(--accent-2); }
.pill-partial { background: var(--warn-soft); color: var(--warn); }
.pill-paid { background: var(--ok-soft); color: var(--ok); }
.pill-void { background: var(--line-soft); color: var(--mute); text-decoration: line-through; }
.pill-overdue { background: var(--bad-soft); color: var(--bad); }
.pill-est-draft { background: var(--line-soft); color: var(--mute); }
.pill-est-sent { background: var(--warn-soft); color: var(--warn); }
.pill-est-approved { background: var(--ok-soft); color: var(--ok); }
.pill-est-declined { background: var(--bad-soft); color: var(--bad); }
.pill-est-expired { background: var(--line-soft); color: var(--mute); }
.pill-kind { background: var(--soft); color: var(--mute); border: 1px solid var(--line-soft); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  padding: 8px 16px; border-radius: 9px; font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none; line-height: 1.3;
}
.btn:hover { background: var(--accent-2); border-color: var(--accent-2); text-decoration: none; color: #fff; }
.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--soft); border-color: var(--mute); color: var(--ink); }
.btn-danger { background: var(--bad); border-color: var(--bad); }
.btn-danger:hover { background: #a03024; border-color: #a03024; }
/* quiet until you go for it: a row action that should not shout from every line */
.btn-ghost.btn-danger-ghost { color: var(--mute); }
.btn-ghost.btn-danger-ghost:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn-ok { background: var(--ok); border-color: var(--ok); }
.btn-ok:hover { background: #0c7040; border-color: #0c7040; }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 7px; }
.btn-lg { padding: 12px 24px; font-size: 15.5px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-ghost-light { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.5); }
.btn-ghost-light:hover { background: rgba(255,255,255,.12); color: #fff; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
/* "Copy to client" is a picker plus its button, so it needs to sit as one unit
   in a row otherwise made of bare buttons, and keep the picker wide enough to
   read a company name in. */
.btn-row form.dupto { display: flex; gap: 8px; align-items: center; }
.btn-row form.dupto .ac { min-width: 230px; }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
label.fld { display: block; font-size: 13px; font-weight: 600; color: var(--ink); }
label.fld span { display: block; margin-bottom: 5px; }
label.fld .hint { font-weight: 400; color: var(--mute); font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=search], input[type=url], select, textarea {
  width: 100%; padding: 8.5px 11px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: 14px; color: var(--ink); background: var(--card);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--body); }
.check input { width: auto; }
.fld-inline { display: flex; gap: 8px; align-items: center; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; align-items: center; flex-wrap: wrap; }
.form-err { background: var(--bad-soft); color: var(--bad); border-radius: 9px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
.form-note { background: var(--accent-soft); color: var(--accent-2); border-radius: 9px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }

/* filter bar */
.filters { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type=search] { width: 220px; }
.filters select { width: auto; }
.filters input[type=date] { width: auto; }

/* ajax type-ahead pickers (stand in for the giant dropdowns) */
.ac { position: relative; display: block; }
.filters .ac { width: 210px; }
.ac .ac-input { padding-right: 30px; text-overflow: ellipsis; }
.ac-clear {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; border: 0; border-radius: 50%; background: none;
  color: var(--mute); font-size: 16px; line-height: 1; cursor: pointer; padding: 0;
}
.ac-clear:hover { background: var(--line-soft); color: var(--ink); }
.ac-list {
  position: absolute; top: calc(100% + 5px); left: 0; right: 0; min-width: 250px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); max-height: 300px; overflow-y: auto; z-index: 70; display: block;
}
.ac-list[hidden] { display: none; }
.ac-item {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  border-bottom: 1px solid var(--line-soft); padding: 8px 12px; cursor: pointer;
  font: inherit; font-size: 13.5px; color: var(--body);
}
.ac-item:last-child { border-bottom: 0; }
.ac-item:hover, .ac-item.on { background: var(--soft); outline: none; }
.ac-item .t { display: block; font-weight: 600; color: var(--ink); }
.ac-item .s { display: block; font-size: 12px; color: var(--mute); }
.ac-empty { display: block; padding: 14px 12px; font-size: 13px; color: var(--mute); }
.ac.ac-err .ac-input { border-color: var(--bad); outline: 2px solid var(--bad-soft); }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 30px 16px; background: linear-gradient(160deg, var(--ink) 0%, #1a2440 55%, #223058 100%); }
.auth-col { width: 100%; max-width: 400px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-brand .auth-logo { width: min(300px, 82%); }
.auth-brand .brand-sub { font-size: 12px; }
.auth-card { background: var(--card); border-radius: 16px; box-shadow: 0 18px 50px rgba(6,10,25,.45); padding: 28px; }
.auth-card h1 { font-size: 20px; }
.auth-card .fld { margin-bottom: 13px; }
.auth-links { margin-top: 14px; font-size: 13.5px; text-align: center; }

/* ---------- toasts + impersonation ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 9px; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); animation: toast-in .25s ease; max-width: 380px; }
.toast-err { background: var(--bad); }
.toast-warn { background: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.impersonation-bar { background: var(--warn); color: #fff; display: flex; gap: 14px; align-items: center; justify-content: center; padding: 8px 14px; font-size: 13.5px; position: sticky; top: 0; z-index: 90; }
.impersonation-bar form { margin: 0; }

/* ---------- pager ---------- */
.pager { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.pager a { min-width: 32px; text-align: center; padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; font-size: 13.5px; color: var(--body); }
.pager a.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager a:hover { text-decoration: none; border-color: var(--accent); }
.pager-gap { align-self: center; color: var(--mute); }

/* ---------- line item editor ---------- */
.items-editor { width: 100%; }
/* The last track holds the amount AND the delete button. It must be wide
   enough for a struck-through value plus FREE, or a no-charge line's amount
   runs past the card edge and clips. */
.items-editor .ie-row { display: grid; grid-template-columns: 1fr 86px 96px 110px 60px minmax(124px, auto); gap: 8px; align-items: start; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.items-editor .ie-head { font-size: 11.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--mute); border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.items-editor .ie-head > div:last-child { text-align: right; padding-right: 26px; }
.items-editor .ie-desc textarea { min-height: 34px; max-height: 220px; font-size: 13px; margin-top: 5px; field-sizing: content; }
.items-editor .ie-amt { text-align: right; font-weight: 600; color: var(--ink); padding-top: 9px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.items-editor .ie-del { width: 26px; background: none; border: 0; color: var(--mute); font-size: 17px; cursor: pointer; padding: 7px 0; text-align: center; }
.items-editor .ie-del:hover { color: var(--bad); }
.items-editor .ie-tax { padding-top: 10px; text-align: center; }
/* no-charge lines: editor controls, then how they read on the documents */
.ie-comp { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; font-size: 12.5px; }
.ie-comp .ie-comp-toggle { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.ie-comp .ie-comp-period { display: inline-flex; align-items: center; gap: 6px; }
.ie-comp .ie-comp-period[hidden] { display: none; }
.ie-comp input[type=number] { width: 62px; padding: 4px 7px; font-size: 12.5px; }
.ie-comp select { width: auto; padding: 4px 26px 4px 7px; font-size: 12.5px; }
.ie-comp .ie-comp-preview { color: var(--ok); font-weight: 600; flex-basis: 100%; }
.ie-comp .ie-comp-preview:empty { display: none; }
.ie-comp .ie-comp-hint { flex-basis: 100%; color: var(--mute); font-weight: 400; }
.ie-comp .ie-comp-hint[hidden] { display: none; }
.items-editor .ie-amt .free { color: var(--ok); }
.items-editor .ie-amt s { color: var(--mute); font-weight: 400; margin-right: 4px; }
.totals-box .tr.comp { color: var(--ok); }
.totals-box .tr.comp b { color: var(--ok); }
table.ip-items tr.comp .c, .doc-items tr.comp .c { color: var(--ok); font-weight: 600; font-size: 12.5px; margin-top: 3px; }
table.ip-items .was, .doc-items .was { color: var(--mute); font-weight: 400; font-size: 12px; display: block; }
table.ip-items .free, .doc-items .free { color: var(--ok); letter-spacing: .04em; }
.ip-compnote, .doc-compnote { margin-top: 12px; padding: 9px 12px; border-radius: 8px; background: var(--ok-soft); color: var(--ok); font-size: 13px; }
.doc-compnote { font-size: 14px; margin-top: 14px; }
.ip-compnote strong, .doc-compnote strong { color: inherit; }
.ie-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.ie-actions .btn svg { width: 14px; height: 14px; }
/* saved items: the per-line bookmark (fades in on hover/focus) + the picker modal */
.items-editor .ie-name { display: flex; align-items: center; gap: 4px; }
.items-editor .ie-name input { flex: 1; min-width: 0; }
.items-editor .ie-save { flex: 0 0 auto; width: 30px; height: 30px; display: inline-grid; place-items: center; background: none; border: 0; border-radius: 7px; color: var(--mute); cursor: pointer; opacity: .35; padding: 0; }
.items-editor .ie-save svg { width: 16px; height: 16px; }
.items-editor .ie-row:hover .ie-save, .items-editor .ie-row:focus-within .ie-save, .items-editor .ie-save.on { opacity: 1; }
.items-editor .ie-save:hover { background: var(--accent-soft); color: var(--accent); }
.items-editor .ie-save.on { color: var(--accent); }
.items-editor .ie-save.on svg { fill: var(--accent-soft); }
.items-editor .ie-save:disabled { opacity: .4; cursor: default; }
.items-editor .ie-row.ie-flash { animation: ie-flash .9s ease; }
@keyframes ie-flash { 0% { background: var(--accent-soft); } 100% { background: transparent; } }
.items-modal .modal { max-width: 660px; padding: 20px 22px; display: flex; flex-direction: column; max-height: 86vh; }
.items-modal .im-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.items-modal .im-head h2 { margin: 0; flex: 1; }
.items-modal .im-x { background: none; border: 0; font-size: 26px; line-height: 1; color: var(--mute); cursor: pointer; padding: 0 4px; }
.items-modal .im-x:hover { color: var(--ink); }
.items-modal .im-search { width: 100%; margin-bottom: 10px; }
.items-modal .im-list { flex: 1; overflow-y: auto; border: 1px solid var(--line-soft); border-radius: 10px; min-height: 220px; }
.items-modal .im-item { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line-soft); padding: 10px 12px; cursor: pointer; font: inherit; color: var(--body); }
.items-modal .im-item:last-child { border-bottom: 0; }
.items-modal .im-item:hover, .items-modal .im-item:focus { background: var(--soft); outline: none; }
.items-modal .im-item.im-added { background: var(--ok-soft); }
.items-modal .im-t { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.items-modal .im-name { font-weight: 600; color: var(--ink); }
.items-modal .im-cat { font-size: 11.5px; color: var(--mute); background: var(--soft); border: 1px solid var(--line-soft); border-radius: 99px; padding: 1px 8px; }
.items-modal .im-price { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; white-space: nowrap; font-size: 13.5px; }
.items-modal .im-desc { font-size: 12.5px; color: var(--mute); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.items-modal .im-empty { padding: 36px 16px; text-align: center; color: var(--mute); font-size: 13.5px; }
.items-modal .im-foot { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 13px; }
.items-modal .im-foot .spacer { flex: 1; }
.totals-box { margin-left: auto; max-width: 340px; margin-top: 14px; font-size: 14.5px; }
.totals-box .tr { display: flex; justify-content: space-between; padding: 5px 0; color: var(--mute); }
.totals-box .tr b { color: var(--body); font-weight: 500; }
.totals-box .tr.grand { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; font-family: var(--head); font-weight: 700; font-size: 17px; color: var(--ink); }
.totals-box .tr.grand b { color: var(--ink); font-weight: 700; }
.totals-box .tr.dep { color: var(--accent-2); font-weight: 600; }

/* ---------- payment schedule editor ---------- */
.sched-editor { margin-top: 4px; }
.sched-head { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.sched-cols, .sched-row { display: grid; grid-template-columns: 26px 1fr 150px 118px 30px; gap: 8px; align-items: center; }
.sched-cols { font-size: 11.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--mute); border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.sched-cols .num, .sched-row .sr-amt { text-align: right; }
.sched-row { padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.sched-row .sr-n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-2); font-size: 12px; font-weight: 700; }
.sched-row.is-balance .sr-n { background: var(--soft); color: var(--mute); }
.sched-row .sr-val { display: flex; gap: 6px; align-items: center; }
.sched-row .sr-val input { width: 78px; text-align: right; font-variant-numeric: tabular-nums; }
.sched-row .sr-val select { width: 62px; padding-left: 10px; }
.sched-row .sr-share { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; padding-left: 4px; }
.sched-row .sr-amt { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sched-row .sr-del { width: 26px; background: none; border: 0; color: var(--mute); font-size: 17px; cursor: pointer; padding: 4px 0; text-align: center; }
.sched-row .sr-del:hover { color: var(--bad); }
.sched-row .sr-lock { font-size: 11px; color: var(--mute); text-align: center; letter-spacing: .04em; }
.sched-row.is-zero .sr-amt, .sched-row.is-zero .sr-share { color: var(--bad); }
.sched-row .sr-due { grid-column: 2 / -1; display: flex; align-items: center; gap: 7px; margin-top: 5px; font-size: 12px; color: var(--mute); flex-wrap: wrap; }
.sched-row .sr-due .sd-k { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.sched-row .sr-due select { width: auto; padding: 3px 24px 3px 8px; font-size: 12px; color: var(--body); }
.sched-row .sr-due select:has(option[value=terms]:checked) { color: var(--mute); }
.sched-row .sr-due .sd-aux { display: inline-flex; align-items: center; gap: 5px; }
.sched-row .sr-due .sd-aux[hidden] { display: none; }
.sched-row .sr-due input[type=number] { width: 62px; padding: 3px 7px; font-size: 12px; }
.sched-row .sr-due input[type=date] { width: 142px; padding: 3px 7px; font-size: 12px; }
.sched-foot { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.sched-hint { font-size: 12.5px; color: var(--mute); }
.sched-hint.warn { color: var(--bad); font-weight: 600; }
.sched-hint:empty { display: none; }
.sched-editor.compact .sched-cols, .sched-editor.compact .sched-row { grid-template-columns: 24px 1fr 128px 0 24px; gap: 6px; }
.sched-editor.compact .sr-amt, .sched-editor.compact .sched-cols .num { display: none; }
.sched-editor.compact .sr-val input { width: 58px; }
.sched-editor.compact .sr-val select { width: 56px; padding-left: 8px; }
@media (max-width: 720px) {
  .sched-cols, .sched-row { grid-template-columns: 22px 1fr 128px 84px 24px; gap: 6px; }
  .sched-row .sr-val input { width: 60px; }
}

/* schedule status table (admin estimate page) */
.sched-status .st-state { font-size: 12.5px; white-space: nowrap; }
.sched-status .st-next { background: var(--accent-soft); }
.sched-status .st-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.sched-status .st-actions form { margin: 0; }

/* ---------- rich text editor ---------- */
.rte { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); }
.rte-bar { display: flex; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--line-soft); background: var(--soft); flex-wrap: wrap; }
.rte-bar button { background: none; border: 1px solid transparent; border-radius: 6px; padding: 4px 9px; font: inherit; font-size: 13px; font-weight: 600; color: var(--body); cursor: pointer; }
.rte-bar button:hover { background: var(--card); border-color: var(--line); }
.rte-area { min-height: 170px; padding: 14px 16px; outline: none; font-size: 14.5px; max-height: 460px; overflow-y: auto; }
.rte-area:focus { background: #fdfdfe; }
.rte-area h2 { font-size: 19px; margin: .7em 0 .35em; }
.rte-area h3 { font-size: 15.5px; margin: .7em 0 .3em; }
.rte-area p { margin: .45em 0; }
.rte-area blockquote { border-left: 3px solid var(--accent); background: var(--soft); margin: .6em 0; padding: 8px 14px; border-radius: 0 8px 8px 0; }
.rte-area hr { border: 0; border-top: 1px solid var(--line); margin: 1em 0; }

/* estimate builder page list */
.page-card { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 14px; background: var(--card); }
.page-card .pc-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); background: var(--soft); border-radius: 12px 12px 0 0; }
.page-card .pc-head input[type=text] { font-weight: 600; }
.page-card .pc-body { padding: 12px 14px; }
.page-card .pc-tools { display: flex; gap: 6px; margin-left: auto; }
.pc-tools button, .pc-tools a { background: none; border: 1px solid var(--line); border-radius: 7px; padding: 4px 9px; font-size: 12.5px; cursor: pointer; color: var(--body); }
.pc-tools button:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
/* designed (image) pages in the estimate pages editor */
.page-card.is-image .pc-head .pill { margin-left: 4px; }
.page-card.is-image .pc-body { display: flex; gap: 16px; align-items: flex-start; }
.page-card .pc-thumb { width: 240px; aspect-ratio: 1603 / 1243; object-fit: cover; border: 1px solid var(--line); border-radius: 8px; background: #fff; flex: 0 0 auto; }
/* page library */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.lib-card { display: block; border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--card); cursor: pointer; position: relative; }
.lib-card input[type=checkbox] { position: absolute; top: 14px; left: 14px; width: 18px; height: 18px; z-index: 1; }
.lib-card img { width: 100%; aspect-ratio: 1603 / 1243; object-fit: cover; border-radius: 6px; border: 1px solid var(--line-soft); display: block; margin-bottom: 8px; }
.lib-card span { display: block; font-weight: 600; font-size: 13.5px; color: var(--ink); }
.lib-card small { display: block; color: var(--mute); font-size: 12px; }
.lib-card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.page-card.lib-edit { margin-bottom: 0; }
.page-card.lib-edit .lib-thumb { width: 100%; aspect-ratio: 1603 / 1243; object-fit: cover; display: block; border-radius: 12px 12px 0 0; border-bottom: 1px solid var(--line-soft); }
/* signing code entry */
.code-input { font-size: 28px; letter-spacing: 8px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }

/* template picker */
.tpl-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tpl-opt { border: 2px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; text-align: center; }
.tpl-opt input { position: absolute; opacity: 0; }
.tpl-opt.on { border-color: var(--accent); background: var(--accent-soft); }
.tpl-opt .swatch { height: 58px; border-radius: 8px; margin-bottom: 8px; background: var(--soft); position: relative; overflow: hidden; }
.tpl-opt .swatch::before { content: ''; position: absolute; inset: 0; }
.tpl-studio .swatch::before { background: linear-gradient(180deg, var(--ink) 55%, #fff 55%); }
.tpl-ledger .swatch::before { background: #fff; border-bottom: 4px solid var(--accent); }
.tpl-atlas .swatch::before { background: linear-gradient(90deg, var(--ink) 34%, #fff 34%); }
.tpl-opt .tn { font-size: 13px; font-weight: 600; color: var(--ink); }

/* ---------- public document pages ---------- */
.doc-wrap { min-height: 100vh; background: #e6e9f0; padding-bottom: 90px; }
.doc-top {
  background: var(--ink); color: #c6cede; padding: 14px 20px; display: flex; gap: 14px;
  align-items: center; position: sticky; top: 0; z-index: 50;
}
.doc-top .doc-logo { display: block; height: 30px; width: auto; flex: 0 0 auto; }
.doc-top .dt-meta { color: #c6cede; font-size: 13.5px; padding-left: 14px; border-left: 1px solid rgba(255,255,255,.16); line-height: 1.3; }
@media (max-width: 640px) {
  .doc-top { flex-wrap: wrap; gap: 10px 12px; }
  .doc-top .doc-logo { height: 24px; }
  .doc-top .dt-meta { font-size: 12.5px; }
}
.doc-top .dt-actions { margin-left: auto; display: flex; gap: 9px; align-items: center; }
.doc-pages { max-width: 860px; margin: 26px auto 0; padding: 0 14px; }
.doc-page { background: #fff; border-radius: 6px; box-shadow: 0 2px 6px rgba(16,23,40,.08), 0 14px 40px rgba(16,23,40,.10); margin-bottom: 26px; padding: 58px 64px; min-height: 420px; }
.doc-page.cover { padding: 0; overflow: hidden; }
.doc-page.deck { padding: 0; overflow: hidden; min-height: 0; }
.doc-page.deck img { display: block; width: 100%; height: auto; }
.doc-status-note { max-width: 860px; margin: 18px auto 0; padding: 0 14px; }
.doc-note { border-radius: 12px; padding: 14px 18px; font-size: 14.5px; display: flex; gap: 10px; align-items: center; }
.doc-note.ok { background: var(--ok-soft); color: var(--ok); }
.doc-note.warn { background: var(--warn-soft); color: var(--warn); }
.doc-note.info { background: var(--accent-soft); color: var(--accent-2); }
.doc-note.bad { background: var(--bad-soft); color: var(--bad); }

/* cover variants */
.cov-band { background: var(--ink); color: #fff; padding: 46px 64px 40px; border-bottom: 6px solid var(--doc-accent, var(--accent)); }
.cov-band .cb-co { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 44px; }
.cov-band .cb-co .co { font-family: var(--head); font-weight: 700; font-size: 17px; letter-spacing: .03em; }
.cov-band .cb-co .no { color: #9fb0d8; font-size: 13px; font-weight: 600; letter-spacing: .08em; }
.cov-band h1 { color: #fff; font-size: clamp(26px, 4.6vw, 40px); margin: 0 0 10px; }
.cov-band .for { color: #c8d2ea; font-size: 15.5px; }
.cov-body { padding: 40px 64px 54px; }
.cov-img { width: 100%; max-height: 300px; object-fit: cover; display: block; }
.cov-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 30px; }
.cov-card { background: var(--soft); border-radius: 10px; padding: 13px 15px; }
.cov-card .k { font-size: 10.5px; font-weight: 700; letter-spacing: .09em; color: var(--mute); text-transform: uppercase; }
.cov-card .v { font-family: var(--head); font-weight: 700; font-size: 16px; color: var(--ink); margin-top: 3px; }
.cov-card .v.acc { color: var(--doc-accent, var(--accent)); }
.cov-2col { display: grid; grid-template-columns: 1.1fr .9fr; gap: 30px; }
.cov-2col .k { font-size: 10.5px; font-weight: 700; letter-spacing: .09em; color: var(--mute); text-transform: uppercase; margin-bottom: 7px; }
.cov-ledger { padding: 64px; }
.cov-ledger .rule { width: 40px; height: 5px; background: var(--doc-accent, var(--accent)); margin-bottom: 26px; }
.cov-ledger .kicker { letter-spacing: .28em; font-weight: 700; font-size: 12.5px; color: var(--mute); margin-bottom: 18px; }
.cov-ledger h1 { font-size: clamp(28px, 4.6vw, 42px); }
.cov-atlas { display: grid; grid-template-columns: 200px 1fr; min-height: 560px; }
.cov-atlas .band { background: var(--ink); border-right: 5px solid var(--doc-accent, var(--accent)); color: #fff; padding: 34px 22px; display: flex; flex-direction: column; }
.cov-atlas .band .co { font-family: var(--head); font-weight: 700; font-size: 15px; }
.cov-atlas .band .no { margin-top: auto; color: #9fb0d8; font-size: 12.5px; font-weight: 600; }
.cov-atlas .band .no b { display: block; color: #fff; font-size: 15px; }
.cov-atlas .rest { padding: 44px 46px; }

/* doc content typography */
.doc-page .dp-title { font-size: 24px; margin-bottom: 4px; }
.doc-page .dp-rule { width: 36px; height: 4px; background: var(--doc-accent, var(--accent)); border-radius: 2px; margin-bottom: 20px; }
.doc-rich { font-size: 15px; color: var(--body); }
.doc-rich h2 { font-size: 20px; margin: 1.1em 0 .4em; }
.doc-rich h3 { font-size: 16px; margin: 1em 0 .35em; }
.doc-rich p { margin: .55em 0; }
.doc-rich li { margin: .3em 0; }
.doc-rich blockquote { border-left: 3px solid var(--doc-accent, var(--accent)); background: var(--soft); margin: .8em 0; padding: 10px 16px; border-radius: 0 8px 8px 0; font-style: italic; }
.doc-rich hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }

/* doc pricing table */
.doc-items { width: 100%; border-collapse: collapse; font-size: 14.5px; margin-top: 6px; }
.doc-items thead th { background: var(--ink); color: #fff; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; padding: 10px 12px; text-align: left; }
.doc-items thead th:first-child { border-radius: 7px 0 0 7px; }
.doc-items thead th:last-child { border-radius: 0 7px 7px 0; }
.doc-items td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.doc-items .n { color: var(--ink); font-weight: 600; }
.doc-items .d { color: var(--mute); font-size: 13px; margin-top: 2px; }
.doc-items .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-items th.num { text-align: right; }
.doc-totals { margin-left: auto; max-width: 320px; margin-top: 16px; font-size: 14.5px; }
.doc-totals .tr { display: flex; justify-content: space-between; padding: 4.5px 0; color: var(--mute); }
.doc-totals .tr.grand { border-top: 2px solid var(--ink); margin-top: 8px; padding-top: 10px; font-family: var(--head); font-weight: 700; font-size: 19px; color: var(--ink); }
.doc-totals .tr.pay { color: var(--ok); font-weight: 600; }
.doc-totals .tr.due { font-family: var(--head); font-weight: 700; font-size: 17px; color: var(--doc-accent, var(--accent)); }
.doc-callout { display: flex; gap: 14px; background: var(--soft); border-left: 4px solid var(--doc-accent, var(--accent)); border-radius: 10px; padding: 15px 18px; margin-top: 24px; font-size: 14.5px; }
.doc-callout b { color: var(--ink); }
/* payment schedule on the estimate's pricing page */
.doc-sched { margin-top: 24px; background: var(--soft); border-left: 4px solid var(--doc-accent, var(--accent)); border-radius: 10px; padding: 15px 18px; font-size: 14px; }
.doc-sched .ds-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.doc-sched .ds-head b { color: var(--ink); font-size: 15px; }
.doc-sched .ds-head span { color: var(--mute); font-size: 13px; }
.doc-sched-tbl { width: 100%; border-collapse: collapse; }
.doc-sched-tbl td { padding: 6px 8px; border-top: 1px solid var(--line-soft); vertical-align: top; }
.doc-sched-tbl tr:first-child td { border-top: 0; }
.doc-sched-tbl .n { width: 28px; color: var(--mute); }
.doc-sched-tbl .l { color: var(--ink); font-weight: 600; }
.doc-sched-tbl .l .d { color: var(--mute); font-weight: 400; font-size: 12.5px; margin-top: 1px; }
.doc-sched-tbl .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-sched-tbl .s { color: var(--mute); width: 70px; }
.doc-sched-tbl .a { font-weight: 700; color: var(--ink); width: 110px; }
.doc-sched .ds-note { margin-top: 10px; font-size: 13px; color: var(--mute); }

/* signature area on doc */
.doc-sig { margin-top: 26px; }
.doc-sig img { max-width: 260px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.doc-sig .meta { color: var(--mute); font-size: 12.5px; margin-top: 6px; }

/* action bar (approve / pay) */
.doc-actionbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 80;
  background: rgba(16,23,40,.97); color: #fff; padding: 13px 18px;
  display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap;
}
.doc-actionbar .ab-info { font-size: 14.5px; color: #c6cede; }
.doc-actionbar .ab-info b { color: #fff; }

/* signature modal */
.modal-back { position: fixed; inset: 0; background: rgba(10,14,26,.6); z-index: 120; display: grid; place-items: center; padding: 16px; }
.modal-back[hidden] { display: none; }
.modal { background: #fff; border-radius: 16px; box-shadow: 0 24px 70px rgba(6,10,25,.5); width: 100%; max-width: 520px; padding: 24px 26px; max-height: 94vh; overflow-y: auto; }
.modal h2 { font-size: 19px; }
.sig-pad-wrap { border: 1.5px dashed var(--line); border-radius: 10px; position: relative; background: #fcfcfe; }
.sig-pad-wrap canvas { display: block; width: 100%; height: 160px; touch-action: none; border-radius: 10px; }
.sig-pad-wrap .sig-hint { position: absolute; inset: 0; display: grid; place-items: center; color: #b9c1d4; font-size: 14px; pointer-events: none; }
.sig-clear { position: absolute; top: 7px; right: 9px; background: var(--soft); border: 1px solid var(--line); border-radius: 7px; font-size: 12px; padding: 3px 9px; cursor: pointer; color: var(--body); }
.consent { font-size: 12.5px; color: var(--mute); margin: 12px 0; display: flex; gap: 9px; align-items: flex-start; }
.consent input { margin-top: 3px; }

/* ---------- invoice paper (letterhead design, shared by admin + public) ---------- */
.inv-paper { background: #fff; padding: 40px 44px; max-width: 860px; font-size: 14px; color: var(--body); }
.card .inv-paper { padding: 34px 38px; border: 1px solid var(--line-soft); border-radius: 10px; max-width: none; }
.ip-top { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.ip-logo { height: 44px; width: auto; max-width: 260px; display: block; }
.ip-wordmark { font-family: var(--head); font-weight: 700; font-size: 22px; color: var(--doc-accent, var(--accent)); letter-spacing: .02em; }
.ip-addr { font-size: 12px; color: var(--mute); margin-top: 8px; line-height: 1.5; }
.ip-title { text-align: right; }
.ip-title h2 { font-family: var(--head); font-size: 26px; letter-spacing: .06em; color: var(--doc-accent, var(--accent)); margin: 0 0 10px; display: flex; gap: 10px; align-items: center; justify-content: flex-end; }
.ip-meta { font-size: 13px; border-collapse: collapse; margin-left: auto; }
.ip-meta td { padding: 2px 0 2px 18px; text-align: right; }
.ip-meta td:first-child { color: var(--mute); }
.ip-meta td:last-child { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.ip-rule { height: 3px; background: var(--doc-accent, var(--accent)); margin: 22px 0 26px; position: relative; border-radius: 2px; }
.ip-rule::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 64px; background: var(--brand-red); border-radius: 2px; }
.ip-mid { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 28px; flex-wrap: wrap; }
.ip-billto .k, .ip-due .k { font-size: 10px; letter-spacing: 1.8px; color: var(--mute); font-weight: 700; }
.ip-billto strong { display: block; font-size: 16px; color: var(--ink); margin: 6px 0 2px; }
.ip-billto div { font-size: 13.5px; }
.ip-due { background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; min-width: 230px; }
.ip-due .v { font-family: var(--head); font-size: 26px; font-weight: 700; color: var(--doc-accent, var(--accent)); margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.ip-due .v.bad { color: var(--brand-red); }
.ip-due .v.ok { color: var(--ok); }
.ip-due .d { font-size: 12.5px; color: var(--mute); }
table.ip-items { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.ip-items th { background: var(--doc-accent, var(--accent)); color: #fff; font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase; padding: 8px 12px; text-align: left; }
table.ip-items th:first-child { border-radius: 6px 0 0 6px; }
table.ip-items th:last-child { border-radius: 0 6px 6px 0; }
table.ip-items td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.ip-items tbody tr:nth-child(even) td { background: var(--soft); }
table.ip-items .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.ip-items th.num { text-align: right; }
table.ip-items .n { color: var(--ink); font-weight: 600; }
table.ip-items .d { color: var(--mute); font-size: 12.5px; margin-top: 2px; white-space: pre-line; }
.ip-totals { margin-left: auto; margin-top: 18px; width: 300px; max-width: 100%; font-size: 14px; }
.ip-totals .row { display: flex; justify-content: space-between; padding: 4px 0; }
.ip-totals .row span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.ip-totals .row.total { border-top: 1.5px solid var(--line); margin-top: 6px; padding-top: 9px; font-weight: 700; }
.ip-totals .due { display: flex; justify-content: space-between; align-items: center; background: var(--doc-accent, var(--accent)); color: #fff; border-radius: 9px; padding: 10px 14px; margin-top: 10px; font-weight: 700; }
.ip-totals .due.bad { background: var(--brand-red); }
.ip-totals .due.ok { background: var(--ok); }
.ip-totals .due span:last-child { font-size: 16px; font-variant-numeric: tabular-nums; }
.ip-pays { margin-top: 20px; font-size: 13px; max-width: 420px; }
.ip-pays .k { font-size: 10px; letter-spacing: 1.8px; color: var(--mute); font-weight: 700; margin-bottom: 6px; }
.ip-pays .row { display: flex; justify-content: space-between; padding: 3px 0; gap: 12px; }
.ip-notes { margin-top: 22px; font-size: 13px; color: var(--body); background: var(--soft); border-radius: 9px; padding: 12px 16px; }
.ip-paynote { margin-top: 18px; text-align: center; font-size: 12.5px; color: var(--doc-accent, var(--accent)); }
.ip-paynote .muted { color: var(--mute); }
.ip-foot { margin-top: 30px; border-top: 1px dashed var(--line); padding-top: 14px; font-size: 12px; color: var(--mute); display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
/* context blocks on installment invoices: the project scope + the payment schedule */
.ip-ctx { margin-top: 22px; font-size: 13px; }
.ip-ctx .k { font-size: 10px; letter-spacing: 1.8px; color: var(--mute); font-weight: 700; margin-bottom: 6px; }
.ip-ctx .k .mute { letter-spacing: 0; font-weight: 600; margin-left: 8px; }
.ip-ctx-tbl { width: 100%; border-collapse: collapse; }
.ip-ctx-tbl td { padding: 5px 8px; border-top: 1px solid var(--line-soft); vertical-align: top; color: var(--body); }
.ip-ctx-tbl tr:first-child td { border-top: 0; }
.ip-ctx-tbl .n { color: var(--ink); font-weight: 600; }
.ip-ctx-tbl .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ip-ctx-tbl .a { color: var(--ink); font-weight: 700; width: 110px; }
.ip-ctx-tbl .st { color: var(--mute); white-space: nowrap; text-align: right; width: 190px; }
.ip-ctx-tbl tr.sub td { color: var(--mute); padding-top: 3px; padding-bottom: 3px; }
.ip-ctx-tbl tr.tot td { border-top: 1.5px solid var(--line); font-weight: 700; color: var(--ink); }
.ip-ctx-tbl tr.this td { background: var(--accent-soft); }
.ip-ctx-tbl tr.this .st { color: var(--accent-2); font-weight: 700; }
.ip-remit { margin-top: 20px; border: 2.5px solid var(--ink, #101728); border-radius: 10px; padding: 12px 18px; text-align: center; background: #fff; }
.ip-remit .k { display: block; font-size: 11px; letter-spacing: .16em; font-weight: 700; color: var(--mute); margin-bottom: 4px; }
.ip-remit strong { font-size: 17px; font-weight: 800; color: var(--ink, #101728); letter-spacing: .01em; }
.ab-payform { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.ab-save { font-size: 13px; color: #fff; max-width: 360px; }
.doc-cardbox { max-width: 860px; margin: 14px auto 0; background: var(--card, #fff); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; }
.doc-cardbox .cb-head { font-size: 14.5px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.doc-cardbox .cb-note { font-size: 13px; color: var(--mute); margin: 6px 0 10px; }
.doc-cardbox .cb-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-start; }
.doc-cardbox .cb-consent { display: flex; flex-direction: column; gap: 8px; max-width: 640px; }
.doc-cardbox .cb-consent .check { font-size: 12.5px; color: var(--body); }
.doc-cardbox .cb-consent .btn { align-self: flex-start; }
/* styled confirm dialog */
.confirm-modal .modal { max-width: 440px; }
.confirm-modal .cm-text { font-size: 14.5px; color: var(--body); margin: 6px 0 4px; line-height: 1.5; }
.confirm-modal .form-actions { margin-top: 18px; }
/* Stripe on-page card form */
.pay-modal .modal { max-width: 480px; }
.pay-modal .pm-sub { font-size: 13.5px; color: var(--mute); margin: -4px 0 14px; line-height: 1.5; }
.pay-modal .pm-element { min-height: 120px; margin-bottom: 12px; }
.pay-modal .pm-loading { font-size: 13px; color: var(--mute); padding: 28px 0; text-align: center; }
.pay-modal .pm-save { font-size: 13px; color: var(--body); margin: 10px 0 4px; align-items: flex-start; }
.pay-modal .pm-save .hint { font-size: 12px; color: var(--mute); }
.pay-modal .pm-error { background: #fdecec; color: #8a1f1f; border-radius: 8px; padding: 10px 12px; font-size: 13px; margin: 8px 0 0; }
.pay-modal .pm-error[hidden] { display: none; }
.pay-modal .form-actions { margin-top: 16px; }
.btn.is-busy { opacity: .6; pointer-events: none; }
.pill-archived { background: var(--line-soft); color: var(--mute); border: 1px dashed var(--line); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); font-size: 13px; color: var(--body); text-decoration: none; }
.chip:hover { border-color: var(--accent); text-decoration: none; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip b { font-weight: 700; }
.chip.bad.on { background: var(--bad); border-color: var(--bad); }
.chip.bad { color: var(--bad); }
tr.row-archived td { opacity: .55; }

/* ---------- import review ---------- */
.imp-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.imp-stat { background: var(--soft); border-radius: 9px; padding: 8px 14px; font-size: 13.5px; color: var(--mute); }
.imp-stat b { color: var(--ink); font-size: 15px; }
.row-dup td { opacity: .55; }
.row-err td { background: var(--bad-soft); }
.row-credit td { opacity: .7; }

/* charts */
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 340px; }

/* description lists */
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; font-size: 14px; }
.dl dt { color: var(--mute); }
.dl dd { margin: 0; color: var(--ink); font-weight: 500; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 100; transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(10,14,26,.45); }
  .nav-toggle { display: block; }
  .global-search { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .content { padding: 18px 14px 60px; }
  .doc-page { padding: 30px 22px; }
  .cov-band, .cov-body, .cov-ledger { padding-left: 26px; padding-right: 26px; }
  .cov-atlas { grid-template-columns: 1fr; }
  .cov-atlas .band { flex-direction: row; align-items: center; gap: 12px; padding: 18px 22px; border-right: 0; border-bottom: 5px solid var(--doc-accent, var(--accent)); }
  .cov-atlas .band .no { margin-top: 0; margin-left: auto; text-align: right; }
  .cov-2col { grid-template-columns: 1fr; }
  .items-editor .ie-row { grid-template-columns: 1fr 64px 84px 90px 44px minmax(108px, auto); }
}

@media print {
  .doc-top, .doc-actionbar, .doc-status-note, .toasts { display: none !important; }
  .doc-wrap { background: #fff; padding: 0; }
  .doc-pages { max-width: none; margin: 0; padding: 0; }
  .doc-page { box-shadow: none; border-radius: 0; margin: 0; page-break-after: always; }
}

/* ==========================================================================
   On-screen tutorial: the help button, the guided tour, and the handbook.
   ========================================================================== */

/* ---------- help button in the top bar ---------- */

.help-dock { position: relative; }
.help-btn {
  width: 32px; height: 32px; flex: 0 0 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--accent);
  font: 700 15px/1 var(--sans);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s, color .15s;
}
.help-btn:hover, .help-dock.on .help-btn { background: var(--accent); border-color: var(--accent); color: #fff; }
.help-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.help-pop {
  position: absolute; right: 0; top: calc(100% + 10px);
  width: 290px; z-index: 60;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: 0 10px 34px rgba(16,23,40,.16);
  padding: 8px;
}
.help-pop-head {
  font: 700 11px/1 var(--sans);
  letter-spacing: 1.3px; text-transform: uppercase;
  color: var(--mute);
  padding: 8px 10px 10px;
}
.help-pop-item {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; cursor: pointer;
  padding: 9px 10px; border-radius: 8px;
  color: var(--body); font: 400 13.5px/1.35 var(--sans);
}
.help-pop-item strong { display: block; color: var(--ink); font-size: 14px; margin-bottom: 2px; }
.help-pop-item span { display: block; color: var(--mute); font-size: 12.5px; }
.help-pop-item:hover { background: var(--soft); text-decoration: none; }

/* ---------- first visit prompt ---------- */

.tour-welcome {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: linear-gradient(120deg, #101728, var(--accent));
  color: #d5d9ec;
  border-radius: var(--r);
  padding: 20px 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.tour-welcome h2 { color: #fff; font-size: 19px; margin: 0 0 4px; font-family: var(--head); }
.tour-welcome p { margin: 0; font-size: 14px; max-width: 62ch; }
.tour-welcome .tw-copy { flex: 1 1 320px; }
.tour-welcome .btn-row { margin: 0; flex-wrap: nowrap; }
.tour-welcome .btn-go { background: #5a78e6; border-color: #5a78e6; color: #fff; }
.tour-welcome .btn-go:hover { background: #4a66d2; border-color: #4a66d2; }
.tour-welcome .btn-skip {
  background: transparent; color: #c4cbe8; border: 1px solid rgba(255,255,255,.3);
}
.tour-welcome .btn-skip:hover { background: rgba(255,255,255,.12); color: #fff; }

/* ---------- the guided tour ---------- */

.tour-root { position: fixed; inset: 0; z-index: 9000; pointer-events: none; display: none; }
.tour-root.on { display: block; }

.tour-ring {
  position: fixed;
  border-radius: 12px;
  box-shadow: 0 0 0 3px #5a78e6, 0 0 0 9999px rgba(16,23,40,.66);
  pointer-events: none;
  transition: left .22s ease, top .22s ease, width .22s ease, height .22s ease;
}

.tour-card {
  position: fixed;
  width: min(390px, calc(100vw - 28px));
  background: var(--card);
  border-radius: var(--r);
  box-shadow: 0 10px 34px rgba(16,23,40,.3);
  padding: 16px 18px 14px;
  pointer-events: auto;
  transition: left .22s ease, top .22s ease;
}
.tour-card.docked {
  left: 14px !important; right: 14px;
  top: auto !important; bottom: 14px;
  width: auto;
  transition: none;
}
.tour-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.tour-badge {
  font: 700 10.5px/1 var(--sans);
  letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--accent);
}
.tour-x {
  margin-left: auto;
  background: none; border: 0; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--mute); padding: 0 2px;
}
.tour-x:hover { color: var(--ink); }
.tour-title { font-size: 16.5px; margin: 0 0 6px; font-family: var(--head); }
.tour-text { font-size: 13.8px; line-height: 1.55; color: var(--body); }
.tour-text strong { color: var(--ink); }
.tour-text code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; background: var(--soft); padding: 1px 5px; border-radius: 5px;
}
.tour-bar { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.tour-dots { display: flex; gap: 4px; flex-wrap: wrap; max-width: 46%; }
.tour-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.tour-dot.on { background: var(--accent); }
.tour-btns { margin-left: auto; display: flex; gap: 8px; }
.tour-btns .btn[disabled] { opacity: .4; pointer-events: none; }

body.tour-on { overflow-x: hidden; }

@media (max-width: 720px) {
  .tour-dots { display: none; }
  .help-pop { width: 260px; }
}

/* ---------- the handbook ---------- */

.tut-shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}
.tut-toc {
  position: sticky; top: 84px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 10px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
}
.tut-toc-head {
  font: 700 10.5px/1 var(--sans);
  letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--mute);
  padding: 4px 10px 10px;
}
.tut-toc-ch {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: 8px;
  color: var(--body); font-size: 13.5px; line-height: 1.25;
  text-decoration: none;
}
.tut-toc-ch:hover { background: var(--soft); text-decoration: none; color: var(--ink); }
.tut-toc-n {
  flex: 0 0 20px; width: 20px; height: 20px;
  border-radius: 6px; background: var(--soft); color: var(--mute);
  font: 700 11px/20px var(--sans); text-align: center;
}

.tut-search-card { padding: 16px 18px; }
.tut-search-card input[type="search"] { width: 100%; }
.tut-search-note { margin-top: 8px; font-size: 12.5px; color: var(--mute); }

.tut-ch { margin-top: 34px; scroll-margin-top: 80px; }
.tut-ch:first-of-type { margin-top: 22px; }
.tut-ch-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.tut-ch-head h2 { font-size: 22px; margin: 0 0 3px; font-family: var(--head); }
.tut-ch-n {
  flex: 0 0 34px; width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--ink); color: #fff;
  font: 700 15px/34px var(--sans); text-align: center;
}
.tut-ch-blurb { color: var(--mute); font-size: 14px; margin: 0; max-width: 74ch; }

.tut-sec { scroll-margin-top: 80px; margin-bottom: 16px; }
.tut-sec h3 { font-size: 16.5px; margin: 0 0 12px; font-family: var(--head); }
.tut-anchor { margin-left: 8px; color: var(--line); font-weight: 400; font-size: 14px; text-decoration: none; }
.tut-sec:hover .tut-anchor { color: var(--accent); }
.tut-sec p { font-size: 14.3px; line-height: 1.62; }
.tut-sec > p:last-child, .tut-sec > ul:last-child, .tut-sec > ol:last-child { margin-bottom: 0; }
.tut-lead { font-size: 15.5px; line-height: 1.6; color: var(--ink); }
.tut-h { font-size: 14px; margin: 20px 0 8px; letter-spacing: .2px; }

.tut-ul { margin: 0 0 1em; padding-left: 20px; font-size: 14.3px; line-height: 1.6; }
.tut-ul li { margin-bottom: 6px; }
.tut-ul li::marker { color: var(--accent); }

.tut-steps { list-style: none; counter-reset: tstep; margin: 0 0 1em; padding: 0; }
.tut-steps li {
  counter-increment: tstep;
  position: relative;
  padding: 0 0 12px 38px;
  font-size: 14.3px; line-height: 1.6;
}
.tut-steps li::before {
  content: counter(tstep);
  position: absolute; left: 0; top: 0;
  width: 25px; height: 25px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font: 700 12.5px/25px var(--sans); text-align: center;
}
.tut-steps li::after {
  content: ''; position: absolute; left: 12px; top: 29px; bottom: 2px; width: 1px;
  background: var(--line);
}
.tut-steps li:last-child { padding-bottom: 0; }
.tut-steps li:last-child::after { display: none; }

.tut-flow { list-style: none; margin: 0 0 1em; padding: 0; }
.tut-flow li {
  display: grid; grid-template-columns: 30px minmax(0, 1fr);
  gap: 2px 12px;
  padding: 0 0 16px 0;
}
.tut-flow-n {
  grid-row: 1 / span 2;
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--ink); color: #fff;
  font: 700 13px/30px var(--sans); text-align: center;
}
.tut-flow strong { color: var(--ink); font-size: 14.5px; align-self: center; }
.tut-flow li > span:last-child { font-size: 14px; line-height: 1.58; color: var(--body); }

.tut-call {
  display: flex; gap: 12px; align-items: flex-start;
  border-radius: 9px;
  padding: 12px 14px;
  margin: 0 0 1em;
  font-size: 14px; line-height: 1.55;
  background: var(--accent-soft); color: var(--ink);
  border-left: 3px solid var(--accent);
}
.tut-call-tag {
  flex: 0 0 auto;
  font: 700 10px/1.6 var(--sans);
  letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
  padding-top: 2px;
}
.tut-call-warn { background: var(--warn-soft); border-left-color: var(--warn); }
.tut-call-warn .tut-call-tag { color: var(--warn); }
.tut-call-danger { background: var(--bad-soft); border-left-color: var(--bad); }
.tut-call-danger .tut-call-tag { color: var(--bad); }
.tut-call-tip { background: var(--ok-soft); border-left-color: var(--ok); }
.tut-call-tip .tut-call-tag { color: var(--ok); }

.tut-dl { margin: 0 0 1em; }
.tut-dl dt { font-weight: 600; color: var(--ink); font-size: 14.3px; margin-top: 12px; }
.tut-dl dt:first-child { margin-top: 0; }
.tut-dl dd { margin: 2px 0 0; font-size: 14px; line-height: 1.58; color: var(--body); }

.tut-table td { vertical-align: top; font-size: 13.6px; line-height: 1.5; }
.tut-table td:first-child { color: var(--ink); font-weight: 500; }
.tut-table .pill { white-space: nowrap; }

.tut-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.tut-play {
  display: inline-block; width: 0; height: 0; margin-right: 7px;
  border: 5px solid transparent; border-left-color: currentColor; border-right: 0;
  vertical-align: middle;
}

.tut-empty { text-align: center; padding: 34px 20px; }

@media (max-width: 980px) {
  .tut-shell { grid-template-columns: 1fr; }
  .tut-toc { position: static; max-height: none; }
}

@media print {
  .sidebar, .topbar, .tut-toc, .tut-search-card, .tut-actions, .toasts, .tour-root { display: none !important; }
  .tut-shell { display: block; }
  .tut-sec { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  .tut-ch { break-before: page; }
}

/* The top bar carries one more control now (the help button); on a narrow
   screen let its buttons wrap instead of running off the right edge. */
@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; row-gap: 10px; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
}

/* the always-visible one-click tour button for the current page */
.page-tour-btn { white-space: nowrap; }
.page-tour-btn .tut-play { color: var(--accent); }

/* live list filtering */
#list-region { transition: opacity .15s; }
#list-region.busy { opacity: .5; pointer-events: none; }
.list-meta { font-size: 13px; color: var(--mute); margin: 2px 0 10px; }
.list-meta strong, .list-meta b { color: var(--ink); }

/* ---------- proposal editor ---------- */
.pb-list { display: grid; gap: 8px; }
details.pb-block { border: 1px solid var(--line); border-radius: 8px; background: #fff; }
details.pb-block.pb-off { opacity: .6; }
details.pb-block > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 11px 14px; font-size: 13.5px; }
details.pb-block > summary::-webkit-details-marker { display: none; }
details.pb-block[open] > summary { border-bottom: 1px solid var(--line); }
.pb-n { font-family: var(--head); font-weight: 700; font-size: 12px; color: var(--mute); }
.pb-t { font-weight: 700; color: var(--ink); white-space: nowrap; }
.pb-h { color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.pb-body { padding: 14px; }
.pb-tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.pb-tools form { display: flex; gap: 6px; align-items: center; }
.pb-libsave input[type=text] { width: 150px; font-size: 12.5px; padding: 6px 8px; }
.pb-fields { display: grid; gap: 10px; }
.pb-l { display: block; font-size: 12px; font-weight: 600; color: var(--mute); margin-bottom: 4px; }
.pb-rowlist { display: grid; gap: 6px; margin-bottom: 6px; }
.pb-row { display: flex; gap: 6px; align-items: flex-start; }
.pb-row input, .pb-row textarea { flex: 1; font-size: 13px; padding: 7px 9px; min-width: 0; }
.pb-row .w-xs { flex: 0 0 64px; }
.pb-row .w-sm { flex: 0 0 110px; }
.pb-x { flex: none; border: 1px solid var(--line); background: #fff; color: var(--mute); border-radius: 6px; width: 28px; height: 32px; cursor: pointer; font-size: 15px; }
.pb-x:hover { color: var(--danger, #b33); border-color: currentColor; }
.pb-addgrid { display: flex; flex-wrap: wrap; gap: 6px; }
.pb-group { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.pb-group:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.pb-ghead { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.pb-librow { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.pb-librow:last-of-type { border-bottom: 0; }
