/*
 * House Survey — the whole stylesheet.
 *
 * MOBILE FIRST, and not as a slogan: the inspection screen is used on a phone
 * held in one hand in somebody's loft. Everything below is written narrow and
 * widened at a breakpoint, tap targets are 44px, and inputs are 16px because
 * anything smaller makes iOS Safari zoom the page on focus and lose your place.
 */

:root {
  --ink: #16202b;
  --ink-soft: #4a5a6a;
  --ink-faint: #7d8b99;
  --line: #d9e0e7;
  --line-soft: #eef2f6;
  --paper: #ffffff;
  --wash: #f4f7fa;
  --accent: #1d5f8a;
  --accent-dark: #17496a;
  --accent-wash: #e7f0f6;

  --r1: #2e7d44;  --r1-bg: #e8f4ea;
  --r2: #b8730d;  --r2-bg: #fdf1de;
  --r3: #b02a2a;  --r3-bg: #fbe9e9;
  --rNI: #6b7885; --rNI-bg: #eef1f4;

  --radius: 10px;
  --shadow: 0 1px 3px rgba(22,32,43,.09), 0 6px 18px rgba(22,32,43,.05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--wash);
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; font-weight: 650; }
h1 { font-size: 1.3rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .98rem; }
p { margin: 0 0 .8rem; }
a { color: var(--accent); }
ul, ol { margin: 0 0 .9rem; padding-left: 1.2rem; }
li { margin-bottom: .35rem; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .88em; background: var(--line-soft); padding: .1rem .3rem; border-radius: 4px; }

.wrap { max-width: 860px; margin: 0 auto; padding: 0 .85rem; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); font-size: .85rem; }

/* ------------------------------------------------------------------- frame */
header.app {
  background: var(--ink); color: #fff;
  padding: calc(.65rem + env(safe-area-inset-top)) 0 .65rem;
}
header.app .wrap { display: flex; align-items: center; justify-content: space-between; gap: .8rem; }
header.app .brand { color: #fff; text-decoration: none; font-size: 1.02rem; }
header.app .who { font-size: .82rem; display: flex; gap: .6rem; align-items: baseline; }
header.app .who a { color: #9fd0ee; }
header.app .who .faint { color: #9fb2c2; }

nav.tabs { background: #21303f; overflow-x: auto; scrollbar-width: none; }
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs .wrap { display: flex; gap: .1rem; padding: 0 .5rem; }
nav.tabs a {
  flex: 0 0 auto; color: #9fb2c2; text-decoration: none; font-size: .87rem;
  padding: .65rem .7rem .55rem; border-bottom: 3px solid transparent; white-space: nowrap;
}
nav.tabs a[aria-current="page"] { color: #fff; border-bottom-color: #5aa9d6; }

main { padding: 1rem 0 3rem; }

footer.app { border-top: 1px solid var(--line); padding: 1rem 0 calc(1.5rem + env(safe-area-inset-bottom)); }
footer.app .faint { font-size: .8rem; }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: .8rem; margin-bottom: .8rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }

nav.subnav { display: flex; gap: .3rem; overflow-x: auto; margin-bottom: .9rem; scrollbar-width: none; }
nav.subnav::-webkit-scrollbar { display: none; }
nav.subnav a {
  flex: 0 0 auto; font-size: .85rem; text-decoration: none; color: var(--ink-soft);
  background: var(--paper); border: 1px solid var(--line); border-radius: 999px;
  padding: .4rem .8rem; white-space: nowrap;
}
nav.subnav a.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ------------------------------------------------------------------- cards */
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .95rem; margin: 0 0 .85rem; box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }

.flash { border-radius: 8px; padding: .65rem .8rem; font-size: .9rem; margin: 0 0 .9rem; }
.flash.ok  { background: var(--r1-bg); color: #1e5c30; border: 1px solid #c6e3cd; }
.flash.bad { background: var(--r3-bg); color: #8c2020; border: 1px solid #eccaca; }

.callout { background: var(--accent-wash); border: 1px solid #cfe0ec; border-radius: var(--radius); padding: .8rem .9rem; font-size: .9rem; margin: 0 0 .9rem; }
.callout.warn { background: var(--r2-bg); border-color: #f0dcb8; }

/* ------------------------------------------------------------- survey list */
.filters { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .9rem; }
.chip {
  font-size: .82rem; text-decoration: none; color: var(--ink-soft);
  background: var(--paper); border: 1px solid var(--line); border-radius: 999px;
  padding: .35rem .7rem;
}
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip b { font-weight: 650; }

.job {
  display: block; text-decoration: none; color: inherit; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .8rem .9rem; margin-bottom: .6rem; box-shadow: var(--shadow);
}
.job:hover { border-color: var(--accent); }
.job-top { display: flex; justify-content: space-between; gap: .6rem; align-items: flex-start; }
.job .addr { font-weight: 650; }
.job .meta { font-size: .84rem; color: var(--ink-soft); margin-top: .2rem; }
.job .bar { display: flex; gap: .35rem; align-items: center; margin-top: .5rem; flex-wrap: wrap; }

.empty { text-align: center; padding: 2rem 1rem; }

/* ------------------------------------------------------------------- pills */
.pill {
  display: inline-block; font-size: .73rem; font-weight: 650; letter-spacing: .02em;
  padding: .2rem .55rem; border-radius: 999px; white-space: nowrap;
  background: var(--accent-wash); color: var(--accent-dark);
}
.pill.lvl   { background: #e6ecf1; color: var(--ink-soft); }
.pill.blank { background: var(--line-soft); color: var(--ink-faint); }
.pill.r1  { background: var(--r1-bg);  color: var(--r1); }
.pill.r2  { background: var(--r2-bg);  color: var(--r2); }
.pill.r3  { background: var(--r3-bg);  color: var(--r3); }
.pill.rNI { background: var(--rNI-bg); color: var(--rNI); }
.pill.st-issued, .pill.st-paid, .pill.st-invoiced { background: var(--r1-bg); color: var(--r1); }
.pill.st-inspected, .pill.st-drafting { background: var(--r2-bg); color: var(--r2); }
.pill.st-lost { background: var(--rNI-bg); color: var(--rNI); }

/* ----------------------------------------------------------------- buttons */
.btn {
  display: inline-block; font: inherit; font-size: .9rem; font-weight: 600;
  border-radius: 8px; padding: .6rem .95rem; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); cursor: pointer; text-decoration: none;
  min-height: 44px; line-height: 1.6;
}
.btn:hover { border-color: var(--accent); color: var(--accent-dark); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); color: #fff; }
.btn.danger { color: var(--r3); border-color: #e8c9c9; }
.btn.small { font-size: .83rem; padding: .4rem .7rem; min-height: 38px; }
.btn.wide { width: 100%; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0; }
.sticky-save { margin: 1rem 0; }

button.link { background: none; border: 0; color: var(--accent); font: inherit; font-size: .78rem; cursor: pointer; padding: .2rem 0; text-decoration: underline; }

.danger-zone { border-top: 1px solid var(--line); margin-top: 1.5rem; padding-top: 1rem; }

/* ------------------------------------------------------------------- forms */
label.field { display: block; margin-bottom: .85rem; }
label.field > .lbl { display: block; font-size: .82rem; font-weight: 650; color: var(--ink-soft); margin-bottom: .25rem; }
label.field > .hint { display: block; font-size: .79rem; color: var(--ink-faint); margin-top: .28rem; }

input[type=text], input[type=date], input[type=number], input[type=email],
input[type=tel], input[type=password], input[type=file], select, textarea {
  width: 100%; font: inherit;
  /* 16px exactly. Anything smaller and iOS Safari zooms the page on focus,
     which on the inspection screen means losing your place mid-element. */
  font-size: 16px;
  padding: .58rem .6rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--paper); color: var(--ink);
}
textarea { min-height: 4.5rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

.row { display: grid; gap: 0 .8rem; grid-template-columns: 1fr; }

.signin { max-width: 380px; margin: 2rem auto; }
body.plain nav.tabs { display: none; }

/* --------------------------------------------------------------- checklist */
.level-note .prog { font-size: .95rem; margin-bottom: .4rem; }
.bar-track { height: 6px; background: var(--line-soft); border-radius: 999px; overflow: hidden; margin-bottom: .6rem; }
.bar-fill { height: 100%; background: var(--accent); }

h2.grp { margin: 1.4rem 0 .6rem; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); }

.elem {
  background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--line);
  border-radius: var(--radius); padding: .85rem .9rem; margin-bottom: .6rem; box-shadow: var(--shadow);
}
.elem.done.r1 { border-left-color: var(--r1); }
.elem.done.r2 { border-left-color: var(--r2); }
.elem.done.r3 { border-left-color: var(--r3); }
.elem.done.rNI { border-left-color: var(--rNI); }
.elem.done.o-clear  { border-left-color: var(--r1); }
.elem.done.o-noted  { border-left-color: var(--r2); }
.elem.done.o-action { border-left-color: var(--r3); }
.elem.done.o-na     { border-left-color: var(--rNI); }

.elem-head .name { font-weight: 650; }
.hint-line { font-size: .85rem; color: var(--ink-soft); margin: .35rem 0 .3rem; }
.depth { font-size: .84rem; color: var(--accent-dark); background: var(--accent-wash); border-radius: 6px; padding: .4rem .55rem; margin: .4rem 0; }

/* The rating buttons. Radio inputs made to look like buttons, so the app works
   with the keyboard and without JavaScript. */
.rates { display: flex; gap: .35rem; margin: .6rem 0 .2rem; flex-wrap: wrap; }
.rate { position: relative; }
.rate input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.rate span {
  display: flex; align-items: center; justify-content: center;
  min-width: 48px; min-height: 44px; padding: 0 .6rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--paper);
  font-weight: 650; font-size: .9rem; color: var(--ink-soft);
}
.rate input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.rate.v1 input:checked + span  { background: var(--r1); border-color: var(--r1); color: #fff; }
.rate.v2 input:checked + span  { background: var(--r2); border-color: var(--r2); color: #fff; }
.rate.v3 input:checked + span  { background: var(--r3); border-color: var(--r3); color: #fff; }
.rate.vNI input:checked + span { background: var(--rNI); border-color: var(--rNI); color: #fff; }
.rate.vclear input:checked + span { background: var(--line-soft); }
.rate-key { margin: .1rem 0 .7rem; font-size: .76rem; }

.thumbs { display: flex; gap: .5rem; flex-wrap: wrap; margin: .7rem 0; }
.thumbs figure { margin: 0; width: 88px; }
.thumbs img { width: 88px; height: 88px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; }
.thumbs figcaption { font-size: .7rem; color: var(--ink-faint); margin-top: .2rem; word-break: break-word; }

.photo-add { display: flex; flex-direction: column; gap: .45rem; border-top: 1px dashed var(--line); padding-top: .7rem; margin-top: .7rem; }

/* --------------------------------------------------------------- reference */
.ref h3 { margin-top: 1.1rem; }
.levelcard { border-left: 4px solid var(--accent); }
dl.ratings { margin: 0; }
dl.ratings dt { margin-top: .7rem; }
dl.ratings dd { margin: .25rem 0 0; font-size: .9rem; color: var(--ink-soft); }
.src { border-bottom: 1px solid var(--line-soft); padding: .65rem 0; }
.src:last-child { border-bottom: 0; }
.src .t { font-weight: 600; }
.src .d { font-size: .86rem; color: var(--ink-soft); margin-top: .2rem; }

/* ------------------------------------------------------------------ report */
.rep-head { border-bottom: 2px solid var(--ink); padding-bottom: .7rem; margin-bottom: 1rem; }
.rep-meta { display: grid; grid-template-columns: 1fr; gap: .3rem 1rem; font-size: .88rem; }
.rep-meta div { display: flex; gap: .5rem; }
.rep-meta dt, .rep-meta .k { color: var(--ink-faint); min-width: 8.5rem; }
table.rep { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.rep th, table.rep td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.rep th { color: var(--ink-faint); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.scroller { overflow-x: auto; }

/* ------------------------------------------------------------ wider screens */
@media (min-width: 620px) {
  h1 { font-size: 1.5rem; }
  .row { grid-template-columns: 1fr 1fr; }
  .rep-meta { grid-template-columns: 1fr 1fr; }
  .photo-add { flex-direction: row; align-items: center; }
  .photo-add input[type=text] { flex: 1; }
}

/* ------------------------------------------------------------------- print
 *
 * The report is produced by printing this page to PDF from the browser. That
 * is the whole mechanism - no library, nothing to install, and it picks up
 * whatever the browser already knows about paper sizes.
 */
@media print {
  header.app, nav.tabs, nav.subnav, footer.app, .no-print,
  .btn, .btn-row, .filters, .danger-zone, form { display: none !important; }
  body { background: #fff; font-size: 10.5pt; color: #000; }
  .wrap { max-width: none; padding: 0; }
  main { padding: 0; }
  .card { box-shadow: none; border: 0; border-bottom: 1px solid #ccc; border-radius: 0; padding: .4rem 0 .8rem; margin: 0 0 .6rem; }
  .elem { box-shadow: none; border: 0; border-left: 3px solid #999; border-radius: 0; padding: .3rem 0 .5rem .6rem; margin-bottom: .5rem; break-inside: avoid; }
  .elem.done.r1 { border-left-color: #2e7d44; }
  .elem.done.r2 { border-left-color: #b8730d; }
  .elem.done.r3 { border-left-color: #b02a2a; }
  h2.grp { color: #000; margin-top: .9rem; }
  .thumbs img { width: 120px; height: 120px; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .8em; color: #444; word-break: break-all; }
  .page-break { break-before: page; }
  table.rep { font-size: 9.5pt; }
}
