/* --- Water Rangers brand tokens --- */
:root {
  --wr-navy:        #13355c;
  --wr-navy-dark:   #0c2240;
  --wr-green:       #88c947;
  --wr-green-dark:  #6fa937;
  --wr-sky:         #0ea5e9;
  --wr-sky-dark:    #0284c7;
  --wr-sky-light:   #e7f4fa;
  --wr-ink:         #1f2937;
  --wr-muted:       #6b7280;
  --wr-bg:          #f9fafb;
  --wr-card:        #ffffff;
  --wr-line:        #e5e7eb;
  --wr-display:     "Tungsten Rounded A", "Tungsten Rounded B", "Helvetica Neue Condensed", "Arial Narrow", sans-serif;
  --wr-body:        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { font-family: var(--wr-body); font-size: 16px; color: var(--wr-ink); background: var(--wr-bg); }
body { margin: 0; padding: 0; }

a { color: var(--wr-sky-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

header.site {
  background: var(--wr-navy);
  color: #f8fafc;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
header.site a { color: #f8fafc; }
header.site .brand {
  font-family: var(--wr-display);
  font-weight: 700;
  font-size: 1.65rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1;
}
header.site nav a { margin-left: 1rem; font-size: 0.9rem; }

main { max-width: 960px; margin: 0 auto; padding: 1.5rem; }

h1, h2, h3, h4 {
  color: var(--wr-navy);
  margin-top: 0;
  font-family: var(--wr-display);
  line-height: 1.05;
  letter-spacing: 0.01em;
}
h1 { font-size: 4.5rem;  font-weight: 500; }
h2 { font-size: 3rem;    font-weight: 400; line-height: 1.1; }
h3 { font-size: 1.5rem; font-weight: 500; line-height: 1.15; letter-spacing: 0.04em; text-transform: uppercase; }
h4 { font-size: 1.1rem;  font-weight: 400; color: var(--wr-muted); line-height: 1.3; }

.flash { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.flash.notice { background: var(--wr-sky-light); color: var(--wr-navy); border-left: 4px solid var(--wr-sky); }
.flash.alert  { background: #fee2e2; color: #991b1b; border-left: 4px solid #dc2626; }

.queues { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin-bottom: 2rem; }
.queue { background: white; border: 1px solid #e5e7eb; border-radius: 8px; padding: 1rem; }
.queue h3 { color: #6b7280; margin-bottom: 0.75rem; }
.queue .count { font-size: 1.75rem; font-weight: 700; color: #0f172a; }
.queue ul { list-style: none; padding: 0; margin: 0.5rem 0 0; font-size: 0.9rem; }
.queue li { padding: 0.35rem 0; border-top: 1px solid #f3f4f6; }
.queue li:first-child { border-top: none; }

table.samples { width: 100%; border-collapse: collapse; background: white; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; }
table.samples th, table.samples td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid #f3f4f6; font-size: 0.9rem; }
table.samples th { background: #f9fafb; font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; color: #6b7280; }
table.samples tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
/* State palette: WR sky for early stages, navy for processing,
   amber for in-flight chemistry, WR green for analysed/done. */
.badge.planned     { background: #dbeafe; color: var(--wr-navy); }
.badge.booked      { background: var(--wr-sky-light); color: var(--wr-sky-dark); }
.badge.delivered   { background: #fef3c7; color: #854d0e; }
.badge.incubating  { background: #fed7aa; color: #9a3412; }
.badge.analysed    { background: #e8f5d3; color: #3d5a1d; }
.badge.submitted   { background: var(--wr-navy); color: #f8fafc; }
.badge.exceeded    { background: #fecaca; color: #991b1b; }

.card { background: white; border: 1px solid #e5e7eb; border-radius: 8px; padding: 1.5rem; margin-bottom: 1rem; }

form.sample { display: grid; gap: 1rem; }
form.sample fieldset {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.5rem 1.25rem 1.25rem;
  margin: 0;
  background: white;
}
form.sample fieldset legend {
  font-size: 0.78rem;
  font-weight: 700;
  color: #0f172a;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 0.5rem;
}
form.sample .fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem 1.5rem;
}
@media (min-width: 640px) {
  form.sample .fields { grid-template-columns: 1fr 1fr; }
}
form.sample .field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}
form.sample .field.full { grid-column: 1 / -1; }
form.sample .field.inline {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}
form.sample .field.inline label { margin: 0; }
form.sample label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
}
/* Mark required fields. Adds a sky asterisk after the label and a subtle
   sky border on the left of the input itself. */
form.sample .field:has(:required:not([type=hidden])) > label::after {
  content: " *";
  color: var(--wr-sky-dark);
  font-weight: 700;
}
form.sample input:required:not([type=hidden]):not([type=checkbox]),
form.sample select:required,
form.sample textarea:required {
  border-left-width: 3px;
  border-left-color: var(--wr-sky);
}
form.sample .hint {
  font-size: 0.78rem;
  color: #6b7280;
  margin: 0;
  line-height: 1.35;
}
form.sample input[type=text],
form.sample input[type=number],
form.sample input[type=datetime-local],
form.sample input[type=date],
form.sample input[type=email],
form.sample input[type=password],
form.sample input[type=tel],
form.sample select,
form.sample textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  font-size: 1rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: white;
  font-family: inherit;
}
form.sample textarea { min-height: 6rem; }
form.sample input[type=checkbox] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: #0ea5e9;
}

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  transition: background 0.15s ease, color 0.15s ease;
}
/* Three-tier hierarchy:
   - primary  = WR green, the headline CTA on a screen
   - secondary = WR navy, important but not the headline action
   - tertiary = transparent text link, for low-emphasis options */
.btn.primary   { background: var(--wr-green); color: var(--wr-navy-dark); }
.btn.primary:hover { background: var(--wr-green-dark); color: var(--wr-navy-dark); text-decoration: none; }
.btn.secondary { background: var(--wr-navy); color: #f8fafc; }
.btn.secondary:hover { background: var(--wr-navy-dark); color: #f8fafc; text-decoration: none; }
.btn.sky      { background: var(--wr-sky); color: #f8fafc; }
.btn.sky:hover { background: var(--wr-sky-dark); color: #f8fafc; text-decoration: none; }
.btn.tertiary  { background: transparent; color: var(--wr-sky-dark); padding: 0.4rem 0.6rem; font-weight: 500; }
.btn.tertiary:hover { color: var(--wr-navy); text-decoration: underline; }
.btn.danger    { background: #dc2626; color: white; }
.btn.danger:hover { background: #b91c1c; text-decoration: none; }

/* Visual hierarchy variants — use sparingly. */
.btn.btn-lg    { padding: 0.85rem 1.5rem; font-size: 1.05rem; }
.btn.btn-sm    { padding: 0.3rem 0.65rem; font-size: 0.8rem; }
.btn.back-home {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1rem;
  background: #0f172a;
  color: #f8fafc;
  padding: 0.65rem 1.1rem;
  font-size: 1rem;
}
.btn.back-home:hover { background: #1e293b; color: #f8fafc; text-decoration: none; }

/* IDEXX Colilert colour cues — total coliforms turn the wells bright yellow,
   E. coli fluoresces turquoise under UV. We mirror those in the form and
   result display so the reader's physical workflow matches the UI. */
form.sample .field.tc {
  background: #fef9c3;
  border: 1px solid #fde047;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}
form.sample .field.ecoli {
  background: #cffafe;
  border: 1px solid #67e8f9;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}
.result-value.tc {
  background: #fef08a;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
}
.result-value.ecoli {
  background: #67e8f9;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
}

.preview-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}
@media (min-width: 640px) {
  .preview-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
}
.preview {
  padding: 1rem 1.25rem;
  border-radius: 10px;
  border: 2px solid transparent;
}
.preview.tc {
  background: #fef9c3;
  border-color: #eab308;
  box-shadow: 0 0 0 4px rgba(234, 179, 8, 0.15);
}
.preview.ecoli {
  background: #cffafe;
  border-color: #06b6d4;
  box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.18);
}
.preview-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #374151;
  font-weight: 600;
}
.preview-value {
  font-size: 2rem;
  font-weight: 700;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  margin-top: 0.25rem;
}
.preview-exceeded {
  margin-top: 0.75rem;
  padding: 0.65rem 1rem;
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: 6px;
  font-size: 0.9rem;
}

.mpn-preview { padding: 1rem; background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 6px; }
.mpn-preview .label { font-size: 0.8rem; color: #0c4a6e; text-transform: uppercase; letter-spacing: 0.05em; }
.mpn-preview .value { font-size: 1.5rem; font-weight: 700; color: #0c4a6e; }

.error-list { background: #fee2e2; color: #991b1b; padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.error-list ul { margin: 0.25rem 0 0 1.25rem; padding: 0; }

dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; font-size: 0.92rem; }
dl.meta dt { font-weight: 600; color: #6b7280; }
dl.meta dd { margin: 0; }

.muted { color: #6b7280; font-size: 0.88rem; }

table.budget-worksheet {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
table.budget-worksheet th,
table.budget-worksheet td {
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}
table.budget-worksheet th {
  background: #f9fafb;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #6b7280;
}
table.budget-worksheet td .hint {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  color: #6b7280;
  font-weight: 400;
}
table.budget-worksheet input[type="number"],
table.budget-worksheet input[type="text"] {
  padding: 0.4rem 0.55rem;
  font-size: 0.92rem;
}
table.budget-worksheet tfoot td {
  border-top: 2px solid var(--wr-line);
  border-bottom: none;
  padding-top: 0.85rem;
  background: #f9fafb;
}
table.budget-worksheet tr.other-row td { border-bottom: 1px dashed #e5e7eb; }

form.sample .field.combobox { position: relative; }
.combo-dropdown {
  position: absolute;
  top: calc(100% + 0.15rem);
  left: 0;
  right: 0;
  z-index: 10;
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  max-height: 300px;
  overflow-y: auto;
}
.combo-results { list-style: none; margin: 0; padding: 0.25rem 0; }
.combo-result {
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  cursor: pointer;
}
.combo-result:hover, .combo-result.active {
  background: #e0f2fe;
}
.combo-error {
  padding: 0.5rem 0.75rem;
  color: #991b1b;
  font-size: 0.85rem;
  background: #fee2e2;
}
.combo-footer {
  padding: 0.6rem 0.75rem;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
}

.location-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin-top: 0.5rem;
}
.location-chips[hidden] { display: none; }
.chip-label {
  font-size: 0.78rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 0.25rem;
}
.chip {
  display: inline-block;
  background: #e0f2fe;
  color: #075985;
  border: 1px solid #7dd3fc;
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
}
.chip:hover { background: #bae6fd; }
.chip.selected {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
  padding-right: 0.35rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.chip-remove {
  background: transparent;
  border: none;
  color: #166534;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.2rem;
  font-weight: 700;
}
.chip-remove:hover { color: #14532d; }

.radio-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.45rem 0;
  font-size: 0.92rem;
  cursor: pointer;
}
.radio-row input[type="radio"] {
  accent-color: #0ea5e9;
}

.dataset-context {
  margin: 0.75rem 0 0;
  padding: 0.5rem 0.75rem;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 6px;
  font-size: 0.88rem;
  color: #14532d;
  font-weight: 600;
}

.input-with-clear {
  position: relative;
}
.input-with-clear input {
  padding-right: 2.25rem !important;
}
.input-clear {
  position: absolute;
  top: 50%;
  right: 0.4rem;
  transform: translateY(-50%);
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  color: #374151;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.input-clear:hover { background: #e5e7eb; color: #111827; }

.form-compat-warning {
  margin: 0.5rem 0 0;
  padding: 0.6rem 0.85rem;
  background: #fef3c7;
  border: 1px solid #fde047;
  border-radius: 6px;
  font-size: 0.88rem;
  color: #854d0e;
}

.btn-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.78rem;
  color: #0369a1;
  cursor: pointer;
  text-decoration: underline;
}
.btn-link:hover { color: #0c4a6e; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem;
}
.photo-thumb {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}

/* ── Public summary / embed page ─────────────────────────────── */

body.embedded {
  background: var(--wr-bg);
}

.summary-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
  font-family: var(--wr-body);
}

.summary-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--wr-line);
}

.summary-header__brand {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 0.5rem;
}

.summary-header__lab {
  font-family: var(--wr-display);
  font-weight: 700;
  font-size: 1.5rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--wr-navy);
}

.summary-header__powered {
  font-size: 0.85rem;
  color: var(--wr-muted);
}

.summary-header__updated {
  margin: 0.4rem 0 0.6rem;
  font-size: 1.05rem;
  color: var(--wr-ink);
}

.summary-header__standard {
  margin: 0;
  font-size: 0.9rem;
  color: var(--wr-ink);
  background: var(--wr-sky-light);
  border-left: 3px solid var(--wr-sky);
  padding: 0.5rem 0.75rem;
  border-radius: 0 6px 6px 0;
  display: inline-block;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
@media (max-width: 720px) {
  .summary-grid { grid-template-columns: 1fr; }
}

.result-card {
  background: white;
  border: 1px solid var(--wr-line);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.result-card--good  { border-top: 4px solid var(--wr-green); }
.result-card--exceeds { border-top: 4px solid #dc2626; }
.result-card--unknown { border-top: 4px solid var(--wr-line); }

.result-card__ecoli {
  padding: 1rem 1rem 0.75rem;
  display: flex;
  flex-direction: column;
}

.result-card__value {
  font-family: var(--wr-display);
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--wr-ink);
}

.result-card__value--unknown {
  font-size: 2rem;
  color: var(--wr-muted);
}

.result-card__unit {
  font-size: 0.75rem;
  color: var(--wr-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.15rem;
}

.result-card__label {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  align-self: flex-start;
}

.result-card__label--unknown { background: #f3f4f6; color: var(--wr-muted); }

.result-card__risk {
  margin-top: 0.5rem;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  align-self: stretch;
}
.result-card__risk-headline {
  font-family: var(--wr-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1;
}
.result-card__risk-detail {
  font-size: 0.75rem;
  line-height: 1.25;
}
.result-card__risk--good { background: #dcfce7; color: #166534; }
.result-card__risk--bad  { background: #fee2e2; color: #991b1b; }

.result-card__body {
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid var(--wr-line);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.result-card__location-link {
  text-decoration: none;
  color: inherit;
}

.result-card__location-link:hover .result-card__location {
  color: var(--wr-sky-dark);
  text-decoration: underline;
}

.result-card__location {
  font-family: var(--wr-display);
  font-weight: 500;
  font-size: 1.75rem;
  letter-spacing: 0.01em;
  line-height: 1.05;
  color: var(--wr-navy);
  margin: 0 0 0.3rem;
}

.result-card__date {
  margin: 0;
  font-size: 0.82rem;
  color: var(--wr-muted);
}

.result-card__sponsor {
  margin: 0.3rem 0 0;
  font-size: 0.82rem;
  color: var(--wr-muted);
}

.summary-empty {
  color: var(--wr-muted);
  font-size: 1rem;
  padding: 2rem 0;
  text-align: center;
}

.summary-updated {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--wr-muted);
  text-align: right;
}

/* ── Mobile layout ───────────────────────────────────────────── */

@media (max-width: 639px) {
  main { padding: 1rem; }

  header.site { flex-wrap: wrap; gap: 0.5rem 1rem; padding: 0.75rem 1rem; }
  header.site nav { display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; font-size: 0.85rem; }
  header.site nav a { margin-left: 0; }

  h1 { font-size: 2.75rem; }
  h2 { font-size: 2rem; }

  .queues { grid-template-columns: 1fr; }

  /* Scrollable tables on narrow screens */
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; }
  .table-scroll table.samples { border-radius: 0; }

  /* Stack the submit/incubate action banners */
  .flash.notice { display: block; }
  .flash.notice > div { margin-bottom: 0.5rem; }
}
