/* v2 */
/* HVAC CRM: one stylesheet, phone first. */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #17212b;
  --muted: #5d6b78;
  --line: #dde3e9;
  --brand: #0f3d5e;
  --brand-ink: #ffffff;
  --primary: #1565c0;
  --primary-ink: #ffffff;
  --accent: #f28c28;
  --green: #1b7f4b;
  --green-bg: #e3f4ea;
  --blue-bg: #e3eefb;
  --warn-bg: #fff4e0;
  --warn-line: #f2c46b;
  --error: #b3261e;
  --error-bg: #fde8e6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 30, 45, .06), 0 1px 1px rgba(15, 30, 45, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f151b;
    --surface: #18212a;
    --text: #e6ebf0;
    --muted: #93a1ae;
    --line: #2a3542;
    --brand: #0b2a41;
    --primary: #4b9be8;
    --primary-ink: #08131d;
    --green: #5fd197;
    --green-bg: #133325;
    --blue-bg: #14273b;
    --warn-bg: #33270f;
    --warn-line: #7a5b1d;
    --error: #ff8a80;
    --error-bg: #3a1714;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--primary); }
h1 { font-size: 1.5rem; margin: .25rem 0 .75rem; line-height: 1.2; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 1rem;
  background: var(--brand); color: var(--brand-ink);
  padding: .6rem 1rem; padding-top: max(.6rem, env(safe-area-inset-top));
  position: sticky; top: 0; z-index: 10;
}
.brand { color: inherit; text-decoration: none; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mainnav { display: flex; gap: .25rem; margin-left: auto; }
.mainnav a { color: inherit; text-decoration: none; padding: .4rem .7rem; border-radius: 6px; opacity: .85; }
.mainnav a[aria-current="page"], .mainnav a:hover { background: rgba(255,255,255,.14); opacity: 1; }
.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; padding: .4rem .7rem; border-radius: 6px; background: rgba(255,255,255,.14); }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu-panel {
  position: absolute; right: 0; top: calc(100% + .4rem); min-width: 190px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .5rem; display: grid; gap: .1rem; box-shadow: 0 6px 24px rgba(0,0,0,.15);
}
.usermenu-panel > * { padding: .45rem .6rem; }
.usermenu-panel a, .linkish { color: var(--text); text-decoration: none; border-radius: 6px; }
.usermenu-panel a:hover, .linkish:hover { background: var(--bg); }
.linkish { background: none; border: 0; font: inherit; text-align: left; width: 100%; cursor: pointer; padding: .45rem .6rem; }

.container { max-width: 960px; margin: 0 auto; padding: 1rem 1rem 3rem; }

/* Cards and layout */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.empty { text-align: center; color: var(--muted); }
.pagehead { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: .75rem; flex-wrap: wrap; }
.pagehead h1 { margin-bottom: .1rem; }
.sectionhead { display: flex; justify-content: space-between; align-items: center; margin: 1.5rem 0 .6rem; }
.sectionhead h2 { margin: 0; }
.back { display: inline-block; margin-bottom: .5rem; text-decoration: none; font-size: .9rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
  min-height: 44px; padding: .5rem 1rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--primary); }
.btn-small { min-height: 36px; padding: .3rem .75rem; font-size: .875rem; }
.btn-quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn-block { width: 100%; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.contact-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* Tags */
.tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: .1rem .45rem; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); vertical-align: middle; margin-left: .25rem; }
.tag-blue { background: var(--blue-bg); color: var(--primary); border-color: transparent; }
.tag-green { background: var(--green-bg); color: var(--green); border-color: transparent; }
.tag-muted { opacity: .8; }
.dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; margin-right: .35rem; vertical-align: middle; }

/* Messages */
.messages { display: grid; gap: .5rem; margin-bottom: 1rem; }
.msg { padding: .7rem 1rem; border-radius: 8px; background: var(--blue-bg); }
.msg-success { background: var(--green-bg); color: var(--green); }
.msg-error { background: var(--error-bg); color: var(--error); }
.callout { margin-top: .75rem; padding: .6rem .8rem; border-radius: 8px; background: var(--blue-bg); font-size: .925rem; }
.callout-warn { background: var(--warn-bg); border: 1px solid var(--warn-line); }

/* Search */
.searchbar { display: flex; gap: .5rem; margin-bottom: .5rem; flex-wrap: wrap; }
.searchbar input { flex: 1 1 240px; width: auto; }
.searchbar select { flex: 0 0 auto; width: auto; }

/* List rows */
.rows { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.rows li + li { border-top: 1px solid var(--line); }
.row { display: flex; justify-content: space-between; gap: 1rem; padding: .8rem 1rem; color: inherit; text-decoration: none; }
.row:hover { background: var(--bg); }
.row-main { min-width: 0; }
.row-side { text-align: right; white-space: nowrap; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; gap: .5rem; }

/* Facts */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem 1rem; margin: 0; }
.facts dt { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.facts dd { margin: 0; overflow-wrap: anywhere; }

/* Locations & equipment */
.location-head { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.location-actions { display: flex; gap: .4rem; }
.equipment-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .6rem; margin: .9rem 0; }
.equipment { display: grid; gap: .2rem; padding: .7rem .8rem; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; color: inherit; text-decoration: none; background: var(--surface); }
.equipment:hover { border-color: var(--muted); border-left-color: var(--accent); }
.equipment-retired { opacity: .6; border-left-color: var(--line); }
.equipment-title { display: flex; justify-content: space-between; align-items: center; gap: .4rem; }

/* Notes */
.noteform { display: grid; gap: .5rem; margin-bottom: 1rem; }
.noteform .btn { justify-self: start; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; }
.timeline li { border-left: 3px solid var(--line); padding-left: .75rem; }
.danger-zone { margin-top: 2rem; text-align: center; }

/* Forms */
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem 1rem; }
.field { display: grid; gap: .3rem; align-content: start; }
.field-wide { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: .9rem; }
.field-check label { display: flex; align-items: center; gap: .5rem; font-weight: 500; min-height: 44px; }
.req { color: var(--error); }
.help { color: var(--muted); font-size: .8rem; }
.error { color: var(--error); font-size: .85rem; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--error); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: .55rem .7rem; min-height: 44px; width: 100%;
}
input[type="checkbox"] { width: 1.25rem; height: 1.25rem; min-height: 0; accent-color: var(--primary); }
input[type="color"] { padding: .2rem; height: 44px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

.login { max-width: 380px; margin: 12vh auto 0; }
.login h1 { margin-bottom: 0; }
.login .fields { grid-template-columns: 1fr; margin: 1rem 0; }

@media (max-width: 600px) {
  h1 { font-size: 1.3rem; }
  .topbar { gap: .5rem; padding-left: .75rem; padding-right: .75rem; }
  .brand { max-width: 40vw; }
  .container { padding: .75rem .75rem 3rem; }
  .row-side .muted { display: none; }
  .searchbar input { flex-basis: 100%; }
  .searchbar select, .searchbar .btn { flex: 1; }
}

/* ---------- Phase 2: jobs ---------- */
:root {
  --st-unscheduled: #8a94a0; --st-scheduled: #1565c0; --st-on_the_way: #7b3fd1;
  --st-working: #d9730d; --st-completed: #1b7f4b; --st-canceled: #9aa3ad; --st-urgent: #c62828;
}
@media (prefers-color-scheme: dark) {
  :root { --st-scheduled: #4b9be8; --st-on_the_way: #a57ef0; --st-working: #f0a050; --st-completed: #5fd197; --st-urgent: #ff6b6b; }
}
.status { display: inline-block; font-size: .72rem; font-weight: 700; padding: .12rem .5rem; border-radius: 999px; color: #fff; vertical-align: middle; }
.status-unscheduled { background: var(--st-unscheduled); }
.status-scheduled { background: var(--st-scheduled); }
.status-on_the_way { background: var(--st-on_the_way); }
.status-working { background: var(--st-working); }
.status-completed { background: var(--st-completed); }
.status-canceled { background: var(--st-canceled); }
.status-urgent { background: var(--st-urgent); }
@media (prefers-color-scheme: dark) { .status { color: #0b1117; } }

.container-wide { max-width: 1500px; }
.twocol { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 1rem; }
.addr { margin: 0 0 .6rem; }
.daynav { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.daynav input[type="date"] { min-height: 36px; padding: .25rem .5rem; width: auto; }
.inlineform { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.inlineform select { flex: 1 1 220px; width: auto; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; }
.refrow { display: block; padding: .45rem 0; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.refrow:last-of-type { border-bottom: 0; margin-bottom: .6rem; }
.refrow:hover strong, .refrow:hover { color: var(--primary); }

/* Big tech buttons */
.jobactions { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.btn-big { min-height: 58px; font-size: 1.1rem; border-radius: 12px; }
.btn-green { background: var(--st-completed); border-color: var(--st-completed); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-green { color: #0b1117; } }
.officeactions { margin: -.25rem 0 1rem; }

/* Checkbox lists (techs, equipment) */
.field-checks > div, .checkgrid > div { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .25rem .75rem; }
.field-checks label, .checkgrid label { display: flex; align-items: center; gap: .5rem; font-weight: 500; min-height: 40px; }
.field-checks > label { min-height: 0; font-weight: 600; }

/* Checklists */
.checklist { display: grid; margin: .5rem 0; }
.cl-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .45rem 0; border-bottom: 1px solid var(--line); min-height: 48px; }
.cl-check { justify-content: flex-start; cursor: pointer; }
.cl-input { display: flex; align-items: center; gap: .4rem; flex: 0 0 auto; }
.cl-input input { width: 120px; min-height: 40px; text-align: right; }

/* Photos */
.photogrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.photogrid figure { margin: 0; }
.photogrid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; background: var(--bg); }
.photoform { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.photoform input[type="text"] { flex: 1 1 220px; width: auto; }
.filebtn { position: relative; overflow: hidden; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Signature */
.sigform { display: grid; gap: .5rem; margin-top: .5rem; }
.sigpad { width: 100%; height: 180px; background: #fff; border: 2px dashed var(--line); border-radius: 8px; touch-action: none; }
.signature-img { max-width: 360px; width: 100%; background: #fff; border-radius: 8px; border: 1px solid var(--line); }

/* My day */
.clockcard { display: flex; justify-content: space-between; align-items: center; gap: 1rem; border-left: 5px solid var(--st-unscheduled); }
.clockcard.clocked-in { border-left-color: var(--st-completed); }
.daycard { display: flex; gap: 1rem; background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--st-scheduled); border-radius: var(--radius); padding: .85rem 1rem; margin-bottom: .6rem; color: inherit; text-decoration: none; }
.daycard:hover { border-color: var(--muted); }
.daycard-time { display: grid; justify-items: center; align-content: start; min-width: 3.2rem; font-size: 1.15rem; }
.daycard-main { display: grid; gap: .15rem; min-width: 0; }
.status-edge-on_the_way { border-left-color: var(--st-on_the_way); }
.status-edge-working { border-left-color: var(--st-working); }
.status-edge-completed { border-left-color: var(--st-completed); opacity: .75; }

/* Tables */
.tablewrap { overflow-x: auto; padding: 0; }
.table { width: 100%; border-collapse: collapse; font-size: .925rem; }
.table th, .table td { padding: .6rem .75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: .8rem; color: var(--muted); font-weight: 600; }
.table .num { text-align: right; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }

/* Dispatch board */
.board { display: grid; grid-template-columns: 260px 1fr; gap: 1rem; align-items: start; }
.board-side { display: grid; gap: 1rem; position: sticky; top: 4.5rem; max-height: calc(100vh - 5.5rem); overflow-y: auto; }
.board-side h2 { font-size: .95rem; }
.dropzone { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: .75rem; }
.jobcard { display: block; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--st-unscheduled); border-radius: 8px; padding: .5rem .6rem; margin-bottom: .45rem; color: inherit; text-decoration: none; font-size: .9rem; cursor: grab; }
.jobcard-urgent { border-left-color: var(--st-urgent); }
.board-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.board-grid { display: grid; grid-template-columns: 56px repeat(var(--cols), minmax(150px, 1fr)); min-width: calc(56px + var(--cols) * 150px); }
.board-head { position: sticky; top: 0; z-index: 2; background: var(--surface); padding: .6rem .5rem; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); font-weight: 700; font-size: .9rem; display: flex; gap: .3rem; align-items: center; flex-wrap: wrap; }
.board-head a { margin-left: auto; font-weight: 400; }
.board-timehead { border-left: 0; }
.board-times { position: relative; }
.board-hour { position: absolute; right: .4rem; transform: translateY(-.55em); font-size: .72rem; color: var(--muted); }
.board-hour:first-child { transform: none; }
.board-col { position: relative; border-left: 1px solid var(--line); }
.board-line { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); opacity: .6; }
.board-col.dropping, .dropzone.dropping { background: var(--blue-bg); }
.jobblock { position: absolute; overflow: hidden; display: flex; flex-direction: column; gap: .05rem;
  padding: .3rem .45rem; border-radius: 6px; border: 1px solid var(--line); border-left: 5px solid; background: var(--blue-bg);
  color: var(--text); text-decoration: none; font-size: .78rem; line-height: 1.25; cursor: grab; box-shadow: var(--shadow); }
.jobblock:hover { z-index: 3; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.jobblock.dragging, .jobcard.dragging { opacity: .4; }
.jb-time { font-weight: 700; font-size: .72rem; }
.jb-sum, .jb-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jb-meta { color: var(--muted); font-size: .72rem; }
.status-bg-on_the_way { background: color-mix(in srgb, var(--st-on_the_way) 18%, var(--surface)); }
.status-bg-working { background: color-mix(in srgb, var(--st-working) 20%, var(--surface)); }
.status-bg-completed { background: color-mix(in srgb, var(--st-completed) 16%, var(--surface)); opacity: .8; }

@media (max-width: 900px) {
  .board { grid-template-columns: 1fr; }
  .board-side { position: static; max-height: none; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; }
  .mainnav { order: 3; width: 100%; margin-left: 0; overflow-x: auto; }
  .usermenu { margin-left: auto; }
  .board-side { grid-template-columns: 1fr; }
}
[id] { scroll-margin-top: 7rem; }
.cl-input .small { min-width: 1.6rem; }

/* ---------- Phase 3: estimates, invoices, payments ---------- */
.status-est-draft, .status-inv-draft { background: var(--st-unscheduled); }
.status-est-sent { background: var(--st-on_the_way); }
.status-est-approved, .status-inv-paid { background: var(--st-completed); }
.status-est-declined, .status-inv-void { background: var(--st-canceled); }
.status-inv-open { background: var(--st-working); }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs a { padding: .55rem .9rem; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 600; }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--primary); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.stat { display: grid; gap: .15rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; color: inherit; text-decoration: none; }
.stat strong { font-size: 1.35rem; }
.stat-warn { border-color: var(--st-urgent); }
.stat-warn strong { color: var(--st-urgent); }
.bigmoney { text-align: right; }
.bigmoney strong { font-size: 1.6rem; }
.callout-ok { border-left: 5px solid var(--st-completed); }

.lines { display: grid; }
.line { display: flex; justify-content: space-between; gap: .75rem; padding: .65rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.line-main { flex: 1 1 220px; min-width: 0; }
.line-edit, .line-ro { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.line-edit label { display: flex; align-items: center; gap: .3rem; color: var(--muted); }
.line-edit input { width: 5.5rem; min-height: 38px; padding: .3rem .5rem; text-align: right; }
.line-edit input[name="quantity"] { width: 4rem; }
.line-edit input[readonly] { background: var(--bg); color: var(--muted); }
.line-amount { min-width: 6rem; text-align: right; font-weight: 700; }
.totals { margin: .75rem 0 0 auto; max-width: 360px; display: grid; gap: .25rem; }
.totals div { display: flex; justify-content: space-between; gap: 1rem; }
.totals dt { color: var(--muted); font-size: .9rem; }
.totals dd { margin: 0; font-variant-numeric: tabular-nums; }
.totals .discount dd { color: var(--green); }
.totals .grand { border-top: 2px solid var(--line); padding-top: .35rem; font-weight: 800; font-size: 1.1rem; }
.totals .grand dt { color: var(--text); font-size: 1.1rem; }

.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 1rem; }
.option-chosen { border: 2px solid var(--st-completed); }
.picker { display: inline-block; }
.picker[open] { display: block; width: 100%; }
.picker > summary { list-style: none; }
.picker > summary::-webkit-details-marker { display: none; }
.picker-body { margin-top: .6rem; border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; max-height: 60vh; overflow-y: auto; background: var(--bg); }
.picker-body h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: .8rem 0 .3rem; }
.picker-item { display: flex; justify-content: space-between; gap: .75rem; width: 100%; text-align: left; padding: .55rem .7rem; margin-bottom: .3rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; color: var(--text); font: inherit; cursor: pointer; min-height: 44px; align-items: center; }
.picker-item:hover { border-color: var(--primary); }
.picker-item[hidden], .picker-cat[hidden] { display: none; }

.share-link { display: flex; gap: .5rem; margin-bottom: .6rem; }
.share-link input { flex: 1; font-size: .85rem; }
.qr { background: #fff; display: inline-block; padding: .5rem; border-radius: 8px; margin-top: .5rem; }
.qr svg { display: block; width: 220px; height: 220px; }
.qr-small svg { width: 170px; height: 170px; }
.collect { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.25rem; }
.collect h3 { margin: 0 0 .4rem; font-size: 1rem; }

/* Customer-facing pages */
.public-head { background: var(--brand); color: var(--brand-ink); padding: .9rem 0; }
.public-head .container { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding-top: 0; padding-bottom: 0; }
.public-head a { color: inherit; }
.public-brand { font-size: 1.15rem; }
.public-main { max-width: 820px; }
.doc-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: .5rem 0 1rem; }
.doc-lines { list-style: none; margin: .5rem 0 0; padding: 0; }
.doc-lines li { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.doc-lines li span { white-space: nowrap; font-weight: 600; }
.public-options .option { cursor: pointer; display: block; }
.public-options input[type="radio"] { width: 1.3rem; height: 1.3rem; min-height: 0; vertical-align: -3px; accent-color: var(--primary); margin-right: .3rem; }
.public-options .option:has(input:checked) { border: 2px solid var(--primary); }
.bigprice { font-size: 1.3rem; }
.paybox { text-align: center; }
.public-foot { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--line); display: grid; gap: .3rem; }
@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --muted: #444; --line: #ccc; color-scheme: light; }
  .noprint, .topbar, .messages { display: none !important; }
  .card { box-shadow: none; break-inside: avoid; }
  .public-head { background: none; color: #000; border-bottom: 2px solid #000; }
}
@media (max-width: 600px) {
  .line-edit { width: 100%; }
  .line-edit .line-amount { margin-left: auto; }
}

/* ---------- Phase 4: memberships and messages ---------- */
.status-mem-active { background: var(--st-completed); }
.status-mem-pending { background: var(--st-on_the_way); }
.status-mem-past_due { background: var(--st-urgent); }
.status-mem-canceled, .status-mem-expired { background: var(--st-canceled); }
.status-visit-done { background: var(--st-completed); }
.status-visit-scheduled { background: var(--st-scheduled); }
.status-visit-due { background: var(--st-working); }
.status-visit-overdue { background: var(--st-urgent); }
.status-visit-canceled { background: var(--st-canceled); }
.status-msg-sent { background: var(--st-completed); }
.status-msg-practice { background: var(--st-on_the_way); }
.status-msg-failed { background: var(--st-urgent); }
.status-msg-skipped { background: var(--st-canceled); }
.memberbadge { display: inline-block; margin: 0 0 .75rem; padding: .35rem .8rem; border-radius: 999px; font-weight: 700; font-size: .9rem; text-decoration: none; color: #fff; background: var(--st-completed); }
.status-mem-bg-pending { background: var(--st-on_the_way); }
.status-mem-bg-past_due { background: var(--st-urgent); }
.status-mem-bg-expired { background: var(--st-canceled); }
@media (prefers-color-scheme: dark) { .memberbadge { color: #0b1117; } }
.memberpitch { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; border-style: dashed; }
.callout-warn.card { border-left: 5px solid var(--st-working); }
.msgrow { border-bottom: 1px solid var(--line); padding: .5rem 0; }
.msgrow summary { cursor: pointer; }
.msgbody { padding: .5rem 0 .25rem 1rem; display: grid; gap: .3rem; overflow-wrap: anywhere; }
input[type="radio"] { width: 1.2rem; height: 1.2rem; min-height: 0; padding: 0; accent-color: var(--primary); flex: 0 0 auto; }
.field label:has(> input[type="radio"]) { display: flex; align-items: center; gap: .5rem; font-weight: 500; min-height: 40px; }

/* --- sign-up --- */
.signup { max-width: 520px; margin: 6vh auto 2rem; }
.signup h1 { margin-top: .25rem; }
.signup .fields { grid-template-columns: 1fr; margin: 1rem 0; }
.signup-brand { margin: 0; font-weight: 700; color: var(--primary); letter-spacing: .02em; }
.signup-wait { margin: .75rem 0 0; text-align: center; }
.signup .hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
/* --- imports --- */
.import-preview th, .import-preview td { white-space: nowrap; }
.import-map td { background: var(--bg); }
.import-map select { min-width: 150px; width: auto; }
.import-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.import-totals { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .3rem; }
.import-reasons { max-height: 22rem; overflow-y: auto; margin: 0 0 1rem; padding-left: 1.2rem; }
.import-example { margin-top: .75rem; }
.import-link { margin: -.25rem 0 .75rem; }
/* --- setup checklist --- */
.setup-banner { display: flex; justify-content: center; align-items: center; gap: .75rem; flex-wrap: wrap; padding: .45rem 1rem; background: var(--warn-bg); border-bottom: 1px solid var(--warn-line); font-size: .9rem; }
.setup-banner a { font-weight: 600; color: var(--text); }
.setup-banner form { margin: 0; }
.setup-banner .linkish { width: auto; padding: .2rem .5rem; color: var(--muted); font-size: .85rem; }
.msg-warning { background: var(--warn-bg); border: 1px solid var(--warn-line); margin-bottom: 1rem; }
.setup-progress { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.setup-progress progress { flex: 1; max-width: 320px; height: .7rem; accent-color: var(--green); }
.setup-steps { list-style: none; margin: 1rem 0 0; padding: 0; }
.setup-step-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.setup-step-head h2 { margin: 0 0 .4rem; font-size: 1.1rem; }
.setup-step.is-done { border-left: 5px solid var(--green); }
.setup-company { display: flex; align-items: center; gap: 1rem; margin-bottom: .5rem; }
.setup-logo { max-height: 64px; max-width: 160px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 4px; }
.setup-links { margin: .75rem 0 0; padding-left: 1.1rem; }
.setup-team { margin: 0 0 .5rem; padding-left: 1.1rem; }
.public-logo { height: 36px; max-width: 120px; object-fit: contain; vertical-align: middle; margin-right: .6rem; background: #fff; border-radius: 4px; padding: 2px; }
/* --- billing banner --- */
.billing-banner { display: flex; justify-content: center; align-items: center; gap: .75rem; flex-wrap: wrap; padding: .45rem 1rem; background: var(--blue-bg); border-bottom: 1px solid var(--line); font-size: .9rem; }
.billing-banner.is-locked { background: var(--error-bg); border-bottom-color: var(--error); }
.billing-banner a, .billing-banner span { font-weight: 600; color: var(--text); }
.billing-banner form { margin: 0; }
.billing-banner .linkish { width: auto; padding: .2rem .5rem; color: var(--muted); font-size: .85rem; }
/* --- read-only --- */
.read-only { max-width: 560px; border-left: 5px solid var(--warn-line); }
.read-only h1 { margin-top: 0; }
.staff-limit { border-left: 5px solid var(--warn-line); }
/* --- platform screen --- */
.pf-nav { display: flex; gap: 1rem; margin-bottom: .75rem; font-size: .9rem; }
.pf-summary .stat strong { font-size: 1.2rem; }
.pf-table td { white-space: nowrap; }
.pf-status { display: inline-block; font-size: .72rem; font-weight: 700; padding: .12rem .5rem; border-radius: 999px; color: #fff; vertical-align: middle; background: var(--st-canceled); }
.pf-status-trialing { background: var(--st-on_the_way); }
.pf-status-active { background: var(--st-completed); }
.pf-status-past_due { background: var(--st-urgent); }
.pf-status-comped { background: var(--st-scheduled); }
.pf-readonly { background: var(--warn-bg); border-color: var(--warn-line); color: var(--text); }
.pf-off { background: var(--error-bg); border-color: transparent; color: var(--error); }
.pf-facts { display: grid; grid-template-columns: minmax(140px, max-content) 1fr; gap: .35rem 1rem; margin: 0; }
.pf-facts dt { color: var(--muted); font-size: .9rem; }
.pf-facts dd { margin: 0; overflow-wrap: anywhere; }
.pf-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: .5rem 0; }
.pf-danger { background: var(--error); border-color: var(--error); color: #fff; }
.pf-danger-card { border-left: 5px solid var(--error); }
.pf-pad { padding: 1rem 1rem 0; }
.pf-notices { margin: 0; padding-left: 1.1rem; }
.pf-confirm { max-width: 640px; }
@media (max-width: 560px) { .pf-facts { grid-template-columns: 1fr; } .pf-facts dd { margin-bottom: .4rem; } }
/* --- plan billing --- */
.plan-price { margin: .25rem 0; }
.plan-status { font-weight: 600; }
.plan-status.is-readonly { color: var(--st-urgent); }
.plan-list { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.plan-card { margin-bottom: 0; display: flex; flex-direction: column; gap: .25rem; }
.plan-card p { margin: .25rem 0; }
.plan-card form { margin-top: auto; padding-top: .5rem; }
.plan-card.is-current { border-left: 5px solid var(--green); }
.plan-card-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.plan-card-head h3 { margin: 0; }
.plan-done { max-width: 560px; margin: 4vh auto; }
/* --- backups and costs --- */
.ops-panel { border-left: 5px solid var(--st-completed); }
.ops-panel.ops-warn { border-left-color: var(--st-urgent); }
.ops-panel h3 { font-size: 1rem; margin: .25rem 0; }
.ops-panel p { margin: .25rem 0; }
.ops-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.ops-warnings { margin: 0 0 .75rem; padding: .5rem .75rem .5rem 1.6rem; background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 6px; }
.ops-ok { background: var(--st-completed); color: #fff; }
.ops-bad { background: var(--error); color: #fff; }
.ops-loss { color: var(--error); font-weight: 600; }
.ops-tables summary { cursor: pointer; margin: .25rem 0; }
.ops-tables .table td { padding: .2rem .5rem; }
/* --- your data --- */
.yd-list { margin: .25rem 0 .75rem; padding-left: 1.2rem; }
.yd-list li { margin-bottom: .35rem; }
.yd-form { max-width: 480px; margin-top: .75rem; }
.yd-danger { border-left: 5px solid var(--error); }
.yd-danger-btn { background: var(--error); border-color: var(--error); color: #fff; }
.yd-pending { border-left: 5px solid var(--warn-line); background: var(--warn-bg); }
.yd-pending h2 { margin-top: 0; }

/* --- two-step login --- */
.twostep { max-width: 560px; }
.twostep .msg { margin-bottom: 1rem; }
.twostep-qr { width: 220px; max-width: 100%; margin: .75rem 0; background: #fff; padding: 4px; border-radius: 8px; }
.twostep-qr svg { display: block; width: 100%; height: auto; }
.twostep-manual summary { cursor: pointer; color: var(--primary); }
.twostep-secret { font-size: 1rem; letter-spacing: .05em; overflow-wrap: anywhere; user-select: all; }
.twostep-codes { columns: 2; column-gap: 2rem; margin: 0; padding-left: 1.5rem; font-size: 1.05rem; line-height: 1.9; }
.twostep-status { margin-top: .2rem; }
@media print {
  .topbar, .twostep-noprint, .messages, .setup-banner, .billing-banner { display: none !important; }
  .twostep-codes-card { border: 1px solid #000; box-shadow: none; }
}
/* --- activity log --- */
.act-filters { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: flex-end; margin-bottom: .75rem; }
.act-filters label { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--muted); flex: 1 1 150px; min-width: 0; }
.act-filters select, .act-filters input { width: 100%; }
.act-filter-buttons { display: flex; gap: .5rem; }
.act-list { list-style: none; margin: 0; padding: 0; }
.act-row { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; padding: .6rem .9rem; }
.act-history .act-row { padding: .5rem 0; }
.act-history .act-row + .act-row { border-top: 1px solid var(--line); }
.act-main { min-width: 0; overflow-wrap: anywhere; }
.act-details summary { cursor: pointer; color: var(--primary); margin-top: .2rem; }
.act-changes { border-collapse: collapse; margin-top: .35rem; width: 100%; }
.act-changes th, .act-changes td { text-align: left; padding: .2rem .5rem .2rem 0; vertical-align: top; border-top: 1px solid var(--line); }
.act-changes thead th { color: var(--muted); font-weight: 600; border-top: 0; }
.act-login_failed .tag, .act-delete .tag { color: var(--error); }

/* --- Orders (bakery / food) --- */
:root { --os-request: #d9730d; --os-quoted: #7b3fd1; --os-confirmed: #1565c0; --os-in_progress: #b8860b;
        --os-ready: #1b7f4b; --os-picked_up: #8a94a0; --os-canceled: #9aa3ad; }
@media (prefers-color-scheme: dark) {
  :root { --os-request: #f0a050; --os-quoted: #a57ef0; --os-confirmed: #4b9be8; --os-in_progress: #e0b84a; --os-ready: #5fd197; }
}
.ostatus-request { background: var(--os-request); }
.ostatus-quoted { background: var(--os-quoted); }
.ostatus-confirmed { background: var(--os-confirmed); }
.ostatus-in_progress { background: var(--os-in_progress); }
.ostatus-ready { background: var(--os-ready); }
.ostatus-picked_up { background: var(--os-picked_up); }
.ostatus-canceled { background: var(--os-canceled); }
[class*="ostatus-"].status, .status[class*="ostatus-"] { color: #fff; }
.nextstep { border-left: 5px solid var(--primary); }
.nextstep h2 { margin-top: 0; }
.quote { margin: .25rem 0 0; padding: .5rem .8rem; border-left: 3px solid var(--line); color: var(--muted); }
.inline { display: inline; }
.copyrow { display: flex; gap: .5rem; flex-wrap: wrap; }
.copyrow input { flex: 1 1 240px; min-width: 0; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.pickupweek { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.pickupday { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem; display: grid; gap: .45rem; align-content: start; min-height: 120px; }
.pickupday header { display: flex; justify-content: space-between; align-items: baseline; gap: .4rem; }
.pickupday.is-today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.pickupday.is-past { opacity: .7; }
.pickup { display: grid; gap: .1rem; padding: .45rem .55rem; border: 1px solid var(--line); border-left: 4px solid var(--os-confirmed); border-radius: 8px; color: inherit; text-decoration: none; }
.ostatus-edge-request { border-left-color: var(--os-request); }
.ostatus-edge-quoted { border-left-color: var(--os-quoted); }
.ostatus-edge-in_progress { border-left-color: var(--os-in_progress); }
.ostatus-edge-ready { border-left-color: var(--os-ready); }
.ostatus-edge-picked_up { border-left-color: var(--os-picked_up); opacity: .75; }
.addlink { text-decoration: none; }
.ordersteps { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem; padding: 0; margin: 0 0 1rem; counter-reset: step; }
.ordersteps li { font-size: .8rem; padding: .3rem .65rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.ordersteps li.done { background: var(--green-bg); color: var(--green); border-color: transparent; }
.ordersteps li.current { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); font-weight: 700; }
.showpast { display: none; margin-bottom: .6rem; }
@media (max-width: 640px) {
  .showpast { display: inline-flex; }
  .pickupweek:not(.show-past) .pickupday.is-past { display: none; }
}
