/* Plumbing Estimator styles. Light, high-contrast, touch-friendly.
   Company colours: the maroon of the McNeill Plumbing logo (#770002) on white, with warm greys. */
:root {
  --bg: #f5f3f2;
  --surface: #ffffff;
  --surface-2: #faf8f7;
  --ink: #1e1919;
  --muted: #655c5c;
  --line: #e5dfdd;
  --line-strong: #cfc6c3;
  --brand: #770002;
  --brand-dark: #5a0001;
  --brand-soft: #f8eeed;
  --ok: #1d7f4a;
  --ok-soft: #e3f4ea;
  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --warn-line: #f0d48a;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(40, 22, 22, .06), 0 1px 1px rgba(40, 22, 22, .04);
  --shadow-lg: 0 12px 32px rgba(40, 22, 22, .22);
  --sidebar-w: 216px;
  --tabbar-h: 58px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 24px; letter-spacing: -.01em; }
h2 { font-size: 16px; }
h3 { font-size: 15px; }
a { color: var(--brand); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.center { text-align: center; padding: 12px 0; }
.grow { flex: 1 1 auto; min-width: 0; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.icon { flex: none; }

.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 24px; color: var(--muted); text-align: center; }
.boot img { display: block; width: min(260px, 70vw); height: auto; background: #fff; padding: 16px 20px; border-radius: 14px; box-shadow: var(--shadow); }
.update-bar { position: fixed; z-index: 3000; top: 12px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 16px; border-radius: 99px; background: #1e1919; color: #fff; font-size: 14px; box-shadow: var(--shadow-lg); max-width: calc(100vw - 24px); }

/* ---- sign-in (team sync) ------------------------------------------------------ */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.signin-card { width: min(400px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 26px; }
.card.signin-card { border-top: 4px solid var(--brand); }
.signin-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 4px; text-align: center; }
.signin-logo { display: block; width: min(250px, 80%); height: auto; }
.signin-brand h1 { font-size: 20px; }
.signin-message { min-height: 20px; font-size: 13.5px; color: var(--danger); }
.signin-message.ok { color: var(--ok); }
.signin-foot { text-align: center; }
.link-button { background: none; border: 0; padding: 4px; font: inherit; font-size: 13.5px; color: var(--brand); cursor: pointer; text-decoration: underline; align-self: center; }

/* ---- shell ------------------------------------------------------------------ */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: linear-gradient(180deg, #7a0002 0%, #560001 100%); color: #f3dede;
  display: flex; flex-direction: column; padding: 16px 12px; gap: 18px; z-index: 20;
}
/* the company logo (from the letterhead) on a white plate, with the app's name under it */
.brand { display: flex; flex-direction: column; gap: 9px; color: #fff; text-decoration: none; padding: 0 2px; border-radius: 10px; }
.brand:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.brand-logo { display: block; background: #fff; border-radius: 10px; padding: 11px 12px 9px; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.brand-logo img { display: block; width: 100%; height: auto; max-height: 96px; object-fit: contain; }
.brand-name { font-weight: 700; font-size: 11.5px; letter-spacing: .22em; text-transform: uppercase; text-align: center; color: rgba(255, 255, 255, .86); }
/* the same logo at the top of the home screen when there is no sidebar (phones, an iPad held upright) */
.home-brand { display: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px;
  color: #f0d6d6; text-decoration: none; font-weight: 500;
}
.nav-link:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.nav-link.active { background: rgba(255, 255, 255, .17); color: #fff; }
.sidebar-foot { margin-top: auto; font-size: 12px; color: #dcb4b4; padding: 0 8px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.sidebar-signout { color: #fff; padding: 2px 0; font-size: 12.5px; }
/* Settings: the sections to click on, one showing at a time */
.settings-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 16px; position: sticky; top: 0; z-index: 5; background: var(--bg, #f4f2f1); padding: 8px 0; }
.settings-panel > .card + .card { margin-top: 16px; }
/* Settings > People: the ways an estimator's bids may show the price */
.person-show { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; margin-top: 6px; }
.person-show .check { font-size: 13px; }
/* the estimate's Price column: how the proposal shows the price */
.proposal-show .sum-row .check { font-size: 13px; }
.proposal-show .show-select { max-width: 100%; }
.proposal-show .range-input { width: 84px; }
.proposal-show .inline-field { display: inline-flex; align-items: center; gap: 4px; margin-right: 8px; }
.home-account { display: flex; gap: 10px; align-items: center; }
.tabbar { display: none; }

.view { margin-left: var(--sidebar-w); min-height: 100vh; }
.page { max-width: 1240px; margin: 0 auto; padding: 28px 28px 80px; }
.page.narrow { max-width: 900px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-intro { margin: -8px 0 16px; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---- buttons ------------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: #b9aeab; }
.btn:focus-visible, .input:focus-visible, .nav-link:focus-visible, .chip:focus-visible, .tpl-card:focus-visible, .est-row:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #991f18; border-color: #991f18; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: rgba(40, 22, 22, .06); border-color: transparent; color: var(--ink); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn-icon { padding: 0; width: 38px; }
.btn-icon.btn-sm { width: 32px; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- inputs --------------------------------------------------------------------- */
.input {
  width: 100%; min-height: 38px; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: inherit;
}
.input::placeholder { color: #a39a98; }
.input:hover { border-color: #b9aeab; }
.input.num { text-align: right; font-variant-numeric: tabular-nums; }
.input.invalid { border-color: var(--danger); background: var(--danger-soft); }
.formula-problem { color: var(--danger); font-size: 12.5px; margin-top: 3px; }
.inline-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sync-pill { display: inline-block; font-size: 11.5px; color: #d9d0cd; margin-top: 4px; }
.first-day-list { margin: 0; padding-left: 18px; } .first-day-list li { margin: 4px 0; }
.work-order { padding: 40px 48px; font-size: 13px; } .wo-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid #222; padding-bottom: 8px; margin-bottom: 12px; }
.wo-title { font-size: 22px; font-weight: 800; letter-spacing: 0.04em; } .wo-meta { text-align: right; } .wo-warn { color: var(--danger); font-weight: 700; }
.wo-block { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; margin-bottom: 8px; } .wo-row { display: flex; gap: 8px; } .wo-label { min-width: 84px; color: #555; }
.work-order h3 { margin: 16px 0 6px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid #bbb; }
.wo-list { margin: 0; padding-left: 20px; } .wo-list li { margin: 3px 0; } .wo-list .wo-sub { margin-left: 18px; list-style: circle; } .wo-list .wo-heading { list-style: none; font-weight: 700; text-decoration: underline; margin-left: -20px; }
.wo-table td, .wo-table th { padding: 4px 8px; } .wo-foot { margin-top: 24px; }
.history-line { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.history-when { white-space: nowrap; }
.history-add { display: flex; gap: 8px; margin-top: 10px; align-items: center; } .history-add .input { flex: 1 1 auto; }
.changed-by { margin-left: auto; }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: #fff; color: var(--brand); font-size: 11.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.tabbar .nav-badge { position: absolute; top: 4px; right: 12%; margin: 0; background: var(--brand); color: #fff; }
.tabbar .nav-link { position: relative; }
.warn-text { color: #8a5a00; font-weight: 600; }
.sync-pill.busy { color: #f3e2b3; }
.sync-pill.offline { color: #ffb4ad; font-weight: 700; }
.formula-problem[hidden] { display: none; }
.input.readonly { background: var(--surface-2); color: #514848; cursor: default; }
.textarea { resize: vertical; min-height: 64px; line-height: 1.45; }
.select { appearance: auto; padding-right: 4px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field-help { font-size: 12px; color: var(--muted); }
.allowance-help { color: var(--warn); font-weight: 600; }
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 24px; }
.field-head .btn { min-height: 26px; text-decoration: underline; }
.field-check { justify-content: flex-end; padding-bottom: 8px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13.5px; font-weight: 600; user-select: none; -webkit-tap-highlight-color: transparent; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.switch-track { flex: none; position: relative; width: 42px; height: 24px; border-radius: 99px; background: #cfc6c3; transition: background .15s; }
.switch-thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(40, 22, 22, .3); transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--brand); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch-label { min-width: 132px; color: var(--ink); }
.switch.disabled { cursor: default; opacity: .6; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.form-grid.tight { gap: 10px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-grid + .form-stack { margin-top: 14px; }
.inline-field { display: inline-flex; align-items: center; gap: 8px; }

/* ---- cards, banners ------------------------------------------------------------------ */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; min-height: 32px; }
.card > .muted.small { margin: -6px 0 12px; }
.banner { display: flex; align-items: center; gap: 12px; background: var(--warn-soft); border: 1px solid var(--warn-line); color: #5c3c00; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; }
.pipeline { display: flex; flex-direction: column; }
.pipeline:empty { display: none; }
.banner-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.banner-review { background: #fff1d6; border-color: #f0d48a; color: #5c3c00; }
.banner-ok { background: var(--ok-soft); border-color: #b5e0c6; color: #12512f; }
.banner-info { background: #fbf8f6; border-color: #e3dad6; border-left: 4px solid var(--brand); color: #33292a; } /* neutral with a maroon edge: a maroon tint would read as an error */
.banner-muted { background: #eeebe9; border-color: var(--line-strong); color: #453d3d; }
.revision-box { display: block; }
.revision-box summary { cursor: pointer; }
.revision-changes { margin: 8px 0 10px; padding-left: 22px; }
.warn-box { background: var(--warn-soft); border: 1px solid var(--warn-line); color: #5c3c00; border-radius: 8px; padding: 9px 11px; margin-top: 10px; }
.warn-box .btn { margin-left: 6px; }
.empty { text-align: center; padding: 56px 20px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty h3 { color: var(--ink); font-size: 17px; }
.empty.small { padding: 24px; }
.flag { display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 99px; font-size: 11px; font-weight: 700; letter-spacing: .02em; background: var(--warn-soft); border: 1px solid var(--warn-line); color: var(--warn); vertical-align: middle; }
.flag-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #e0a100; margin: 0 6px; flex: none; }
.group-title { margin: 22px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.group-title:first-child { margin-top: 0; }

/* ---- estimates list --------------------------------------------------------------------- */
/* attachments on an estimate: subcontractor quotes and pictures */
.att-section + .att-section { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.att-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; min-height: 32px; }
.att-list { display: flex; flex-direction: column; }
.att-row { display: grid; grid-template-columns: minmax(140px, 1.2fr) auto minmax(160px, 1.5fr) 38px; gap: 12px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.att-row:last-child { border-bottom: 0; }
.att-open { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 38px; padding: 0; border: 0; background: none; font: inherit; font-weight: 600; color: var(--brand); text-align: left; cursor: pointer; }
.att-open:hover .att-name { text-decoration: underline; }
.att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-meta { white-space: nowrap; }
.att-note { min-height: 34px; }
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.att-thumb { position: relative; display: block; aspect-ratio: 4 / 3; padding: 0; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; background: var(--surface-2); cursor: pointer; }
.att-thumb:hover { border-color: var(--brand); }
.att-thumb:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.att-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.att-thumb-wait { display: grid; place-items: center; width: 100%; height: 100%; color: var(--muted); }
.att-thumb-note { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 7px; font-size: 11.5px; line-height: 1.25; color: #fff; background: rgba(20, 12, 12, .62); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.att-viewer { display: grid; place-items: center; min-height: 220px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.att-viewer img { display: block; max-width: 100%; max-height: 66vh; }
/* job number and costs on an accepted bid; cost reports */
.job-number-row { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.job-number-row .field { flex: 0 1 220px; }
.job-number-row .field-help { flex: 1 1 260px; padding-bottom: 10px; font-size: 13px; }
.job-number-input { font-weight: 700; font-variant-numeric: tabular-nums; }
.job-empty { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.job-table { font-family: inherit; font-size: 14px; }
.job-table td, .job-table th { white-space: nowrap; }
.job-table td:first-child { white-space: normal; min-width: 150px; }
.job-facts { display: flex; gap: 26px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.job-facts > div { display: flex; flex-direction: column; gap: 1px; font-variant-numeric: tabular-nums; }
.cost-over { color: var(--danger); font-weight: 600; }
.cost-under { color: var(--ok); font-weight: 600; }
.job-list { margin-top: 16px; }
.job-list summary { cursor: pointer; font-weight: 600; }
.job-orphans { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.job-orphans .row-tag { margin-left: 0; }
.office-switches { display: flex; flex-direction: column; gap: 8px; flex: 0 0 auto; min-width: 230px; }
.office-help { margin: -4px 0 12px; padding-left: 20px; }
/* the administrator's toggle between estimators */
.people-toggle { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.people-toggle:empty { display: none; }
.people-toggle-label { margin-right: 4px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat-button { text-align: left; font: inherit; color: inherit; cursor: pointer; }
.stat-button:hover { border-color: var(--line-strong); }
.stat-button.active { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.stat-accent { background: #fff7e3; border-color: #f0d48a; }
.row-tag { display: inline-block; margin-left: 8px; padding: 0 7px; border-radius: 99px; font-size: 11px; font-weight: 700; background: #ece8e6; color: #514949; white-space: nowrap; }
.row-tag.tag-warn { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-line); }
.row-tag.tag-danger { background: var(--danger-soft); color: var(--danger); }
.est-row-replaced { opacity: .6; }
.reports { display: flex; flex-direction: column; gap: 16px; }
.report-period { width: auto; min-width: 170px; }
.report-table td, .report-table th { white-space: nowrap; }
.report-bars { display: flex; flex-direction: column; gap: 8px; }
.report-bar { display: grid; grid-template-columns: minmax(120px, 260px) minmax(0, 1fr) 32px; gap: 10px; align-items: center; }
.report-bar-track { height: 10px; border-radius: 99px; background: #ece8e6; overflow: hidden; }
.report-bar-fill { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.report-list { display: flex; flex-direction: column; }
.report-row { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); } /* the bid link, then Edit answers and the proposal */
.report-row:last-child { border-bottom: 0; }
.report-link { display: block; flex: 1 1 auto; min-width: 0; padding: 8px 0; color: inherit; text-decoration: none; }
.report-link:hover strong { color: var(--brand); text-decoration: underline; }
.stat-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12.5px; }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .select { width: auto; min-width: 170px; }
.search { position: relative; display: flex; align-items: center; min-width: 220px; }
.search .icon { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.search .input { padding-left: 34px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--surface); font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip-count { font-weight: 500; opacity: .8; }
.list-meta { margin: -4px 0 10px; }

.est-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.est-row { display: grid; grid-template-columns: 92px minmax(0, 1fr) 170px 128px 130px 110px 44px 40px; gap: 14px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.est-row:last-child { border-bottom: 0; }
a.est-row:hover { background: var(--surface-2); }
/* the icon at the end of a row: straight to the proposal (the rest of the row opens the estimate) */
.est-open { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; margin-left: auto; border-radius: 8px; color: var(--brand); border: 1px solid var(--line); background: var(--surface); }
.est-open:hover, .est-open:focus-visible { background: var(--brand); color: #fff; border-color: var(--brand); outline: none; }
.est-open svg { width: 18px; height: 18px; }
.est-menu { display: inline-flex; justify-content: flex-end; } /* approved / not approved / delete, from the row */
.est-row-head { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); padding-top: 9px; padding-bottom: 9px; }
.est-num { font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.est-main { display: flex; flex-direction: column; min-width: 0; }
.est-main > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.est-total { font-weight: 700; font-variant-numeric: tabular-nums; display: flex; align-items: center; justify-content: flex-end; }
.status { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status-draft { background: #ece8e6; color: #514949; }
.status-review { background: #fff1d6; color: #8a5a00; }
.status-reviewed { background: #e0f2f1; color: #0b6b63; }
.status-superseded { background: #eeebe9; color: #6f6665; text-decoration: line-through; }
.status-sent { background: #e4eef8; color: #1b4f86; }
.status-approved { background: var(--ok-soft); color: var(--ok); }
.status-declined { background: var(--danger-soft); color: var(--danger); }

/* ---- editor ------------------------------------------------------------------------------- */
.editor-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.editor-head-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.editor-head-top { display: flex; align-items: center; gap: 10px; }
.editor-head-actions { display: flex; align-items: center; gap: 6px; }
.title-input { font-size: 20px; font-weight: 700; letter-spacing: -.01em; border-color: transparent; background: transparent; padding-left: 6px; margin-left: -6px; }
.title-input:hover { border-color: var(--line-strong); background: var(--surface); }
.title-input:focus { background: var(--surface); }
.status-select { width: auto; min-height: 28px; padding: 1px 6px; border-radius: 99px; font-size: 12.5px; font-weight: 700; }
.status-select.status-draft { background: #ece8e6; color: #514949; border-color: #d9d2cf; }
.status-select.status-review { background: #fff1d6; color: #8a5a00; border-color: #f0d48a; }
.status-select.status-reviewed { background: #e0f2f1; color: #0b6b63; border-color: #a9d9d4; }
.status-select.status-sent { background: #e4eef8; color: #1b4f86; border-color: #bcd6ee; }
.status-select.status-approved { background: var(--ok-soft); color: var(--ok); border-color: #b5e0c6; }
.status-select.status-declined { background: var(--danger-soft); color: var(--danger); border-color: #f3c2bd; }
.saved { font-size: 12.5px; color: var(--ok); font-weight: 600; }
.saved.dirty { color: var(--muted); }
.saved.error { color: var(--danger, #b3261e); }
/* a PDF shown inside the app (a Home Screen app cannot open a new tab for it) */
.pdf-frame { width: 100%; height: min(72vh, 900px); border: 1px solid var(--line, #ddd); border-radius: 6px; background: #fff; }

.editor-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-items: start; padding-bottom: 64px; }
.editor-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.sections { display: flex; flex-direction: column; gap: 16px; }
.section { padding: 14px 14px 12px; }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.section-name { font-weight: 700; font-size: 15.5px; border-color: transparent; background: transparent; padding-left: 6px; margin-left: -6px; }
.section-name:hover { border-color: var(--line-strong); }
.option-name-box { resize: vertical; min-height: 38px; line-height: 1.3; flex: 1 1 auto; } /* an option's name: one line, or "?formula: name" lines */
.section-total { font-weight: 600; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.section-adders { display: flex; gap: 8px; flex-wrap: wrap; }

.lines-head, .line-main {
  display: grid; gap: 6px; align-items: center;
  grid-template-columns: 112px minmax(160px, 1fr) 76px 150px 96px 104px 34px;
}
.lines-head { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 0 0 6px; border-bottom: 1px solid var(--line); }
.lines { display: flex; flex-direction: column; }
.line { padding: 5px 0; border-bottom: 1px solid #f0ecea; }
.line:last-child { border-bottom: 0; }
.cell { min-width: 0; }
.cell-label { display: none; }
.c-type { grid-column: 1; } .c-desc { grid-column: 2; } .c-qty { grid-column: 3; } .c-unit { grid-column: 4; }
.c-cost { grid-column: 5; } .c-total { grid-column: 6; } .c-menu { grid-column: 7; }
.line .input { min-height: 34px; padding: 5px 8px; font-size: 14px; }
.line-total-wrap { display: flex; align-items: center; justify-content: flex-end; }
.line-total { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.type-select { font-size: 12.5px !important; font-weight: 700; padding-left: 6px !important; border-color: transparent; }
.type-labor { background: #e8eef9; color: #25478f; }
.type-material { background: #e6f3ee; color: #17664a; }
.type-equipment { background: #f6ecdd; color: #8a5316; }
.type-sub { background: #f1e9f7; color: #6a3a94; }
.type-permit { background: #fbe9ec; color: #9a2f45; }
.type-other { background: #eeebe9; color: #564d4d; }
.line-extra { display: flex; align-items: center; gap: 14px; padding: 6px 0 4px 118px; flex-wrap: wrap; }
.line-compact { display: none; }
.adders { display: flex; gap: 2px; flex-wrap: wrap; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.adders .btn-default { margin-left: 6px; }

/* summary: beside the lines on wide screens, below them (with a fixed total bar) otherwise */
.totalbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; position: fixed; z-index: 25;
  left: var(--sidebar-w); right: 0; bottom: 0; padding: 8px 28px;
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 14px rgba(40, 22, 22, .08);
}
.totalbar strong { font-size: 19px; font-variant-numeric: tabular-nums; }
@media (min-width: 1480px) {
  .editor-body { grid-template-columns: minmax(0, 1fr) 320px; padding-bottom: 0; }
  .summary { position: sticky; top: 18px; }
  .totalbar { display: none; }
}
.sum-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; font-variant-numeric: tabular-nums; }
.sum-sub { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; font-weight: 600; }
.sum-input { display: inline-flex; align-items: center; gap: 6px; }
.sum-input .input { width: 64px; min-height: 30px; padding: 3px 7px; }
.sum-note { min-height: 4px; }
.sum-input .input { flex: none; }
.price-head { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); }
.method-select, .round-select { width: auto; min-height: 32px; padding: 3px 6px; font-size: 13.5px; }
.tiers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-bottom: 8px; }
.tier-group + .tier-group { margin-top: 2px; }
.tier-title { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 2px 0 4px; }
.tpl-preview .tier-picker { margin-top: 10px; }
.tpl-preview .tiers { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 4px; }
.stepper { display: flex; align-items: stretch; gap: 6px; }
.stepper .input { text-align: center; min-width: 0; }
.stepper .btn { flex: none; width: 44px; }
.tier { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-height: 40px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); font: inherit; color: var(--ink); cursor: pointer; font-variant-numeric: tabular-nums; }
.tier:hover { border-color: var(--brand); }
.tier.active { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); font-weight: 700; }
.tier-pct { color: var(--muted); font-size: 13px; font-weight: 700; }
.tier.active .tier-pct { color: var(--brand); }
.tag-pt { display: inline-block; margin-right: 6px; padding: 0 5px; border-radius: 4px; font-size: 10.5px; font-weight: 800; letter-spacing: .04em; background: #eeebe9; color: #564d4d; }
.bid-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sum-total { border-top: 2px solid var(--ink); margin-top: 8px; padding-top: 12px; font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.internal { margin-top: 16px; padding: 12px; border-radius: 8px; background: var(--surface-2); border: 1px dashed var(--line-strong); font-size: 13.5px; }
.internal-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; }
.formula-help { display: flex; flex-direction: column; gap: 3px; }

/* template editor rows */
.rows { display: flex; flex-direction: column; gap: 10px; }
.row-card { display: flex; align-items: flex-start; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.row-card .form-grid { flex: 1 1 auto; min-width: 0; }
.tpl-line.kind-labor { border-left: 3px solid #6f8fd6; }
.tpl-line.kind-catalog { border-left: 3px solid #4fae8a; }
.tpl-line.kind-item { border-left: 3px solid #c9a15a; }
.tpl-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tpl-item { display: flex; align-items: center; gap: 10px; padding: 14px 16px; }
.tpl-name { font-weight: 700; color: var(--ink); text-decoration: none; }
.tpl-name:hover { color: var(--brand); text-decoration: underline; }

/* ---- price book, customers ------------------------------------------------------------------ */
.pb-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 24px; }
.pb-meta .link-button { padding: 0 2px; }
.pb-cats { display: flex; flex-direction: column; gap: 10px; }
.pb-cat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.pb-cat-head { display: flex; align-items: center; gap: 6px; padding: 5px 8px 5px 5px; }
.pb-toggle { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.pb-toggle:hover { background: rgba(40, 22, 22, .05); }
.pb-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.pb-toggle .icon { color: var(--muted); }
.pb-name { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-count { margin-left: auto; padding-left: 8px; white-space: nowrap; }
.pb-cat-body { border-top: 1px solid var(--line); }
.pb-sub + .pb-sub, .pb-empty + .pb-sub { border-top: 1px solid var(--line); }
.pb-sub-head { display: flex; align-items: center; gap: 4px; padding: 2px 8px 2px 16px; background: var(--surface-2); }
.pb-sub.open > .pb-sub-head { border-bottom: 1px solid var(--line); }
.pb-toggle-sub { min-height: 38px; }
.pb-toggle-sub .pb-name { font-size: 14px; font-weight: 600; }
.pb-sub .pb-row { padding-left: 54px; }
.pb-empty { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 16px; }
.pb-sub .pb-empty { padding-left: 54px; }
.pb-row { display: grid; grid-template-columns: minmax(0, 1fr) 56px 120px 38px; gap: 12px; align-items: center; padding: 9px 16px; border-bottom: 1px solid var(--line); }
.pb-row:last-child { border-bottom: 0; }
.pb-head { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.pb-desc { font-weight: 600; }
.pb-price { font-weight: 700; font-variant-numeric: tabular-nums; }
.pb-price-cell { text-align: right; }
.pb-cell { display: flex; align-items: center; gap: 6px; }
.pb-cell::before { content: "$"; color: var(--muted); font-size: 13px; }
.pb-cell .cell-label { display: none; }
.pb-cell .input { min-height: 34px; padding: 5px 8px; }
.mail-attachment { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 14px; }
.mail-attachment .icon { color: var(--danger); }
.outlook-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 14px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.signin-message.ok { color: var(--ok); }
.mail-steps { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.mail-step { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mail-step-n { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 13px; display: grid; place-items: center; }
.mail-step-n:empty { background: transparent; }
.mail-step > .muted { flex: 1 1 240px; }
.count-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.count-cell { display: flex; align-items: center; gap: 4px; min-height: 46px; padding: 4px 6px 4px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); }
.count-cell.on { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.count-name { flex: 1 1 auto; min-width: 0; font-size: 14.5px; }
.count-cell.on .count-name { font-weight: 700; }
.count-qty { flex: none; min-width: 28px; text-align: center; font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.count-cell .btn { flex: none; width: 40px; min-height: 38px; color: var(--ink); }
.count-other { grid-column: 1 / -1; padding-left: 6px; }
.count-other .input { flex: 1 1 auto; min-width: 0; min-height: 36px; border-color: transparent; background: transparent; }
.count-other .input:focus-visible { border-color: var(--line-strong); background: var(--surface); }
.multi-options { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); }
.multi-options .multi-other { flex: 1 1 220px; width: auto; min-height: 34px; }
.labor-desc { display: flex; gap: 6px; min-width: 0; }
.labor-desc .select { flex: 1 1 150px; min-width: 0; }
.labor-desc .input:not(.select) { flex: 2 1 0; min-width: 0; }
.estimator-bar { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; padding-bottom: 14px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.estimator-bar .field { flex: 0 1 320px; }
.estimator-bar .field-help { flex: 1 1 220px; padding-bottom: 10px; font-size: 13px; }
.people { display: flex; flex-direction: column; }
.person-row { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.person-row:last-child { border-bottom: 0; }
.person-main { flex: 1 1 220px; min-width: 0; }
.person-name { font-weight: 600; }
.person-next { white-space: nowrap; font-variant-numeric: tabular-nums; }
.person-approval { flex: 0 0 auto; min-width: 190px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.person-limit { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.person-row > :last-child { margin-left: auto; } /* the row's menu keeps to the right edge, also when the row wraps */
.person-limit-input { width: 118px; min-height: 34px; padding: 4px 8px; }
.person-limit-input:disabled { background: var(--surface-2); color: var(--muted); }
.person-phone { display: flex; align-items: center; gap: 8px; margin-top: 6px; white-space: nowrap; } /* the phone that prints on "Prepared by" */
.person-phone-input { width: 150px; min-height: 34px; padding: 4px 8px; }
.people .warn-box { margin: 0 0 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cust-list { display: flex; flex-direction: column; gap: 10px; }
.cust-row { display: flex; align-items: center; gap: 10px; padding: 12px 16px; flex-wrap: wrap; }
.cust-name { font-weight: 700; }
.history { display: flex; flex-direction: column; }
.history-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.history-row:hover { background: var(--surface-2); }
.history-actions { display: inline-flex; gap: 6px; margin-left: auto; } /* edit the answers, open the proposal */
.history-pick { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); font: inherit; text-align: left; cursor: pointer; } /* a bid to pick, from a template */
.history-actions .est-open { width: 32px; height: 32px; margin-left: 0; }

/* settings */
.rate-table { display: flex; flex-direction: column; margin-top: 12px; }
.rate-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px 38px; gap: 10px; align-items: center; padding: 5px 0; }
.rate-head { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.logo-host { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.logo-preview { max-height: 56px; max-width: 220px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; padding: 4px; background: #fff; }
.logo-empty { border: 1px dashed var(--line-strong); border-radius: 6px; padding: 14px 18px; }
.page.narrow .card { margin-bottom: 16px; }

/* ---- dialogs, menus, toasts -------------------------------------------------------------------- */
.dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: var(--shadow-lg); color: var(--ink); overflow: visible; }
.dialog[open] { display: flex; flex-direction: column; }
.dialog-wide { width: min(880px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgba(30, 14, 14, .5); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 14px 12px 20px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font-size: 17px; }
.dialog-body { padding: 18px 20px; overflow: auto; flex: 1 1 auto; overscroll-behavior: contain; }
body:has(dialog[open]) { overflow: hidden; } /* a swipe that overshoots the dialog moves nothing behind it ("differently" 19) */
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 14px 14px; }
.dialog-actions:empty { display: none; }
.dialog-message { color: var(--muted); margin-bottom: 12px; }

.menu { position: absolute; z-index: 1000; min-width: 210px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 5px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; font: inherit; font-size: 14px; color: var(--ink); text-align: left; cursor: pointer; }
.menu-item:hover { background: var(--surface-2); }
.menu-item:disabled { opacity: .4; cursor: default; }
.menu-item.danger { color: var(--danger); }
body > .menu { position: fixed; }

.ac-box { position: absolute; z-index: 1000; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 4px; max-width: min(560px, calc(100vw - 16px)); }
.ac-item { display: flex; justify-content: space-between; gap: 16px; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.ac-item:hover, .ac-item.active { background: var(--brand-soft); }
.ac-detail { color: var(--muted); font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }

.toast-host { position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 2000; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.toast { background: #1e1919; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 14px; transition: opacity .3s, transform .3s; }
.toast-error { background: var(--danger); }
.toast-out { opacity: 0; transform: translateY(6px); }

/* template chooser */
.tpl-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tpl-card { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 13px 14px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); font: inherit; color: var(--ink); cursor: pointer; }
.tpl-card:hover { border-color: var(--brand); background: var(--brand-soft); }
.tpl-blank { border-style: dashed; }
.tpl-flow > .tpl-grid:first-child { margin-bottom: 4px; }
.tpl-params-head { margin-bottom: 14px; }
.tpl-params { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 14px; }
.tpl-params .field-check { padding-bottom: 0; justify-content: center; }
.param-group { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.tpl-params-head + .param-group { margin-top: 0; }
.tpl-preview, .tpl-test { margin-top: 16px; padding: 14px 16px; border-radius: 10px; background: var(--brand-soft); border: 1px solid #e6cdcb; }
.tpl-test { margin-top: 0; }
.tpl-preview-total { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.tpl-preview-total strong { font-size: 24px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tpl-preview-stats { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 4px; }

/* picker & import */
.picker-list { border: 1px solid var(--line); border-radius: 10px; max-height: 52vh; overflow: auto; }
.picker-row { display: grid; grid-template-columns: minmax(0, 1fr) 130px 72px auto; gap: 12px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.picker-row:last-child { border-bottom: 0; }
.picker-desc { font-weight: 600; }
.picker-price { text-align: right; font-variant-numeric: tabular-nums; }
.picker-qty { min-height: 34px; }
.picker-crumbs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 8px; min-height: 30px; } /* where the browse is (one item wanted) */
.picker-crumb { font-weight: 700; }
.picker-cats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 10px; } /* the categories, then the sub-categories, as tiles */
.picker-cat strong { font-size: 15px; }
@media (max-width: 720px) { .picker-cats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.import { display: flex; flex-direction: column; gap: 14px; }
.import-opts { display: flex; gap: 20px; flex-wrap: wrap; }
.table-scroll { overflow: auto; margin-top: 6px; }

/* ---- proposal (screen) ---------------------------------------------------------------------------- */
.proposal { max-width: 1000px; }
.proposal-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.proposal-opts { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.proposal-opts .select { width: auto; }
.proposal-opts .range-input { width: 104px; min-height: 34px; }
.paper {
  background: #fff; color: #111; border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 2px;
  width: var(--paper-w, 8.5in); max-width: 100%; min-height: var(--paper-h, 11in); margin: 12px auto 0; padding: var(--pad, 0.5in 0.75in 0.4in);
  display: flex; flex-direction: column;
  font-family: "Times New Roman", Times, serif; font-size: 15px; line-height: 1.4;
}
.p-body { flex: 0 0 auto; padding: 0 var(--body-inset, 0); }
.p-head { text-align: center; margin-bottom: 10px; }
.p-logo { display: block; width: 2.09in; max-width: 60%; height: auto; margin: 0 auto 10px; }
.p-company-name { font-size: 26px; font-weight: 700; }
.p-lh-line { font-weight: 700; font-size: 15px; line-height: 1.25; }
.p-doc-title { font-size: 17px; font-weight: 700; margin-top: 8px; }
.p-contact { font-size: 13.5px; margin-top: 1px; }
/* customer block: kept tight (name / date, address / bid #, phone / email), so the scope starts high on the page */
.p-customer { display: flex; flex-direction: column; gap: 2px; font-weight: 700; line-height: 1.25; }
.p-field-row { display: flex; gap: 28px; }
.p-field { display: flex; gap: 8px; align-items: baseline; min-width: 170px; }
.p-field.grow { flex: 1 1 0; }
.p-field-label { white-space: nowrap; }
.p-field-value { flex: 1 1 auto; font-weight: 400; border-bottom: 1px solid #999; min-height: 1.25em; padding: 0 4px; }
.p-rule { border: 0; border-top: 1.5px solid #222; margin: 10px 0 8px; }
.p-block { margin-top: 18px; }
.p-block h3 { break-after: avoid; }
.p-heading { font-size: 15.5px; font-weight: 700; text-decoration: underline; margin-bottom: 8px; }
.p-subheading { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.pb-note { font-style: italic; color: #6b4a00; }
.behind-bar { background: var(--danger-soft); color: #5a0f0f; border-bottom: 1px solid var(--danger); display: flex; gap: 12px; align-items: center; padding: 8px 14px; font-size: 13.5px; }
.p-list { margin: 0; padding-left: 24px; font-weight: 700; }
.p-list li { margin: 5px 0; break-inside: avoid; }
.p-sublist { margin: 4px 0 8px; padding-left: 40px; list-style: disc; }
.p-included { font-weight: 400; }
.p-para { margin: 6px 0; font-weight: 700; }
.p-subhead { margin: 10px 0 4px; font-weight: 700; text-decoration: underline; break-after: avoid; }
.p-plain { margin: 4px 0; font-weight: 700; } /* a line marked plain: no bullet */
.line-marks { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.p-list + .p-list { margin-top: 8px; }
.p-text { white-space: pre-wrap; }
.p-price { margin-top: 22px; font-size: 15.5px; font-weight: 700; display: flex; gap: 10px; align-items: baseline; break-inside: avoid; }
.p-price-value { font-size: 18px; }
.p-discount { margin: 3px 0 0; font-size: 12px; break-inside: avoid; } /* "Includes a 10% discount: ..." under the price */
.discount-select { max-width: 120px; }
.discount-custom { width: 64px; }
/* options the customer may tick, after the price (options.js): a box, the name, "Add $..." at the right */
.p-options { margin-top: 14px; break-inside: avoid; }
.p-option-list { display: flex; flex-direction: column; gap: 4px; }
.p-option-row { display: flex; align-items: baseline; gap: 10px; font-weight: 700; }
.p-tick { font-family: "Segoe UI Symbol", "Segoe UI", sans-serif; font-size: 16px; line-height: 1; }
.p-option-name { flex: 1 1 auto; }
.p-option-price { white-space: nowrap; }
.p-option-wording { padding-left: 26px; font-size: 13px; }
.p-option-wording .p-list { margin-top: 2px; }
.p-option-note { margin: 8px 0 0; font-size: 12.5px; color: #333; }
.p-price-total { margin-top: 10px; border-top: 1px solid #999; padding-top: 8px; }
.p-price-total .p-price-value { font-size: 16px; }
.p-note { margin-top: 10px; font-weight: 700; break-inside: avoid; }
.p-valid { margin-top: 18px; font-size: 12.5px; color: #444; }
.p-table { width: 100%; border-collapse: collapse; }
.p-table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: #555; border-bottom: 1.5px solid #222; padding: 5px 8px; }
.p-table td { padding: 7px 8px; border-bottom: 1px solid #e3e3e3; vertical-align: top; }
.p-table tr { break-inside: avoid; }
.p-table .right { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.p-table tfoot td { font-weight: 700; border-bottom: 0; border-top: 1.5px solid #222; }
.p-summary { break-inside: avoid; }
.p-summary tfoot td { font-size: 16px; font-weight: 800; padding-top: 10px; background: #f3f1f0; text-transform: uppercase; letter-spacing: .02em; }
.p-sign { break-inside: avoid; margin-top: 30px; }
.p-closing { break-inside: avoid; } /* terms and signature lines never split across pages */
.p-sign-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.p-sign-title { font-weight: 700; text-transform: uppercase; font-size: 12.5px; letter-spacing: .04em; }
.p-sign-line { border-bottom: 1px solid #222; height: 40px; margin-bottom: 4px; }

/* contract footer: notice, then Additional Terms | Personal Guarantee, pinned to the foot of the page */
.p-contract { margin: auto 0 0; padding-top: 9px; border-top: 2px solid #1a1a1a; break-inside: avoid; }
.p-body + .p-contract { margin-top: auto; }
.p-c-notice { font-size: 11.5px; line-height: 1.32; text-align: justify; margin: 0 0 9px; }
.p-c-cols { display: grid; grid-template-columns: 1.3fr 1fr; border-top: 1px solid #9a9a9a; } /* the terms run longer than the guarantee */
.p-c-cols.single { grid-template-columns: 1fr; }
.p-c-cols.single .p-c-col { padding-right: 0; }
.p-c-cols.single .p-c-sig { max-width: 3.6in; } /* a signature line, not a page-wide rule */
.p-c-col { display: flex; flex-direction: column; padding: 8px 16px 0 0; min-width: 0; }
.p-c-col + .p-c-col { padding: 8px 0 0 16px; border-left: 1px solid #9a9a9a; }
.p-c-title { font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; margin: 0 0 4px; }
.p-c-text { font-size: 10.5px; line-height: 1.28; text-align: justify; } /* no auto-hyphenation: legal wording prints the same on every device */
.p-c-sign { margin-top: auto; padding-top: 9px; font-size: 10.5px; line-height: 1.28; }
.p-c-accept { font-weight: 700; }
.p-c-signed { margin-top: 5px; display: flex; align-items: baseline; gap: 4px; white-space: nowrap; }
.p-c-blank { display: inline-block; flex: 1 1 0.7in; max-width: 1.7in; border-bottom: 1px solid #222; height: 1em; }
.p-c-sigrow { display: flex; gap: 14px; margin-top: 32px; align-items: flex-start; } /* room above the line for ink */
.p-c-company { padding-top: 10px; font-size: 10.5px; line-height: 1.28; } /* the company's acceptance, under the customer's signature */
.p-c-company .p-c-sigrow { margin-top: 26px; }
.p-c-sig { flex: 1 1 0; min-width: 0; }
.p-c-sig + .p-c-sig { flex-grow: 1.25; }
.p-c-line { border-bottom: 1px solid #222; height: 0; position: relative; }
.p-c-line.marked::before { content: "X"; position: absolute; left: 0; bottom: 2px; font-size: 11px; font-weight: 700; }
.p-c-label { font-size: 9.5px; margin-top: 3px; color: #222; white-space: nowrap; }
.p-sig-img { position: absolute; left: 16px; bottom: -6px; height: 36px; width: auto; max-width: calc(100% - 20px); overflow: visible; }
.p-sig-typed { bottom: 1px; height: 27px; } /* a typed name: the box ends at the text baseline, which rests on the line */
.p-c-typed { position: absolute; left: 4px; bottom: 2px; font-size: 12.5px; white-space: nowrap; }
.p-c-blank.filled { height: auto; min-height: 1em; text-align: center; font-weight: 700; line-height: 1.05; padding: 0 4px; }
.p-c-esign { font-size: 8.5px; color: #333; margin-top: 1px; min-height: 1.25em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sig-controls { margin-top: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
.sig-stale { color: var(--danger); font-size: 12px; max-width: 260px; }
.p-sign .p-c-line { margin-top: 38px; }

/* signature pad dialog */
.sigpad-statement { font-weight: 700; margin-bottom: 4px; }
.sigpad-summary { color: var(--muted); font-size: 13.5px; margin-bottom: 12px; }
.sigpad-options { margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); display: flex; flex-direction: column; gap: 6px; } /* the options to tick while signing */
.sigpad-option { font-size: 14px; }
/* options on the estimate: one row each (tick, name, price, Edit); the details open under the row */
.option-list { display: flex; flex-direction: column; }
.option-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.option-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.option-row:last-child { border-bottom: 0; }
.option-row.option-on { background: var(--surface-2); margin: 0 -16px; padding: 8px 16px; }
.option-tick { width: 20px; height: 20px; flex: 0 0 auto; accent-color: var(--brand); }
.option-name { flex: 1 1 240px; min-width: 200px; min-height: 34px; padding: 4px 8px; font-weight: 600; }
.option-price { font-weight: 700; color: var(--brand); white-space: nowrap; }
.option-details { padding: 10px 12px 14px 42px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.option-details .field-label { margin-top: 10px; }
/* the template's options: like sections */
.option .option-price { font-weight: 700; color: var(--brand); }
/* the "Options to Offer" boxes on the New Estimate screen: one block per option (type, item or name, add / deduct,
   price, description) and an empty one for the next */
.offers { display: flex; flex-direction: column; gap: 10px; }
.offers .offer { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 12px; background: var(--surface); }
.offers .offer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.offers .offer-price { min-height: 38px; display: flex; align-items: center; font-weight: 700; color: var(--brand); }
.offers .offer .select, .offers .offer .textarea { width: 100%; }
.offers .offer-item { min-height: 38px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; } /* the price book item chosen, and the button to change it */
.offers .offer-item-name { font-weight: 600; }
.sigpad-area { position: relative; margin-top: 12px; height: 220px; border: 1.5px dashed var(--line-strong); border-radius: 10px; background: #fff; touch-action: none; user-select: none; -webkit-user-select: none; }
.sigpad-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; border-radius: 10px; }
.sigpad-baseline { position: absolute; left: 46px; right: 24px; bottom: 58px; border-bottom: 1.5px solid #a8a09e; pointer-events: none; }
.sigpad-x { position: absolute; left: 22px; bottom: 60px; font: 700 20px "Times New Roman", serif; color: #756c6b; pointer-events: none; }
.sigpad-hint { position: absolute; left: 0; right: 0; bottom: 18px; text-align: center; color: #968d8b; font-size: 13px; pointer-events: none; }

/* ---- responsive --------------------------------------------------------------------------------------- */
@media screen and (max-width: 1100px) {
  .est-row { grid-template-columns: 84px minmax(0, 1fr) 128px 120px 44px 40px; }
  .est-type, .est-date, .est-row-head span:nth-child(3), .est-row-head span:nth-child(6) { display: none; }

  /* line items collapse to one tappable row; the open line shows its fields as a card */
  .lines-head { display: none; }
  .line { padding: 0; }
  .line.open { padding-bottom: 14px; background: var(--surface-2); margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
  .line-compact {
    display: grid; grid-template-columns: 6px minmax(0, 1fr) auto 16px; gap: 10px; align-items: center;
    width: 100%; min-height: 54px; padding: 8px 0; border: 0; background: transparent; font: inherit; color: inherit; text-align: left; cursor: pointer;
  }
  .line-compact .icon { color: var(--muted); transition: transform .15s; }
  .line.open .line-compact .icon { transform: rotate(180deg); }
  .lc-dot { width: 6px; height: 34px; border-radius: 3px; }
  .lc-text { display: flex; flex-direction: column; min-width: 0; }
  .lc-desc { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lc-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lc-total { font-weight: 700; font-variant-numeric: tabular-nums; }
  .line:not(.open) .line-main, .line:not(.open) .line-extra { display: none; }
  .line-main { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
  .cell-label { display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
  .c-type { grid-column: 1 / span 3; grid-row: 1; } .c-type .cell-label, .c-desc .cell-label { display: none; }
  .c-total { display: none; }
  .c-menu { grid-column: 6; grid-row: 1; justify-self: end; }
  .c-desc { grid-column: 1 / -1; grid-row: 2; }
  .c-qty { grid-column: 1 / span 2; grid-row: 3; } .c-unit { grid-column: 3 / span 2; grid-row: 3; } .c-cost { grid-column: 5 / span 2; grid-row: 3; }
  .line.labor .c-unit { grid-column: 3 / span 4; }
  .line.labor .c-cost { grid-column: 1 / span 2; grid-row: 4; }
  .line-extra { padding-left: 0; }
  .line-total { font-size: 16px; }
}

@media screen and (max-width: 860px) {
  .sidebar { display: none; }
  .home-brand { display: flex; flex-direction: column; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--brand); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px 12px; margin-bottom: 16px; }
  .home-logo { display: block; width: min(240px, 72%); height: auto; }
  .view { margin-left: 0; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); position: fixed; inset: auto 0 0 0; z-index: 30; /* however many screens there are, one row */
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .tabbar .nav-link { flex-direction: column; gap: 2px; justify-content: center; padding: 4px 1px; font-size: 10.5px; color: var(--muted); border-radius: 0; min-width: 0; white-space: nowrap; overflow: hidden; }
  .tabbar .nav-link.active { color: var(--brand); background: transparent; }
  .tabbar .nav-link:hover { background: transparent; }
  .page { padding: 18px 14px 96px; }
  h1 { font-size: 21px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid, .form-grid.tight, .tpl-params { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-3 { grid-column: span 2; }
  .tpl-list, .tpl-grid { grid-template-columns: minmax(0, 1fr); }
  .input, .btn { min-height: 42px; }
  .btn-sm { min-height: 36px; }
  .btn-icon { width: 42px; }

  .line .input { min-height: 40px; }
  .title-input { font-size: 17px; }
  .status-select { min-height: 30px; }
  .totalbar { left: 0; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 8px 14px; }
  .editor-head-actions .btn-primary { display: none; }
  .toast-host { bottom: calc(var(--tabbar-h) + 76px); }

  .att-row { grid-template-columns: minmax(0, 1fr) 42px; gap: 4px 8px; }
  .att-row .att-meta { grid-column: 1; grid-row: 2; }
  .att-row .att-note { grid-column: 1 / -1; grid-row: 3; }
  .att-row > :last-child { grid-column: 2; grid-row: 1; }
  .pb-row { grid-template-columns: minmax(0, 1fr) 110px 42px; gap: 8px; }
  .pb-head, .pb-unit { display: none; }
  .pb-sub .pb-row, .pb-sub .pb-empty { padding-left: 28px; }
  .pb-sub-head { padding-left: 8px; }
  .rate-row { grid-template-columns: minmax(0, 1fr) 110px 42px; }
  .rate-head { display: none; }
  .picker-row { grid-template-columns: minmax(0, 1fr) 72px auto; }
  .picker-price { grid-column: 1; grid-row: 2; text-align: left; display: flex; gap: 10px; align-items: baseline; }
  .picker-info { grid-column: 1 / -1; }
  .paper { padding: 26px 16px; min-height: 0; }
  .p-body { padding: 0 4px; }
  .p-c-cols { grid-template-columns: 1fr; }
  .p-c-col, .p-c-col + .p-c-col { padding: 10px 0 12px; border-left: 0; }
  .p-c-col + .p-c-col { border-top: 1px solid #9a9a9a; }
  .p-field-row { flex-direction: column; gap: 3px; }
  .p-sign-grid { grid-template-columns: 1fr; gap: 24px; }
  .dialog { width: 100vw; max-width: 100vw; max-height: var(--vvh, 100vh); height: var(--vvh, 100vh); border-radius: 0; margin: 0; } /* --vvh: the visible height, keyboard up or not (app.js) */
  .dialog-actions { border-radius: 0; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}

/* a finger rather than a mouse, at any width ("differently" 18 and 21, 2026-09-27): an iPad in landscape used to get the
   desktop sizes; a held finger on a bid row opened the link preview; a quick double tap on a stepper zoomed the page */
@media (pointer: coarse) {
  .input, .btn { min-height: 42px; }
  .btn-sm, .btn.small { min-height: 38px; }
  .btn-icon { width: 42px; }
  .status-select { min-height: 34px; padding: 3px 10px; }
  .est-open, .est-menu .btn { width: 42px; height: 42px; min-height: 42px; }
  .chip { min-height: 40px; }
  .tier { min-height: 46px; }
  .count-cell .btn { width: 44px; min-height: 42px; }
  .input.num.pct-input, .range-input { min-height: 42px; }
  .btn, .tier, .chip, .count-cell, .line-compact, .pb-toggle, .est-row, .nav-link, .tabbar, .menu-item, .switch, .tpl-card, .history-row, .stat, .stepper button {
    -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: manipulation;
  }
}

@media screen and (max-width: 520px) {
  .est-row { grid-template-columns: minmax(0, 1fr) auto 40px 40px; row-gap: 2px; }
  .est-row-head { display: none; }
  .est-row .est-num { grid-column: 1; grid-row: 1; font-size: 13px; }
  .est-row .est-main { grid-column: 1; grid-row: 2; }
  .est-row > span:nth-child(4) { grid-column: 2; grid-row: 1; justify-self: end; }
  .est-row .est-total { grid-column: 2; grid-row: 2; }
  .est-row .est-open { grid-column: 3; grid-row: 1 / span 2; align-self: center; }
  .est-row .est-menu { grid-column: 4; grid-row: 1 / span 2; align-self: center; }
  .form-grid, .form-grid.tight, .tpl-params { grid-template-columns: minmax(0, 1fr); }
  .span-2, .span-3 { grid-column: span 1; }
  .toolbar .select { width: 100%; }
  .tpl-preview .tiers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pb-cat-head > .btn-sm:not(.btn-icon) { width: 36px; padding: 0; }
  .pb-cat-head > .btn-sm:not(.btn-icon) span { display: none; }
  .pb-name { font-size: 15px; white-space: normal; overflow: visible; }
  .pb-toggle { padding: 6px 8px; gap: 8px; }
}

/* ---- print: only the proposal paper ---------------------------------------------------------------------- */
@page { size: letter; margin: 0.6in 0.65in; }
@media print {
  body { background: #fff; }
  .sidebar, .tabbar, .no-print, .toast-host, .totalbar { display: none !important; }
  .view { margin: 0; padding: 0; }
  .page { max-width: none; padding: 0; }
  .paper { border: 0; box-shadow: none; border-radius: 0; padding: 0; margin: 0; width: auto; max-width: none; min-height: 0; font-size: 11.5pt; }
  .paper.has-contract { min-height: var(--print-min-h, 9.9in); }
  .p-c-notice { font-size: 8.5pt; } .p-c-title { font-size: 8pt; } .p-c-text, .p-c-sign { font-size: 8pt; } .p-c-label { font-size: 7pt; } .p-c-esign { font-size: 6.5pt; }
  .p-lh-line { font-size: 11pt; } .p-doc-title { font-size: 12.5pt; margin-top: 6px; }
  .p-head { margin-bottom: 8px; } .p-rule { margin: 8px 0 6px; } .p-block { margin-top: 13px; }
  .p-table td { padding: 4.5px 8px; } .p-sign { margin-top: 20px; } .p-sign-line { height: 30px; }
  .p-summary tfoot td { background: #f3f1f0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .toolbar, .stats, .chips, .est-menu, .est-open, .page-head .btn, .history-actions, .cust-row .btn, .cust-row .menu-button, .banner, .report-period { display: none !important; } /* the lists and reports print as they read ("beyond" 15) */
  .est-row { grid-template-columns: 90px minmax(0, 1fr) 100px 90px 90px 80px; }
}
