/* Neutral field look: light ground for sunlight, white cards, one red accent used sparingly.
   Answer colours carry meaning only: Y = ok green, N = bad red, NA = grey. */
:root {
  --ground: #f4f4f1;
  --card: #ffffff;
  --rule: #dcdcd5;
  --ink: #16191f;
  --mute: #646a73;
  --accent: #c0392b;
  --accent-ink: #9c2b20;
  --ok: #1f6b3d; --ok-bg: #e3f1e8;
  --bad: #9c2b20; --bad-bg: #f8e4e1;
  --warn: #7a5a12; --warn-bg: #f6edd5;
  --na: #4b5058; --na-bg: #e6e7ea;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 12px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); color: var(--ink); font: 16px/1.4 var(--sans); -webkit-text-size-adjust: 100%; }
html.signing, html.signing body { overflow: hidden; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 2rem; color: var(--mute); }

/* top bar */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  background: var(--card); border-bottom: 1px solid var(--rule); padding: .25rem .5rem; min-height: 48px; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; padding: .5rem; }
.brand-mark { width: 14px; height: 14px; border-radius: 3px; background: var(--accent); }
.saved { font: 600 .62rem var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--mute); }
.progress { height: 3px; background: var(--rule); }
.progress span { display: block; height: 100%; background: var(--ink); transition: width .2s; }

.screen { max-width: 640px; margin: 0 auto; padding: 1rem 16px 7rem; }
.home { padding-top: 2rem; }
h1 { font-size: 1.65rem; line-height: 1.15; letter-spacing: -.02em; margin: .2rem 0 .6rem; }
.eyebrow { font: 700 .64rem var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--mute); margin-bottom: .35rem; }
.muted { color: var(--mute); }
.small { font-size: .86rem; }
.fine { font-size: .74rem; color: var(--mute); margin-top: 2rem; }
.center { text-align: center; }
.stack { display: grid; gap: .6rem; margin: 1rem 0; }

.card { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px; margin: 0 0 12px; }
.card-name { font-size: 1.1rem; font-weight: 700; margin-bottom: .2rem; overflow-wrap: anywhere; }
.resume { border-top: 4px solid var(--ink); }

/* buttons */
.btn { display: flex; align-items: center; justify-content: center; min-height: 48px; padding: .6rem 1rem; width: 100%;
  border: 1px solid var(--rule); border-radius: 10px; background: var(--card); font-weight: 600; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.accent { border: 1.5px dashed var(--accent); color: var(--accent-ink); background: transparent; }
.btn.small { min-height: 44px; width: auto; padding: .4rem .9rem; }
.btn:disabled { opacity: .5; }
.btn:active { transform: translateY(1px); }
.link { background: none; border: 0; padding: .6rem .5rem; min-height: 44px; color: var(--ink); font-weight: 600; cursor: pointer; text-align: left; }
.link.small { font-size: .88rem; color: var(--accent-ink); padding-left: 0; }
.link.danger { color: var(--bad); }
.center-block { display: block; margin: 1.5rem auto 0; }
.icon-btn { width: 44px; height: 44px; border: 0; background: none; color: var(--mute); font-size: 1.1rem; flex: none; cursor: pointer; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .5rem; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* bottom nav */
.nav { position: fixed; inset: auto 0 0 0; z-index: 5; display: grid; grid-template-columns: 30% 1fr; gap: .5rem;
  padding: .6rem 16px calc(.6rem + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--rule); }
.nav .btn.primary { gap: .5rem; white-space: nowrap; }
.next-to { font: 600 .62rem var(--mono); letter-spacing: .1em; text-transform: uppercase; opacity: .7; }
.nav .btn:only-child { grid-column: 1 / -1; }

/* fields */
.fields { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; grid-column: span 6; min-width: 0; }
.field.half { grid-column: span 3; }
.field.third { grid-column: span 2; }
.field-label { font: 600 .66rem var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--mute); }
.field-label em { text-transform: none; letter-spacing: 0; font-family: var(--sans); font-style: normal; }
input, select, textarea { width: 100%; min-height: 46px; padding: .55rem .7rem; border: 1px solid var(--rule); border-radius: 8px; background: #fff; }
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ink); outline-offset: -1px; }
.card .eyebrow + .fields, .card .choice-row + .fields { margin-top: .4rem; }
.card .fields + .fields { margin-top: 10px; }

/* segmented answers */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.seg-btn { min-height: 46px; border: 1px solid var(--rule); border-radius: 8px; background: #fff; font-weight: 700; cursor: pointer; }
.seg-btn[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.seg-btn[aria-pressed="true"][data-v="Y"], .seg-btn[aria-pressed="true"][data-v="PASSED"] { background: var(--ok); border-color: var(--ok); }
.seg-btn[aria-pressed="true"][data-v="N"], .seg-btn[aria-pressed="true"][data-v="FAILED"] { background: var(--bad); border-color: var(--bad); }
.seg-btn[aria-pressed="true"][data-v="NA"] { background: var(--na); border-color: var(--na); }
.seg.big .seg-btn { min-height: 56px; font-size: 1.05rem; }
.seg.ynna { margin-top: .6rem; }
.choice-row { display: grid; grid-template-columns: 5.5rem 1fr; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.gate .field-label { display: block; margin-bottom: .5rem; }

.q-tools { display: flex; justify-content: space-between; align-items: center; margin: .4rem 0 .2rem; }
.questions, .defs { list-style: none; padding: 0; margin: 0 0 12px; }
.q { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 12px; margin-bottom: 8px; }
.q.done { border-color: #cfd3cf; }
.q-text { display: flex; gap: .6rem; align-items: flex-start; }
.q-num { flex: none; min-width: 2rem; height: 1.6rem; padding: 0 .3rem; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; background: var(--ground); font: 700 .8rem var(--mono); }
.q .fields { margin-top: .6rem; }
.q-words { flex: 1; min-width: 0; }

/* per-question photos: a small camera in each tile's top-right corner, thumbnails under the text */
.cam { position: relative; flex: none; width: 40px; height: 40px; margin: -8px -8px 0 0; display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 8px; background: none; color: var(--mute); cursor: pointer; }
.cam:active { background: var(--ground); }
.cam.has { color: var(--ink); }
.cam.busy { opacity: .4; }
.cam b { position: absolute; top: 3px; right: 2px; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 99px; background: var(--ink); color: #fff;
  font: 700 .62rem/15px var(--mono); text-align: center; }
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: .5rem; }
.thumb { width: 56px; height: 56px; padding: 0; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; background: var(--ground); cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-full { display: block; width: 100%; max-height: 62vh; object-fit: contain; background: var(--ground); border-radius: 10px; margin: .4rem 0 .6rem; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(5.5rem + env(safe-area-inset-bottom)); z-index: 30; padding: .7rem .9rem; border-radius: 10px;
  background: var(--ink); color: #fff; font-size: .9rem; }

/* contractor suggestions under the name field */
.block-note { margin: -.1rem 0 .5rem; }
.suggest { grid-column: span 6; display: grid; gap: 4px; }
.suggest:empty { display: none; }
.suggestion { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-height: 48px; width: 100%; padding: .45rem .7rem;
  border: 1px solid var(--rule); border-radius: 8px; background: var(--ground); text-align: left; cursor: pointer; }
.suggestion span { font-weight: 600; overflow-wrap: anywhere; }
.suggestion small { color: var(--mute); font-size: .78rem; }
.photo-log { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--rule); }
.explain { margin-top: .6rem; }

/* deficiencies */
.def-head { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.def-head select { flex: 1; min-width: 0; font-size: .94rem; padding-right: .3rem; text-overflow: ellipsis; }
.empty { color: var(--mute); text-align: center; padding: 1rem; border: 1px dashed var(--rule); border-radius: var(--radius); }
.fit { font-size: .86rem; margin-top: .8rem; padding: .5rem .7rem; border-radius: 8px; }
.fit:empty { display: none; }
.fit.ok { background: var(--ok-bg); color: var(--ok); }
.fit.over { background: var(--bad-bg); color: var(--bad); }
.auto-notes { margin: 0; white-space: pre-wrap; font-size: .92rem; }

.callout { padding: .7rem .8rem; border-radius: 10px; background: var(--na-bg); margin: .6rem 0; }
.callout.warn { background: var(--warn-bg); color: var(--warn); }
.callout.ok { background: var(--ok-bg); color: var(--ok); }

/* signatures */
.sig-box { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 96px; border: 1.5px dashed var(--rule);
  border-radius: 10px; background: #fff; color: var(--mute); font-weight: 600; cursor: pointer; padding: 6px; }
.sig-box.signed { border-style: solid; color: #13244f; }
.sig-svg { width: 100%; height: 84px; }
.sig-card .fields { margin-top: 10px; }
.date-row { display: flex; align-items: flex-end; gap: .6rem; }
.date-row .field { flex: 1; }

.todo ul { list-style: none; margin: 0; padding: 0; }
.todo li { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--rule); }
.todo li:first-child { border-top: 0; }
.todo b, .badge { font: 700 .8rem var(--mono); background: var(--bad-bg); color: var(--bad); border-radius: 99px; padding: .1rem .55rem; }
.export { margin-top: .5rem; min-height: 56px; font-size: 1.05rem; }
.done-card { margin-top: 12px; border-top: 4px solid var(--ok); }
.done-card .btn.primary { margin-top: .6rem; }

/* sheets (parts list, signature pad) */
.sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: #0d0d0d73; }
.sheet-panel { position: relative; width: 100%; max-width: 640px; max-height: 88vh; overflow: auto; background: var(--card);
  border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.parts { list-style: none; margin: 0; padding: 0; }
.part-link { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: .5rem; min-height: 52px;
  border: 0; border-top: 1px solid var(--rule); background: none; text-align: left; cursor: pointer; padding: .4rem .2rem; }
.part-link small { display: block; font: 600 .6rem var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--mute); }
.tick { color: var(--ok); font-weight: 700; }
.sig-wrap { position: relative; margin: .6rem 0; }
.sig-canvas { display: block; width: 100%; border: 1px solid var(--rule); border-radius: 10px; background: #fff; touch-action: none; }
.sig-line { position: absolute; left: 8%; right: 8%; bottom: 22%; border-top: 1px solid #b9bcc2; font-size: .7rem; color: var(--mute);
  padding-top: 2px; pointer-events: none; }
.sheet-actions { display: grid; gap: .5rem; }

@media (min-width: 700px) {
  .nav { grid-template-columns: 200px 1fr; padding-left: max(16px, calc(50% - 304px)); padding-right: max(16px, calc(50% - 304px)); }
}
