:root {
  --primary: #37474F; --primary-ink: #263238; --accent: #BF5B3C;
  --green: #2E7D32; --amber: #F9A825; --red: #C62828; --grey: #78909C;
  --bg: #f4f6f7; --card: #ffffff; --ink: #1d2529; --muted: #5b6770; --line: #d9e0e4;
  --bar: #37474F; --on-primary: #ffffff; --warn-bg: #fff4e5; --warn-ink: #6b3d12; --danger: #b3261e;
  --chip: #e3e9ec; --chip-ink: #263238; --focus: #BF5B3C;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #90a4ae; --primary-ink: #cfd8dc; --accent: #e08a6c; --bar: #263238; --on-primary: #ffffff;
    --bg: #0f1416; --card: #1a2126; --ink: #e6ebee; --muted: #a2adb4; --line: #2c373e;
    --warn-bg: #3a2a12; --warn-ink: #ffd9a8; --danger: #ff8a80; --chip: #2a353c; --chip-ink: #dfe6ea; --focus: #e08a6c;
    --amber: #ffc83d; --green: #4caf50; --red: #ef5350;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); overflow-x: hidden; }
a { color: var(--primary); }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bar); color: #fff; }
.topbar h1 { margin: 0; font-size: 20px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { min-width: 44px; min-height: 44px; margin-left: -10px; border: 0; background: none; color: #fff; font-size: 34px; line-height: 1; cursor: pointer; }
main { max-width: 720px; margin: 0 auto; padding: 16px; outline: none; }
main:focus-visible { outline: none; }   /* main only takes focus from script after a route change */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 60px; min-width: 44px; color: var(--muted); text-decoration: none; font-size: 11px; }
.tabs a svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current="page"] { color: var(--accent); font-weight: 650; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 22px 4px 8px; }
h2:first-child { margin-top: 4px; }
h3 { font-size: 18px; margin: 0 0 6px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; overflow-wrap: anywhere; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin-bottom: 10px; }
.row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 16px; border-top: 1px solid var(--line);
  color: inherit; text-decoration: none; }
.row:first-child { border-top: 0; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 600; }
.row .sub { color: var(--muted); font-size: 15px; }
a.row::after { content: "\203A"; color: var(--muted); font-size: 24px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 13px; background: var(--chip); color: var(--chip-ink); margin: 2px 4px 2px 0; }
.badge.overdue { background: #fde3e1; color: #8c1d18; }
.badge.accent { background: var(--accent); color: #fff; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.notice { background: var(--warn-bg); color: var(--warn-ink); border-radius: 12px; padding: 12px 14px; font-size: 15px; margin: 10px 0; }
.notice a { color: inherit; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--bar); border-color: var(--bar); color: var(--on-primary); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; margin-top: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.btnrow .btn { flex: 1 1 auto; }
label { display: block; font-weight: 600; margin: 12px 0 4px; }
input, select, textarea { width: 100%; min-width: 0; max-width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font: inherit; }
textarea { min-height: 84px; resize: vertical; }
input[type=file] { padding: 8px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 8px 0; min-height: 44px; padding: 6px 0; cursor: pointer; }
.check input { width: 24px; min-height: 24px; height: 24px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.check .stamp { display: block; font-size: 13px; color: var(--muted); }
.counter { text-align: right; font-size: 13px; color: var(--muted); }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 10px; }
.two > div { min-width: 0; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin: 8px 0; }
.photo { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--line); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo button { position: absolute; width: 44px; height: 44px; border-radius: 50%; border: 0; top: 0; right: 0;
  background: rgba(0,0,0,.55); color: #fff; font-size: 20px; cursor: pointer; }
.photo button.cap { right: auto; left: 0; font-size: 16px; }
.photo .caption { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 6px; font-size: 12px; color: #fff; background: rgba(0,0,0,.55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty .big { font-size: 44px; color: var(--primary); }
dialog { width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain; border: 0; border-radius: 16px; padding: 0; background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { padding: 18px 18px 14px; }
.seg { display: flex; gap: 8px; }
.seg label { flex: 1; margin: 0; position: relative; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 48px; border: 1px solid var(--line); border-radius: 12px; font-weight: 600; cursor: pointer; text-align: center; padding: 0 6px; }
.seg input:checked + span { border-color: var(--accent); background: var(--chip); color: var(--ink); }
.seg input:focus-visible + span { outline: 2px solid var(--focus); }
.footer-note { font-size: 13px; color: var(--muted); margin: 14px 4px; }
details summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.source { font-size: 13px; color: var(--muted); margin-top: 6px; }
.light { display: flex; align-items: flex-start; gap: 12px; margin: 10px 0; }
.light .dot { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(0,0,0,.15); margin-top: 2px; }
.light.green .dot { background: var(--green); } .light.amber .dot { background: var(--amber); } .light.red .dot { background: var(--red); } .light.unknown .dot { background: var(--grey); }
.light .name { font-weight: 700; text-transform: uppercase; letter-spacing: .04em; font-size: 14px; }
.light.green .name { color: var(--green); } .light.amber .name { color: #8a5a00; } .light.red .name { color: var(--red); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .light.amber .name { color: var(--amber); } }
.life { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.life div { background: var(--bg); border-radius: 10px; padding: 10px; }
.life .num { font-size: 22px; font-weight: 700; }
.clock { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--line); }
.clock:first-of-type { border-top: 0; }
.clock .days { font-weight: 700; white-space: nowrap; }
.clock .days.past { color: var(--danger); }
.hint { font-size: 14px; color: var(--muted); margin: 2px 0 0; }
/* v0.2: storm marks, quotes, readiness, roof packet */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 6px; }
.chip { min-height: 44px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; }
.chip[aria-pressed="true"] { border: 2px solid var(--accent); background: var(--chip); color: var(--chip-ink); font-weight: 650; }
.chip[aria-pressed="true"]::before { content: "\2713\00a0"; }
.daterow { display: flex; gap: 8px; align-items: center; }
.daterow input { flex: 1; }
/* Every quote flag looks the same on purpose: flags point at a line to read, they never rank a quote. */
.flag { display: block; width: fit-content; max-width: 100%; margin-top: 4px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font-size: 13px; }
.cmp-wide { display: none; overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 10px; }
.cmp { width: 100%; border-collapse: collapse; font-size: 15px; }
.cmp th, .cmp td { text-align: left; vertical-align: top; padding: 8px 10px; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.cmp thead th { border-top: 0; }
.cmp tbody th { font-weight: 600; font-size: 13px; color: var(--muted); width: 24%; }
.cmp-list { margin: 0; }
.cmp-list > div { padding: 8px 0; border-top: 1px solid var(--line); }
.cmp-list dt { font-size: 13px; color: var(--muted); }
.cmp-list dd { margin: 0; }
@media (min-width: 640px) { .cmp-wide { display: block; } .cmp-narrow { display: none; } }
.ready-line { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 0; border-top: 1px solid var(--line); }
.ready-line .mark { flex: none; width: 24px; text-align: center; font-size: 20px; }
.ready-line .main { flex: 1; min-width: 0; }
.packet header { margin-bottom: 6px; }
.packet section { margin-top: 14px; }
.packet h2 { margin: 0 0 6px; }
.packet h3 { font-size: 16px; margin: 10px 0 4px; }
.packet header h3 { font-size: 20px; margin: 0 0 4px; }
.packet ul { margin: 4px 0; padding-left: 20px; }
.packet footer { margin-top: 18px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 14px; font-weight: 600; }
.kv { margin: 0; }
.kv > div { display: grid; grid-template-columns: minmax(0, 10em) minmax(0, 1fr); gap: 2px 12px; padding: 4px 0; }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { margin: 0; }
@media (max-width: 420px) { .kv > div { grid-template-columns: minmax(0, 1fr); } }
.pitem { margin: 8px 0; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; margin: 8px 0; }
.pfig { margin: 0; break-inside: avoid; }
.pfig img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: var(--line); }
.pfig figcaption { font-size: 13px; color: var(--muted); margin-top: 2px; }
.task { scroll-margin-top: 72px; }
.matrow { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.matrow:first-child { border-top: 0; padding-top: 0; }
.matrow input[data-mat="text"] { grid-column: 1 / -1; }
/* v0.3: quote-request message preview, numbered steps */
.msg { margin: 4px 0 0; font: inherit; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.steps { margin: 6px 0; padding-left: 22px; }
.steps li { margin: 3px 0; }
/* v0.4: dashboard tiles, thin progress bars (a count, never a score), job steps, record counts, choice sheets */
.tiles { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-bottom: 10px; }
.tile { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 4px; min-width: 0; min-height: 96px; padding: 12px;
  border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; text-align: left; text-decoration: none; cursor: pointer; overflow-wrap: anywhere; }
.tile .tile-label { font-weight: 650; font-size: 16px; line-height: 1.25; }
.tile .tile-sub { font-size: 13px; color: var(--muted); line-height: 1.3; }
.tile.lead { grid-column: 1 / -1; min-height: 64px; background: var(--bar); border-color: var(--bar); color: var(--on-primary); }
.tile.lead .tile-sub { color: rgba(255, 255, 255, .85); }
.tiles > .tile:last-child:nth-child(even) { grid-column: 1 / -1; min-height: 64px; }
.bar { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; margin: 6px 0; }
.bar span { display: block; height: 100%; background: var(--primary); border-radius: inherit; }
.row .bar { max-width: 260px; }
.step { border-top: 1px solid var(--line); }
.bar + .step { margin-top: 8px; }
.step-line { display: flex; align-items: center; gap: 8px; }
.step-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 0; border: 0; background: none;
  color: inherit; font: inherit; text-align: left; cursor: pointer; }
.step-main .mark { flex: none; width: 24px; text-align: center; font-size: 20px; }
.step-main .main { flex: 1; min-width: 0; }
.step[data-state="done"] .step-main .main { color: var(--muted); }
.step[data-next="true"] .step-main .main { font-weight: 650; }
.step-skipped { display: block; }
.btn.slim { flex: none; padding: 0 12px; font-size: 14px; }
.step-next { padding: 0 0 12px 34px; }
.step-next .hint { margin: 0; }
.step-next .btnrow { margin-top: 6px; }
.counts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.count { flex: 1 1 58px; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 64px; padding: 8px 3px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: inherit; text-decoration: none; text-align: center; }
.count .num { font-weight: 700; font-size: 17px; white-space: nowrap; }
.count .lbl { font-size: 12px; color: var(--muted); line-height: 1.2; }
.choices { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.choices .btn.block { margin-top: 0; }
.btn.choice { justify-content: flex-start; text-align: left; padding: 10px 14px; }
.choice-sub { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }
.btn.primary .choice-sub { color: rgba(255, 255, 255, .85); }
/* v0.4.1: web-form copy sheet */
.copyrow { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.copyrow:first-child { border-top: 0; }
.copyrow .main { flex: 1; min-width: 0; }
.copyval { overflow-wrap: anywhere; }
.copyblock { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin: 8px 0; }
.copyblock .msg { max-height: 220px; overflow-y: auto; }
/* v0.5 draft: the licensed roofer list (dev hosts only) */
.dir-row { padding: 12px 14px; }
.dir-name { font-weight: 600; letter-spacing: .01em; overflow-wrap: anywhere; }   /* the DBPR record as published: upper case, no emphasis */
.dir-badge { margin-top: 2px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.dir-seg { margin-top: 12px; }
button.row { width: 100%; background: none; border: 0; border-top: 1px solid var(--line); font: inherit; text-align: left; cursor: pointer; }
button.row:first-child { border-top: 0; }
.linkrow::after { content: "\203A"; color: var(--muted); font-size: 24px; }
.scanrow { border-top: 1px solid var(--line); padding-top: 10px; }
.checkrow:empty { display: none; }
.checkrow { display: flex; align-items: center; gap: 10px; margin-top: 6px; padding: 6px 10px; border-radius: 10px; }
.checkrow.pending { background: var(--warn-bg); color: var(--warn-ink); }
.checkrow.pending span { flex: 1; }

/* v0.5 draft: page 1 (the request) and page 2 (the roofer's quote form). On screen as cards; in print one US Letter page each. */
.qdoc { background: #fff; color: #111; border: 1px solid var(--line); border-radius: 6px; padding: 22px 24px; margin-bottom: 14px; font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.qdoc p { margin: 6px 0; }
.qhead { border-bottom: 2px solid #111; padding-bottom: 6px; margin-bottom: 8px; }
.qhead h3 { font-size: 20px; margin: 0; }
.qsub, .qgrey { color: #555; }
.qband { background: #efefef; color: #555; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 3px 6px; margin: 10px 0 5px; }
.qf { margin-bottom: 4px; }
.qf-l { font-size: 10px; font-weight: 600; text-transform: uppercase; color: #555; letter-spacing: .03em; }
.qf-v { font-size: 13.5px; }
.qtwo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 18px; }
.qask { columns: 2; column-gap: 18px; margin: 4px 0; padding-left: 24px; }
.qask li { break-inside: avoid; margin-bottom: 3px; }
.qask li::marker { font-weight: 700; }
.qattached { margin: 4px 0; padding-left: 18px; }
.qblanks { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 18px; }
.qline { border-bottom: 1px solid #999; min-height: 20px; font-size: 13.5px; }
.qtable { width: 100%; border-collapse: separate; border-spacing: 0 4px; }
.qtable th { width: 26px; text-align: left; vertical-align: top; font-size: 14px; padding-top: 4px; }
.qtable .ql { width: 40%; vertical-align: top; padding: 4px 8px 0 0; }
.qtable .qa { position: relative; border: 1px solid #999; height: 26px; padding: 4px 6px; vertical-align: top; }
.qtable tr.tall .qa { height: 36px; }
.qunit { color: #555; position: absolute; top: 4px; }
.qunit.l { left: 6px; } .qunit.r { right: 6px; }
.qchoices { white-space: normal; }
.qbox { font-size: 15px; }
.qnotes { border: 1px solid #999; height: 70px; }
.qsign { display: grid; grid-template-columns: minmax(0, 62fr) minmax(0, 38fr); gap: 18px; margin-top: 12px; }
.qsign .qline { min-height: 28px; }
.qfoot { display: flex; gap: 12px; justify-content: space-between; border-top: 1px solid #999; margin-top: 12px; padding-top: 6px; font-size: 10px; color: #555; }
.qfoot span:last-child { white-space: nowrap; }
@media (max-width: 480px) { .qdoc { padding: 14px; } .qask { columns: 1; } .qtwo, .qblanks { grid-template-columns: minmax(0, 1fr); } .qtable .ql { width: 45%; } }
.print-only { display: none; }
@media print {
  /* Paper is always light, whatever the screen theme: reset the colour tokens so dark mode never prints pale text or dark cards. */
  :root, :root:not([data-theme="light"]) { --bg: #fff; --card: #fff; --ink: #000; --muted: #333; --line: #999; --chip: #eee; --chip-ink: #000;
    --warn-bg: #fff; --warn-ink: #000; --primary: #000; --accent: #000; color-scheme: light; }
  html { background: #fff; }
  body { padding: 0; background: #fff; color: #000; font-size: 12pt; }
  .topbar, .tabs, .no-print, dialog { display: none !important; }
  main { max-width: none; padding: 0; }
  .card { border: 1px solid #999; break-inside: avoid; }
  .print-only { display: block; }
  .photos { grid-template-columns: repeat(3, 1fr); }
  .photo { aspect-ratio: 4 / 3; }
  .photo button { display: none; }
  a { color: #000; text-decoration: none; }
  h2, .muted, .hint, .kv dt, .pfig figcaption { color: #333; }
  .packet { border: 0; padding: 0; break-inside: auto; }
  .packet section { break-inside: auto; }
  .packet footer { border-top: 1px solid #999; }
  .pgrid { grid-template-columns: repeat(3, 1fr); }
  @page { size: letter; margin: 0.5in; }
  .qdoc { border: 0; border-radius: 0; padding: 0; margin: 0; font-size: 10pt; break-after: page; display: flex; flex-direction: column; min-height: 9.9in; }
  .qdoc .qfoot { margin-top: auto; }
  .qhead h3 { font-size: 17pt; }
  .qtwo, .qblanks { grid-template-columns: 1fr 1fr; }
  .qask { columns: 2; }
  .qtable .qa { height: 22px; } .qtable tr.tall .qa { height: 32px; }
}
/* Job logs (debug and local hosts only until the service opens) */
.error { color: #b3261e; font-size: 14px; margin: 4px 0 0; }
.error:empty { display: none; }
.jl-entry .btnrow { flex-wrap: wrap; }
.jl-entry .btnrow .btn { min-height: 36px; font-size: 14px; }
.jl-file { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.jl-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; }
.jl-mail { white-space: pre-wrap; max-height: 16em; overflow: auto; }
.kvline { display: flex; justify-content: space-between; gap: 12px; }
.kvline span:last-child { text-align: right; }
.jl-toast { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); background: var(--card); border: 1px solid var(--line); border-radius: 99px; padding: 6px 14px; z-index: 50; }
.jl-print .jl-pline { margin: 2px 0 2px 8px; }
.jl-print .jl-pentry { margin-top: 10px; break-inside: avoid; }
.jl-pthumb { height: 90px; max-width: 160px; object-fit: contain; margin-left: 8px; }
.jl-hash { font-family: ui-monospace, monospace; font-size: 9px; color: var(--muted); margin: 2px 0 0 8px; word-break: break-all; }
