/* NEU plant app. Phone first: one column, big tap targets; wider screens get more room. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5d6877;
  --line: #dde2e8;
  --brand: #0f5c4d;
  --brand-ink: #ffffff;
  --accent: #e8f3f0;
  --warn-bg: #fff6e0;
  --warn-ink: #7a5200;
  --error-bg: #fdecec;
  --error-ink: #8a1c1c;
  --ok-bg: #e7f6ec;
  --ok-ink: #1d6b39;
  --radius: 10px;
  --tap: 44px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* Room under the last form button or table row for the report pill (bottom right). */
  padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  background: var(--brand);
  color: var(--brand-ink);
}
.topbar a { color: var(--brand-ink); text-decoration: none; }
.topbar .brand { font-weight: 700; letter-spacing: 0.2px; }
.topbar nav { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar form { margin: 0; }
.badge {
  display: inline-block;
  min-width: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: #ffd166;
  color: #3a2a00;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.container { max-width: 1100px; margin: 0 auto; padding: 16px; }

h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 18px; margin: 20px 0 8px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}

.muted { color: var(--muted); }
.small { font-size: 14px; }

.actions { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 0; padding: 0; list-style: none; }
.actions a {
  display: block;
  min-height: var(--tap);
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
}
.actions a strong { display: block; color: var(--brand); }
.actions a span { font-size: 14px; color: var(--muted); }

.btn, button, input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 8px 16px;
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  background: var(--brand);
  color: var(--brand-ink);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.btn.secondary, button.secondary { background: var(--surface); color: var(--brand); }
.btn.danger, button.danger { background: var(--error-ink); border-color: var(--error-ink); }
.btn.small, button.small { min-height: 34px; padding: 4px 10px; font-size: 14px; }
.topbar button.link { min-height: 0; padding: 0; border: 0; background: none; color: var(--brand-ink); }

label { display: block; font-weight: 600; margin: 10px 0 4px; }
input[type="text"], input[type="number"], input[type="file"], select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}
.radio-row ul, ul.radio-row { list-style: none; padding: 0; margin: 0; display: flex; gap: 16px; }
.radio-row label { font-weight: 400; display: inline-flex; gap: 6px; align-items: center; }
.errorlist { color: var(--error-ink); margin: 4px 0; padding-left: 18px; }

.messages { list-style: none; padding: 0; margin: 0 0 12px; }
.messages li { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 8px; background: var(--accent); }
.messages li.error { background: var(--error-bg); color: var(--error-ink); }
.messages li.warning { background: var(--warn-bg); color: var(--warn-ink); }
.messages li.success { background: var(--ok-bg); color: var(--ok-ink); }

.notice-box { padding: 12px 14px; border-radius: var(--radius); background: var(--warn-bg); color: var(--warn-ink); margin-bottom: 12px; }
.error-box { padding: 12px 14px; border-radius: var(--radius); background: var(--error-bg); color: var(--error-ink); margin-bottom: 12px; }

/* Tables scroll sideways on a phone instead of squashing. */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.data { border-collapse: collapse; width: 100%; font-size: 14px; }
table.data th, table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { background: #eef1f4; white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
.toolbar form { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin: 0; }
.toolbar select, .toolbar input { width: auto; }

.inbox { list-style: none; margin: 0; padding: 0; }
.inbox li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; justify-content: space-between; }
.inbox li:last-child { border-bottom: 0; }
.inbox li.unread .title { font-weight: 700; }

.status { display: inline-block; padding: 1px 8px; border-radius: 10px; background: var(--accent); font-size: 13px; }

.footer { color: var(--muted); font-size: 13px; text-align: center; padding: 16px; }

/* Report button: on every screen, a compact pill in the bottom right corner. The body's bottom
   padding keeps the end of every page clear of it. */
.report-button {
  position: fixed;
  right: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  border-radius: 20px;
  background: #3a4656;
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0.92;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.report-button span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffd166;
  color: #3a2a00;
  font-size: 13px;
}
.report-button:hover, .report-button:focus { opacity: 1; }
dialog.report-dialog { width: min(560px, calc(100vw - 24px)); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
dialog.report-dialog::backdrop { background: rgba(20, 28, 38, 0.45); }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; background: #f0f2f5; padding: 8px; border-radius: 6px; }

/* Stage B: flags, button rows, forms on the floor screens */
ul.flags { list-style: none; padding: 0; margin: 0 0 12px; }
.flag { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 6px; }
.flag.warn { background: var(--warn-bg); color: var(--warn-ink); font-weight: 600; }
.flag.info { background: var(--accent); }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 14px; }
.spaced-top { margin-top: 10px; }
.button-row form { margin: 0; }
.field { margin-bottom: 6px; }
.field.has-error input, .field.has-error select { border-color: var(--error-ink); }
label.check { display: inline-flex; gap: 8px; align-items: center; font-weight: 400; }
label.check input { width: 22px; height: 22px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
input[type="date"], input[type="email"] { width: 100%; min-height: var(--tap); padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
tr.removed td { color: var(--muted); text-decoration: line-through; }
table.data td:first-child a { white-space: nowrap; } /* lot and package IDs stay on one line */
.lot-card p { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 0; }
#scan-video { width: 100%; max-height: 50vh; background: #000; border-radius: var(--radius); }

/* Stage C: run console, home panel, checklists */
.status.ok { background: var(--ok-bg); color: var(--ok-ink); }
.quick-add { list-style: none; padding: 0; margin: 0 0 14px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.quick-add .btn { width: 100%; min-height: 52px; font-weight: 600; }
.ops-panel .card-title, .card h2.card-title { margin-top: 0; }
.run-tiles { list-style: none; padding: 0; margin: 0 0 8px; }
.run-tiles a { display: block; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; text-decoration: none; color: var(--text); }
.run-tiles a strong { display: block; color: var(--brand); }
.run-tiles a span { font-size: 14px; color: var(--muted); }
ol.checklist { padding-left: 0; list-style: none; counter-reset: item; }
ol.checklist > li { counter-increment: item; }
ol.checklist > li .item-text::before { content: counter(item) ". "; font-weight: 700; }
.prefilled pre { margin: 4px 0 8px; font-size: 14px; }
.checks ul { list-style: none; padding: 0; margin: 0; }
.checks label { font-weight: 400; display: flex; gap: 8px; align-items: center; min-height: 36px; }
span.label { display: block; font-weight: 600; margin: 10px 0 4px; }
form.inline { display: inline; margin: 0; }
td.item-tools { white-space: nowrap; }
td.item-tools form { display: inline; }
tr.this-week td { background: var(--accent); }
input[type="datetime-local"] { width: 100%; min-height: var(--tap); padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }

/* Stage D: lab screens (PC first; one column on a phone) */
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
.chip { display: inline-block; margin: 0 4px 4px 0; padding: 1px 8px; border-radius: 10px; font-size: 12px; line-height: 1.5; }
.chip.warn { background: var(--warn-bg); color: var(--warn-ink); font-weight: 600; }
.chip.info { background: #eef1f4; color: var(--muted); }
.chip.void { background: var(--error-bg); color: var(--error-ink); }
.status.bad { background: var(--error-bg); color: var(--error-ink); }
table.data td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.results-grid tr.void td { color: var(--muted); }
table.results-grid tr.void td.num strong { text-decoration: line-through; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.flag.warn.coa-problem { font-weight: 400; }

@media (min-width: 700px) {
  .quick-add { grid-template-columns: repeat(3, 1fr); }
  .actions { grid-template-columns: repeat(2, 1fr); }
  h1 { font-size: 26px; }
}
@media (min-width: 1000px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .field.wide { grid-column: 1 / -1; }
  .actions { grid-template-columns: repeat(3, 1fr); }
  .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
}

/* Stage E: dashboard tiles, balance */
.dash-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.dash-tile h2 { margin-top: 0; font-size: 18px; }
.dash-tile dl.facts { font-size: 15px; }
.basis { display: inline-block; font-size: 12px; padding: 0 6px; border-radius: 8px; background: #eef1f4; color: var(--muted); }
.basis.calculated { background: var(--accent); color: var(--brand); }
.dash-tile ul.tile-lines { padding-left: 18px; margin: 6px 0; font-size: 14px; }
.placeholder-note { background: var(--warn-bg); color: var(--warn-ink); padding: 10px 14px; border-radius: var(--radius); }
@media (min-width: 1000px) {
  .dash-grid { grid-template-columns: 1fr 1fr; }
}
