/* Hand-written, no framework, no build step.

   Two audiences pull in opposite directions and both have to be served by one
   stylesheet: a technician one-thumbing a form in a mechanical room, and office
   staff reading an aging report on a desktop. So: mobile-first, 44px minimum
   tap targets, 17px form text (below that iOS zooms on focus) — and dense
   multi-column tables that only appear once there is room for them. */

:root {
  --ink: #16181d;
  --muted: #5d6470;
  --faint: #8b929e;
  --line: #dfe3ea;
  --bg: #f6f7f9;
  --card: #ffffff;
  --accent: #14532d;
  --accent-soft: #eaf3ee;
  --accent-ink: #ffffff;
  --ok: #2f7a52;
  --warn: #8a6a2f;
  --bad: #a33a3a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

.wrap { max-width: 720px; margin: 0 auto; padding: 16px 16px 72px; }
.wrap.wide { max-width: 1180px; }
.wrap.narrow { max-width: 520px; }

/* --- Header ------------------------------------------------------------- */

header.bar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
header.bar .inner {
  max-width: 1180px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 14px;
}
header.bar .brand { color: var(--ink); text-decoration: none; font-weight: 700; font-size: 16px; }
header.bar .brand span { display: block; font-size: 11px; font-weight: 500; color: var(--faint); }
/* align-items is load-bearing. Without it flex defaults to stretch, so text
   links grow to the height of the Sign out button and their labels sit visibly
   above the button's own centred text. */
header.bar nav {
  margin-left: auto; display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
}
header.bar nav a {
  font-weight: 500; color: var(--muted); font-size: 14.5px; text-decoration: none;
  padding: 6px 9px; border-radius: 7px;
}
header.bar nav a:hover { color: var(--accent); background: var(--accent-soft); }
header.bar nav a.on { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
header.bar form { display: inline; }
.whoami {
  font-size: 12px; color: var(--faint); border-left: 1px solid var(--line);
  padding-left: 12px; margin-left: 4px;
}

/* --- Type --------------------------------------------------------------- */

h1 { font-size: 24px; margin: 18px 0 6px; line-height: 1.25; }
h2 { font-size: 19px; margin: 26px 0 10px; }
h3 { font-size: 16px; margin: 18px 0 8px; }
p.hint { color: var(--muted); margin: 0 0 18px; }
.lead { font-size: 18px; color: var(--muted); }
.small { font-size: 13px; color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.page-head h1 { margin-bottom: 0; }
.page-head .spacer { margin-left: auto; }

/* --- Cards -------------------------------------------------------------- */

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card.tight { padding: 12px 14px; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }

/* A whole card that is a link. Without this the browser's default link styling
   underlines every word inside it, including the description, and the card
   reads as a paragraph of links rather than one target. */
a.card {
  display: block; text-decoration: none; color: var(--ink);
  transition: border-color .12s ease;
}
a.card:hover { border-color: var(--accent); }
a.card strong { color: var(--accent); display: block; margin-bottom: 3px; }
a.card .small { color: var(--muted); }

/* min() on the track floor is load-bearing: a bare minmax(300px, 1fr) is a
   *hard* minimum, so on a 375px phone the grid overflows and the page scrolls
   sideways. min(300px, 100%) lets the track collapse instead. */
.cards {
  display: grid; gap: 12px; margin-bottom: 14px;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
}
.cards.roomy { grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
}
.stat b { display: block; font-size: 26px; line-height: 1.15; }
.stat span { color: var(--muted); font-size: 12.5px; }
.stat.bad b { color: var(--bad); }
.stat.ok b { color: var(--ok); }
.stat.warn b { color: var(--warn); }
.stat a { text-decoration: none; }

/* --- Forms -------------------------------------------------------------- */

label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
label .opt { font-weight: 400; color: var(--faint); }

input[type=text], input[type=tel], input[type=email], input[type=password],
input[type=number], input[type=search], input[type=date], input[type=file],
textarea, select {
  width: 100%; padding: 11px 12px; font-size: 17px; /* 17px stops iOS zooming */
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
  font-family: inherit;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: 14px; }
.field .help { font-size: 12.5px; color: var(--faint); margin-top: 4px; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 11px 18px; font-size: 15.5px; font-weight: 600;
  border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink);
  cursor: pointer; text-decoration: none; font-family: inherit;
}
.btn:hover { filter: brightness(1.15); }
.btn.secondary { background: #fff; color: var(--accent); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn.ghost:hover { color: var(--accent); border-color: var(--accent); filter: none; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { min-height: 34px; padding: 5px 11px; font-size: 13.5px; }
.btn.block { width: 100%; }
.btn.big { min-height: 58px; font-size: 18px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Checkbox rows sit horizontally against the block `label` default. The whole
   row is the label, so the text is a tap target too — thumbs miss a 16px box. */
label.check {
  display: flex; align-items: center; gap: 10px;
  margin: 12px 0 4px; font-weight: 500; cursor: pointer; font-size: 15px;
}
label.check input[type=checkbox] {
  width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--accent);
}

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; align-items: center; }
.actions form { display: contents; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }

/* --- Flashes ------------------------------------------------------------ */

.flash { padding: 12px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid; font-size: 15px; }
.flash.info    { background: #eef4fa; border-color: #c7dbef; color: #244b6e; }
.flash.success { background: #eef7f1; border-color: #c3e3d0; color: #1f5c3c; }
.flash.warning { background: #fbf5e8; border-color: #ecd9ae; color: #6d5320; }
.flash.danger  { background: #fbeeee; border-color: #eec9c9; color: #7d2a2a; }

/* --- Pills and badges --------------------------------------------------- */

.pill {
  display: inline-block; font-size: 11.5px; padding: 2px 9px; border-radius: 999px;
  border: 1px solid; font-weight: 600; white-space: nowrap;
}
.pill.ok   { color: var(--ok);   border-color: #bfe0cd; background: #f1f9f4; }
.pill.warn { color: var(--warn); border-color: #ead9b4; background: #fdf8ee; }
.pill.bad  { color: var(--bad);  border-color: #ebc6c6; background: #fdf1f1; }
.pill.info { color: #24618e;     border-color: #c7dbef; background: #eef4fa; }
.pill.flat { color: var(--muted); border-color: var(--line); background: #fff; }

/* --- Tables ------------------------------------------------------------- */

table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { border-top: 2px solid var(--ink); border-bottom: 0; font-weight: 700; }
tr.sub td { font-weight: 600; background: #fafbfc; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.compact td, table.compact th { padding: 6px 8px; }

/* --- Lists of things you tap -------------------------------------------- */

ul.plain { list-style: none; margin: 0; padding: 0; }

.stop {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 14px; margin-bottom: 10px; text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow);
}
.stop:hover { border-color: var(--accent); }
/* Wide enough for "12:00pm" at this weight, and no narrower. At 40px the
   arrival time overflowed its box and printed straight through the customer's
   name on a 390px screen — which is the width this screen is actually used at. */
.stop .seq {
  flex: none; min-width: 66px; text-align: left;
  font-weight: 700; font-size: 16px; color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.stop .seq small { display: block; font-size: 11px; font-weight: 500; color: var(--faint); }
.stop .body { flex: 1; min-width: 0; }
.stop .body strong { display: block; font-size: 15.5px; }
.stop .body .addr { color: var(--muted); font-size: 14px; }
.stop .body .meta { color: var(--faint); font-size: 12.5px; margin-top: 3px; }
.stop .tail { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.stop.done { opacity: .65; }
.stop.late { border-left: 4px solid var(--bad); }

/* --- Booking ------------------------------------------------------------ */

.offer {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
  padding: 14px; margin-bottom: 12px;
}
.offer h3 { margin: 0 0 4px; font-size: 17px; }
.offer .when { color: var(--muted); font-size: 13.5px; margin-bottom: 10px; }
.slots { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); }
.slots button {
  min-height: 52px; font-size: 15.5px; font-weight: 600; font-family: inherit;
  border: 1px solid var(--accent); border-radius: 8px;
  background: #fff; color: var(--accent); cursor: pointer;
}
.slots button:hover { background: var(--accent); color: #fff; }
.slots button[disabled] { border-color: var(--line); color: var(--faint); background: #fafbfc; cursor: not-allowed; }
.slots button small { display: block; font-weight: 500; font-size: 11.5px; opacity: .8; }

.steps { display: flex; gap: 6px; margin: 0 0 18px; font-size: 12.5px; color: var(--faint); flex-wrap: wrap; }
.steps span { padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); background: #fff; }
.steps span.on { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.steps span.done { color: var(--ok); border-color: #bfe0cd; }

/* --- Definition grids --------------------------------------------------- */

dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; margin: 0; font-size: 14.5px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }

/* --- Public front page -------------------------------------------------- */

.hero {
  background: var(--accent); color: #fff; padding: 44px 16px 40px; text-align: center;
}
.hero h1 { font-size: 30px; margin: 0 0 8px; color: #fff; }
.hero p { max-width: 620px; margin: 0 auto 22px; color: #d6e6dc; font-size: 17px; }
.hero .btn { background: #fff; color: var(--accent); border-color: #fff; }
.hero .btn.secondary { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }
.zonegrid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
.zonecard { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; background: var(--card); }
.zonecard h3 { margin: 0 0 2px; }
.zonecard .days { color: var(--accent); font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.zonecard .villages { color: var(--muted); font-size: 13.5px; }

/* --- Reading -------------------------------------------------------------*/

.prose { max-width: 68ch; }
.prose h2 { margin-top: 30px; }
.prose li { margin-bottom: 6px; }
.prose code {
  background: #eef0f3; padding: 1px 5px; border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px;
}
.callout {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  padding: 12px 14px; border-radius: 0 8px 8px 0; margin: 16px 0; font-size: 14.5px;
}

/* --- Misc --------------------------------------------------------------- */

.empty { color: var(--muted); padding: 24px 16px; text-align: center; font-size: 15px; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.tag-list { display: flex; gap: 6px; flex-wrap: wrap; }

details.panel summary {
  cursor: pointer; color: var(--accent); font-size: 14px; font-weight: 600;
  list-style: none; padding: 6px 0;
}
details.panel summary::-webkit-details-marker { display: none; }
details.panel summary::before { content: "+ "; }
details.panel[open] summary::before { content: "− "; }
details.panel .panel-body { padding-top: 10px; border-top: 1px solid var(--line); margin-top: 6px; }

/* The header is the one piece of chrome on every screen, including the phone in
   a boiler room. Below 620px the tagline is dropped and the brand shrinks —
   otherwise "Varisco Backflow Testing" wraps onto three lines and pushes the
   navigation into a column, which is most of a phone screen spent on a logo. */
@media (max-width: 620px) {
  header.bar .inner { padding: 8px 12px; gap: 8px; }
  header.bar .brand { font-size: 14px; line-height: 1.25; }
  header.bar .brand span { display: none; }
  header.bar nav { gap: 2px; }
  header.bar nav a { padding: 5px 7px; font-size: 13.5px; }
  .whoami { display: none; }
  .wrap { padding: 12px 12px 64px; }
}

@media (min-width: 760px) {
  h1 { font-size: 28px; }
  .hero h1 { font-size: 38px; }
}

@media print {
  header.bar, .actions, .btn, .steps { display: none !important; }
  body { background: #fff; }
  .card { border: 0; box-shadow: none; padding: 0; }
  .wrap { max-width: none; padding: 0; }
}
