* { box-sizing: border-box; }

html { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 16px; color: #1f2937; background: #f9fafb; }
body { margin: 0; padding: 0; }

a { color: #0369a1; text-decoration: none; }
a:hover { text-decoration: underline; }

header.site {
  background: #0f172a;
  color: #f8fafc;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
header.site a { color: #f8fafc; }
header.site .brand { font-weight: 700; font-size: 1.1rem; }
header.site nav a { margin-left: 1rem; font-size: 0.9rem; }

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

h1, h2, h3 { color: #0f172a; margin-top: 0; }

.flash { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.flash.notice { background: #dcfce7; color: #166534; }
.flash.alert { background: #fee2e2; color: #991b1b; }

.queues { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.queue { background: white; border: 1px solid #e5e7eb; border-radius: 8px; padding: 1rem; }
.queue h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; 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; }
.badge.planned     { background: #e0f2fe; color: #075985; }
.badge.booked      { background: #e0e7ff; color: #3730a3; }
.badge.delivered   { background: #fef3c7; color: #854d0e; }
.badge.incubating  { background: #fed7aa; color: #9a3412; }
.badge.analysed    { background: #bbf7d0; color: #14532d; }
.badge.submitted   { background: #e5e7eb; color: #374151; }
.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;
}
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: 1px solid transparent; cursor: pointer; text-decoration: none; }
.btn.primary   { background: #0ea5e9; color: white; }
.btn.primary:hover { background: #0284c7; text-decoration: none; }
.btn.secondary { background: white; color: #0f172a; border-color: #d1d5db; }
.btn.secondary:hover { background: #f3f4f6; text-decoration: none; }
.btn.danger    { background: #dc2626; color: white; }
.btn.danger:hover { background: #b91c1c; text-decoration: none; }
.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; }

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;
}
.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;
}
