/* Fireside Sweeps — Inspection app
   Tablet-first, also usable on phones. Offline, no backend. */

:root {
  --ink: #1c1a17;
  --muted: #5c574f;
  --line: #d4cfc6;
  --paper: #f7f4ee;
  --card: #fffdf8;
  --gold: #c48a1a;
  --gold-soft: #f3e4c0;
  --brick: #9c2f16;
  --brick-soft: #f4d8d0;
  --forest: #2a5a3c;
  --forest-soft: #d7eadc;
  --sky: #2d4f74;
  --sky-soft: #d6e3f0;
  --gray-bar: #d8d8d8;
  --shadow: 0 1px 3px rgba(28, 26, 23, 0.12);
  --radius: 12px;
  --tap: 48px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --report-serif: "Times New Roman", Times, Georgia, serif;
  --app-bar: 58px;
  --steps: 52px;
  --foot: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--paper); color: var(--ink); font-family: var(--font); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img { max-width: 100%; height: auto; }

body.app {
  min-height: 100vh;
  min-height: 100dvb;
}

/* ---- App shell ---- */
.app-bar {
  position: sticky; top: 0; z-index: 20;
  height: var(--app-bar);
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px;
  background: #1c1a17; color: #f7f4ee;
  box-shadow: var(--shadow);
}
.app-bar img.mark { height: 40px; width: auto; background: #fff; border-radius: 4px; padding: 2px 4px; }
.app-bar .brand { display: flex; flex-direction: column; line-height: 1.15; }
.app-bar .brand strong { font-size: 15px; font-weight: 650; letter-spacing: 0.01em; }
.app-bar .brand span { font-size: 11px; color: #d8c8a0; }
.app-bar .spacer { flex: 1; }
.app-bar .status { font-size: 12px; color: #cfc8bb; }
.app-bar .icon-btn {
  min-width: var(--tap); min-height: 40px;
  border: 1px solid #4a453e; background: #2a2723; color: #f7f4ee;
  border-radius: 8px; padding: 0 10px; font-size: 13px;
}

.steps {
  position: sticky; top: var(--app-bar); z-index: 19;
  display: flex; gap: 4px; overflow-x: auto;
  padding: 8px 10px;
  background: #efeae1; border-bottom: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
}
.steps button {
  flex: 1 0 auto;
  min-height: 36px; min-width: 92px;
  border: 0; border-radius: 999px;
  background: transparent; color: var(--muted);
  font-size: 13px; font-weight: 600; padding: 0 12px;
  white-space: nowrap;
}
.steps button.active { background: var(--ink); color: #fff; }
.steps button.done { color: var(--forest); }
.steps button.done .n { background: var(--forest); color: #fff; }
.steps button .n {
  display: inline-block; width: 18px; height: 18px; line-height: 18px;
  border-radius: 50%; background: currentColor; color: #efeae1;
  font-size: 11px; text-align: center; margin-right: 6px;
}
.steps button.active .n { background: var(--gold); color: #1c1a17; }

#main {
  padding: 16px 16px calc(var(--foot) + 16px);
  max-width: 1100px; margin: 0 auto;
}

.app-foot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: var(--foot);
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  background: #fffdf8; border-top: 1px solid var(--line);
}
.app-foot .spacer { flex: 1; }
.btn {
  min-height: var(--tap); padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-weight: 650; font-size: 15px;
}
.btn:disabled { opacity: 0.45; }
.btn.primary { background: var(--brick); border-color: var(--brick); color: #fff; }
.btn.ghost { background: transparent; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #1c1a17; }

h1 { font-size: 1.45rem; margin: 0 0 8px; }
h2 { font-size: 1.15rem; margin: 0 0 8px; }
.lede { color: var(--muted); margin: 0 0 16px; line-height: 1.45; }

/* ---- Job picker ---- */
.job-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.job-card {
  text-align: left;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 16px;
  min-height: 132px;
  box-shadow: var(--shadow);
}
.job-card:hover, .job-card:focus { border-color: var(--gold); }
.job-card.selected { border-color: var(--brick); box-shadow: 0 0 0 3px var(--brick-soft); }
.job-card .level {
  display: inline-block; font-size: 11px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--gold-soft); color: #6a4a08;
  border-radius: 999px; padding: 2px 8px; margin-bottom: 6px;
}
.job-card .level.l2 { background: var(--sky-soft); color: var(--sky); }
.job-card h2 { font-size: 1.05rem; margin: 0 0 6px; }
.job-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; }

.module-card {
  margin-top: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.module-card label.toggle {
  display: flex; align-items: flex-start; gap: 12px;
  font-weight: 600; cursor: pointer;
}
.module-card input[type=checkbox] { width: 24px; height: 24px; margin-top: 2px; flex: none; }
.module-card p { margin: 8px 0 0 36px; color: var(--muted); font-size: 13px; }

/* ---- Forms ---- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.form-grid .full { grid-column: 1 / -1; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 650; color: var(--muted); }
label.field input, label.field select, label.field textarea, .text-input {
  min-height: var(--tap);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
label.field textarea { min-height: 88px; resize: vertical; }
.photo-field { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.photo-field img.thumb { width: 120px; height: 80px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

/* ---- Checklist ---- */
.checklist {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 16px;
  align-items: start;
}
.sec-nav {
  position: sticky; top: calc(var(--app-bar) + var(--steps) + 8px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  max-height: calc(100vh - var(--app-bar) - var(--steps) - var(--foot) - 24px);
  overflow: auto;
}
.sec-nav button {
  display: block; width: 100%; text-align: left;
  border: 0; background: transparent;
  padding: 10px 10px; border-radius: 8px;
  font-size: 13px; color: var(--ink);
}
.sec-nav button .codes { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
.sec-nav button.active { background: #1c1a17; color: #fff; }
.sec-nav button.active .codes { color: #e6d3a0; }
.sec-nav button .dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--line); margin-right: 6px;
}
.sec-nav button.has-findings .dot { background: var(--brick); }
.sec-nav button.complete .dot { background: var(--forest); }

.section-head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 14px;
  margin-bottom: 10px;
}
.section-head h2 { margin: 0; }
.badge {
  font-size: 11px; font-weight: 700; letter-spacing: 0.03em;
  background: var(--gold-soft); color: #6a4a08;
  border-radius: 999px; padding: 3px 8px;
}
.route-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}
.route-box .choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.choice {
  min-height: var(--tap); padding: 0 14px;
  border-radius: 10px; border: 2px solid var(--line);
  background: #fff; font-weight: 650;
}
.choice.selected { border-color: var(--brick); background: var(--brick-soft); }

.item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.item.finding { border-color: #c9897a; background: #fdf6f3; }
.item.limited { border-color: #8aa0b8; background: #f3f7fb; }
.item .q { font-weight: 600; margin-bottom: 8px; line-height: 1.3; }
.item .q .tag { font-size: 11px; font-weight: 700; color: var(--brick); margin-left: 8px; }
.ynpc, .yn {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.ynpc button, .yn button {
  flex: 1 1 56px;
  min-height: var(--tap);
  border-radius: 10px;
  border: 2px solid var(--line);
  background: #fff;
  font-weight: 750;
  letter-spacing: 0.02em;
}
.ynpc button.sel-Y { background: var(--forest-soft); border-color: var(--forest); color: var(--forest); }
.ynpc button.sel-N { background: var(--brick-soft); border-color: var(--brick); color: var(--brick); }
.ynpc button.sel-P { background: #eceae6; border-color: #7a756c; }
.ynpc button.sel-C { background: var(--sky-soft); border-color: var(--sky); color: var(--sky); }
/* When Y or N is the "good" answer, flip the colors via .good / .bad */
.ynpc button.sel-Y.bad, .ynpc button.sel-N.bad { background: var(--brick-soft); border-color: var(--brick); color: var(--brick); }
.ynpc button.sel-Y.good, .ynpc button.sel-N.good { background: var(--forest-soft); border-color: var(--forest); color: var(--forest); }

.item-extra { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.item-extra label { flex: 1 1 120px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.checks label {
  display: flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  font-weight: 600; font-size: 14px;
}
.checks input { width: 18px; height: 18px; }

/* ---- Findings ---- */
.finding-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.finding-card header { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; margin-bottom: 8px; }
.finding-card h3 { margin: 0; font-size: 1rem; }
.search { min-height: 44px; width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
.row-list { max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.row-item {
  display: block; width: 100%; text-align: left;
  border: 0; border-bottom: 1px solid var(--line);
  padding: 10px 12px; background: #fff;
}
.row-item:hover { background: #f4efe6; }
.row-item.picked { background: var(--gold-soft); }
.row-item strong { display: block; font-size: 14px; }
.row-item span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.picked-row { margin-top: 10px; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.picked-row .brief { font-weight: 700; margin-bottom: 6px; }
.picked-row textarea { width: 100%; min-height: 120px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.blanks { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.blanks label { font-size: 12px; font-weight: 650; color: var(--muted); }
.blanks input { min-height: 40px; border: 1px dashed var(--gold); border-radius: 6px; padding: 4px 8px; min-width: 140px; }
.photos { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.photos .shot { position: relative; width: 140px; }
.photos .shot img { width: 140px; height: 100px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.photos .shot button.remove {
  position: absolute; top: 4px; right: 4px;
  width: 28px; height: 28px; border: 0; border-radius: 50%;
  background: #1c1a17; color: #fff; font-weight: 700;
}
.add-photo { min-height: 44px; }

.extra-add { margin: 16px 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---- Report editor ---- */
.report-wrap { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.report-tools {
  position: sticky; top: calc(var(--app-bar) + var(--steps) + 8px);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
  max-height: calc(100vh - var(--app-bar) - var(--steps) - var(--foot) - 24px);
  overflow: auto;
}
.report-tools h3 { margin: 12px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.report-tools h3:first-child { margin-top: 0; }
.check-list label { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; font-size: 13px; line-height: 1.3; }
.check-list input { margin-top: 2px; width: 18px; height: 18px; flex: none; }

/* Preview of the customer report (also used for print) */
.report-preview {
  background: #fff; border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 18px 22px 28px;
  font-family: var(--report-serif);
  color: #000;
}
.report-preview .letterhead {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding-bottom: 6px;
}
.report-preview .letterhead .mark { height: 64px; width: auto; }
.report-preview .letterhead .ncsg { height: 72px; width: auto; }
.report-preview .co {
  text-align: center; line-height: 1.25;
  font-size: 13.5px;
}
.report-preview .co .name { font-size: 18px; font-weight: 700; }
.gray-bar {
  background: var(--gray-bar);
  text-align: center;
  font-family: var(--report-serif);
  font-size: 18px; font-weight: 700;
  padding: 5px 8px;
  margin: 0 -4px;
  border-top: 1px solid #bbb;
  border-bottom: 1px solid #bbb;
}
.prepared {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 16px;
  align-items: start;
  padding: 12px 8px 8px;
}
.prepared .lbl { font-style: italic; margin-bottom: 8px; }
.prepared .who { font-size: 15px; line-height: 1.35; }
.prepared .date { margin-top: 12px; font-size: 15px; }
.prepared .house { width: 200px; height: 140px; object-fit: cover; border: 1px solid #333; justify-self: end; }
.boilerplate {
  border-top: 8px solid var(--gray-bar);
  border-bottom: 8px solid var(--gray-bar);
  padding: 8px 6px;
  font-size: 12.5px;
  line-height: 1.35;
  margin: 4px 0 14px;
}
.finding-block { margin: 0 0 16px; }
.finding-block .cat {
  font-family: var(--report-serif);
  font-size: 15px; font-weight: 700;
  margin: 0 0 8px;
  border-bottom: 1px solid #ddd;
  padding-bottom: 2px;
}
.overview {
  display: grid; grid-template-columns: 220px 1fr; gap: 12px;
  margin: 0 0 14px; align-items: start;
}
.overview img { width: 220px; height: auto; border: 1px solid #333; }
.overview .cap { font-size: 13px; padding-top: 4px; }
.pair {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 12px;
  margin: 0 0 14px;
  align-items: start;
  break-inside: avoid;
}
.pair img { width: 220px; height: auto; border: 1px solid #333; object-fit: cover; max-height: 200px; }
.pair .txt, .solo-txt {
  border: 1.5px solid #111;
  padding: 8px 10px;
  font-size: 12.5px;
  line-height: 1.4;
  min-height: 80px;
}
.solo-txt { margin: 0 0 14px; }
.report-preview h3.block-h {
  font-family: var(--report-serif);
  font-size: 16px; margin: 16px 0 8px;
}
.report-preview p { margin: 0 0 10px; font-size: 13px; line-height: 1.4; }
.editable[contenteditable="true"] { outline: 1px dashed transparent; }
.editable[contenteditable="true"]:hover, .editable[contenteditable="true"]:focus {
  outline: 1px dashed var(--gold);
  background: #fffbeb;
}

/* ---- Export ---- */
.export-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.callout {
  background: var(--gold-soft);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.45;
}

/* ---- Checklist print preview (in export / print) ---- */
.checklist-print { font-size: 12px; }
.checklist-print h1 { font-size: 18px; }
.cl-sec { margin-bottom: 12px; break-inside: avoid; }
.cl-sec h2 { font-size: 14px; background: var(--gray-bar); padding: 3px 6px; }
.cl-row { display: grid; grid-template-columns: 70px 1fr; gap: 8px; padding: 2px 0; border-bottom: 1px solid #eee; }
.cl-row .ans { font-weight: 700; }

/* ---- Phone ---- */
@media (max-width: 780px) {
  .form-grid, .checklist, .report-wrap, .prepared, .pair, .overview {
    grid-template-columns: 1fr;
  }
  .sec-nav { position: static; max-height: none; display: flex; gap: 4px; overflow-x: auto; padding: 6px; }
  .sec-nav button { flex: 0 0 auto; width: auto; white-space: nowrap; }
  .sec-nav button .codes { display: none; }
  .prepared .house { width: 100%; height: auto; }
  .report-preview .letterhead { grid-template-columns: auto 1fr; }
  .report-preview .letterhead .ncsg { grid-column: 2; justify-self: end; }
  #main { padding: 12px 10px calc(var(--foot) + 12px); }
}

/* ---- Print ---- */
@media print {
  body.app * { visibility: hidden; }
  #print-root, #print-root * { visibility: visible; }
  #print-root {
    position: absolute; left: 0; top: 0; width: 100%;
    display: block !important;
    background: #fff; color: #000;
  }
  .app-bar, .steps, .app-foot, #main { display: none !important; }
  a[href]::after { content: none !important; }
}

#print-root { display: none; }
body.printing #print-root { display: block; }

@page { size: letter; margin: 0.5in 0.65in 0.55in; }

.print-report {
  font-family: var(--report-serif);
  color: #000;
  font-size: 12.5px;
  line-height: 1.35;
}
.print-report .letterhead {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding-bottom: 4px;
}
.print-report .letterhead .mark { height: 62px; }
.print-report .letterhead .ncsg { height: 70px; }
.print-report .co { text-align: center; line-height: 1.2; font-size: 13px; }
.print-report .co .name { font-size: 18px; font-weight: 700; }
.print-report .prepared {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 14px;
  padding: 10px 4px 6px;
}
.print-report .prepared .house { width: 220px; height: 148px; object-fit: cover; border: 1px solid #222; }
.print-report .pair {
  display: grid;
  grid-template-columns: 2.3in 1fr;
  gap: 10px;
  margin: 0 0 12px;
  break-inside: avoid;
  page-break-inside: avoid;
}
.print-report .pair img { width: 2.3in; border: 1px solid #222; }
.print-report .pair .txt, .print-report .solo-txt {
  border: 1.5px solid #111;
  padding: 7px 9px;
}
.print-report .overview { display: grid; grid-template-columns: 2.3in 1fr; gap: 10px; margin: 0 0 12px; page-break-inside: avoid; }
.print-report .overview img { width: 2.3in; border: 1px solid #222; }
.print-report .boilerplate {
  border-top: 7px solid #d0d0d0;
  border-bottom: 7px solid #d0d0d0;
  padding: 7px 4px;
  margin: 2px 0 12px;
  font-size: 11.5px;
}
.print-report h3.block-h { font-size: 15px; margin: 12px 0 8px; page-break-after: avoid; }
.print-report .cat { font-size: 14px; font-weight: 700; margin: 8px 0; border-bottom: 1px solid #ccc; page-break-after: avoid; }

.print-checklist { font-family: var(--font); font-size: 11px; color: #000; }
.print-checklist h1 { font-size: 16px; margin: 0 0 4px; }
.print-checklist .meta { margin-bottom: 10px; font-size: 12px; }
.print-checklist table { width: 100%; border-collapse: collapse; }
.print-checklist th, .print-checklist td { border-bottom: 1px solid #ddd; padding: 3px 5px; text-align: left; vertical-align: top; }
.print-checklist th { background: #ddd; }
.print-checklist .sec-title td { background: #eee; font-weight: 700; font-size: 12px; padding-top: 8px; }
.print-checklist .finding-row td { background: #f8ece8; }

.hidden-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.toast {
  position: fixed; bottom: calc(var(--foot) + 12px); left: 50%; transform: translateX(-50%);
  background: #1c1a17; color: #fff; padding: 10px 16px; border-radius: 8px;
  z-index: 40; font-size: 14px; box-shadow: var(--shadow);
}
