/* Mobile-first. Designed at 390px; desktop just gets a wider column. */
:root {
  --ink: #16191d;
  --ink-2: #3a3f46;
  --muted: #6b7078;
  --paper: #f3f1ec;
  --card: #ffffff;
  --line: #e1ddd4;
  --line-2: #cfc9bd;
  --accent: #c2410c;
  --accent-press: #9a3412;
  --ok: #1d7a3e;
  --ok-bg: #e6f4ea;
  --warn: #9a5800;
  --warn-bg: #fff3dc;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --info-bg: #eef1f6;
  --radius: 12px;
  --tap: 44px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
.boot { padding: 40px 16px; color: var(--muted); }

/* ---------- shell */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--ink); color: #fff;
}
.topbar .brand { font-weight: 700; letter-spacing: 0.02em; font-size: 15px; }
.topbar .who { font-size: 12px; color: #b9bec6; }
.topbar button { background: transparent; color: #fff; border: 1px solid #4a5059; min-height: 32px; padding: 0 10px; font-size: 13px; }
main { max-width: 760px; margin: 0 auto; padding: 16px 16px 112px; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1; display: flex; align-items: center; justify-content: center;
  min-height: 56px; font-size: 12px; font-weight: 600; color: var(--muted); text-decoration: none;
}
.tabs a[aria-current="page"] { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.back { display: inline-block; margin-bottom: 10px; font-size: 14px; text-decoration: none; }

/* ---------- controls */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--card); color: var(--ink);
  font: 600 14px var(--font); text-decoration: none; cursor: pointer;
}
button:active, .btn:active { transform: translateY(1px); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:active { background: var(--accent-press); }
button.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
button.ghost { background: transparent; border-color: transparent; color: var(--accent); padding: 0 8px; }
button.danger { color: var(--bad); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.small, .btn.small { min-height: 34px; padding: 0 10px; font-size: 13px; }
.block { width: 100%; }

label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: 8px 10px;
  border: 1px solid var(--line-2); border-radius: 10px; background: #fff; color: var(--ink);
  font: 16px var(--font); /* 16px stops iOS zoom-on-focus */
}
textarea { min-height: 80px; resize: vertical; }
input[type="checkbox"] { width: 22px; min-height: 22px; height: 22px; accent-color: var(--accent); flex: none; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 8px; align-items: flex-end; }
.row > * { flex: 1; min-width: 0; }
.row > .shrink { flex: none; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; font-weight: 500; color: var(--ink); }

/* ---------- cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card > h2 { margin-bottom: 10px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.muted { color: var(--muted); }
.small-text { font-size: 13px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }
.money { font-weight: 700; white-space: nowrap; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 10px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.list a.rowlink { display: block; color: inherit; text-decoration: none; }
.spread { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.stack > * + * { margin-top: 8px; }
.empty { padding: 18px; text-align: center; color: var(--muted); border: 1px dashed var(--line-2); border-radius: var(--radius); }

/* ---------- chips & badges */
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; background: var(--info-bg); color: var(--ink-2); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.dark { background: var(--ink); color: #fff; }
.badge-unverified { display: inline-block; padding: 1px 6px; border: 1px dashed var(--warn); border-radius: 6px; color: var(--warn); font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.badge-stale { display: inline-block; padding: 1px 6px; border-radius: 6px; background: var(--bad); color: #fff; font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }

/* ---------- banners */
.banner { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; font-size: 14px; scroll-margin-top: 72px; }
.banner strong { display: block; margin-bottom: 4px; }
.banner ul { margin: 6px 0 0; padding-left: 18px; }
.banner.warn { background: var(--warn-bg); border: 1px solid #f0cf8f; color: #5c3a00; }
.banner.bad { background: var(--bad-bg); border: 1px solid #f3b8b1; color: #7a1a12; }
.banner.ok { background: var(--ok-bg); border: 1px solid #b5dcc0; color: #134d27; }
.banner.info { background: var(--info-bg); border: 1px solid #d3d9e3; color: var(--ink-2); }

/* ---------- pipeline board */
.board {
  display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 0 -16px; padding: 0 16px 8px; -webkit-overflow-scrolling: touch;
}
.col { flex: 0 0 82%; max-width: 300px; scroll-snap-align: start; background: #e9e6df; border-radius: var(--radius); padding: 10px; }
.col-head { display: flex; justify-content: space-between; align-items: center; margin: 2px 2px 10px; font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-2); }
.col-head .count { background: var(--card); border-radius: 999px; padding: 0 8px; font-size: 12px; }
.pcard { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 8px; }
.pcard .who { font-weight: 700; }
.pcard .addr { font-size: 13px; color: var(--muted); margin-top: 2px; }
.pcard .total { font-size: 16px; font-weight: 700; margin-top: 8px; }
.pcard .total.low { color: var(--bad); }
.pcard .next { font-size: 13px; margin-top: 6px; color: var(--ink-2); }
.pcard .next::before { content: "Next: "; font-weight: 700; }
.pcard .actions { display: flex; gap: 6px; margin-top: 10px; }
.pcard .actions > * { flex: 1; }
.stage-dots { display: flex; gap: 4px; margin-bottom: 12px; overflow-x: auto; }
.stage-dots a { flex: none; font-size: 12px; padding: 4px 8px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--ink-2); text-decoration: none; }

/* ---------- quote builder */
.qline { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; background: #fcfbf9; }
.qline .top { display: flex; gap: 6px; align-items: flex-start; }
.qline .top input { font-weight: 600; }
.qline .nums { display: grid; grid-template-columns: 0.8fr 1fr 1fr; gap: 6px; margin-top: 6px; }
.qline .nums label { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.qline .meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; }
.qline .meta select { min-height: 34px; font-size: 14px; width: auto; padding: 4px 8px; }
.qline .ext { font-weight: 700; font-size: 14px; }
.qline.tiered { border-left: 4px solid var(--accent); }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 16px 0 8px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); }
.adders { display: grid; gap: 8px; }
.totals-bar {
  position: fixed; left: 0; right: 0; bottom: 56px; z-index: 15;
  background: var(--ink); color: #fff; padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom) * 0);
}
.totals-bar .inner { max-width: 760px; margin: 0 auto; display: flex; gap: 8px; overflow-x: auto; }
.tier-total { flex: 1; min-width: 96px; }
.tier-total .t { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: #b9bec6; }
.tier-total .v { font-size: 18px; font-weight: 800; }
.tier-total .m { font-size: 12px; color: #9fe0b4; }
.tier-total.low .v, .tier-total.low .m { color: #ff8f84; }
.has-totals main { padding-bottom: 190px; }

/* ---------- proposal (customer-facing) */
.proposal { max-width: 680px; margin: 0 auto; padding: 0 0 40px; }
.prop-head { background: var(--ink); color: #fff; padding: 22px 16px 18px; padding-top: max(22px, env(safe-area-inset-top)); }
.prop-head .biz { font-size: 13px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: #f0a37e; }
.prop-head h1 { margin-top: 8px; font-size: 24px; }
.prop-head .for { margin-top: 6px; color: #c8ccd2; font-size: 14px; }
.prop-body { padding: 16px; }
.seg { display: flex; background: #e6e2d9; border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.seg button { flex: 1; border: 0; background: transparent; min-height: 52px; flex-direction: column; gap: 0; border-radius: 9px; }
.seg button .tn { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }
.seg button .tp { font-size: 14px; font-weight: 800; }
.seg button[aria-pressed="true"] { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,0.12); color: var(--accent); }
.pline { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.pline:first-child { border-top: 0; }
.pline .q { color: var(--muted); font-size: 12px; }
.grand { display: flex; justify-content: space-between; align-items: baseline; font-size: 22px; font-weight: 800; padding: 6px 0; }
.sig { font-family: "Snell Roundhand", "Segoe Script", "Brush Script MT", cursive; font-size: 24px; }

/* ---------- photos */
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
.thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: var(--line); }

/* ---------- tables */
.table-wrap { overflow-x: auto; margin: 0 -14px; padding: 0 14px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: right; padding: 8px 6px; border-top: 1px solid var(--line); white-space: nowrap; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); border-top: 0; }
th:first-child, td:first-child { text-align: left; white-space: normal; }
td.bad { color: var(--bad); font-weight: 700; }
td.ok { color: var(--ok); font-weight: 700; }

.bars .bar { display: grid; grid-template-columns: 110px 1fr 28px; gap: 8px; align-items: center; font-size: 13px; padding: 4px 0; }
.bars .track { height: 10px; background: #ece8e0; border-radius: 6px; overflow: hidden; }
.bars .fill { height: 100%; background: var(--accent); border-radius: 6px; }
.stat { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: 76px; z-index: 50; max-width: 520px; margin: 0 auto;
  background: var(--ink); color: #fff; padding: 12px 14px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.25);
}
#toast.error { background: var(--bad); }
.has-totals #toast { bottom: 150px; } /* clear the quote totals bar */
.hint { font-size: 12px; color: var(--muted); margin: -2px 0 0; }

@media (min-width: 900px) {
  .col { flex-basis: 260px; }
  main { padding-top: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
