:root {
  --paper: #f4f7f6; --surface: #ffffff; --ink: #0e2f30; --teal: #0f4c4d; --muted: #566866;
  --line: #d6e0de; --track: #e2eae8;
  --jade: #18805a; --amber: #b06a00; --crimson: #bd2f2f; --plain: #2f7f86;
  --font: "Be Vietnam Pro", system-ui, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 15px/1.55 var(--font); }
h1, h2, h3, p, dl, dd, ul { margin: 0; padding: 0; }
ul { list-style: none; }
a { color: var(--teal); text-underline-offset: 3px; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #e8a400; outline-offset: 2px; border-radius: 4px; }
.boot, .wait { padding: 48px 16px; color: var(--muted); }

/* top bar */
.top { background: var(--teal); color: #fff; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 28px; padding: 10px max(16px, calc((100vw - 1120px) / 2)); }
.top .brand { color: #fff; font-weight: 700; font-size: 17px; text-decoration: none; letter-spacing: -0.01em; }
.top nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.top nav a { color: #cfe3e1; text-decoration: none; padding: 6px 12px; border-radius: 6px; font-weight: 500; }
.top nav a:hover { color: #fff; }
.top nav a.on { background: #fff; color: var(--teal); }
.who { display: flex; gap: 14px; align-items: center; font-size: 14px; color: #cfe3e1; }
.who .link { color: #fff; }
.demo { background: #fff3c9; color: #5a4300; padding: 8px max(16px, calc((100vw - 1120px) / 2)); font-size: 14px; }

/* range bar */
.range { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding: 14px max(16px, calc((100vw - 1120px) / 2)); border-bottom: 1px solid var(--line); background: var(--surface); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-weight: 500; }
.chip:hover { border-color: var(--teal); }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.dates { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.fresh { margin-left: auto; font-size: 13px; color: var(--muted); }
.fresh.bad { color: var(--crimson); font-weight: 600; }
input, select { border: 1px solid #b9c7c4; border-radius: 6px; padding: 7px 10px; background: #fff; min-height: 38px; }

.page { max-width: 1120px; margin: 0 auto; padding: 28px 16px 80px; }
.page > * + * { margin-top: 28px; }
.title h1 { font-size: 30px; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; }
.title p { color: var(--muted); margin-top: 4px; }
.back { display: inline-block; margin-bottom: 8px; font-size: 14px; }
section > h2 { font-size: 19px; font-weight: 600; margin-bottom: 10px; }
.note { color: var(--muted); font-size: 14px; max-width: 70ch; margin-bottom: 10px; }
.warn { background: #fff3c9; border-left: 4px solid var(--amber); padding: 10px 14px; max-width: 80ch; }

/* one product: the meter is the centre of the page */
.prod { background: var(--surface); border-top: 3px solid var(--ink); padding: 22px 24px 20px; }
.prod-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 14px; }
.prod-head h2 { font-size: 20px; font-weight: 600; margin: 0; }
.tag { font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.tag.ok { background: #dcf1e7; color: #0d5a3d; }
.tag.near { background: #ffe9bf; color: #6d4100; }
.tag.over { background: var(--crimson); color: #fff; }
.hero { display: grid; grid-template-columns: auto 1fr; align-items: end; gap: 2px 28px; margin: 14px 0 34px; }
.big { font-size: clamp(44px, 9vw, 68px); line-height: 1; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; grid-row: 1 / 3; }
.big-label { color: var(--muted); align-self: end; }
.hero .meter { align-self: start; margin-top: 8px; }

.meter { position: relative; height: 16px; background: var(--track); border-radius: 3px; }
.meter .fill { height: 100%; border-radius: 3px; background: var(--plain); }
.meter.ok .fill { background: var(--jade); }
.meter.near .fill { background: var(--amber); }
.meter.over .fill { background: var(--crimson); }
.meter .tick { position: absolute; top: -6px; bottom: -6px; width: 2px; background: var(--ink); }
.meter .tick span { position: absolute; top: calc(100% + 2px); left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 12px; font-weight: 600; }
.meter.small { height: 8px; width: 120px; }
.meter.small .tick { top: -3px; bottom: -3px; }

.figs { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.figs > div { padding: 12px 16px 12px 0; border-bottom: 1px solid var(--line); }
.figs dt { color: var(--muted); font-size: 13px; }
.figs dd { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.figs small { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }
details { margin-top: 14px; }
summary { cursor: pointer; font-weight: 600; color: var(--teal); padding: 6px 0; }
details .scroll { margin-top: 8px; }

/* tables */
.scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
th { font-size: 13px; font-weight: 600; color: var(--muted); background: #f8faf9; }
td:first-child, th:first-child { white-space: normal; min-width: 150px; }
.n { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 0; }
tr.off td { color: #8a9997; }
tr.flag td:first-child { box-shadow: inset 4px 0 0 var(--amber); }
.pct { font-weight: 600; }
.pct.over { color: var(--crimson); } .pct.near { color: var(--amber); } .pct.ok { color: var(--jade); }

/* buttons */
.primary, .button { display: inline-block; border-radius: 6px; padding: 9px 18px; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 40px; }
.primary { background: var(--teal); color: #fff; border: 1px solid var(--teal); }
.primary:hover { background: var(--ink); }
.primary:disabled { opacity: 0.6; cursor: wait; }
.button { background: #fff; color: var(--ink); border: 1px solid #b9c7c4; }
.link { background: none; border: 0; padding: 0; color: var(--teal); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link.danger { color: var(--crimson); }
.row-actions { display: flex; gap: 16px; }
.bar { display: flex; justify-content: flex-end; }

/* login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--teal); }
.auth-box { background: var(--surface); width: min(420px, 100%); padding: 32px 28px; border-radius: 10px; }
.auth-box .brand { font-weight: 700; color: var(--teal); margin-bottom: 18px; }
.auth-box h1 { font-size: 26px; letter-spacing: -0.02em; }
.lead { color: var(--muted); margin: 6px 0 4px; }
.auth form { display: grid; gap: 6px; margin-top: 16px; }
.auth label { font-weight: 600; font-size: 14px; margin-top: 8px; }
.auth input { width: 100%; min-height: 44px; }
.auth .primary { margin-top: 12px; }
.error { color: var(--crimson); font-weight: 600; min-height: 1.4em; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 10px; }

/* admin */
.tabs { display: flex; flex-wrap: wrap; gap: 4px 22px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 0; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--ink); border-color: var(--ink); }
.empty { background: var(--surface); border: 1px dashed #b9c7c4; border-radius: 8px; padding: 28px 24px; max-width: 70ch; }
.empty h2 { font-size: 18px; margin-bottom: 4px; }
.empty .button { margin-top: 14px; }
.reviews li, .log li { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; margin-bottom: 10px; }
.reviews p { margin: 4px 0 10px; max-width: 80ch; }
.log li.bad { border-color: var(--crimson); }
.log pre { margin: 6px 0 0; white-space: pre-wrap; font: 13px/1.5 ui-monospace, Consolas, monospace; color: var(--muted); }
.inline { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-bottom: 14px; }
.field { display: grid; gap: 4px; font-weight: 600; font-size: 14px; }
.field input, .field select { font-weight: 400; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.check input { min-height: 0; width: 18px; height: 18px; }
fieldset { border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px; display: grid; gap: 6px; }
legend { font-weight: 600; font-size: 14px; padding: 0 6px; }
dialog { border: 0; border-radius: 10px; padding: 24px; width: min(480px, calc(100vw - 32px)); color: var(--ink); }
dialog::backdrop { background: rgba(14, 47, 48, 0.55); }
dialog h2 { font-size: 20px; margin-bottom: 12px; }
dialog h3 { font-size: 15px; margin: 16px 0 8px; }
dialog form { display: grid; gap: 12px; }
dialog input:not([type="checkbox"]), dialog select { width: 100%; }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.history li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 50; max-width: calc(100vw - 32px); }
.toast.bad { background: var(--crimson); }

@media (max-width: 640px) {
  .figs { grid-template-columns: repeat(2, 1fr); }
  .prod { padding: 18px 16px; margin-left: -16px; margin-right: -16px; }
  .hero { grid-template-columns: 1fr; margin-bottom: 30px; }
  .big { grid-row: auto; }
  .fresh { margin-left: 0; width: 100%; }
  .who span { display: none; }
  th, td { padding: 8px 10px; }
}
@media (prefers-reduced-motion: no-preference) {
  .meter .fill { transition: width 0.5s ease-out; }
}
