:root {
  color-scheme: only light; /* the sheet is a paper replica; ask browsers not to auto-darken it */
  --navy: #0F1B2D;
  --accent: #F26B1D;
  --label: #2B3445;
  --quote: #6B7280;
  --rule: #8A94A3;
  --ink: #1B3FA0;
  --paper: #FFFFFF;
  --bg: #EEF1F5;
  --grid: #E3E8EF;
  --line-h: 30px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--label);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body.sketch-open { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- top bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-top)) calc(16px + var(--safe-right)) 10px calc(16px + var(--safe-left));
  background: var(--navy); color: #fff;
}
.bar-title { font-weight: 800; letter-spacing: .06em; text-transform: uppercase; font-size: 15px; }
.bar-title span { color: var(--accent); }
.bar-flex { flex: 1; }
.status { font-size: 13px; color: #A9B4C4; min-width: 56px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 42px; padding: 0 16px; border-radius: 10px;
  border: 1.5px solid #C9D1DC; background: #fff; color: var(--navy);
  font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: .6; }
.bar .btn { border-color: rgba(255,255,255,.35); background: transparent; color: #fff; }
.bar .btn.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { border-color: transparent; padding: 0 8px; }

.brand-select select {
  min-height: 42px; border-radius: 10px; padding: 0 12px;
  background: rgba(255,255,255,.08); color: #fff; border: 1.5px solid rgba(255,255,255,.35);
}
.brand-select option { color: var(--navy); }

/* ---------- jobs list ---------- */
.list {
  max-width: 900px; margin: 0 auto;
  padding: 20px calc(16px + var(--safe-right)) calc(40px + var(--safe-bottom)) calc(16px + var(--safe-left));
}
.list h1 { font-size: 22px; margin: 4px 0 14px; color: var(--navy); }
.list h2 { font-size: 17px; margin: 0; color: var(--navy); }
.list section { margin-bottom: 28px; }
.brand-picks { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.brand-pick {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 18px;
  min-height: 130px; padding: 20px; border-radius: 14px;
  border: 2px solid var(--navy); background: var(--paper); text-align: left;
  box-shadow: 0 2px 0 var(--navy);
}
.brand-pick:active { transform: translateY(2px); box-shadow: none; }
.brand-pick .plus { font-weight: 700; color: var(--accent); }
.logo { max-height: 48px; max-width: 220px; object-fit: contain; }
.logo.big { max-height: 40px; }
.wordmark { font-weight: 900; font-size: 22px; letter-spacing: .04em; color: var(--navy); }
.wordmark em { font-style: normal; color: var(--accent); }

.jobs-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.count { display: inline-block; min-width: 24px; padding: 1px 8px; border-radius: 99px; background: var(--navy); color: #fff; font-size: 13px; text-align: center; }
.search { flex: 1; max-width: 340px; min-height: 42px; padding: 0 12px; border-radius: 10px; border: 1.5px solid #C9D1DC; font-size: 16px; }
.job-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.job-list li { display: flex; align-items: stretch; background: var(--paper); border-radius: 12px; border: 1px solid #D6DCE4; overflow: hidden; }
.job { flex: 1; display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; padding: 14px 16px; color: inherit; text-decoration: none; min-width: 0; }
.job-brand { grid-row: span 3; align-self: start; padding: 3px 8px; border-radius: 6px; background: #FDEBDF; color: #B4470C; font-size: 12px; font-weight: 700; }
.job-name { font-weight: 700; color: var(--navy); font-size: 17px; }
.job-addr, .job-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-meta { font-size: 13px; color: var(--quote); }
.icon-btn { border: 0; border-left: 1px solid #E3E7ED; background: none; padding: 0 16px; font-weight: 600; color: var(--quote); }
.icon-btn.danger:hover, .icon-btn.danger:active { color: #C0262D; background: #FDF0F0; }
.empty { padding: 24px; border-radius: 12px; border: 2px dashed #C9D1DC; text-align: center; color: var(--quote); }
.backup p { color: var(--quote); margin: 6px 0 12px; }
.backup-btns { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- the sheet ---------- */
.editor { padding: 16px calc(12px + var(--safe-right)) calc(48px + var(--safe-bottom)) calc(12px + var(--safe-left)); }
.sheet {
  max-width: 1400px; margin: 0 auto; padding: 18px 16px 12px;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 20px 20px;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(15,27,45,.12), 0 8px 24px rgba(15,27,45,.06);
}
.sheet-brand { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding-bottom: 8px; }
.sheet-brand .wordmark { font-size: 20px; }
.sheet-sub { font-weight: 800; font-size: 18px; letter-spacing: .04em; color: var(--navy); text-transform: uppercase; }
.sheet-sub em { font-style: normal; color: var(--accent); }

.sheet-head {
  display: grid; grid-template-columns: 1fr 1.6fr 180px; gap: 6px 16px;
  padding-bottom: 10px; margin-bottom: 22px; border-bottom: 3px solid var(--accent);
}
.hf { display: flex; align-items: flex-end; gap: 8px; }
.hf > span { color: #555; font-size: 14px; padding-bottom: 6px; }

.ln {
  flex: 1; min-width: 0; width: 100%;
  border: 0; border-bottom: 1.5px solid var(--rule); border-radius: 0;
  background: transparent; padding: 4px 2px; min-height: 36px;
  font-size: 16px; color: var(--ink);
  -webkit-appearance: none; appearance: none;
}
.ln:focus, .ruled:focus { outline: none; border-color: var(--accent); background-color: rgba(242,107,29,.05); }
input[type="date"].ln, input[type="time"].ln { min-height: 38px; }

.ruled {
  display: block; width: 100%; resize: none; overflow: hidden;
  border: 0; border-radius: 0; padding: 0 2px; margin: 4px 0;
  font-size: 16px; color: var(--ink);
  line-height: var(--line-h);
  min-height: calc(var(--line-h) + 2px);
  background: transparent repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--line-h) - 1.5px), var(--rule) calc(var(--line-h) - 1.5px), var(--rule) var(--line-h));
  background-attachment: local;
}
.ruled::placeholder { color: #A3ACB9; font-style: italic; }

.grid {
  display: grid; gap: 26px 12px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-areas:
    "p1 p1 p2 p2 p3 p3"
    "p4 p4 p4 p4 p4 p4"
    "p5 p5 p5 p5 p6 p6"
    "p7 p7 p7 p8 p8 p8"
    "p9 p9 p10 p10 p11 p11"
    "p12 p12 p12 p12 p12 p12";
}
.card {
  position: relative; min-width: 0;
  background: var(--paper);
  border: 1.5px solid var(--navy); border-radius: 6px;
  padding: 18px 14px 12px;
}
.card h2 {
  position: absolute; top: -0.75em; left: 10px; right: 10px;
  margin: 0; font-size: 12px; line-height: 1.5; font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none;
}
.card h2 > span { background: var(--paper); }
.card h2 .num { color: var(--navy); padding-left: 6px; }
.card h2 .ttl { color: var(--accent); padding: 0 6px 0 8px; }

.q { margin: 2px 0 6px; color: var(--quote); font-style: italic; font-size: 14px; }
.q b { color: var(--navy); }
.note { margin: 10px 0 0; text-align: right; color: var(--quote); font-style: italic; font-size: 13.5px; }

.chks { display: flex; flex-wrap: wrap; gap: 0 18px; margin: 2px 0; }
.chk {
  display: inline-flex; align-items: center; gap: 9px;
  min-height: 42px; padding: 0; border: 0; background: none; text-align: left;
  color: var(--label); cursor: pointer; user-select: none; -webkit-user-select: none;
}
.chk.full { flex-basis: 100%; }
.chk input { position: absolute; opacity: 0; pointer-events: none; }
.box {
  flex: none; position: relative; width: 24px; height: 24px;
  border: 2px solid var(--navy); border-radius: 5px; background: #fff;
  transition: background .12s, border-color .12s;
}
.chk input:checked + .box, .chk.checked .box { background: var(--accent); border-color: var(--accent); }
.chk input:checked + .box::after, .chk.checked .box::after {
  content: ""; position: absolute; left: 6.5px; top: 2px; width: 7px; height: 12px;
  border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg);
}
.chk input:focus-visible + .box, .chk:focus-visible .box { outline: 3px solid rgba(242,107,29,.4); outline-offset: 2px; }
.choice { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0 14px; }
.choice .sep { color: var(--label); }

/* 04 questions */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
.qf { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0 10px; margin-bottom: 6px; }
.qf > span { padding-bottom: 7px; font-size: 15px; display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0 8px; }
.qf > .ln { flex: 1 1 160px; }
.qf > .ruled { flex-basis: 100%; }

/* 05 sketch */
.sketch { margin-top: 4px; }
.sk-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.sk-tools button {
  min-width: 42px; min-height: 42px; padding: 0 12px;
  border: 1.5px solid #C9D1DC; border-radius: 10px; background: #fff; color: var(--navy); font-weight: 600;
}
.sk-tools button.on { border-color: var(--navy); background: var(--navy); color: #fff; }
.sk-tools button:disabled { opacity: .35; }
.sk-tools .sw { padding: 0; }
.sk-tools .sw::before { content: ""; display: block; width: 20px; height: 20px; margin: auto; border-radius: 50%; background: var(--c); }
.sk-tools .sw.on { background: #fff; box-shadow: inset 0 0 0 2px #fff; }
.sk-tools .sz i { display: block; width: 22px; height: var(--s); margin: auto; border-radius: 99px; background: currentColor; }
.sk-gap { width: 6px; }
.sk-flex { flex: 1; }
.sk-wrap { position: relative; }
.sk-wrap canvas {
  display: block; touch-action: none;
  border: 1.5px solid #C9D1DC; border-radius: 6px; background: #fff;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.sketch.expanded {
  position: fixed; inset: 0; z-index: 50; margin: 0;
  display: flex; flex-direction: column;
  padding: calc(10px + var(--safe-top)) calc(12px + var(--safe-right)) calc(12px + var(--safe-bottom)) calc(12px + var(--safe-left));
  background: var(--bg);
}
.sketch.expanded .sk-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }

/* 06 findings */
.fh { display: block; margin-bottom: 8px; }
.fh > span { display: block; font-weight: 800; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--navy); }
.fh.urgent > span { color: #C0262D; }

/* 09 money */
.money { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; margin: 4px 0 8px; }
.money label, .fu label { display: flex; align-items: flex-end; gap: 6px; }
.money label > span, .fu label > span { padding-bottom: 7px; white-space: nowrap; }
.money .unit { padding-bottom: 7px; }

/* 11 follow-up */
.fu { display: grid; grid-template-columns: 1.4fr 1fr; gap: 4px 12px; margin: 4px 0; }

.sheet-foot { margin: 22px 0 4px; text-align: center; font-size: 12px; color: var(--quote); }

/* ---------- lock screen & passcode dialogs ---------- */
.lock {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: calc(24px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
  background: var(--navy);
}
.lock-card {
  width: 100%; max-width: 400px; padding: 28px 24px 22px;
  border-radius: 16px; background: var(--paper); text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,.35);
}
.lock-icon {
  width: 60px; height: 60px; margin: 0 auto 12px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: #FDEBDF; color: var(--accent);
}
.lock-card h1 { margin: 0 0 8px; font-size: 22px; color: var(--navy); }
.lock-card p { margin: 0 0 16px; color: var(--quote); }
.lock-card p b { color: var(--navy); }
.lock-input, .pass-dialog input {
  display: block; width: 100%; min-height: 48px; margin: 0 0 10px; padding: 0 14px;
  border: 1.5px solid #C9D1DC; border-radius: 10px; font-size: 17px; background: #fff;
}
.lock-input:focus, .pass-dialog input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(242,107,29,.2); }
.lock-err { min-height: 1.4em; margin: 0 0 8px !important; color: #C0262D !important; font-weight: 600; }
.lock-btn { width: 100%; min-height: 50px; font-size: 17px; }
.link-btn { margin-top: 14px; border: 0; background: none; color: var(--quote); text-decoration: underline; min-height: 40px; }

.pass-dialog {
  width: min(420px, calc(100vw - 32px)); padding: 22px; border: 0; border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,.35);
}
.pass-dialog::backdrop { background: rgba(15,27,45,.55); }
.pass-dialog h2 { margin: 0 0 8px; color: var(--navy); font-size: 19px; }
.pass-dialog p { margin: 0 0 14px; color: var(--quote); }
.pass-dialog label > span { display: block; margin-bottom: 4px; font-weight: 600; font-size: 14px; }
.dlg-btns { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.pass-dialog .file-name { color: var(--navy); font-weight: 600; word-break: break-word; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); z-index: 100;
  transform: translate(-50%, 20px); opacity: 0; transition: .25s;
  padding: 12px 18px; border-radius: 10px; background: var(--navy); color: #fff; font-weight: 600;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- dark mode ----------
   The sheet stays paper-white on purpose (it mirrors the printed PDF). Declaring
   our own dark styles also stops browsers like Samsung Internet from force-darkening
   the page, which made the ink colours unreadable. */
@media (prefers-color-scheme: dark) {
  :root { --bg: #1B2433; }
  .list h1, .list h2 { color: #F4F6F9; }
  .backup p, .empty { color: #A9B4C4; }
  .empty { border-color: #3A4658; }
  .lock { background: #070D18; }
}

/* ---------- responsive ---------- */
/* iPad portrait / small laptops */
@media (max-width: 1099px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "p1 p2" "p3 p3" "p4 p4" "p5 p5" "p6 p6" "p7 p8" "p9 p10" "p11 p11" "p12 p12";
  }
  .money { grid-template-columns: 1fr; }
}
/* phones */
@media (max-width: 699px) {
  .grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "p1" "p2" "p3" "p4" "p5" "p6" "p7" "p8" "p9" "p10" "p11" "p12"; }
  .cols { grid-template-columns: 1fr; }
  .sheet { padding: 14px 10px 10px; }
  .sheet-head { grid-template-columns: 1fr; }
  .editor { padding-left: calc(6px + var(--safe-left)); padding-right: calc(6px + var(--safe-right)); }
  .card { padding: 18px 10px 10px; }
  .card h2 { white-space: normal; position: static; margin: -28px 0 6px; line-height: 1.3; }
  .card h2 > span { box-decoration-break: clone; -webkit-box-decoration-break: clone; }
  .bar { flex-wrap: wrap; gap: 8px; }
  .editor-bar .status { order: 5; }
  .sheet-sub { font-size: 15px; }
  .sk-flex { display: none; }
}
