/* ShopFlow: iOS-inspired design (system font, grouped lists, frosted bars) in Velocity Motors red and black. */
:root {
  --bg: #f2f2f7; --panel: #fff; --ink: #1c1c1e; --muted: #6e6e73; --line: #e5e5ea; --fill: rgba(118, 118, 128, .12);
  --side: #0b0b0c; --side-ink: #d1d1d6; --accent: #e20b11; --accent-dark: #b8090e; --tint: rgba(226, 11, 17, .1); --silver: #b4b4b4;
  --good: #248a3d; --warn: #c45500; --bad: #d70015; --info: #0a6cd6;
  --radius: 14px; --radius-sm: 10px;
  --bar: rgba(249, 249, 251, .82); --hair: rgba(60, 60, 67, .18);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* The page is always exactly the screen's width: wide content wraps or scrolls inside its own box, never the page
   (so you can't zoom out or drag sideways into the black edge on a phone). */
html { overflow-x: hidden; overflow-x: clip; overscroll-behavior-x: none; }
body { max-width: 100%; overflow-x: clip; }

body { margin: 0; font: 15px/1.42 var(--font); color: var(--ink); background: var(--bg); display: flex; min-height: 100vh;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; -webkit-tap-highlight-color: transparent; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -.022em; line-height: 1.15; }
h2 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 12px; }
h3 { font-size: 12px; font-weight: 600; margin: 0 0 6px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.sub, .muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- sidebar (desktop) / drawer (phone) ---------- */
.sidebar { width: 236px; flex: none; background: var(--side); color: var(--side-ink); position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { color: #fff; padding: 22px 18px 18px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  border-bottom: 1px solid transparent; border-image: linear-gradient(90deg, transparent, #6d6d70, #d9d9dc, #6d6d70, transparent) 1; }
.brand-logo { width: 92px; height: 92px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px #2c2c2e, 0 8px 24px rgba(226, 11, 17, .22); }
#shop-name { font-weight: 700; font-size: 14px; letter-spacing: .04em; text-transform: uppercase; }
.sidebar nav { padding: 8px 10px 0; }
.sidebar nav a { display: block; color: var(--side-ink); padding: 8px 12px; border-radius: 8px; margin: 1px 0; font-weight: 500; }
.sidebar nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--accent); color: #fff; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #8e8e93; padding: 16px 12px 4px; }
.nav-me { margin: 18px 2px 20px; padding: 12px 10px 0; border-top: 1px solid #2c2c2e; font-size: 13px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#me { color: var(--side-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#me:hover { color: #fff; }
.nav-signout { background: rgba(255, 255, 255, .08); border: 0; color: #e5e5ea; border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.nav-signout:hover { background: var(--accent); color: #fff; }

/* ---------- page ---------- */
main { flex: 1; padding: 28px 32px 64px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .spacer { flex: 1; }
.loading { color: var(--muted); padding: 40px; text-align: center; }
.empty { color: var(--muted); padding: 28px 20px; text-align: center; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; background: var(--fill); color: var(--ink);
  border-radius: var(--radius-sm); padding: 8px 14px; min-height: 36px; font: inherit; font-weight: 600; letter-spacing: -.005em; cursor: pointer;
  white-space: nowrap; text-decoration: none !important; transition: background .15s, transform .1s; }
.btn:hover { background: rgba(118, 118, 128, .2); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--fill); }
.btn.sm { padding: 5px 10px; min-height: 30px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- cards, stats, pipeline ---------- */
.card { background: var(--panel); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border-radius: var(--radius); padding: 16px 18px; box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
.stat .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 13px; }
.pipeline { display: flex; gap: 10px; margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.pipeline::-webkit-scrollbar { display: none; }
.pipeline a { flex: 1; min-width: 132px; background: var(--panel); border-radius: var(--radius); padding: 14px 16px; color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
.pipeline a:hover { text-decoration: none; background: #fafafa; }
.pipeline .n { font-size: 28px; font-weight: 700; color: var(--accent); letter-spacing: -.02em; }
.pipeline .t { font-size: 12px; color: var(--muted); line-height: 1.3; }

/* ---------- lists ---------- */
.table-wrap { background: var(--panel); border-radius: var(--radius); overflow: auto; box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
table.list { width: 100%; border-collapse: collapse; background: var(--panel); }
table.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: #f7f7f9; }
.card table.list td, .card table.list th { padding-left: 0; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
dl.info { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.info dt { color: var(--muted); }
dl.info dd { margin: 0; }

/* ---------- badges & chips ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: rgba(120, 120, 128, .14); color: #48484a;
  text-transform: capitalize; white-space: nowrap; }
.badge.new, .badge.draft, .badge.scheduled, .badge.open { background: rgba(0, 122, 255, .12); color: #0058b8; }
.badge.sent, .badge.waiting_parts, .badge.partial { background: rgba(255, 149, 0, .16); color: #9a4d00; }
.badge.approved, .badge.ready, .badge.completed, .badge.paid, .badge.done { background: rgba(52, 199, 89, .16); color: #1c7a33; }
.badge.in_progress { background: rgba(255, 59, 48, .12); color: #c41e14; }
.badge.declined, .badge.void, .badge.overdue { background: rgba(255, 59, 48, .12); color: #c4001a; }
.badge.converted, .badge.invoiced, .badge.archived { background: rgba(120, 120, 128, .14); color: #48484a; }
.role-chip { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.chip-owner { background: #1c1c1e; color: #fff; }
.chip-admin { background: var(--tint); color: #a30a0e; }
.chip-team { background: rgba(120, 120, 128, .14); color: #48484a; }

/* ---------- segmented filters, tabs, search ---------- */
.tabs, .subnav, .seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 9px; background: rgba(118, 118, 128, .12); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar, .subnav::-webkit-scrollbar { display: none; }
.tabs, .subnav { margin-bottom: 14px; }
.tabs button, .subnav button, .seg button { border: 0; background: transparent; border-radius: 7px; padding: 6px 14px; font: inherit; font-size: 13px; font-weight: 500;
  color: var(--ink); cursor: pointer; white-space: nowrap; text-transform: capitalize; }
.tabs button.on, .subnav button.on, .seg button.on { background: #fff; font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 1px 1px rgba(0, 0, 0, .04); }
input.search { padding: 8px 12px 8px 34px; border: 0; border-radius: var(--radius-sm); font: inherit; min-width: 240px; background: rgba(118, 118, 128, .12)
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238e8e93' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M11 11l3.5 3.5'/%3E%3C/svg%3E") no-repeat 11px center; }
input.search:focus { outline: none; background-color: rgba(118, 118, 128, .18); }

/* ---------- workflow stepper ---------- */
.stepper { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.stepper::-webkit-scrollbar { display: none; }
.stepper .step { flex: 1; min-width: 104px; padding: 9px 12px; border-radius: 12px; background: #fff; font-size: 12px; color: var(--muted); box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
.stepper .step b { display: block; font-size: 13px; color: var(--ink); font-weight: 600; }
.stepper .step.done { background: #eaf7ee; }
.stepper .step.current { background: var(--tint); box-shadow: inset 0 0 0 1.5px var(--accent); }

/* ---------- forms & sheets ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .38); display: flex; align-items: flex-start; justify-content: center; padding: 7vh 16px; z-index: 50; overflow-y: auto;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); animation: fade .18s ease; }
.modal { background: #fff; border-radius: 16px; padding: 22px 24px; width: 100%; max-width: 640px; box-shadow: 0 24px 70px rgba(0, 0, 0, .25); animation: rise .22s cubic-bezier(.2, .8, .2, 1); }
.modal h2 { font-size: 19px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(16px); opacity: .6; } }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 500; }
.field.full { grid-column: 1 / -1; }
.field input, .field select, .field textarea, .inline-input { font: inherit; color: var(--ink); padding: 9px 12px; border: 1px solid #d1d1d6; border-radius: var(--radius-sm);
  background: #fff; width: 100%; min-height: 40px; transition: border-color .15s, box-shadow .15s; }
.field input:focus, .field select:focus, .field textarea:focus, .inline-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(226, 11, 17, .14); }
.field input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); }
.field textarea { resize: vertical; }
.field input[type=color] { height: 40px; padding: 4px; }
select.inline-input, .field select { -webkit-appearance: none; appearance: none; padding-right: 32px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%238e8e93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5l3 3 3-3'/%3E%3C/svg%3E") no-repeat right 12px center; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.vin-row { display: flex; gap: 6px; }
.vin-row input { flex: 1; min-width: 0; }

/* ---------- line items ---------- */
table.lines { width: 100%; border-collapse: collapse; }
table.lines th { font-size: 12px; color: var(--muted); font-weight: 500; text-align: left; padding: 6px; border-bottom: 1px solid var(--line); }
table.lines td { padding: 4px; border-bottom: 1px solid var(--line); }
table.lines input, table.lines select { font: inherit; padding: 6px 8px; border: 1px solid transparent; border-radius: 8px; width: 100%; background: transparent; }
table.lines input:hover, table.lines select:hover { border-color: var(--line); }
table.lines input:focus, table.lines select:focus { border-color: var(--accent); outline: none; background: #fff; box-shadow: 0 0 0 3px rgba(226, 11, 17, .12); }
table.lines input[type=checkbox] { accent-color: var(--accent); width: 18px; height: 18px; }
table.lines .kind-labor { color: var(--info); font-weight: 600; }
table.lines .kind-part { color: var(--good); font-weight: 600; }
table.lines .kind-discount { color: #c92a2a; font-weight: 600; }
.totals .disc span:last-child { color: #c92a2a; }
.totals { margin-left: auto; max-width: 320px; margin-top: 14px; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 18px; font-weight: 700; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
.add-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ---------- schedule ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(132px, 1fr)); gap: 8px; overflow-x: auto; }
.day { background: var(--panel); border-radius: var(--radius); min-height: 260px; padding: 10px; box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
.day.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.day h4 { margin: 0 0 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
.job { display: block; border-left: 3px solid var(--info); background: #f5f7fb; border-radius: 8px; padding: 7px 9px; margin-bottom: 6px; font-size: 12px; color: var(--ink); }
.job:hover { text-decoration: none; background: #eef2f9; }
.job.in_progress { border-left-color: var(--accent); }
.job.waiting_parts { border-left-color: #ff9500; }
.job.ready, .job.completed { border-left-color: #34c759; }
.job.invoiced { border-left-color: #c7c7cc; opacity: .7; }

/* ---------- inspection ---------- */
.insp-row { display: grid; grid-template-columns: minmax(180px, 1.2fr) auto 110px 1.5fr; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.insp-row:last-child { border-bottom: none; }
.seg button { padding: 5px 11px; font-size: 12px; color: var(--muted); }
.seg button.on.good { background: #34c759; color: #fff; }
.seg button.on.attention { background: #ff9500; color: #fff; }
.seg button.on.urgent { background: #ff3b30; color: #fff; }
.seg button.on.na { background: #8e8e93; color: #fff; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.dot.good { background: #34c759; } .dot.attention { background: #ff9500; } .dot.urgent { background: #ff3b30; } .dot.na { background: #c7c7cc; }

/* ---------- notices ---------- */
#toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 8px); background: rgba(28, 28, 30, .92); color: #fff; padding: 11px 18px; border-radius: 14px;
  font-weight: 500; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 99; max-width: calc(100vw - 32px); text-align: center;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); box-shadow: 0 8px 30px rgba(0, 0, 0, .2); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: rgba(215, 0, 21, .94); }
.warn { background: rgba(255, 149, 0, .12); color: #8a4500; border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; margin-top: 10px; }
.email-status { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: rgba(255, 149, 0, .12); color: #8a4500; margin-bottom: 12px; font-size: 13px; }
.email-status.on { background: rgba(52, 199, 89, .14); color: #1c7a33; }
.smtp-alt { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.smtp-alt summary { cursor: pointer; color: var(--muted); font-size: 13px; }

/* ---------- misc pages ---------- */
.activity { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: center; }
.act-sig { display: flex; gap: 14px; align-items: center; }
.act-sig img { max-height: 54px; max-width: 200px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 4px; }
.logo-row { display: flex; gap: 16px; align-items: center; margin-bottom: 14px; }
.logo-box { width: 200px; height: 90px; border: 1px dashed #d1d1d6; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; background: #fafafa; }
.logo-box img { max-width: 190px; max-height: 80px; object-fit: contain; }
.perm-table td:not(:first-child), .perm-table th:not(:first-child) { text-align: center; width: 120px; }
.perm-yes { color: #34c759; font-weight: 700; }
.perm-no { color: #c7c7cc; }

/* ---------- sign in ---------- */
body.auth-mode .sidebar, body.auth-mode main { display: none; }
body.booting .sidebar, body.booting main { visibility: hidden; }
.auth-bg { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: radial-gradient(circle at 50% 18%, #2b0809, #0b0b0c 62%); }
.auth-card { background: #fff; width: 100%; max-width: 380px; border-radius: 22px; padding: 30px 26px 24px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55); text-align: center; }
.auth-card .field { text-align: left; }
.auth-card h1 { font-size: 22px; }
.auth-card p { margin: 0 0 4px; font-size: 14px; }
.auth-logo { width: 104px; height: 104px; border-radius: 50%; object-fit: cover; margin: 0 auto 2px; }
.auth-go { min-height: 46px; font-size: 16px; border-radius: 12px; }
.auth-err { color: var(--bad); font-weight: 500; font-size: 13px; }
.auth-ok { color: var(--good); font-weight: 500; font-size: 13px; }
.auth-ok:empty, .auth-err:empty { display: none; }
.auth-links { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; flex-wrap: wrap; }

/* ---------- roles ---------- */
body.role-team .admin-only { display: none !important; }
body.role-team [data-del]:not(#lines [data-del]), body.role-team [data-delpay] { display: none !important; }

/* ---------- print view of work orders / inspections ---------- */
.print-page { background: #fff; max-width: 820px; margin: 0 auto; padding: 36px 40px; border-radius: var(--radius); }
.print-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid var(--ink); padding-bottom: 14px; margin-bottom: 18px; }
.print-head .shop { font-size: 20px; font-weight: 700; }
.print-head .doc { text-align: right; }
.print-head .doc .t { font-size: 22px; font-weight: 700; text-transform: uppercase; }
.print-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 18px; }
.print-page table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.print-page th { text-align: left; border-bottom: 1px solid var(--ink); padding: 5px 4px; font-size: 12px; }
.print-page td { padding: 5px 4px; border-bottom: 1px solid #eee; }
.sig { margin-top: 40px; display: flex; gap: 30px; }
.sig div { flex: 1; border-top: 1px solid var(--ink); padding-top: 4px; font-size: 12px; color: var(--muted); }
body.printing .sidebar { display: none; }
@media print {
  body { background: #fff; }
  .sidebar, .no-print, .mbar, .tabbar { display: none !important; }
  main { padding: 0; }
  .print-page { border: none; padding: 0; max-width: none; }
}

/* ---------- install tip, VIN scanner ---------- */
.install-tip { position: fixed; z-index: 60; left: 12px; right: 12px; bottom: calc(92px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .96); color: var(--ink);
  border-radius: 18px; padding: 16px 18px; box-shadow: 0 12px 40px rgba(0, 0, 0, .22); font-size: 15px; -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.install-tip .x { position: absolute; top: 8px; right: 10px; background: var(--fill); border: 0; color: var(--muted); width: 26px; height: 26px; border-radius: 50%; font-size: 16px; line-height: 1; }
.share-ico { display: inline-block; width: 17px; height: 17px; vertical-align: -3px; color: #007aff; }
.scan-overlay { position: fixed; inset: 0; z-index: 90; background: #000; display: flex; flex-direction: column; }
.scan-overlay video { flex: 1; width: 100%; object-fit: cover; }
.scan-frame { position: absolute; left: 8%; right: 8%; top: 38%; height: 18%; border: 3px solid #fff; border-radius: 14px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .4); pointer-events: none; }
.scan-bar { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; gap: 10px; align-items: center; background: linear-gradient(transparent, rgba(0, 0, 0, .85)); color: #fff; }
.scan-bar span { flex: 1; font-size: 15px; }
.scan-top { position: absolute; top: 0; left: 0; right: 0; padding: calc(env(safe-area-inset-top) + 16px) 16px 16px; color: #fff; text-align: center; font-weight: 600; font-size: 17px; background: linear-gradient(rgba(0, 0, 0, .7), transparent); }

/* ================= iPhone layout ================= */
.mbar, .tabbar, .scrim { display: none; }
@media (max-width: 800px) {
  /* The page itself is black so iPhone treats the top as dark: white clock, no light fog over the banner.
     Only the content area below the banner is light. */
  html, body { background: #0b0b0c; color-scheme: dark; }
  body { display: block; font-size: 16px; min-height: 100vh; }
  main { background: var(--bg); color-scheme: light; min-height: calc(100vh - 58px - env(safe-area-inset-top)); }
  .modal-bg, .install-tip, .tabbar, .auth-bg, .scan-overlay { color-scheme: light; }
  /* branded banner: black with a red glow, chrome wordmark, red racing stripe; runs up under the clock */
  .mbar { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; position: sticky; top: 0; z-index: 30; color: #fff;
    background: radial-gradient(130% 160% at 50% -30%, #3a0d0f 0%, #160708 38%, #0b0b0c 70%);
    padding: env(safe-area-inset-top) 6px 0; min-height: calc(58px + env(safe-area-inset-top)); transition: box-shadow .2s; }
  .mbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
    background: linear-gradient(90deg, transparent 0%, var(--accent) 18%, #ff5257 50%, var(--accent) 82%, transparent 100%); }
  body.scrolled .mbar { box-shadow: 0 8px 24px rgba(0, 0, 0, .28); }
  .mbar-menu { background: none; border: 0; color: #fff; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 12px; }
  .mbar-menu:active { background: rgba(255, 255, 255, .1); }
  .mbar-brand { display: flex; align-items: center; justify-content: center; gap: 10px; min-width: 0; color: #fff; text-decoration: none !important; padding: 6px 0 8px; }
  #mbar-logo { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex: none;
    box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .18), 0 3px 14px rgba(226, 11, 17, .45); }
  .mbar-words { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
  #mbar-shop { font-size: 17px; font-weight: 800; font-style: italic; letter-spacing: .07em; text-transform: uppercase; white-space: nowrap;
    background: linear-gradient(180deg, #ffffff 0%, #e6e6ea 45%, #a9a9b0 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
    text-shadow: 0 1px 0 rgba(0, 0, 0, .2); }
  #mbar-title { font-size: 10.5px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: #ff6b6f; margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mbar-me { justify-self: end; margin-right: 4px; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(180deg, #2c2c2e, #1c1c1e); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14); color: #fff; font-size: 13px; font-weight: 700;
    letter-spacing: .02em; text-decoration: none !important; }
  /* dark slide-out menu */
  .sidebar { position: fixed; z-index: 50; top: 0; left: 0; bottom: 0; width: 284px; height: auto; transform: translateX(-105%);
    transition: transform .28s cubic-bezier(.2, .8, .2, 1); padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 50px rgba(0, 0, 0, .45); }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .35); }
  .sidebar nav a { padding: 11px 14px; font-size: 16px; }
  .brand-logo { width: 76px; height: 76px; }
  /* frosted tab bar */
  .tabbar { display: flex; position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; background: var(--bar);
    -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-top: .5px solid var(--hair);
    padding: 4px 2px env(safe-area-inset-bottom); }
  .tabbar a, .tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; color: #8e8e93; background: none; border: 0;
    font: inherit; font-size: 10px; font-weight: 500; padding: 5px 0 6px; text-decoration: none !important; }
  .tabbar svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar svg circle[r="1.5"] { fill: currentColor; }
  .tabbar a.active { color: var(--accent); }
  body.auth-mode .mbar, body.auth-mode .tabbar, body.printing .mbar, body.printing .tabbar { display: none; }
  main { padding: 2px 16px calc(96px + env(safe-area-inset-bottom)); }
  /* iOS large title */
  main > .page-head { gap: 8px; margin-bottom: 16px; }
  main > .page-head h1 { width: 100%; font-size: 32px; font-weight: 700; letter-spacing: -.025em; margin: 4px 0 2px; }
  main > .page-head .badge { order: -1; }
  main > .page-head .spacer { display: none; }
  main > .page-head .sub { width: 100%; margin-top: -4px; }
  main > .page-head > .btn, main > .page-head > a.btn { flex: 1 1 auto; padding-left: 10px; padding-right: 10px; }
  main > .page-head > select.inline-input { flex: 1 1 100%; width: 100% !important; }
  /* controls: 44pt touch targets, 16px text (stops iPhone zooming into fields) */
  .btn { min-height: 44px; padding: 10px 16px; font-size: 16px; border-radius: 12px; }
  .btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
  input, select, textarea, .inline-input, input.search { font-size: 16px !important; }
  .field input, .field select, .field textarea, .inline-input { min-height: 46px; border-radius: 12px; }
  input.search { min-width: 0; width: 100%; min-height: 40px; }
  .form-grid { grid-template-columns: 1fr; }
  .grid.two, .grid.three { grid-template-columns: 1fr; gap: 0; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat .v { font-size: 22px; }
  .card { padding: 16px; border-radius: 14px; }
  .insp-row { grid-template-columns: 1fr; }
  .row-actions { flex-wrap: wrap; }
  .tabs, .subnav { display: flex; }
  /* bottom sheets */
  .modal-bg { padding: 0; align-items: flex-end; }
  .modal { max-width: 100% !important; border-radius: 16px 16px 0 0; max-height: calc(100vh - env(safe-area-inset-top) - 10px); overflow-y: auto; padding: 8px 18px calc(20px + env(safe-area-inset-bottom));
    animation: sheet .3s cubic-bezier(.2, .8, .2, 1); }
  .modal::before { content: ""; display: block; width: 36px; height: 5px; border-radius: 3px; background: #c7c7cc; margin: 4px auto 14px; }
  .modal-actions { position: sticky; bottom: calc(-20px - env(safe-area-inset-bottom)); background: #fff; padding: 12px 0 4px; margin-bottom: -4px; }
  .modal-actions .btn { flex: 1; }
  @keyframes sheet { from { transform: translateY(100%); } }
  /* tables become grouped lists with chevrons */
  .table-wrap { overflow: hidden; }
  table.list:not(.perm-table) thead { display: none; }
  table.list:not(.perm-table), table.list:not(.perm-table) tbody { display: block; }
  table.list:not(.perm-table) tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 12px 16px; border-bottom: .5px solid var(--line); position: relative; }
  table.list:not(.perm-table) tr:last-child { border-bottom: 0; }
  table.list:not(.perm-table) td { display: block; padding: 0; border: 0; font-size: 14px; color: var(--muted); }
  table.list:not(.perm-table) td:first-child { flex-basis: 100%; font-size: 16px; color: var(--ink); }
  table.list:not(.perm-table) td.num { margin-left: auto; color: var(--ink); font-weight: 600; }
  /* the row's amount sits top-right, like the date in Mail; any second amount is dropped on phones */
  table.list:not(.perm-table) td:not(.num) + td.num { position: absolute; top: 12px; right: 16px; font-size: 16px; }
  table.list:not(.perm-table) tr.click td:not(.num) + td.num { right: 34px; }
  table.list:not(.perm-table) td.num + td.num { display: none; }
  table.list:not(.perm-table) tr:has(td.num) td:first-child { padding-right: 104px; }
  .card table.list:not(.perm-table) td:not(.num) + td.num { right: 0; }
  .card table.list:not(.perm-table) tr.click td:not(.num) + td.num { right: 22px; }
  table.list:not(.perm-table) td:empty { display: none; }
  table.list:not(.perm-table) td .row-actions { margin-top: 6px; }
  table.list tr.click { padding-right: 34px !important; }
  table.list tr.click::after { content: ""; position: absolute; right: 16px; top: 50%; width: 8px; height: 8px; border-right: 2px solid #c7c7cc; border-top: 2px solid #c7c7cc;
    transform: translateY(-50%) rotate(45deg); }
  table.list tr.click:hover td { background: none; }
  table.list tr.click:active { background: #e9e9ee; }
  .card table.list:not(.perm-table) tr { padding-left: 0; padding-right: 0; }
  .card table.list tr.click { padding-right: 26px !important; }
  .card table.list tr.click::after { right: 4px; }
  dl.info { grid-template-columns: 1fr; gap: 0; }
  dl.info dt { font-size: 13px; margin-top: 10px; }
  dl.info dt:first-child { margin-top: 0; }
  .totals { max-width: none; }
  .stepper .step { min-width: 96px; }
  #toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
}

/* Line items become cards with labeled fields on phones and narrow windows. */
@media (max-width: 1100px) {
  table.lines thead { display: none; }
  table.lines, table.lines tbody { display: block; }
  table.lines tr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px 10px; padding: 12px; margin-bottom: 10px; background: #f7f7fa; border-radius: 14px; }
  table.lines td { padding: 0; border: 0; min-width: 0; }
  table.lines td:nth-child(2) { order: -1; grid-column: 1 / -1; }
  table.lines td:nth-child(n+3):nth-child(-n+7)::before, table.lines td:nth-child(1)::before { display: block; font-size: 11px; color: var(--muted); margin: 0 0 2px 2px; }
  table.lines td:nth-child(1)::before { content: "Type"; }
  table.lines td:nth-child(3)::before { content: "Part #"; }
  table.lines td:nth-child(4)::before { content: "Qty / hrs"; }
  table.lines td:nth-child(5)::before { content: "Price"; }
  table.lines td:nth-child(6)::before { content: "Cost"; }
  table.lines td:nth-child(7)::before { content: "Taxable"; }
  table.lines td:nth-child(7) { text-align: left !important; }
  table.lines td:nth-child(8) { grid-column: 1 / 3; align-self: center; text-align: left; font-weight: 700; font-size: 17px; }
  table.lines td:nth-child(9) { grid-column: 3; justify-self: end; align-self: center; }
  table.lines input, table.lines select { background: #fff; border: 1px solid #e0e0e5; border-radius: 10px; min-height: 40px; }
  table.lines td:nth-child(2) input { font-weight: 600; }
  table.lines tr:only-child td.empty { grid-column: 1 / -1; }
}

/* scanner controls stay visible on the black camera screen */
.scan-close { position: absolute; z-index: 2; top: calc(env(safe-area-inset-top) + 10px); left: 12px; display: flex; align-items: center; gap: 4px;
  background: rgba(255, 255, 255, .18); color: #fff; border: 0; border-radius: 99px; padding: 8px 14px; font: inherit; font-size: 16px; font-weight: 600;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.scan-top { padding-top: calc(env(safe-area-inset-top) + 58px); }
.scan-bar .btn { background: #fff; color: #1c1c1e; min-width: 110px; }
.req { color: var(--accent); font-style: normal; margin-left: 2px; }

@media (max-width: 800px) {
  /* schedule reads as a day-by-day agenda instead of seven tiny columns */
  .week { grid-template-columns: 1fr; gap: 10px; overflow: visible; }
  .day { min-height: 0; padding: 12px 14px; }
  .day h4 { font-size: 13px; margin-bottom: 6px; }
  .day:not(:has(.job))::after { content: "No jobs"; color: #aeaeb2; font-size: 14px; }
  .job { font-size: 14px; padding: 9px 11px; }
  /* the status picker already shows the status */
  main > .page-head > .badge { display: none; }
}
/* bottom tab icon with a count bubble (new requests) */
.tab-ico { position: relative; display: inline-flex; }
.tab-count { position: absolute; top: -4px; right: -10px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent);
  color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px #f9f9fb; }

/* color picker + specs */
.modal-bg.over { z-index: 70; }
.cdot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; margin-right: 7px; vertical-align: -2px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .18); flex: none; }
.cdot.big { width: 26px; height: 26px; margin: 0; align-self: center; }
.cdot.empty { background: repeating-conic-gradient(#e5e5ea 0 25%, #fff 0 50%) 50% / 10px 10px !important; }
.sw-group { margin: 14px 0 8px; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; }
.swatch { display: flex; align-items: center; text-align: left; background: #f5f5f7; border: 1px solid transparent; border-radius: 10px; padding: 9px 10px; font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; }
.swatch:hover, .swatch:active { border-color: var(--accent); background: #fff; }
.swatch .cdot { width: 20px; height: 20px; }
.spec-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 6px 24px; }
.spec-group h3 { margin: 10px 0 6px; color: var(--accent); }
.spec-group dl.info { grid-template-columns: max-content 1fr; }
@media (max-width: 800px) {
  .swatches { grid-template-columns: 1fr 1fr; }
  .spec-group dl.info { grid-template-columns: 1fr 1fr; gap: 4px 12px; }
  .spec-group dl.info dt { margin-top: 0; }
}

/* review request line on invoices */
.review-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -4px 0 12px; font-size: 14px; }
.review-line .muted { flex: 1 1 200px; }

/* labor / part picker: the list scrolls on its own on a computer; on a phone the whole sheet scrolls
   and the search + tabs stay pinned at the top */
.pick-list { max-height: 50vh; overflow-y: auto; }
@media (max-width: 800px) {
  .pick-list { max-height: none; overflow: visible; }
  .pick-head { position: sticky; top: -8px; z-index: 2; background: #fff; margin: 0 -18px; padding: 8px 18px 8px; }
  .pick-head .page-head { flex-wrap: wrap; }
  .pick-head .search { width: 100%; }
}
@media (max-width: 800px) {
  /* several buttons in a sheet's footer wrap onto two rows instead of running off the screen */
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1 1 40%; min-width: 0; white-space: normal; }
  .modal-actions .spacer { display: none; }
}
@media (max-width: 800px) {
  .pick-list td.num br, .pick-list td.num .muted { display: none; }
}

/* Face ID sign-in */
.auth-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 2px 0; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.auth-bg.lock { z-index: 90; }

/* service info quick links + torque tables */
.svc-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.svc-link { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: #f5f5f7; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 14px; }
.svc-link:hover { background: #ececf0; }
.svc-link span { font-size: 18px; }
.torque-edit { width: 100%; border-collapse: collapse; }
.torque-edit th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 0 4px 4px; }
.torque-edit td { padding: 3px 4px; }
.torque-edit input { width: 100%; }
@media (max-width: 800px) {
  .torque-edit thead { display: none; }
  .torque-edit tr { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .torque-edit td { padding: 0; }
  .torque-edit td:first-child { grid-column: 1 / -1; }
}
@media (max-width: 800px) { .svc-links { grid-template-columns: 1fr 1fr; } .svc-link { font-size: 13px; padding: 10px; } }

/* AI spec finder */
.ai-box { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.ai-wait { display: flex; align-items: center; gap: 10px; color: var(--muted); margin-top: 12px; font-size: 14px; }
.ai-wait .spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.ai-err { color: #c92a2a; margin: 12px 0 0; }
.ai-answer, .ai-review { margin-top: 12px; background: #f7f7fa; border-radius: 12px; padding: 12px 14px; }
.ai-q { font-weight: 700; margin-bottom: 6px; }
.ai-sources { margin-top: 8px; font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.ai-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.ai-row { display: grid; grid-template-columns: auto 1.2fr 1fr auto; gap: 6px 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.ai-row input[type=checkbox] { width: 20px; height: 20px; margin: 0; }
.ai-src { font-size: 12px; white-space: nowrap; }
.ai-note { grid-column: 2 / -1; font-size: 12px; color: var(--muted); }
@media (max-width: 800px) {
  .ai-row { grid-template-columns: auto 1fr auto; }
  .ai-row .inline-input { grid-column: 2 / 3; }
}

/* AI assistant bubble */
#ai-fab { position: fixed; right: 20px; bottom: 20px; z-index: 60; width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
  background: radial-gradient(circle at 30% 25%, #ff5257, var(--accent, #e20b11) 55%, #9d070b); color: #fff; font-size: 24px;
  box-shadow: 0 8px 24px rgba(226, 11, 17, .35), 0 2px 6px rgba(0, 0, 0, .2); display: grid; place-items: center; transition: transform .15s; }
#ai-fab:hover { transform: scale(1.06); }
#ai-fab.open { transform: rotate(-12deg) scale(.94); }
#ai-panel { position: fixed; right: 20px; bottom: 88px; z-index: 61; width: 380px; max-width: calc(100vw - 32px); height: min(560px, calc(100vh - 120px));
  background: #fff; border-radius: 18px; box-shadow: 0 24px 70px rgba(0, 0, 0, .28); display: flex; flex-direction: column; overflow: hidden; }
.ai-panel-head { display: flex; align-items: center; gap: 6px; padding: 12px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.ai-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.ai-msg { max-width: 88%; padding: 9px 12px; border-radius: 16px; font-size: 15px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.ai-msg.user { align-self: flex-end; background: var(--accent, #e20b11); color: #fff; border-bottom-right-radius: 5px; }
.ai-msg.assistant { align-self: flex-start; background: #f0f0f3; color: var(--ink); border-bottom-left-radius: 5px; }
.ai-msg.error { align-self: flex-start; background: #fff0f0; color: #c92a2a; }
.ai-msg a { color: var(--accent, #e20b11); font-weight: 600; }
.ai-hello { color: var(--muted); font-size: 14px; line-height: 1.5; }
.ai-examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ai-chip { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 11px; font: inherit; font-size: 13px; color: var(--ink); cursor: pointer; }
.ai-typing { display: flex; gap: 4px; padding: 13px 14px; }
.ai-typing span { width: 7px; height: 7px; border-radius: 50%; background: #a1a1aa; animation: blink 1.2s infinite; }
.ai-typing span:nth-child(2) { animation-delay: .2s; } .ai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.ai-input { display: flex; gap: 8px; padding: 10px 12px 6px; border-top: 1px solid var(--line); align-items: flex-end; }
.ai-input textarea { flex: 1; resize: none; font: inherit; font-size: 16px; border: 1px solid #d1d1d6; border-radius: 18px; padding: 9px 14px; max-height: 120px; }
.ai-fine { margin: 0; padding: 0 14px 10px; font-size: 11px; color: var(--muted); }
body.auth-mode #ai-fab, body.auth-mode #ai-panel, body.printing #ai-fab, body.printing #ai-panel { display: none; }
@media (max-width: 800px) {
  #ai-fab { right: 16px; bottom: calc(env(safe-area-inset-bottom) + 72px); width: 52px; height: 52px; }
  #ai-panel { right: 0; left: 0; bottom: 0; width: auto; max-width: none; height: calc(100% - env(safe-area-inset-top) - 40px);
    border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); z-index: 62; }
  #ai-fab.open { display: none; }
}
@media print { #ai-fab, #ai-panel { display: none !important; } }

/* Grow */
.grow-setup { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; color: var(--muted); }
.grow-setup .ok { color: #2f9e44; font-weight: 600; }
.plan-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.plan-item:last-child { border-bottom: 0; }
.plan-item input { width: 20px; height: 20px; margin-top: 2px; flex: none; }
.plan-item.done b { text-decoration: line-through; color: var(--muted); }
.auto-row { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.auto-row:last-child { border-bottom: 0; }
.auto-who { margin-top: 6px; font-size: 13px; background: #f7f7fa; border-radius: 8px; padding: 6px 10px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #d1d1d6; border-radius: 99px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 26px; height: 26px; left: 2px; top: 2px; background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: .2s; }
.switch input:checked + span { background: #34c759; }
.switch input:checked + span::before { transform: translateX(20px); }
.post { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: 10px; }
.post.posted { opacity: .7; }
.post-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.post-body { white-space: pre-wrap; font-size: 14px; line-height: 1.5; }
.due { color: #c92a2a; font-weight: 600; }

/* Preview / PDF pages on a phone: full screen like the Camera or FaceTime. The document runs edge to edge (it
   only starts below the Dynamic Island), a soft shade keeps the clock readable, and Back / Send / Print float at
   the bottom where your thumb is. Nothing interactive sits near the island. None of this prints. */
@media (max-width: 800px) {
  body.printing main { padding: calc(env(safe-area-inset-top) + 6px) 10px calc(env(safe-area-inset-bottom) + 92px); min-height: 100vh; }
  body.printing::before { content: ""; position: fixed; top: 0; left: 0; right: 0; height: calc(env(safe-area-inset-top) + 14px); z-index: 24;
    pointer-events: none; background: linear-gradient(rgba(11, 11, 12, .72), rgba(11, 11, 12, 0)); }
  body.printing main > .page-head.no-print { position: fixed; z-index: 40; left: 12px; right: 12px; top: auto;
    bottom: calc(env(safe-area-inset-bottom) + 10px); max-width: none !important; margin: 0 !important; padding: 6px; gap: 6px;
    flex-wrap: nowrap; border-radius: 999px; background: rgba(28, 28, 30, .86);
    -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
  body.printing main > .page-head.no-print > .spacer { display: none; }
  body.printing main > .page-head.no-print > .btn { flex: 1 1 auto; min-width: 0; min-height: 44px; padding: 10px 8px; border-radius: 999px;
    font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body.printing main > .page-head.no-print > .btn:not(.primary) { background: rgba(255, 255, 255, .14); color: #fff; }
}
@media print { body.printing::before { display: none; } }


/* Full screen on the phone (planned around the clock, Dynamic Island and home bar, like Apple's own apps):
   - the branded banner is the top of the page and scrolls away with it, so content gets the whole screen
   - menu and account are small floating glass buttons just below the island, always reachable
   - a soft shade keeps the clock readable when content scrolls under it
   - the tab bar floats as a rounded glass bar above the home bar */
@media (max-width: 800px) {
  .mbar { position: relative; top: auto; z-index: 1; padding-top: calc(env(safe-area-inset-top) + 18px); min-height: calc(76px + env(safe-area-inset-top)); }
  .mbar-brand { grid-column: 2; }
  body.scrolled .mbar { box-shadow: none; }
  .mbar-menu, .mbar-me { position: fixed; z-index: 36; top: calc(env(safe-area-inset-top) + 27px);
    width: 40px; height: 40px; border-radius: 50%; color: #fff;
    background: rgba(28, 28, 30, .55); -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
    box-shadow: inset 0 0 0 .5px rgba(255, 255, 255, .22), 0 4px 14px rgba(0, 0, 0, .18); }
  .mbar-menu { left: 12px; }
  .mbar-me { right: 12px; margin: 0; }
  .mbar-menu:active, .mbar-me:active { transform: scale(.94); }
  body::before { content: ""; position: fixed; z-index: 35; top: 0; left: 0; right: 0; height: calc(env(safe-area-inset-top) + 12px);
    pointer-events: none; background: linear-gradient(rgba(11, 11, 12, .6), rgba(11, 11, 12, 0)); opacity: 0; transition: opacity .2s; }
  body.scrolled::before { opacity: 1; }  /* only once you've scrolled: at the top, the dark banner already keeps the clock readable */
  body.auth-mode::before { display: none; }
  body.auth-mode .mbar-menu, body.auth-mode .mbar-me, body.printing .mbar-menu, body.printing .mbar-me { display: none; }
  .tabbar { left: 12px; right: 12px; bottom: max(8px, calc(env(safe-area-inset-bottom) - 10px)); border-top: 0; border-radius: 30px;
    padding: 4px 6px; background: rgba(255, 255, 255, .78); -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .14), inset 0 0 0 .5px rgba(0, 0, 0, .06); }
  .tabbar a, .tabbar button { padding: 6px 0 5px; border-radius: 24px; }
  .tabbar a.active { background: rgba(226, 11, 17, .08); }
  main { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
  #ai-fab { bottom: calc(env(safe-area-inset-bottom) + 84px); }
}

/* Your numbers (custom KPIs) */
.kpi-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kpi-row select { width: auto; }
.kpi-now { font-size: 13px; }
.kpi-moves { display: flex; gap: 2px; }
.kpi-add { display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 800px) { .kpi-row { grid-template-columns: 1fr auto; } .kpi-row .kpi-name { grid-column: 1 / -1; } }
/* Expenses */
.month-nav { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 0 0 14px; font-size: 16px; }
.receipt-box { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; padding: 12px; border: 1px dashed #c7c7cc; border-radius: 12px; }
.receipt-preview img { max-width: 100%; max-height: 240px; border-radius: 8px; display: block; }
.receipt-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.receipt-actions label.btn { cursor: pointer; }
/* keep the AI bubble off open sheets and forms */
body:has(> .modal-bg) #ai-fab { display: none !important; }
/* Communication history */
details.comm { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
details.comm > summary { cursor: pointer; font-weight: 600; }
.comm-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.comm-list li { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.comm-ico { width: 24px; flex: 0 0 24px; text-align: center; }
.comm-list .muted { font-size: 12.5px; }
.comm-msg { margin-top: 4px; }
.comm-msg > summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.comm-msg > div { white-space: pre-wrap; background: #f4f5f7; border-radius: 8px; padding: 8px 10px; margin-top: 4px; font-size: 13px; }
/* AI-drafted estimate */
.ai-draft-note { background: #fff7e6; border: 1px solid #f3d38b; color: #6b4a00; border-radius: 12px; padding: 10px 14px; margin: 0 0 14px; font-size: 14px; }
/* Long text in the customer activity card wraps instead of running past the edge */
.activity > div, .act-sig > div { min-width: 0; overflow-wrap: anywhere; }
.badge.sig-changed { white-space: normal; text-transform: none; display: inline; line-height: 1.6; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.comm-list li > div { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 800px) { .act-sig { flex-wrap: wrap; } }
/* Saved document copies */
.archive-bar { max-width: 860px; margin: 0 auto 14px; display: flex; flex-direction: column; gap: 10px; }
.archive-note { background: #eef4ff; border: 1px solid #c9dafb; color: #1d3a6b; border-radius: 12px; padding: 10px 14px; font-size: 14px; }
.archive-versions { margin-top: 6px; font-size: 13px; }
.appt-copy .comm-msg-body, .comm-msg-body { white-space: pre-wrap; background: #f4f5f7; border-radius: 8px; padding: 10px 12px; font-size: 14px; }
/* Appointment card on a job */
#appt .card { margin-bottom: 16px; }
.appt-status { margin-top: 10px; font-size: 14px; }

/* iPhone draws date and time boxes at their own width; make them fit the form like every other box */
.field { min-width: 0; }
.field input[type=date], .field input[type=time], .field input[type=datetime-local] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%; text-align: left; }
.field input::-webkit-date-and-time-value { text-align: left; margin: 0; }

/* address search-as-you-type */
.addr-wrap { position: relative; }
.addr-list { position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid #d1d1d6; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .14); overflow: hidden; }
.addr-list button { display: flex; gap: 8px; width: 100%; text-align: left; padding: 11px 12px; border: 0; border-top: 1px solid #eee; background: none;
  font: inherit; font-size: 15px; color: var(--ink); cursor: pointer; }
.addr-list button:first-child { border-top: 0; }
.addr-list button:hover, .addr-list button:focus { background: #f4f4f6; }
