:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #f8f9f6;
  --line: #e3e5df;
  --line-strong: #cfd3ca;
  --text: #1c2420;
  --muted: #6b746e;
  --brand: #1f5f4a;
  --brand-ink: #ffffff;
  --brand-soft: #e3efe9;
  --accent: #c9792b;
  --accent-soft: #fbefe2;
  --good: #2f8a57;
  --good-soft: #e2f3e8;
  --warn: #b7791f;
  --warn-soft: #fdf3dc;
  --bad: #c0392b;
  --bad-soft: #fbe6e3;
  --blue: #2c6aa8;
  --blue-soft: #e4eef8;
  --side: #17211d;
  --side-ink: #c9d2cc;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 2px 8px rgba(20, 30, 25, .04);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111614; --surface: #19201d; --surface-2: #1e2622; --line: #2a332f; --line-strong: #3a4540;
    --text: #e6ebe8; --muted: #95a19a; --brand: #4fb08a; --brand-ink: #0d1411; --brand-soft: #1f3a30;
    --accent: #e3994f; --accent-soft: #3a2a1a; --good: #5cc48a; --good-soft: #1c3527; --warn: #e2b04d; --warn-soft: #3a3019;
    --bad: #ef7b6c; --bad-soft: #3d2320; --blue: #6aa6e0; --blue-soft: #1d2d3d; --side: #0c110f; --side-ink: #b4c0b9;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
small { display: block; color: var(--muted); font-size: 12px; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
textarea { resize: vertical; }

/* ---------- shell ---------- */
#app { display: flex; min-height: 100vh; }
.sidebar { width: 228px; background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; z-index: 30; }
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px; color: #fff; }
.brand:hover { text-decoration: none; }
.logo { width: 36px; height: 36px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px; }
.brand-text { font-weight: 700; font-size: 14px; line-height: 1.15; }
.brand-text small { color: var(--side-ink); font-weight: 500; opacity: .7; }
.sidebar nav { display: flex; flex-direction: column; padding: 6px 10px; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px; color: var(--side-ink); font-weight: 500; }
.sidebar nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: rgba(255, 255, 255, .1); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; padding: 14px 16px; display: flex; gap: 10px; align-items: center; border-top: 1px solid rgba(255, 255, 255, .08); }
.sidebar-foot b { color: #fff; font-size: 13px; }

/* Sync status: in the sidebar above the user, and inline on Settings */
.sync-badge { display: flex; align-items: center; gap: 8px; font-size: 12px; color: rgba(255, 255, 255, .65); }
.sidebar .sync-badge { margin: auto 16px 0; padding: 8px 0; }
.sidebar .sync-badge:hover { color: #fff; text-decoration: none; }
.sync-badge:not([hidden]) + .sidebar-foot { margin-top: 0; }
.sync-badge.inline { color: var(--muted); font-weight: 500; }
.sync-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); flex-shrink: 0; }
.sync-badge.synced .dot { background: var(--good); }
.sync-badge.saving .dot, .sync-badge.connecting .dot { background: var(--accent); animation: pulse 1.2s infinite; }
.sync-badge.offline .dot { background: var(--warn); }
.sync-badge.error .dot { background: var(--bad); }

/* Sign-in screen */
#gate { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); background: var(--bg); }
.gate-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 32px 28px; text-align: center; display: grid; gap: 14px; justify-items: center; box-shadow: 0 10px 40px rgba(0, 0, 0, .08); }
.gate-card .logo { width: 52px; height: 52px; font-size: 24px; border-radius: 13px; }
.gate-card h1 { margin: 0; font-size: 22px; }
.gate-card p { margin: 0; color: var(--muted); line-height: 1.5; }
.gate-card .btn.big { width: 100%; justify-content: center; display: inline-flex; gap: 10px; align-items: center; }
.gate-error { color: var(--bad) !important; font-size: 13px; }
.gate-card .link { border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; text-decoration: underline; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); display: flex; gap: 12px; align-items: center; padding: 10px 24px; border-bottom: 1px solid var(--line); }
.topbar .menu-btn { display: none; }
.search { position: relative; flex: 1; max-width: 520px; }
.search input { width: 100%; padding-left: 34px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23889' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 11px center; }
.search-results { display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0, 0, 0, .12); max-height: 60vh; overflow: auto; padding: 4px; }
.search-results.show { display: block; }
.search-results a { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 6px; color: var(--text); }
.search-results a:hover { background: var(--surface-2); text-decoration: none; }
.clock-chip { margin-left: auto; display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font-weight: 600; white-space: nowrap; max-width: 280px; }
.clock-chip:hover { text-decoration: none; border-color: var(--brand); }
.clock-chip .dot, .crew .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); flex-shrink: 0; }
.clock-chip.on { border-color: var(--good); background: var(--good-soft); }
.clock-chip.on .dot, .dot.on { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 25%, transparent); animation: pulse 2s infinite; }
.clock-chip.break { border-color: var(--warn); background: var(--warn-soft); }
.clock-chip.break .dot, .dot.break { background: var(--warn); }
.chip-job { font-weight: 500; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px transparent; } }
main { padding: 22px 24px 60px; max-width: 1480px; width: 100%; }
.bottom-nav { display: none; }

/* ---------- common ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.eyebrow a { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { border-color: var(--brand); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.big { padding: 14px 18px; font-size: 16px; }
.btn.block { width: 100%; }
.danger-text { color: var(--bad) !important; }
.warn-text { color: var(--warn); font-weight: 600; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.icon-btn.sm { width: 26px; height: 26px; font-size: 13px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.btn-col { display: flex; flex-direction: column; gap: 8px; }
.muted { color: var(--muted); }
.r { text-align: right; }
.nowrap { white-space: nowrap; }
.neg { color: var(--bad); }
.pos { color: var(--good); }
.grow { flex: 1; }
.pad { padding: 14px 16px; }
.hint { background: var(--blue-soft); color: var(--blue); padding: 9px 14px; border-radius: 8px; margin-bottom: 12px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card.flush > .card-head { margin: 0; border-bottom: 1px solid var(--line); }
.stack { display: flex; flex-direction: column; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty-sm { color: var(--muted); padding: 8px 0; font-size: 13px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); text-transform: capitalize; white-space: nowrap; }
.pill.good, .st-approved, .st-paid, .st-received { background: var(--good-soft); color: var(--good); border-color: transparent; }
.pill.warn, .st-pending, .st-open, .st-unpaid, .st-ordered { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad, .st-declined, .st-void { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.blue { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.pill.amber { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.status-approved, .status-in-progress { background: var(--good-soft); color: var(--good); border-color: transparent; }
.status-punch-list { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.status-estimating, .status-lead { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--line); font-size: 11px; font-weight: 600; color: var(--muted); }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table th.r { text-align: right; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr[data-href], .table tr[data-id], .table tr[data-entry] { cursor: pointer; }
.table tbody tr[data-href]:hover, .table tbody tr[data-id]:hover, .table tbody tr[data-entry]:hover { background: var(--surface-2); }
.table tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--line); }
.table.compact td { padding: 7px 10px; }
.table .done td { opacity: .5; }
.card > .table th:first-child, .card > .table td:first-child { padding-left: 0; }
.card.flush .table th:first-child, .card.flush .table td:first-child { padding-left: 16px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 520px; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input.grow { min-width: 200px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 9px; padding: 3px; gap: 2px; }
.seg.wrap { flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 6px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button span { font-weight: 500; opacity: .7; font-size: 12px; }
.seg button.on { background: var(--brand); color: var(--brand-ink); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a span { font-size: 11px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; margin-left: 2px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field input, .field select, .field textarea { width: 100%; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.row2, .row3 { display: grid; gap: 12px; }
.row2 > *, .row3 > * { min-width: 0; }
.row2 { grid-template-columns: 1fr 1fr; }
.row3 { grid-template-columns: 1fr 1fr 1fr; }
.check-row { display: flex; gap: 8px; align-items: center; }

/* ---------- modal & toast ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(15, 20, 18, .45); display: grid; place-items: center; padding: 20px; z-index: 100; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 14px; width: min(520px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal.wide { width: min(820px, 100%); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 6px; }
.modal header h2 { font-size: 17px; }
.modal-body { padding: 10px 20px; overflow-y: auto; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line); }
.modal footer .danger-text { margin-right: auto; }
@keyframes fade { from { opacity: 0; } }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); opacity: 0; background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-weight: 600; z-index: 200; transition: .25s; box-shadow: 0 8px 30px rgba(0, 0, 0, .2); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.warn { background: var(--warn); color: #fff; }

/* ---------- dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpis.small { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi span { font-size: 12px; font-weight: 600; color: var(--muted); }
.kpi b { display: block; font-size: 24px; font-weight: 700; margin: 2px 0; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpis.small .kpi b { font-size: 19px; }
.kpi.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.kpi.warn b { color: var(--warn); }
.kpi.good b { color: var(--good); }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.feed li:last-child { border-bottom: 0; }
.feed time { color: var(--muted); font-size: 12px; min-width: 60px; }
.feed li > span:not(.pill) { flex: 1; min-width: 0; }
.feed .pill { flex-shrink: 0; }
.feed small { display: inline; }
.bar { height: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin: 4px 0; }
.bar span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.bar.over span { background: var(--bad); }
.bar.big { height: 10px; }
.table .bar { width: 90px; margin-left: auto; }
.welcome { max-width: 720px; margin: 40px auto; text-align: center; }
.welcome h1 { font-size: 30px; margin-bottom: 8px; }
.welcome > p { color: var(--muted); font-size: 16px; margin-bottom: 28px; }
.welcome-steps { display: grid; gap: 10px; margin-bottom: 20px; text-align: left; }
.step { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--text); font-weight: 500; }
.step:hover { border-color: var(--brand); text-decoration: none; }
.step b { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex-shrink: 0; }

/* ---------- CRM ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 10px; }
.board-col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 300px; }
.board-col.over { border-color: var(--brand); background: var(--brand-soft); }
.board-col header { display: flex; justify-content: space-between; padding: 2px 4px 10px; font-size: 13px; }
.board-col header span { color: var(--muted); font-size: 12px; }
.board-cards { display: flex; flex-direction: column; gap: 8px; }
.board-card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--text); box-shadow: var(--shadow); cursor: grab; }
.board-card:hover { border-color: var(--brand); text-decoration: none; }
.board-card .meta { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.stage-bar { display: flex; margin-bottom: 16px; overflow-x: auto; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface); }
.stage-bar button { flex: 1; border: 0; background: transparent; padding: 9px 12px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; border-right: 1px solid var(--line); }
.stage-bar button:last-child { border-right: 0; }
.stage-bar button.on { background: var(--brand); color: var(--brand-ink); }
.stage-bar button.on.lost { background: var(--bad); color: #fff; }
.contact { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); cursor: default; }
.contact:last-child { border-bottom: 0; }
.contact > div:first-child { flex: 1; min-width: 0; }
[data-user].contact, [data-vendor].contact { cursor: pointer; }
.contact-links { display: flex; flex-direction: column; gap: 3px; font-size: 13px; margin-top: 4px; }
.contact .contact-links { flex: 1.3; margin: 0; }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; font-weight: 500; }
.note-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.note-form > div { display: flex; gap: 8px; justify-content: flex-end; }
.danger-zone { text-align: right; }

/* ---------- catalog ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card.asm { text-align: left; cursor: pointer; margin: 0; font: inherit; color: inherit; }
.card.asm:hover { border-color: var(--brand); }
.card.asm ul { margin: 10px 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.asm-foot { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 8px; }
.picker-search { width: 100%; margin-bottom: 10px; }
.picker { max-height: 52vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.pick { display: grid; grid-template-columns: auto 1fr auto 80px; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.pick:hover { background: var(--surface-2); }
.pick.asm-pick { grid-template-columns: auto 1fr; background: var(--accent-soft); }
.pick .qty, input.qty { width: 80px; text-align: right; padding: 5px 8px; }
.table.mini td { padding: 6px 4px; }

/* ---------- job ---------- */
.job-num { white-space: nowrap; font-size: 14px; font-weight: 600; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; vertical-align: middle; margin-left: 6px; }
.status-select { font-weight: 600; border-radius: 999px; padding: 7px 12px; }
.job-overview { display: grid; grid-template-columns: 330px minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.summary { background: var(--side); color: #e9efeb; border: 0; padding: 6px 0; }
.sum-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 18px; border-bottom: 1px solid rgba(255, 255, 255, .08); gap: 10px; }
.sum-row:last-child { border-bottom: 0; }
.sum-row span { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: #aab8b0; }
.sum-row span small { text-transform: none; letter-spacing: 0; color: #7f8e86; font-weight: 500; }
.sum-row b { font-size: 17px; font-variant-numeric: tabular-nums; }
.sum-row.pos b { color: #7ddba5; }
.sum-row.neg b { color: #ff9a8b; }
.sum-row.warn b { color: #f3c56b; }
/* The one-line answer at the top of the job summary */
.verdict { grid-column: 1 / -1; padding: 16px 18px 14px; border-bottom: 1px solid rgba(255, 255, 255, .12); display: grid; gap: 2px; }
.verdict span { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: #aab8b0; }
.verdict b { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.verdict small { color: #aab8b0; font-size: 12px; }
.verdict.pos b { color: #7ddba5; }
.verdict.neg b { color: #ff9a8b; }
.sum-head { grid-column: 1 / -1; padding: 12px 18px 2px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.sum-meter { grid-column: 1 / -1; padding: 0 18px 10px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.sum-meter .bar { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .1); }
.sum-meter .bar span { background: #7ddba5; }
.sum-meter small { color: #7f8e86; font-size: 12px; }
.job-meta { display: flex; gap: 10px; align-items: center; margin: 6px 0 0; color: var(--muted); font-size: 13px; flex-wrap: wrap; }

/* Budget: quick add */
.quick-add { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; padding: 12px 16px; }
.quick-add .grow { flex: 1 1 260px; min-width: 0; }
.quick-add .field { margin: 0; }
.quick-add input[type=number] { width: 80px; }
.kbd-help { font-size: 12px; margin: 6px 2px 0; }

/* Tasks */
.task-add { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.task-add .grow { flex: 1 1 240px; min-width: 0; }
.task-add .field { margin: 0; }
.tasks { list-style: none; margin: 0; padding: 0; }
.task { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task input[type=checkbox] { width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--brand); }
.task-title { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 0; font: inherit; color: var(--text); cursor: pointer; display: flex; flex-direction: column; }
.task-title small { color: var(--muted); font-size: 12px; }
a.task-title:hover { text-decoration: none; color: var(--brand); }
.task.done .task-title { color: var(--muted); text-decoration: line-through; }
.task-meta { display: flex; gap: 6px; align-items: center; font-size: 12px; flex-shrink: 0; }

/* Files */
.dropzone { display: grid; gap: 4px; justify-items: center; text-align: center; padding: 26px 16px; border: 2px dashed var(--line-strong); cursor: pointer; background: var(--surface); }
.dropzone.over { border-color: var(--brand); background: color-mix(in srgb, var(--brand-soft) 50%, var(--surface)); }
.dz-folder { margin-top: 6px; font-size: 13px; }
.dz-folder select { margin-left: 6px; }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.file { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; grid-template-areas: "thumb info del" "thumb move move"; gap: 4px 10px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 10px; }
.file-thumb { width: 56px; height: 56px; border-radius: 8px; overflow: hidden; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-thumb .ext { font-size: 11px; font-weight: 800; color: var(--accent); letter-spacing: .04em; }
.file-info { min-width: 0; display: grid; }
.file-info a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.file-info small { color: var(--muted); font-size: 12px; }

/* Schedule */
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.week-grid .day { padding: 8px 10px 12px; border-right: 1px solid var(--line); min-height: 90px; min-width: 0; }
.week-grid .day:last-child { border-right: 0; }
.week-grid .day header { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.week-grid .day.today { background: color-mix(in srgb, var(--brand-soft) 40%, var(--surface)); }
.week-grid .day.today header b { color: var(--brand); }
.week-grid .day.past { opacity: .7; }
.week-grid .task { padding: 5px 0; font-size: 13px; align-items: flex-start; }
.week-grid .task-meta { display: none; }
.milestone { display: block; font-size: 12px; font-weight: 600; padding: 3px 6px; border-radius: 6px; margin-bottom: 4px; }
.milestone.start { background: var(--good-soft); color: var(--good); }
.milestone.end { background: var(--warn-soft); color: var(--warn); }
.card.attention { border-color: var(--bad); }
.timeline { display: grid; gap: 6px; }
.tl-scale { position: relative; height: 18px; margin-left: 220px; font-size: 11px; color: var(--muted); }
.tl-scale span { position: absolute; top: 0; white-space: nowrap; }
.tl-row { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 10px; align-items: center; color: var(--text); }
.tl-row:hover { text-decoration: none; }
.tl-name { display: grid; min-width: 0; font-weight: 600; font-size: 13px; }
.tl-name small { color: var(--muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-track { position: relative; height: 22px; background: var(--surface-2); border-radius: 6px; }
.tl-bar { position: absolute; top: 3px; bottom: 3px; border-radius: 5px; background: var(--brand); }
.tl-bar.status-estimating { background: var(--line-strong); }
.tl-bar.status-punch-list { background: var(--accent); }
.tl-off { position: absolute; left: 8px; top: 3px; font-size: 11px; }
@media (max-width: 820px) {
  .week-grid { grid-template-columns: 1fr; }
  .week-grid .day { border-right: 0; border-bottom: 1px solid var(--line); min-height: 0; }
  .week-grid .day.past { display: none; }
  .tl-scale { display: none; }
  .tl-row { grid-template-columns: 1fr; gap: 4px; }
}
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bva { display: grid; grid-template-columns: 120px 1fr auto; gap: 10px; align-items: center; padding: 5px 0; font-size: 13px; }
.bva small { display: inline; white-space: nowrap; }
.scope { white-space: normal; color: var(--text); max-height: 360px; overflow: auto; }

.budget-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.budget-stats { display: flex; gap: 6px; flex-wrap: wrap; }
.budget-stats > div { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; }
.budget-stats span { display: block; font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.budget-stats b { font-variant-numeric: tabular-nums; }
.budget-stats .minor { background: transparent; }
table.budget { width: 100%; border-collapse: collapse; min-width: 1060px; font-variant-numeric: tabular-nums; }
table.budget th { position: sticky; top: 0; text-align: left; font-size: 12px; color: var(--muted); padding: 8px 6px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; z-index: 1; }
table.budget th.r { text-align: right; }
table.budget td { padding: 2px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 13px; white-space: nowrap; }
table.budget .name-col { width: 34%; min-width: 280px; }
table.budget tfoot td { padding: 10px; }
.cell-name { display: flex; align-items: center; gap: 4px; padding-left: calc(var(--d) * 18px); }
.in { border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 5px 6px; width: 100%; }
.in:hover { border-color: var(--line); }
.in:focus { background: var(--surface); border-color: var(--brand); outline: 0; }
.in:disabled { color: var(--text); opacity: 1; }
.in.num { width: 92px; }
.in.pctin { width: 64px; }
.in.unit { width: 100px; }
.in.type { width: 112px; padding: 4px; }
.in.tax { width: 64px; display: inline-block; padding: 2px 4px; }
.in.sku { width: 110px; }
tr.grp td { background: color-mix(in srgb, var(--brand-soft) 60%, var(--surface)); }
tr.grp.d1 td { background: color-mix(in srgb, var(--brand-soft) 30%, var(--surface)); }
tr.grp.d2 td, tr.grp.d3 td { background: var(--surface-2); }
.grp-in { font-weight: 700; }
tr.grp.excluded td { background: var(--surface-2); color: var(--muted); }
tr.grp.excluded .grp-in { text-decoration: line-through; text-decoration-color: var(--line-strong); }
.cell-name .pill { flex-shrink: 0; margin-left: 6px; }
.caret { border: 0; background: transparent; cursor: pointer; color: var(--muted); width: 22px; height: 22px; transition: transform .15s; flex-shrink: 0; }
.caret.open { transform: rotate(90deg); }
.grip { color: var(--line-strong); cursor: grab; width: 22px; text-align: center; flex-shrink: 0; font-size: 11px; letter-spacing: -2px; }
tr.drop td { box-shadow: inset 0 2px 0 var(--accent); }
tr.grp.drop td { box-shadow: inset 0 0 0 2px var(--accent); }
tr.dragging { opacity: .4; }
.row-acts { opacity: .55; }
tr:hover .row-acts { opacity: 1; }

.grid-orders { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.vendor-block h3 span { font-weight: 500; }
.po-card { display: flex; justify-content: space-between; gap: 10px; color: var(--text); margin-bottom: 10px; }
.po-card:hover { border-color: var(--brand); text-decoration: none; }
.po-card .r b { display: block; margin-top: 4px; }

.log-form .log-actions { display: flex; gap: 10px; align-items: center; justify-content: flex-end; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-top: 10px; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.log p { margin: 0; }

/* ---------- documents ---------- */
.status-steps { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.status-steps > button:not(.btn) { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; padding: 6px 14px; font-weight: 600; text-transform: capitalize; cursor: pointer; color: var(--muted); }
.status-steps > button.on { border-color: transparent; box-shadow: 0 0 0 2px currentColor inset; }
.status-steps > button:not(.on) { background: var(--surface); color: var(--muted); }
.sign-btn { margin-left: auto; }
.signed-banner { display: flex; align-items: center; gap: 10px; background: var(--good-soft); color: var(--good); padding: 8px 14px; border-radius: 8px; margin-bottom: 14px; }
.signed-banner img { height: 40px; margin-left: auto; background: #fff; border-radius: 6px; padding: 2px 8px; }
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
table.doc-lines { width: 100%; border-collapse: collapse; margin: 6px 0; min-width: 640px; }
table.doc-lines th { text-align: left; font-size: 12px; color: var(--muted); padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.doc-lines th.r { text-align: right; }
table.doc-lines td { padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.doc-lines td.r { padding-top: 10px; white-space: nowrap; }
table.doc-lines .in.desc { font-size: 12px; color: var(--muted); resize: none; overflow: hidden; min-height: 26px; }
table.doc-lines tr.hdr td { background: var(--brand-soft); }
table.doc-lines tr.hdr.d1 td { background: color-mix(in srgb, var(--brand-soft) 45%, var(--surface)); }
table.doc-lines tr.hdr small { padding-left: 8px; }
.totals { margin: 14px 0 18px auto; width: min(340px, 100%); }
.totals > div { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-variant-numeric: tabular-nums; }
.totals .grand { border-top: 1px solid var(--line-strong); font-size: 17px; }
.pay { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.sign-sum { display: flex; justify-content: space-between; background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.sig-wrap { position: relative; border: 2px dashed var(--line-strong); border-radius: 10px; background: #fff; touch-action: none; }
.sig-wrap canvas { width: 100%; height: 200px; display: block; cursor: crosshair; touch-action: none; }
.sig-wrap [data-clear] { position: absolute; top: 6px; right: 6px; }
.sig-line { position: absolute; left: 16px; right: 16px; bottom: 40px; border-top: 1px solid #bbb; font-size: 11px; color: #999; padding-top: 2px; pointer-events: none; }

.shop { max-width: 640px; margin: 0 auto; }
.shop-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.shop-head > div { flex: 1; }
.shop-count { font-size: 22px; font-weight: 800; }
.shop-list { list-style: none; padding: 0; margin: 14px 0; display: flex; flex-direction: column; gap: 8px; }
.shop-list li { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; cursor: pointer; user-select: none; }
.shop-list li .check { width: 30px; height: 30px; border-radius: 8px; border: 2px solid var(--line-strong); display: grid; place-items: center; font-weight: 800; color: #fff; flex-shrink: 0; }
.shop-list li > div { flex: 1; }
.shop-list li.got { opacity: .55; }
.shop-list li.got .check { background: var(--good); border-color: var(--good); }
.shop-list li.got b { text-decoration: line-through; }
.shop-qty { font-size: 20px; font-weight: 800; text-align: right; }

/* ---------- time ---------- */
.clock-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.clock-card { text-align: center; padding: 26px; border-width: 2px; }
.clock-card.on { border-color: var(--good); }
.clock-card.break { border-color: var(--warn); }
.clock-card .field { text-align: left; }
.who { display: flex; justify-content: center; margin-bottom: 10px; }
.who select { margin-left: 6px; font-weight: 600; }
.clock-state { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.clock-card.on .clock-state { color: var(--good); }
.clock-card.break .clock-state { color: var(--warn); }
.clock-timer { font-size: 72px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; margin: 6px 0 10px; }
.clock-job { margin-bottom: 16px; font-size: 16px; font-weight: 600; }
.clock-btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
button.link { border: 0; background: none; padding: 6px 0; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; text-decoration: underline; justify-self: center; }
button.link:hover { color: var(--text); }
.crew { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.crew:last-child { border-bottom: 0; }
.crew > span:last-child { margin-left: auto; font-size: 13px; }
.entry { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.entry:last-child { border-bottom: 0; }
.table.week th small { font-weight: 500; }

.codes { display: flex; flex-wrap: wrap; gap: 6px; }
.codes .tag { cursor: pointer; font-size: 12px; padding: 3px 8px; }
.codes .tag:hover { border-color: var(--bad); color: var(--bad); }

/* ---------- print view ---------- */
body.bare .sidebar, body.bare .topbar, body.bare .bottom-nav { display: none; }
body.bare main { max-width: none; padding: 20px; }
.print-actions { display: flex; gap: 8px; justify-content: center; margin-bottom: 16px; }
.paper { background: #fff; color: #1a1a1a; max-width: 850px; margin: 0 auto; padding: 48px 54px; box-shadow: 0 4px 24px rgba(0, 0, 0, .12); border-radius: 4px; font-size: 13px; }
.paper a { color: inherit; }
.p-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid #1f5f4a; padding-bottom: 16px; }
.p-head h1 { font-size: 22px; color: #1f5f4a; }
.p-head p { margin: 6px 0 0; color: #555; }
.p-title { text-align: right; }
.p-title h2 { font-size: 22px; text-transform: uppercase; letter-spacing: .06em; color: #c9792b; }
.p-title p { margin: 6px 0 0; }
/* First block at the left edge, last block against the right edge (under the end of the green rule). */
.p-parties { display: flex; justify-content: space-between; gap: 20px; margin: 20px 0; }
.p-parties > div { min-width: 0; max-width: 34%; overflow-wrap: anywhere; }
.p-brand { display: flex; gap: 14px; align-items: center; }
.p-brand img { max-height: 64px; max-width: 180px; object-fit: contain; }
.p-hdr td.r { font-weight: 700; }
.p-group td { padding-top: 10px; padding-bottom: 10px; }
.p-options, .p-schedule { margin: 18px 0 6px; }
.p-options h4, .p-schedule h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #888; margin-bottom: 2px; }
.p-options tr.chosen td { background: #f1f8f3; }
.p-options input[type=checkbox] { width: 20px; height: 20px; accent-color: #1f5f4a; cursor: pointer; }
.p-box { font-size: 16px; }
.p-note { margin: 2px 0 6px; color: #555; }
.p-accept { margin: 30px 0 0; color: #444; font-size: 12px; }
.p-parties h4, .p-terms h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #888; margin-bottom: 4px; }
.p-parties p { margin: 0; }
.p-doc-title { font-size: 17px; margin: 10px 0; }
.p-intro { margin: 10px 0 18px; color: #333; }
.p-lines { width: 100%; border-collapse: collapse; margin: 10px 0; }
.p-lines th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #666; border-bottom: 2px solid #1a1a1a; padding: 6px; }
.p-lines th.r { text-align: right; }
.p-lines td { padding: 7px 6px; border-bottom: 1px solid #e3e3e3; vertical-align: top; }
.p-lines .chk { width: 26px; text-align: center; font-size: 15px; }
.p-hdr td { font-weight: 700; background: #f1f5f2; }
.p-hdr.d1 td { background: #fafbfa; padding-left: 18px; }
.p-desc { color: #666; font-size: 12px; margin-top: 2px; }
.p-foot-row { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; margin: 16px 0 24px; }
.p-foot-row .p-totals { margin: 0; width: auto; }
.p-paybox { border: 1px solid #d8dcd9; padding: 14px 16px 0; font-size: 13px; }
.p-paybox > b { display: block; color: #1f4f8a; margin-bottom: 6px; }
.p-paybox.full > b, .p-paid.full b { color: #1f6b3d; }
.p-paybox div { display: flex; justify-content: space-between; padding: 4px 0; }
.p-paybox .bal { background: #f1f3f2; margin: 8px -16px 0; padding: 12px 16px; font-weight: 700; font-size: 15px; }
.p-paid { margin-left: 18px; }
.p-paid b { display: block; color: #1f4f8a; font-size: 14px; }
.p-paid span { color: #555; font-size: 12px; }
.p-tm { border: 1px solid #d8dcd9; margin: 0 0 16px; }
.p-tm td { padding: 9px 12px; }
.p-tm .p-desc { font-size: 11px; line-height: 1.45; color: #333; }
.p-note-small { font-size: 11px; color: #777; margin-top: 24px; }
.p-totals { margin: 16px 0 24px auto; width: 300px; }
.p-totals div { display: flex; justify-content: space-between; padding: 5px 0; }
.p-totals .grand { border-top: 2px solid #1a1a1a; font-size: 16px; }
.p-terms { font-size: 12px; color: #444; border-top: 1px solid #e3e3e3; padding-top: 12px; }
.p-sign { display: grid; grid-template-columns: 2fr 1.4fr 1fr; gap: 24px; margin-top: 44px; }
.p-sign div { border-bottom: 1px solid #333; min-height: 54px; display: flex; flex-direction: column; justify-content: flex-end; position: relative; }
.p-sign img { max-height: 54px; max-width: 100%; object-fit: contain; object-position: left bottom; }
.p-sign span { position: absolute; bottom: -18px; font-size: 11px; color: #888; }
.p-foot { text-align: center; color: #999; font-size: 11px; margin-top: 50px; }

/* Customers */
.next-step { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; border-left: 4px solid var(--brand); }
.next-step > div:first-child { display: grid; gap: 2px; }
.next-step b { font-size: 16px; }
.next-step small { color: var(--muted); }
.next-step.due { border-left-color: var(--bad); }
.next-step.due small { color: var(--bad); font-weight: 600; }
.visit { display: grid; grid-template-columns: 170px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.visit:last-child { border-bottom: 0; }
.visit span { color: var(--muted); min-width: 0; }
.visit.past b { color: var(--muted); font-weight: 600; }
details summary { cursor: pointer; padding: 6px 0; }
.log-entry { display: grid; gap: 8px; margin-bottom: 10px; }
.log-entry .seg { flex-wrap: wrap; }
.row-inline { display: flex; gap: 8px; flex-wrap: wrap; }
.row-inline input[name=nextStep] { flex: 1 1 180px; min-width: 0; }
.card-step { display: block; color: var(--brand); font-weight: 600; margin-top: 4px; }
.card-step.due { color: var(--bad); }
.referrer .card-head h2 a { color: inherit; }
.milestone.visit { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); color: var(--accent); }
.milestone.visit.done { opacity: .6; text-decoration: line-through; }
@media (max-width: 820px) { .visit { grid-template-columns: 1fr auto; } .visit span { grid-column: 1 / -1; grid-row: 2; } }

/* Catalog: store items and prices */
.cat-name { display: flex; gap: 10px; align-items: center; }
.cat-name img { width: 40px; height: 40px; object-fit: contain; border-radius: 6px; background: #fff; border: 1px solid var(--line); flex-shrink: 0; }
.price-banner { display: flex; gap: 14px; justify-content: space-between; align-items: flex-start; border-left: 4px solid var(--warn); flex-wrap: wrap; }
.price-banner ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 4px; font-size: 13px; }
.price-banner li .btn { margin-left: 6px; }
.price-hint { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.price-meta { display: flex; gap: 12px; align-items: flex-start; margin-top: 6px; }
.price-meta img { width: 72px; height: 72px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.price-meta > div { display: grid; gap: 4px; }
.price-meta small { color: var(--muted); }
.shop-list.wide li { grid-template-columns: 30px minmax(0, 1fr) auto auto; }
.calc .slot { display: block; margin-top: 4px; max-width: 100%; font-size: 12px; }

/* Receipts */
.receipt-btn { font-size: 18px; text-decoration: none; }
.receipt-start { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.receipt-start .btn.big { cursor: pointer; }
.receipt-start p { flex-basis: 100%; margin: 0; }
.receipt-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.assign-all { display: flex; gap: 10px; align-items: center; margin: 8px 0; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.receipt-lines tr.todo td { background: var(--warn-soft); }
.receipt-photo img { width: 100%; max-height: 420px; object-fit: contain; border-radius: 8px; }
.split-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.split-row small { grid-column: 1 / -1; color: var(--muted); }
.receipt-lines select { max-width: 160px; }
.receipt-lines td:first-child .in { min-width: 200px; }
.receipt-lines td .num { min-width: 64px; }
.receipt-drop { display: grid; gap: 12px; border: 2px dashed var(--line); transition: border-color .15s, background .15s; }
.receipt-drop.over { border-color: var(--brand); background: var(--surface-2); }
.receipt-drop .drop-text { display: grid; gap: 2px; }
.receipt-drop p { margin: 0; }
.receipt-work tr.bad small { color: var(--bad); }
.receipt-work tr.warn small { color: var(--warn); }
.receipt-work .bar { max-width: 260px; }
.receipt-warn { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: 13px; }
.receipt-warn p { margin: 4px 0; }
.receipt-photo iframe { width: 100%; height: 520px; border: 0; border-radius: 8px; background: #fff; }
.dup-card.bad { border-color: var(--bad); background: var(--bad-soft); }
.dup-card.warn { border-color: var(--warn); background: var(--warn-soft); }
.dup-card p { margin: 6px 0; }
.dup-card small { display: block; color: var(--muted); }
.tag.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
@media (max-width: 820px) { .receipt-layout { grid-template-columns: 1fr; } }

/* Customer link page */
body.public { background: var(--bg); }
body.public main { max-width: 900px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 40px max(12px, env(safe-area-inset-left)); }
.public-msg { max-width: 520px; margin: 18vh auto; text-align: center; color: var(--muted); font-size: 16px; line-height: 1.5; }
.public-panel { max-width: 850px; margin: 18px auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; display: grid; gap: 10px; }
.public-panel.done { border-color: var(--good); background: var(--good-soft); color: var(--text); }
.public-panel h3 { margin: 0; font-size: 18px; }
.public-panel p { margin: 0; }
.public-panel .btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.public-foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 18px; }

/* Document editor additions */
.opt-row { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 2px; }
.opt-row label { display: inline-flex; gap: 5px; align-items: center; cursor: pointer; }
.overdue-banner { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: 10px 14px; margin: 10px 0; }
.overdue-banner .btn { margin-left: auto; }
.sent-line { color: var(--muted); font-size: 13px; margin: 6px 0 10px; }
.sched-row { display: grid; grid-template-columns: minmax(0, 1fr) 58px 80px 28px; gap: 6px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.sched-row .sched-inv { grid-column: 3 / 5; text-align: right; }
.sched-row b { font-variant-numeric: tabular-nums; font-size: 13px; }
.sched-sum { margin: 6px 0; font-size: 12px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; }
.logo-row { display: flex; gap: 14px; align-items: center; margin: 8px 0; }
.logo-preview { width: 140px; height: 64px; border: 1px dashed var(--line-strong); border-radius: 8px; display: grid; place-items: center; background: #fff; overflow: hidden; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }

@media print {
  @page { margin: 0.5in; }
  .public-panel, .public-foot { display: none !important; }
  body { background: #fff; }
  .print-actions, .sidebar, .topbar, .bottom-nav { display: none !important; }
  body.bare main { padding: 0; }
  .paper { box-shadow: none; padding: 0; max-width: none; }
  .p-lines tr { break-inside: avoid; }
}

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .job-overview { grid-template-columns: 1fr 1fr; }
  .job-overview .summary { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .doc-layout { grid-template-columns: 1fr; }
  .grid-orders { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  body.nav-open .sidebar { transform: none; }
  /* Dim the page behind the open menu; tapping it closes the menu (see app.js). */
  body.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 28; }
  .topbar .menu-btn { display: inline-grid; }
  .topbar { padding: 8px 12px; }
  .chip-job { display: none; }
  main { padding: 16px 16px 90px; }
  .grid-2, .grid-3, .clock-layout, .job-overview, .doc-layout, .grid-orders { grid-template-columns: minmax(0, 1fr); }
  .job-overview .summary { grid-template-columns: 1fr; }
  .row3 { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 21px; }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line); z-index: 25; padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; font-size: 11px; font-weight: 600; color: var(--muted); }
  .bottom-nav a.active { color: var(--brand); }
  .bottom-nav a:hover { text-decoration: none; }
  .clock-timer { font-size: 60px; }
  .clock-btns { grid-template-columns: 1fr; }
  .paper { padding: 24px 18px; }
  .p-parties { flex-direction: column; gap: 14px; }
  .p-parties > div { max-width: none; }
  .p-foot-row { grid-template-columns: minmax(0, 1fr); }
  .p-sign { grid-template-columns: 1fr; gap: 34px; }
  .kpi b { font-size: 20px; }
  .modal-wrap { padding: 0; align-items: end; }
  .modal, .modal.wide { width: 100%; border-radius: 16px 16px 0 0; max-height: 92vh; }
  .sign-btn { margin-left: 0; width: 100%; }
}
/* A printed page is narrower than the phone breakpoint; keep the paper's side-by-side header there. */
@media print {
  .p-parties { flex-direction: row; gap: 20px; }
  .p-parties > div { max-width: 34%; }
}
@media (max-width: 480px) {
  .row2, .row3 { grid-template-columns: 1fr; }
  .quick { grid-template-columns: 1fr; }
  .bva { grid-template-columns: 90px 1fr; }
  .bva small { grid-column: 1 / -1; }
  .page-head .actions { width: 100%; }
}

/* Crew page */
.crew-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.crew-card { cursor: pointer; }
.crew-card:hover { border-color: var(--accent, #1f5f4a); }
.crew-card.inactive { opacity: .6; }
.crew-card p { margin: 4px 0; }
.crew-notes { font-size: 13px; white-space: pre-line; border-top: 1px solid var(--line, #e3e3e3); padding-top: 8px; }

/* Job menu on pages inside a job (documents, order forms) */
.job-head.compact { margin-bottom: 10px; }
.job-head.compact h1 { font-size: 20px; }
.job-head.compact .job-meta { display: none; }
.doc-head h2 { font-size: 22px; margin: 2px 0 0; }

/* Filter chips (Documents, Files, Photos) */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chips button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.chips button span { font-weight: 500; margin-left: 4px; opacity: .8; }
.chips button.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Proposal quick pick */
.pick-head { display: flex; align-items: center; gap: 10px; margin: 8px 0 6px; }
.pick-box { max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.pick-tree { list-style: none; margin: 0; padding-left: 0; }
.pick-tree .pick-tree { padding-left: 18px; }
.pick-tree li { display: block; }
.pick-tree li > label, .pick-tree summary { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; align-items: center; }
.pick-tree li:not(.pick-group) { display: flex; justify-content: space-between; gap: 10px; }
.pick-tree summary { cursor: pointer; list-style: none; }
.pick-tree summary::before { content: '▸'; color: var(--muted); margin-right: 4px; }
.pick-tree details[open] > summary::before { content: '▾'; }
.pick-tree summary label { flex: 1; }
.p-under { margin: -10px 0 16px auto; width: 320px; font-size: 13px; }
.p-under div { display: flex; justify-content: space-between; padding: 4px 0; }

/* Tasks and punch list */
a.task-title { color: inherit; text-decoration: none; flex: 1; min-width: 0; }
a.task-title:hover { text-decoration: underline; }
.punch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.punch-add { display: flex; gap: 8px; margin-top: 8px; }
.punch-add input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font: inherit; background: var(--surface); color: inherit; }
.room-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px 12px; margin-bottom: 10px; }
.task-page { max-width: 760px; }
.check-row.big { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.photo-wrap { position: relative; display: inline-block; }
.photo-wrap .icon-btn { position: absolute; top: 4px; right: 4px; background: rgba(255, 255, 255, .9); }
.file-move { grid-area: move; justify-self: start; max-width: 100%; font-size: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: inherit; padding: 3px 4px; }

/* Photo gallery */
.photo-add { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.photo-tagpick { display: flex; flex-wrap: wrap; gap: 6px 12px; width: 100%; align-items: center; font-size: 13px; }
.tagbox { display: inline-flex; gap: 4px; align-items: center; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.gallery figure { margin: 0; position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.gallery figcaption { padding: 6px 8px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.gallery figcaption small { color: var(--muted); margin-left: auto; }
.gallery.selecting figure { cursor: pointer; }
.gallery figure.picked { outline: 3px solid var(--brand); }
.pick-dot { position: absolute; top: 8px; left: 8px; width: 24px; height: 24px; border-radius: 50%; background: rgba(255, 255, 255, .9); border: 2px solid var(--brand); display: grid; place-items: center; font-weight: 700; color: var(--brand); }
@media (max-width: 600px) { .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } }
.choice-in { max-width: 230px; font-size: 12px; }
.choice-group { border-top: 1px solid var(--line); padding: 10px 0; }
.choice-group:first-of-type { border-top: 0; }
.choice-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.choice-list { list-style: none; margin: 6px 0 0; padding: 0 0 0 4px; }
.choice-list li { display: flex; justify-content: space-between; max-width: 520px; padding: 2px 0; color: var(--muted); }
.choice-list li.on { color: var(--text); font-weight: 600; }
.sel-room { margin: 14px 0 4px; font-size: 15px; }

/* Crew availability on the schedule */
.day header { display: flex; gap: 6px; align-items: center; }
.day-add { margin-left: auto; width: 22px; height: 22px; font-size: 15px; line-height: 1; }
.crew-event { display: block; width: 100%; text-align: left; border: 0; border-left: 3px solid #b5651d; background: #fbefe2; color: #6b3a10; border-radius: 6px; padding: 4px 6px; margin: 4px 0; font: inherit; font-size: 12px; cursor: pointer; }
.crew-event small { display: block; opacity: .85; }
.crew-event.k-off { border-color: #6a5acd; background: #efedfb; color: #3b3170; }
.crew-event.k-appointment { border-color: #2f7d95; background: #e5f3f7; color: #1c4f5e; }
.crew-event.k-elsewhere { border-color: #5b7f3a; background: #eef5e7; color: #34501c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .crew-event { filter: brightness(.85) saturate(.9); } }
.card.narrow { max-width: 860px; }
.vendor-card { cursor: pointer; }
.vendor-card:hover { border-color: var(--brand); }
.vendor-card p { margin: 4px 0; }
.file-thumb { grid-area: thumb; }
.file-info { grid-area: info; }
.file [data-filedel] { grid-area: del; }
.check-row.top { align-items: flex-start; margin-bottom: 8px; }
.check-row.top input { margin-top: 3px; flex: none; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text); }
.table th.sortable i { font-style: normal; font-size: 10px; margin-left: 4px; opacity: .35; }
.table th.sortable.sorted { color: var(--text); }
.table th.sortable.sorted i { opacity: 1; color: var(--accent); }
.row5 { display: grid; gap: 12px; grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 720px) { .row5 { grid-template-columns: 1fr 1fr; } }
.code-table td { vertical-align: middle; padding-top: 6px; padding-bottom: 6px; }
.code-table .code-num { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.code-table .depth-1 .code-num { padding-left: 32px; }
.code-table .depth-2 .code-num { padding-left: 52px; }
.code-table .depth-3 .code-num { padding-left: 72px; }
.code-table .depth-1 .code-num::before, .code-table .depth-2 .code-num::before, .code-table .depth-3 .code-num::before { content: "└ "; color: var(--muted); font-weight: 400; }
.code-table tr:not(.depth-0) { background: var(--surface-2); }
.code-table .in { width: 100%; max-width: 320px; }
.sched-gantt .tl-track { overflow: hidden; }
.sched-gantt .tl-name .warn-text { white-space: normal; }
.tl-bar.type-punch { background: var(--accent); }
.tl-bar.type-inspection { background: var(--blue); }
.tl-bar.type-order { background: var(--warn); }
.tl-bar.type-call { background: var(--line-strong); }
.tl-bar.late { background: var(--bad); }
.tl-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--bad); opacity: .55; z-index: 1; }
@media (max-width: 720px) { .sched-add .field:not(.grow) { flex: 1 1 40%; } }
.receipt-rename .ren-out { font-size: 13px; }
.receipt-rename .ren-out small { display: block; }
.receipt-photo small { display: block; margin-top: 4px; }

/* All receipts & reports */
.receipt-filters .filter-row { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; }
.receipt-filters .filter-row + .filter-row { margin-top: 10px; }
.receipt-filters .field { margin: 0; min-width: 140px; }
.receipt-filters .field.grow { flex: 1 1 240px; }
.report-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; margin-bottom: 16px; }
.report-side { display: grid; gap: 16px; }
.report-grid .card { margin-bottom: 0; }
.report-grid tr[data-pick-code], .report-grid tr[data-pick-store] { cursor: pointer; }
.report-grid tr.on td { background: color-mix(in srgb, var(--brand) 10%, transparent); }
.report-grid .depth-1 td:nth-child(2) { padding-left: 22px; }
.report-grid .depth-2 td:nth-child(2) { padding-left: 36px; }
.bar.thin { height: 4px; margin-top: 4px; }
.th-sort { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.receipt-library small { display: block; color: var(--muted); }
@media (max-width: 820px) { .report-grid { grid-template-columns: 1fr; } .receipt-filters .field { min-width: 0; flex: 1 1 45%; } }
.list-filters { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; border-bottom: 1px solid var(--line); padding-top: 0; }
.list-filters .field { margin: 0; min-width: 130px; }
.list-filters .field.grow { flex: 1 1 220px; }
.pager { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.pager > .muted:first-child { margin-right: auto; }
@media (max-width: 820px) { .list-filters .field { min-width: 0; flex: 1 1 45%; } }
