/* SAES report generator — interface styles.
   No framework and no build step: this host has neither node nor npm, and the only
   JavaScript the app needs is the browser-side photo resizer. */

/* ---------- colour ----------
   Two independent axes, so neither has to know about the other:
     data-palette  which hue the interface is built around
     data-theme    light or dark (absent = follow the operating system)

   A palette supplies a light and a dark value for everything it touches, as -l / -d
   pairs. The blocks further down resolve those pairs to the tokens the components
   actually use. Adding a palette therefore means adding one block of data, and no
   component CSS changes at all.

   The neutrals shift with the palette rather than staying grey — a slate interface with
   green-tinted paper reads as a mistake. Only the accents and the paper move; the
   semantic colours (amber for caution, rust for alarm) stay put, because a warning must
   not change meaning when someone changes the colour scheme.

   None of this reaches the PDF. The document is SAES green and always will be — the
   brand is fixed, and only the tool around it is adjustable. */

:root {
  /* SAES green — the default, and the brand the documents are printed in. */
  --p-paper-l: #F6F8F7; --p-card-l: #FFFFFF; --p-ink-l: #10201A;
  --p-muted-l: #5F6F67; --p-faint-l: #84968C; --p-line-l: #DCE4E0; --p-linesoft-l: #EAF0ED;
  --p-accent-l: #00703C; --p-accentink-l: #005C31; --p-accentwash-l: #EAF4EE;

  --p-paper-d: #0E1512; --p-card-d: #161F1B; --p-ink-d: #E5EDE9;
  --p-muted-d: #94A69C; --p-faint-d: #71847A; --p-line-d: #26332D; --p-linesoft-d: #1D2823;
  --p-accent-d: #4FB884; --p-accentink-d: #6BC998; --p-accentwash-d: #12271D;

  --radius: 5px;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

/* Cool blue-grey. The furthest thing from green while staying sober. */
:root[data-palette="slate"] {
  --p-paper-l: #F5F7F9; --p-card-l: #FFFFFF; --p-ink-l: #14202A;
  --p-muted-l: #5C6B78; --p-faint-l: #8496A3; --p-line-l: #DBE2E8; --p-linesoft-l: #E9EEF2;
  --p-accent-l: #1F5A7A; --p-accentink-l: #17475F; --p-accentwash-l: #E7F0F6;

  --p-paper-d: #0D1319; --p-card-d: #151E26; --p-ink-d: #E3EBF1;
  --p-muted-d: #92A4B1; --p-faint-d: #6F8290; --p-line-d: #253038; --p-linesoft-d: #1B242B;
  --p-accent-d: #6FB4D6; --p-accentink-d: #8AC5E1; --p-accentwash-d: #10222C;
}

/* Warm terracotta. Reads as paper and ink rather than software. */
:root[data-palette="copper"] {
  --p-paper-l: #FAF7F4; --p-card-l: #FFFFFF; --p-ink-l: #241A14;
  --p-muted-l: #6E5F55; --p-faint-l: #9A8B80; --p-line-l: #E5DCD4; --p-linesoft-l: #F1EAE4;
  --p-accent-l: #A2542A; --p-accentink-l: #874320; --p-accentwash-l: #FAEEE6;

  --p-paper-d: #14100D; --p-card-d: #1E1815; --p-ink-d: #EEE6DF;
  --p-muted-d: #A89588; --p-faint-d: #86756A; --p-line-d: #33291F; --p-linesoft-d: #241D18;
  --p-accent-d: #E0956A; --p-accentink-d: #EBAB86; --p-accentwash-d: #2B1A10;
}

/* Deep violet. The most decorative of the set; still legible at length. */
:root[data-palette="plum"] {
  --p-paper-l: #F8F6FA; --p-card-l: #FFFFFF; --p-ink-l: #1E1624;
  --p-muted-l: #665C71; --p-faint-l: #94899F; --p-line-l: #E2DCE8; --p-linesoft-l: #EEE9F2;
  --p-accent-l: #6A3D7C; --p-accentink-l: #563066; --p-accentwash-l: #F3ECF7;

  --p-paper-d: #120E16; --p-card-d: #1C161F; --p-ink-d: #EBE4EF;
  --p-muted-d: #A497AD; --p-faint-d: #83758C; --p-line-d: #2E2536; --p-linesoft-d: #201924;
  --p-accent-d: #C08FD4; --p-accentink-d: #CDA5DD; --p-accentwash-d: #221429;
}

/* Near-monochrome. For anyone who would rather the tool disappeared. */
:root[data-palette="graphite"] {
  --p-paper-l: #F7F7F8; --p-card-l: #FFFFFF; --p-ink-l: #1A1D1F;
  --p-muted-l: #616669; --p-faint-l: #8B9296; --p-line-l: #DFE1E3; --p-linesoft-l: #ECEEEF;
  --p-accent-l: #3E4A52; --p-accentink-l: #2C363C; --p-accentwash-l: #ECEFF1;

  --p-paper-d: #101213; --p-card-d: #1A1D1F; --p-ink-d: #E8EAEB;
  --p-muted-d: #9AA1A5; --p-faint-d: #798085; --p-line-d: #2A2E31; --p-linesoft-d: #1F2325;
  --p-accent-d: #A9B7BF; --p-accentink-d: #BDC9CF; --p-accentwash-d: #1D2326;
}

/* ---------- resolve the palette against light or dark ---------- */

:root, :root[data-theme="light"] {
  --paper: var(--p-paper-l); --card: var(--p-card-l); --ink: var(--p-ink-l);
  --muted: var(--p-muted-l); --faint: var(--p-faint-l);
  --line: var(--p-line-l); --line-soft: var(--p-linesoft-l);
  --accent: var(--p-accent-l); --accent-ink: var(--p-accentink-l); --accent-wash: var(--p-accentwash-l);
  --amber: #8A5A0B; --amber-wash: #FBF2E2;
  --rust: #A33221; --rust-wash: #FBEDEA;
  --shadow-sm: 0 1px 2px rgba(16, 32, 26, .06);
  --shadow: 0 1px 2px rgba(16, 32, 26, .05), 0 6px 18px rgba(16, 32, 26, .06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: var(--p-paper-d); --card: var(--p-card-d); --ink: var(--p-ink-d);
    --muted: var(--p-muted-d); --faint: var(--p-faint-d);
    --line: var(--p-line-d); --line-soft: var(--p-linesoft-d);
    --accent: var(--p-accent-d); --accent-ink: var(--p-accentink-d); --accent-wash: var(--p-accentwash-d);
    --amber: #DCA95C; --amber-wash: #2A2113;
    --rust: #E28E7D; --rust-wash: #2C1815;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.3);
  }
}

/* An explicit choice must beat the operating system in BOTH directions. */
:root[data-theme="dark"] {
  --paper: var(--p-paper-d); --card: var(--p-card-d); --ink: var(--p-ink-d);
  --muted: var(--p-muted-d); --faint: var(--p-faint-d);
  --line: var(--p-line-d); --line-soft: var(--p-linesoft-d);
  --accent: var(--p-accent-d); --accent-ink: var(--p-accentink-d); --accent-wash: var(--p-accentwash-d);
  --amber: #DCA95C; --amber-wash: #2A2113;
  --rust: #E28E7D; --rust-wash: #2C1815;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- chrome ---------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--card); border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.topbar .inner {
  max-width: 1120px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.brand {
  font-weight: 700; letter-spacing: -.01em; color: var(--accent);
  text-decoration: none; font-size: 17px; display: flex; align-items: baseline; gap: 8px;
}
.brand span { font-weight: 400; color: var(--muted); font-size: 13px; letter-spacing: 0; }
.topbar .spacer { flex: 1; }
.topbar .ref {
  font-family: var(--mono); font-size: 13px; color: var(--muted);
  padding: 3px 9px; background: var(--accent-wash); border-radius: 3px;
}

main { max-width: 1120px; margin: 0 auto; padding: 28px 24px 120px; }

h1 { font-size: 25px; letter-spacing: -.02em; margin: 0 0 4px; font-weight: 640; }
h1 + .sub { color: var(--muted); margin: 0 0 26px; font-size: 15px; }

/* ---------- buttons ---------- */

.btn {
  font: inherit; font-size: 14px; font-weight: 550; cursor: pointer;
  padding: 8px 16px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  text-decoration: none; display: inline-flex; align-items: center; gap: 7px;
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { border-color: var(--muted); }
.btn-primary {
  /* The green is light enough in dark mode that white text would fail contrast, so the
     label follows the page ground rather than being hard-coded white. */
  background: var(--accent); border-color: var(--accent); color: var(--paper);
}
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn-quiet:hover { background: var(--line-soft); border-color: transparent; color: var(--ink); }
.btn-danger { color: var(--rust); border-color: transparent; background: transparent; }
.btn-danger:hover { background: var(--rust-wash); border-color: transparent; }
.btn-sm { padding: 5px 11px; font-size: 13px; }

/* ---------- cards & sections ---------- */

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 20px;
}
.card > header {
  padding: 14px 20px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
}
.card > header h2 {
  margin: 0; font-size: 13px; font-family: var(--mono); font-weight: 500;
  letter-spacing: .09em; text-transform: uppercase; color: var(--muted);
}
.card > header .hint { font-size: 13px; color: var(--faint); margin-left: auto; }
.card .body { padding: 20px; }

/* ---------- form fields ---------- */

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; }
.grid.one { grid-template-columns: 1fr; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: 1 / -1; }
@media (max-width: 700px) {
  .grid, .grid.three { grid-template-columns: 1fr; }
}

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label {
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  letter-spacing: .01em;
}
.field .note { font-size: 12.5px; color: var(--faint); }

input[type="text"], input[type="date"], input[type="number"], input[type="email"],
textarea, select {
  font: inherit; font-size: 14.5px; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 10px; width: 100%; min-width: 0;
}
textarea { resize: vertical; min-height: 62px; line-height: 1.45; }
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
input[readonly] { background: var(--line-soft); color: var(--muted); }

/* yes / no as a segmented control — two states, always visible, no menu to open */
.yesno { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.yesno label {
  padding: 7px 18px; font-size: 14px; cursor: pointer; background: var(--card);
  color: var(--muted); border-right: 1px solid var(--line); user-select: none;
}
.yesno label:last-child { border-right: 0; }
.yesno input { position: absolute; opacity: 0; pointer-events: none; }
.yesno label:has(input:checked) { background: var(--accent); color: var(--paper); font-weight: 600; }
.yesno label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- combobox: the learning dropdown ---------- */

.combo { position: relative; }
.combo-input { padding-right: 30px; }
.combo-toggle {
  position: absolute; right: 1px; top: 1px; bottom: 1px; width: 28px;
  border: 0; background: transparent; cursor: pointer; color: var(--muted);
  display: grid; place-items: center; border-radius: 0 var(--radius) var(--radius) 0;
}
.combo-toggle:hover { color: var(--ink); }
.combo-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 3px);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); max-height: 240px; overflow-y: auto; padding: 4px;
  margin: 0; list-style: none;
}
.combo-list[hidden] { display: none; }
.combo-list li {
  padding: 7px 10px; border-radius: 3px; cursor: pointer; font-size: 14.5px;
}
.combo-list li[aria-selected="true"], .combo-list li:hover { background: var(--accent-wash); }
.combo-list li .new { color: var(--accent); font-weight: 600; }
.combo-list li.empty { color: var(--faint); cursor: default; }
.combo-list li.empty:hover { background: transparent; }

/* The second column of an option that carries something with it — the postcode beside a
   suburb. Pushed to the right edge so the suburb names stay a readable column. */
.combo-meta {
  color: var(--muted); font-variant-numeric: tabular-nums; flex: none; margin-left: auto;
}

/* A field whose value is being decided by something else — the air monitoring lines when
   there is no certificate of analysis. Dashed, like an overridden attachment, and for the
   same reason: the override should be visible rather than eerie. */
.field.forced .yesno, .field.forced input, .field.forced .combo-input {
  border-style: dashed; color: var(--muted);
}

/* ---------- attachments & live appendix preview ---------- */

.attach { display: flex; flex-direction: column; gap: 10px; }
.attach label {
  display: flex; align-items: flex-start; gap: 11px; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
}
.attach label:has(input:checked) { border-color: var(--accent); background: var(--accent-wash); }
.attach label.forced { border-style: dashed; }
.attach input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; }
.attach .t { font-weight: 600; font-size: 14.5px; }
.attach .d { font-size: 13px; color: var(--muted); }

.appendix-preview { display: flex; flex-direction: column; gap: 7px; }
.appendix-preview .row {
  display: flex; align-items: center; gap: 11px; font-size: 14px;
  padding: 8px 11px; background: var(--accent-wash); border-radius: var(--radius);
}
.appendix-preview .letter {
  font-family: var(--mono); font-weight: 700; color: var(--accent);
  width: 22px; text-align: center; flex: none;
}
.appendix-preview .none { color: var(--faint); font-size: 14px; font-style: italic; }
.appendix-preview .pages { margin-left: auto; color: var(--muted); font-size: 13px; }

/* ---------- samples table ---------- */

.samples { width: 100%; border-collapse: collapse; }
.samples th {
  text-align: left; font-size: 11px; font-family: var(--mono); letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); font-weight: 500;
  padding: 0 8px 8px; border-bottom: 1px solid var(--line);
}
.samples td { padding: 6px 8px; vertical-align: top; }
.samples td:first-child, .samples th:first-child { padding-left: 0; }
.samples td:last-child, .samples th:last-child { padding-right: 0; }
.samples .num {
  font-family: var(--mono); font-size: 13px; color: var(--muted); white-space: nowrap;
  padding-top: 15px;
}
.samples .conc {
  font-family: var(--mono); font-size: 13px; padding-top: 15px; white-space: nowrap;
}
.samples .conc.computed { color: var(--accent); }
.samples .conc.manual { color: var(--rust); font-weight: 600; }
.samples input[type="number"] { text-align: right; font-variant-numeric: tabular-nums; }

/* The generated field blank. Read-only by being text rather than inputs, and set apart so it
   reads as something the report adds rather than a row left half-filled. */
.samples tfoot .blank-row td {
  border-top: 1px dashed var(--line); padding-top: 14px;
  font-family: var(--mono); font-size: 13px; color: var(--muted);
}

/* A prefix printed against a field — the `J0` of a project number. It sits inside the same
   box as the input so the two read as one value. */
.affix { display: flex; align-items: stretch; }
.affix-prefix {
  display: flex; align-items: center; padding: 0 2px 0 10px;
  border: 1px solid var(--line); border-right: 0;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--paper); color: var(--muted);
  font-family: var(--mono); font-size: 14px; white-space: nowrap;
}
.affix input {
  border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 0;
  font-family: var(--mono); letter-spacing: .04em;
}
.affix:focus-within .affix-prefix { border-color: var(--accent); }

/* The × that removes an entry from a dropdown. Kept quiet until the row is pointed at, so a
   list of options does not read as a list of delete buttons. */
.combo-del {
  flex: none; margin-left: auto; border: 0; background: none; cursor: pointer;
  color: var(--faint); font-size: 16px; line-height: 1; padding: 0 2px;
  opacity: 0; transition: opacity .12s ease, color .12s ease;
}
.combo-list li { display: flex; align-items: center; gap: 10px; }
.combo-list li:hover .combo-del,
.combo-list li[aria-selected="true"] .combo-del,
.combo-del:focus-visible { opacity: 1; }
.combo-del:hover { color: var(--rust); }
.combo-error { color: var(--rust); display: block; margin-top: 4px; }

/* The Yes / No prompt. Anchored to what is being deleted rather than floating in the middle
   of the screen, because "delete this" only means anything next to the this. */
.confirm {
  position: absolute; z-index: 60; margin-top: 6px; max-width: 320px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 14px;
}
.confirm p { margin: 0 0 10px; font-size: 13.5px; line-height: 1.45; }
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }
/* The two anchors it attaches to have to establish the positioning context. Scoped to those,
   rather than every cell on the page. */
.field, .list .row-actions form { position: relative; }
/* Far enough from the right edge of the table to stay on screen. */
.list .row-actions .confirm { right: 0; }

.sample-alert {
  margin-top: 14px; padding: 11px 14px; border-radius: var(--radius);
  background: var(--rust-wash); color: var(--rust); font-size: 14px;
  border: 1px solid color-mix(in srgb, var(--rust) 30%, transparent);
}
.sample-alert[hidden] { display: none; }

/* ---------- photos ---------- */

.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 30px 20px;
  text-align: center; color: var(--muted); cursor: pointer; background: var(--card);
  transition: border-color .12s ease, background .12s ease;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-wash); }
.dropzone strong { color: var(--ink); display: block; font-size: 15px; margin-bottom: 3px; }
.dropzone .sub { font-size: 13px; }

.photo-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px; margin-top: 18px;
}
.photo {
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  background: var(--card); display: flex; flex-direction: column;
}
.photo.dragging { opacity: .4; }
.photo.dragover { border-color: var(--accent); }
.photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--line-soft); }
.photo .meta { padding: 9px 10px; display: flex; flex-direction: column; gap: 7px; }
.photo .n {
  font-family: var(--mono); font-size: 11.5px; color: var(--muted);
  display: flex; align-items: center; gap: 8px;
}
.photo .n .grab { cursor: grab; color: var(--faint); }
.photo .n .del { margin-left: auto; }
.photo textarea { font-size: 13px; min-height: 46px; padding: 6px 8px; }

.upload-status { margin-top: 12px; font-size: 14px; color: var(--muted); }
.upload-status .bar {
  height: 4px; background: var(--line-soft); border-radius: 2px; overflow: hidden; margin-top: 7px;
}
.upload-status .bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s ease; }

/* ---------- sign in ---------- */

body.signin { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.signin-panel {
  width: 100%; max-width: 380px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 32px;
}
.signin-panel h1 {
  font-size: 21px; color: var(--accent); margin: 0 0 24px; font-weight: 700; letter-spacing: -.01em;
}
.signin-panel h1 span { font-weight: 400; color: var(--muted); font-size: 15px; }
.signin-panel form { display: flex; flex-direction: column; gap: 16px; }
.signin-panel .btn { justify-content: center; margin-top: 4px; }
.signin-panel .note { font-size: 13px; color: var(--faint); margin: 22px 0 0; }

/* ---------- appearance picker ---------- */

.appearance { position: relative; }
.appearance-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 11px; font: inherit; font-size: 13px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--ink);
}
.appearance-btn:hover { border-color: var(--muted); }
.appearance-btn .dot {
  width: 12px; height: 12px; border-radius: 50%; background: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.12);
}
.appearance-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px; min-width: 226px;
}
.appearance-menu[hidden] { display: none; }
.appearance-menu h3 {
  margin: 0 0 8px; font-size: 10.5px; font-family: var(--mono); font-weight: 500;
  letter-spacing: .1em; text-transform: uppercase; color: var(--faint);
}
.appearance-menu h3 + * { margin-top: 0; }
.appearance-menu .modes { display: flex; gap: 0; margin-bottom: 16px; }
.appearance-menu .modes button {
  flex: 1; font: inherit; font-size: 13px; padding: 6px 4px; cursor: pointer;
  background: var(--card); color: var(--muted);
  border: 1px solid var(--line); border-right-width: 0;
}
.appearance-menu .modes button:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.appearance-menu .modes button:last-child { border-radius: 0 var(--radius) var(--radius) 0; border-right-width: 1px; }
.appearance-menu .modes button[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: var(--paper); font-weight: 600;
}
.appearance-menu .palettes { display: flex; flex-direction: column; gap: 2px; }
.appearance-menu .palettes button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  font: inherit; font-size: 13.5px; text-align: left; cursor: pointer;
  padding: 7px 9px; border: 0; border-radius: 3px;
  background: transparent; color: var(--ink);
}
.appearance-menu .palettes button:hover { background: var(--line-soft); }
.appearance-menu .palettes button[aria-pressed="true"] { background: var(--accent-wash); font-weight: 600; }
.appearance-menu .palettes .swatch {
  width: 15px; height: 15px; border-radius: 50%; flex: none;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.15);
}
.appearance-menu .palettes .tick { margin-left: auto; color: var(--accent); }

/* ---------- the issue / approve gate ---------- */

.gate { border-left: 3px solid var(--muted); }
.gate-draft { border-left-color: var(--muted); }
.gate-awaiting_approval { border-left-color: var(--amber); }
.gate-issued { border-left-color: var(--accent); }
.gate-line { margin: 0 0 16px; font-size: 14.5px; max-width: 74ch; }
.gate-line strong { font-weight: 640; }

fieldset[disabled] { opacity: .72; }
fieldset[disabled] .dropzone { cursor: not-allowed; }

/* ---------- messages ---------- */

.flash, .prompt, .empty {
  border-radius: var(--radius); padding: 13px 16px; margin-bottom: 18px; font-size: 14.5px;
}
.flash { background: var(--accent-wash); color: var(--accent-ink); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); }
.prompt { background: var(--amber-wash); color: var(--amber); border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent); }
.prompt form { display: inline; }
.prompt .choices { margin-top: 9px; display: flex; gap: 8px; flex-wrap: wrap; }

.empty {
  background: var(--card); border: 1px dashed var(--line); color: var(--muted);
  text-align: center; padding: 44px 20px;
}

/* ---------- report list ---------- */

.listbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.listbar input[type="search"] {
  font: inherit; font-size: 14.5px; flex: 1; min-width: 220px; max-width: 460px;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--ink);
}
.listbar input[type="search"]:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.filters { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.filter {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 13px; border-radius: 999px; text-decoration: none;
  font-size: 13.5px; color: var(--muted); border: 1px solid var(--line);
  background: var(--card);
}
.filter:hover { border-color: var(--muted); color: var(--ink); }
.filter.on { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.filter .n { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; opacity: .75; }

.row-actions { text-align: right; white-space: nowrap; }
.row-actions form { display: inline; }
.row-actions .btn { margin-left: 4px; }

.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.list th {
  text-align: left; font-size: 11px; font-family: var(--mono); letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); font-weight: 500;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--line-soft);
}
.list td { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.list tr:last-child td { border-bottom: 0; }
.list tr:hover td { background: var(--accent-wash); }
.list a.ref { font-family: var(--mono); font-weight: 600; color: var(--accent); text-decoration: none; }
.list a.ref:hover { text-decoration: underline; }
.list .site { color: var(--muted); font-size: 13.5px; }
.status {
  font-size: 11px; font-family: var(--mono); text-transform: uppercase; letter-spacing: .06em;
  padding: 3px 8px; border-radius: 3px; border: 1px solid currentColor;
}
.status.draft { color: var(--muted); }
.status.awaiting_approval { color: var(--amber); }
.status.issued { color: var(--accent); }

/* ---------- sticky save bar ---------- */

.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  background: var(--card); border-top: 1px solid var(--line);
  box-shadow: 0 -2px 12px rgba(16,32,26,.07);
}
.actionbar .inner {
  max-width: 1120px; margin: 0 auto; padding: 11px 24px;
  display: flex; align-items: center; gap: 12px;
}
.actionbar .note { color: var(--muted); font-size: 13.5px; margin-right: auto; }

a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* A photograph can span the page instead of taking one grid cell — site maps and plans
   are unreadable at grid size. Per photograph, not per report. */
.wide-toggle {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--muted); cursor: pointer; user-select: none;
}
.wide-toggle input { width: 15px; height: 15px; accent-color: var(--accent); margin: 0; }

/* ======================================================================
   Phones
   This is a field tool: the photographs are taken on site, on a phone, and
   often one-handed. Three things below are corrections, not decoration —
   inputs must be 16px or iOS zooms the page on every tap; the data tables
   have to stop being tables; and photo reordering cannot rely on HTML5
   drag-and-drop, which does not fire on touch at all.
   ====================================================================== */

/* Collapsible navigation. Hidden entirely on wide screens — there the items
   simply sit in the bar. */
.menu-toggle { display: none; }
.topnav { display: contents; }

@media (max-width: 860px) {
  .topbar .inner { padding: 10px 16px; gap: 10px; }
  .topbar .ref { order: 10; flex-basis: 100%; }

  .menu-toggle {
    display: grid; place-content: center; gap: 4px;
    width: 42px; height: 42px; padding: 0;
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); cursor: pointer;
  }
  .menu-toggle span {
    display: block; width: 18px; height: 2px; background: var(--ink); border-radius: 2px;
  }

  .topnav {
    display: none; order: 20; flex-basis: 100%;
    flex-direction: column; align-items: stretch; gap: 6px;
    padding-top: 10px; border-top: 1px solid var(--line-soft);
  }
  .topnav.open { display: flex; }
  .topnav .btn, .topnav form { width: 100%; }
  .topnav .btn { justify-content: center; min-height: 44px; }
  .topnav form .btn { width: 100%; }
}

@media (max-width: 700px) {
  main { padding: 18px 16px 140px; }
  h1 { font-size: 22px; }
  .card .body { padding: 16px; }
  .card > header { padding: 12px 16px; }

  /* iOS zooms the whole page when a focused input is under 16px. Every control
     that can take focus goes to 16px on small screens; nothing else changes. */
  input[type="text"], input[type="date"], input[type="number"], input[type="email"],
  input[type="password"], input[type="search"], textarea, select,
  .combo-input, .combo-list li {
    font-size: 16px;
  }

  /* Comfortable targets for a thumb. */
  .btn { min-height: 44px; padding: 10px 16px; }
  .btn-sm { min-height: 38px; }
  .yesno label { padding: 11px 22px; min-height: 44px; display: flex; align-items: center; }
  .combo-toggle { width: 40px; }

  /* The action bar is fixed to the bottom edge, which on a modern iPhone is
     under the home indicator without this. */
  .actionbar .inner { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .actionbar .note { flex-basis: 100%; margin: 0 0 6px; }
  .actionbar .btn { flex: 1; justify-content: center; }

  /* ---- the report list stops being a table ----
     Seven columns cannot be read on a phone. Each row becomes a card, with the
     column headings carried in as labels so nothing loses its meaning. */
  .list table, .list thead, .list tbody, .list tr, .list th, .list td { display: block; }
  .list thead { display: none; }
  .list tr { padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .list tr:hover td { background: transparent; }
  .list td { padding: 0 0 6px; border: 0; }
  .list td::before {
    content: attr(data-label) " ";
    font-family: var(--mono); font-size: 10px; letter-spacing: .08em;
    text-transform: uppercase; color: var(--faint); display: block;
  }
  /* The reference and the actions read as the card's head and foot. */
  .list td:first-child::before { display: none; }
  .list td:first-child { font-size: 17px; margin-bottom: 2px; }
  .list td.row-actions { text-align: left; margin-top: 10px; display: flex; gap: 8px; }
  .list td.row-actions::before { display: none; }
  .list td.row-actions .btn { margin: 0; }

  /* ---- samples stop being a table too ----
     Six inputs across is unusable; stacked and labelled, it is just a short form. */
  .samples, .samples thead, .samples tbody, .samples tr, .samples th, .samples td { display: block; }
  .samples thead { display: none; }
  .samples tr {
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 14px; margin-bottom: 12px; background: var(--card);
  }
  .samples td { padding: 0 0 10px; }
  .samples td:last-child { padding-bottom: 0; }
  .samples td::before {
    content: attr(data-label);
    font-size: 12.5px; font-weight: 600; color: var(--muted);
    display: block; margin-bottom: 4px;
  }
  .samples .num, .samples .conc { padding-top: 0; }
  .samples .num { font-size: 15px; color: var(--accent); font-weight: 600; }
  .samples input[type="number"] { text-align: left; }

  /* Two photographs per row is still readable and halves the scrolling. */
  .photo-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .photo .meta { padding: 8px; }
  .photo textarea { font-size: 16px; }
  /* Number, reorder and remove will not sit on one line in a half-width card. */
  .photo .n { flex-wrap: wrap; gap: 6px; }
  .photo .n .del { margin-left: 0; }

  .dropzone { padding: 26px 16px; }

  .appearance-menu { position: fixed; left: 16px; right: 16px; top: auto; min-width: 0; }
  .filters { gap: 6px; }
  .filter { min-height: 38px; }
}

@media (max-width: 420px) {
  .photo-grid { grid-template-columns: 1fr; }
  .listbar input[type="search"] { min-width: 0; }
}

/* Reordering photographs.
   HTML5 drag-and-drop does not fire on touch, so dragging is a desktop
   convenience and these buttons are how reordering actually works. They are
   shown everywhere rather than only on small screens: they are also the
   keyboard-accessible route, which dragging never was. */
.photo .move { display: flex; gap: 2px; }
.photo .move button {
  width: 30px; height: 28px; padding: 0; font-size: 14px; line-height: 1;
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: 3px; cursor: pointer;
}
.photo .move button:hover:not(:disabled) { color: var(--ink); border-color: var(--muted); }
.photo .move button:disabled { opacity: .35; cursor: default; }

@media (max-width: 700px) {
  .photo .move button { width: 38px; height: 36px; font-size: 16px; }
  .photo .n .grab { display: none; }   /* dragging is not available here */
}

@media (hover: none) {
  .photo .n .grab { display: none; }
}
