/* Scope Notes — built for a phone on a roof: big targets, high contrast, system fonts. */
:root {
  --blue: #2f55b8; --blue-d: #1f3f93; --blue-l: #e8eefb;
  --ink: #12161f; --ink2: #4a5262; --line: #cfd5e0; --bg: #f2f4f8; --card: #fff;
  --ok: #17803d; --ok-l: #e5f5ea; --warn: #a15c00; --warn-l: #fff3df; --bad: #b42318; --bad-l: #fde8e6;
  --r: 12px; --tap: 46px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }

/* ---------- top bar ---------- */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--blue-d); color: #fff; min-height: 56px; }
.brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; flex: 1; }
.logo { background: #fff; color: var(--blue-d); border-radius: 6px; padding: 2px 6px; font-size: 14px; }
.title { flex: 1; min-width: 0; display: flex; }
.title span { display: flex; flex-direction: column; min-width: 0; }
.title b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title small { opacity: .8; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon { background: none; border: 0; color: #fff; font-size: 28px; line-height: 1; min-width: var(--tap); min-height: var(--tap); cursor: pointer; border-radius: 8px; }
.icon:active { background: rgba(255,255,255,.15); }
.pill { border: 0; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; min-height: 34px; }
.pill.dim { background: rgba(255,255,255,.18); color: #fff; }
.pill.ok { background: #d6f2df; color: #0d5a29; }
.pill.busy { background: #fff; color: var(--blue-d); }
.pill.warn { background: #ffe2a8; color: #6b3d00; }
.pill.bad { background: #ffd2cc; color: #8a1a10; }

/* ---------- section tabs ---------- */
.tabs { position: sticky; top: 56px; z-index: 15; display: flex; overflow-x: auto; gap: 4px; padding: 6px 8px; background: #fff; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-radius: 999px; text-decoration: none; color: var(--ink2); font-weight: 600; min-height: 42px; }
.tabs a.on { background: var(--blue); color: #fff; }
.badge { background: var(--bad); color: #fff; font-size: 12px; border-radius: 999px; padding: 1px 7px; }
.tabs a.on .badge { background: #fff; color: var(--bad); }

main { max-width: 1100px; margin: 0 auto; padding: 12px 12px 110px; }

/* ---------- list ---------- */
.list { max-width: 720px; display: flex; flex-direction: column; gap: 10px; }
.search { width: 100%; min-height: var(--tap); border: 1px solid var(--line); border-radius: var(--r); padding: 0 14px; background: #fff; }
.row { display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; text-decoration: none; color: var(--ink); }
.row:active { background: var(--blue-l); }
.r1 { display: flex; justify-content: space-between; gap: 8px; font-size: 17px; }
.r2 { color: var(--ink2); margin-top: 2px; }
.r3 { font-size: 13px; color: var(--ink2); margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; }
.appt { font-size: 14px; font-weight: 700; color: var(--blue-d); margin-top: 6px; }
.appt.today { color: var(--bad); }
.callnote { font-size: 13px; color: var(--ink); background: #fffbe6; border-left: 3px solid #e0b400; border-radius: 4px; padding: 6px 8px; margin-top: 6px; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tag { font-size: 12px; font-weight: 700; background: var(--blue-l); color: var(--blue-d); border-radius: 6px; padding: 2px 8px; align-self: center; white-space: nowrap; }
.tag.ok { background: var(--ok-l); color: var(--ok); }
.miss { color: var(--bad); font-weight: 600; }
.okt { color: var(--ok); font-weight: 600; }
.empty, .foot { text-align: center; color: var(--ink2); padding: 24px 8px; }
.foot { font-size: 13px; padding: 12px; }
.dim { color: var(--ink2); }

/* ---------- cards & fields ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.card h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--blue-d); margin: 0 0 10px; }
.grid { display: grid; grid-template-columns: 1fr; gap: 12px 14px; }
@media (min-width: 760px) { .grid { grid-template-columns: 1fr 1fr; } .grid .wide { grid-column: 1 / -1; } }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; border-radius: 10px; transition: background .3s, box-shadow .3s; }
.field.flash { background: var(--warn-l); box-shadow: 0 0 0 6px var(--warn-l); }
.lab { font-size: 13px; font-weight: 700; color: var(--ink2); display: flex; align-items: center; gap: 6px; }
.chip { font-size: 11px; font-weight: 700; border-radius: 6px; padding: 1px 6px; text-transform: uppercase; letter-spacing: .03em; }
.chip.auto { background: var(--blue-l); color: var(--blue); }
.chip.need { background: var(--bad-l); color: var(--bad); }
.field.need select, .field.need .seg { box-shadow: 0 0 0 2px var(--bad); border-radius: 10px; }
input, select, textarea { width: 100%; min-height: var(--tap); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: #fff; }
textarea { resize: vertical; line-height: 1.35; }
select { appearance: none; -webkit-appearance: none; padding-right: 36px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%234a5262' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 12px center; text-overflow: ellipsis; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(47,85,184,.35); border-color: var(--blue); }
.addtxt { min-height: 42px; }
.preview { font-size: 13px; color: var(--ink2); background: var(--bg); border-radius: 8px; padding: 6px 10px; white-space: pre-wrap; }
.preview.block { font-family: var(--mono); font-size: 13px; margin-top: 8px; }
.hint { font-size: 14px; color: var(--ink2); margin: 0 0 10px; }
.link { background: none; border: 0; color: var(--blue); font-weight: 600; padding: 4px 0; text-align: left; cursor: pointer; align-self: flex-start; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; margin-bottom: 10px; }
.check input { width: 24px; min-height: 24px; height: 24px; flex: none; margin-top: 2px; }

/* segmented buttons */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { min-height: 42px; padding: 6px 12px; border: 1px solid var(--line); background: #fff; border-radius: 10px; cursor: pointer; font-weight: 600; color: var(--ink2); }
.seg button.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.seg button.on.auto { background: var(--blue-l); color: var(--blue-d); border: 2px dashed var(--blue); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); padding: 0 18px; border-radius: 10px; border: 1px solid transparent; font-weight: 700; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:active { background: var(--blue-d); }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--blue-d); }
.btn.ok { background: var(--ok); color: #fff; }
.btn.danger { background: #fff; border-color: #f0b4ad; color: var(--bad); }
.btn.big { min-height: 56px; font-size: 18px; }
.row2 { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }

/* pager */
.pager { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); border-top: 1px solid var(--line); }
.pager .btn { flex: 1; max-width: 260px; }

/* slopes, elevations, rooms */
.slopes { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 12px; }
@media (min-width: 760px) { .slopes { grid-template-columns: 1fr 1fr; } .slopes > .row2, .slopes > .preview { grid-column: 1 / -1; } }
.slope, .elev, .room { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; background: #fbfcfe; }
.elev, .room { margin-bottom: 10px; }
.shead { display: flex; gap: 8px; align-items: center; }
.shead h3 { margin: 0; font-size: 17px; flex: 1; }
.sname { font-weight: 700; flex: 1; }
.cause { width: auto; max-width: 52%; font-size: 14px; }
.x { flex: none; width: var(--tap); height: var(--tap); border: 1px solid var(--line); background: #fff; border-radius: 10px; font-size: 22px; color: var(--bad); cursor: pointer; }
.counts { display: flex; gap: 10px; flex-wrap: wrap; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper .slab { font-weight: 700; font-size: 14px; color: var(--ink2); min-width: 38px; }
.stepper button { width: var(--tap); height: var(--tap); border: 1px solid var(--line); background: #fff; border-radius: 10px; font-size: 22px; font-weight: 700; color: var(--blue-d); cursor: pointer; }
.stepper button:active { background: var(--blue-l); }
.num { width: 58px; text-align: center; font-weight: 700; font-size: 18px; padding: 4px; }
.addsel { margin-top: 4px; font-weight: 600; color: var(--blue-d); }

/* items */
.items { display: flex; flex-direction: column; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chipbtn { min-height: 40px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--ink); }
.chipbtn.has { background: var(--blue-l); border-color: var(--blue); color: var(--blue-d); }
.chipbtn.custom { border-style: dashed; color: var(--blue); }
.chipbtn:active { transform: scale(.97); }
.irow { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.irow .iname { font-weight: 700; display: flex; flex-direction: column; grid-column: 1 / 2; }
.irow .iname small { font-weight: 400; color: var(--ink2); }
.irow .stepper { grid-column: 2 / 3; }
.irow .x { grid-column: 3 / 4; grid-row: 1; }
.irow .spec { grid-column: 1 / -1; min-height: 40px; }
.irow .tog { grid-column: 1 / -1; min-height: 38px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-weight: 700; color: var(--ink2); cursor: pointer; }
.irow .tog.on { background: var(--bad-l); border-color: #f0b4ad; color: var(--bad); }
@media (min-width: 760px) {
  .irow { grid-template-columns: minmax(150px, 1fr) auto minmax(140px, 1.2fr) auto auto; }
  .irow .spec { grid-column: 3 / 4; grid-row: 1; }
  .irow .tog { grid-column: 4 / 5; grid-row: 1; padding: 0 10px; }
  .irow .x { grid-column: 5 / 6; }
}
.dims { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dims label { display: flex; align-items: center; gap: 4px; font-weight: 700; color: var(--ink2); }
.dims input { width: 72px; text-align: center; }
.calc { font-size: 13px; font-family: var(--mono); color: var(--ink2); }
.snote { min-height: 42px; }

/* report */
.warn { background: var(--warn-l); color: #5e3700; border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; line-height: 1.9; }
.good { background: var(--ok-l); color: var(--ok); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; font-weight: 700; }
.mlink { display: inline-block; background: #fff; border: 1px solid #f0c98a; border-radius: 999px; padding: 0 10px; margin: 0 4px 0 0; text-decoration: none; color: #6b3d00; font-weight: 600; font-size: 14px; }
.tabs2 button { flex: 1; }
.doc { font-family: Calibri, "Segoe UI", Arial, sans-serif; font-size: 15px; line-height: 1.4; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; background: #fff; }
.doc p { margin: 0 0 3px; }
.doc mark { background: #ffe08a; padding: 0 3px; border-radius: 3px; }
.ws { font-family: var(--mono); font-size: 13px; white-space: pre-wrap; background: #fbfcfe; border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-x: auto; }
.sheet { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: #fff; overflow-x: auto; }

/* scope sheet (screen + print) */
.sheet header, #print header { display: flex; justify-content: space-between; gap: 12px; border-bottom: 3px solid var(--blue-d); padding-bottom: 6px; margin-bottom: 8px; position: static; background: none; color: inherit; }
.sheet h1, #print h1 { margin: 0; font-size: 22px; color: var(--blue-d); }
.sheet .meta, #print .meta { text-align: right; font-size: 13px; }
.sheet h2, #print h2 { font-size: 15px; text-transform: uppercase; color: var(--blue-d); border-bottom: 1px solid var(--line); margin: 14px 0 6px; padding-bottom: 2px; }
.sheet h3, #print h3 { font-size: 14px; margin: 10px 0 4px; }
.sheet h3 .dim, #print h3 .dim { font-weight: 400; font-family: var(--mono); font-size: 12px; }
.sheet table, #print table { border-collapse: collapse; width: 100%; font-size: 13px; margin-bottom: 6px; }
.sheet th, .sheet td, #print th, #print td { border: 1px solid #d5dae3; padding: 3px 6px; text-align: left; vertical-align: top; }
.sheet .kv th, #print .kv th { width: 28%; background: #f4f6fa; font-weight: 600; }
.sheet .it th, #print .it th { background: #f4f6fa; }
.sheet .q, #print .q { text-align: center; width: 48px; }
.sheet .ck, #print .ck { width: 22px; text-align: center; }
.sheet .note, #print .note { font-size: 13px; margin: 4px 0; white-space: pre-wrap; }
.sheet .none, #print .none { font-size: 13px; color: #777; margin: 2px 0; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); opacity: 0; background: #12161f; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 50; transition: .25s; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* tablet: sidebar nav */
@media (min-width: 1000px) {
  .tabs { position: fixed; top: 56px; left: 0; bottom: 0; width: 190px; flex-direction: column; overflow: auto; border-right: 1px solid var(--line); border-bottom: 0; padding: 12px 8px; }
  .tabs a { justify-content: space-between; }
  main.claim { margin-left: 190px; max-width: none; padding: 16px 24px 110px; }
  .pager { left: 190px; }
}

#print { display: none; }
@media print {
  @page { margin: 0.5in; }
  body.printing > *:not(#print) { display: none !important; }
  body.printing #print { display: block; color: #000; }
  #print .ws { border: 0; padding: 0; font-size: 10pt; }
  #print table { page-break-inside: auto; }
  #print tr { page-break-inside: avoid; }
}

/* ---------- v1.1: bigger targets on phones, no iOS zoom-on-focus ---------- */
input, select, textarea { font-size: 16px; }            /* under 16px makes iPhone zoom in and stay zoomed */
.cause { font-size: 16px; }
button, a, select, label { touch-action: manipulation; }  /* no double-tap zoom */
/* (removed in 1.3.1: overflow on html+body breaks vertical scrolling on iPhone) */
@media (max-width: 700px) {
  :root { --tap: 50px; }
  body { font-size: 17px; }
  main { padding-left: 10px; padding-right: 10px; }
  .card { padding: 12px; }
  .lab { font-size: 14px; }
  .seg button { min-height: 46px; padding: 8px 14px; font-size: 16px; }
  .chipbtn { min-height: 46px; padding: 8px 14px; font-size: 16px; }
  .tabs a { min-height: 46px; font-size: 16px; }
  .elev, .room, .slope { padding: 8px; }
  .cause { max-width: 60%; }
  .top2 .btn { flex: 1 1 100%; }
}
.top2 { margin: 0; }
.top2 .btn { flex: 1; }

/* rich item rows (gutters, downspouts, fascia, siding, screens) */
.irow.rich, .irow { display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 8px; }
.ihead { display: flex; align-items: center; gap: 6px; }
.ihead .iname { flex: 1; min-width: 0; }
.irow .spec { min-height: 44px; }
.irow .tog { min-height: 44px; }
.seg.sm { gap: 5px; }
.seg.sm button { min-height: 44px; padding: 6px 12px; }
.seg .paint { border-style: dashed; }
.seg .paint.on { background: var(--ok-l); border: 1px solid var(--ok); color: var(--ok); }
.picks { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.picks .plab { font-size: 14px; font-weight: 700; color: var(--ink2); min-width: 64px; }
.picks button { min-width: 50px; min-height: 44px; border: 1px solid var(--line); background: #fff; border-radius: 10px; font-weight: 700; font-size: 16px; color: var(--blue-d); cursor: pointer; }
.picks button.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.picks .lfnum { width: 84px; min-height: 44px; text-align: center; font-weight: 700; }
@media (min-width: 760px) { .irow { display: flex; } }

/* assignment */
.kvt { width: 100%; border-collapse: collapse; font-size: 15px; }
.kvt th { text-align: left; color: var(--ink2); font-weight: 600; padding: 5px 10px 5px 0; vertical-align: top; width: 34%; }
.kvt td { padding: 5px 0; overflow-wrap: anywhere; }
.kvt tr + tr th, .kvt tr + tr td { border-top: 1px solid #eef0f4; }
.quote { background: var(--bg); border-left: 4px solid var(--blue); border-radius: 6px; padding: 8px 12px; margin: 4px 0 0; font-size: 15px; }
.sheet .qq, #print .qq { white-space: nowrap; width: 1%; }
.ihead { flex-wrap: wrap; }
.ihead .iname { flex: 1 1 140px; }
.ihead .x { order: 2; }
.ihead .stepper { order: 3; }
@media (max-width: 420px) { .ihead .stepper { flex: 1 1 100%; } .ihead .stepper .num { flex: 1; } }
.counts { align-items: center; }
.eight { min-height: var(--tap); padding: 0 16px; border-radius: 10px; border: 2px solid var(--blue); background: #fff; color: var(--blue-d); font-weight: 800; font-size: 17px; cursor: pointer; }
.eight.on { background: var(--blue); color: #fff; }
@media (max-width: 420px) { .picks .plab { min-width: 0; font-size: 13px; } .picks button { min-width: 44px; } .picks .lfnum { width: 64px; } }

/* ---------- v1.3: nothing may be wider than the phone ---------- */
.grid { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
main, .card, .field, .elev, .room, .slope, .irow, .items, .slopes { min-width: 0; max-width: 100%; }
select { width: 100%; max-width: 100%; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview, .doc, .kvt td, .hint, .warn { overflow-wrap: anywhere; }
.seg { max-width: 100%; }
.seg button { max-width: 100%; white-space: normal; text-align: left; }
.btn.addmore { width: 100%; border-style: dashed; margin: 2px 0 6px; }

/* phones: all section tabs visible in two rows — no sideways scrolling */
@media (max-width: 999px) {
  .tabs { flex-wrap: wrap; overflow-x: visible; justify-content: center; gap: 4px; padding: 6px; }
  .tabs a { flex: 1 1 calc(25% - 4px); justify-content: center; padding: 8px 4px; min-height: 42px; font-size: 15px; gap: 4px; }
  .tabs a .badge { font-size: 11px; padding: 0 6px; }
}
@media (max-width: 999px) { .tabs a { white-space: nowrap; flex: 1 1 auto; padding: 8px 8px; } }
@media (max-width: 380px) { .tabs a { font-size: 14px; padding: 8px 5px; } }

/* v1.3.1 — phones: only the blue title bar stays pinned; the tab rows scroll away with the page.
   Prev/next buttons at the bottom still move between sections. */
@media (max-width: 999px) { .tabs { position: static; } }
.codecov { min-height: var(--tap); display: flex; align-items: center; padding: 0 12px; border-radius: 10px; background: var(--ok-l); color: var(--ok); font-weight: 800; font-size: 20px; }
.room.struct > .lab { margin-top: 6px; font-size: 15px; color: var(--blue-d); text-transform: uppercase; letter-spacing: .03em; }
.room.struct .elev { background: #fff; }
.viewsw { margin: 2px 0 0; }
.viewsw button { flex: 1; justify-content: center; text-align: center; }
.row2.tight { margin: 4px 0 0; gap: 6px; }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 15px; }
#updbar { position: fixed; left: 10px; right: 10px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 60; display: flex; gap: 10px; align-items: center; justify-content: space-between; background: #12161f; color: #fff; padding: 10px 12px; border-radius: 12px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
#updbar button { min-height: 42px; border: 0; border-radius: 10px; background: #fff; color: var(--blue-d); font-weight: 800; padding: 0 14px; }

/* 1.7: label at the start of a row of toggles (drip cap detach & reset) */
.seg .plab { align-self: center; font-size: 14px; font-weight: 700; color: var(--ink2); margin-right: 4px; }
