/* Shelf Life. The day dot (kitchen stock-rotation sticker) is the one bold element; everything else stays quiet. */
:root {
  --paper: #F1F4F6;
  --surface: #FFFFFF;
  --ink: #1D2B36;
  --muted: #5B6B77;
  --line: #D6DEE3;
  --accent: #23577A;
  --accent-ink: #FFFFFF;
  --expired: #B42318;
  --u0: #D9620B;
  --u1: #B88A00;
  --u2: #3F7D4E;
  --u3: #23577A;
  --ok: #8A99A4;
  --error-bg: #FBE9E7;
  --ok-bg: #E6F1EA;
  --notice-bg: #FFF4DB;
  --brand: var(--u0);
  --brand-2: var(--u2);
  --brand-line: var(--line);
  --brand-ink: #FFFFFF;
  --brand-stripe: none;
  --font: "Atkinson Hyperlegible", Verdana, "Segoe UI", Arial, sans-serif;
  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121A20; --surface: #1A242C; --ink: #E7EDF1; --muted: #9CABB6; --line: #2E3C47;
    --accent: #6FA8D1; --accent-ink: #0E1A23;
    --expired: #F0705F; --u0: #F29A4A; --u1: #E2C04A; --u2: #78B888; --u3: #6FA8D1; --ok: #6D7D88;
    --error-bg: #3A1F1C; --ok-bg: #1C3124; --notice-bg: #3A3118;
    color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 1.0625rem/1.5 var(--font); }
a { color: var(--accent); }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: 1.2rem; margin: 2rem 0 .75rem; }
code { font-size: .9em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* header */
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1.25rem;
  padding: .75rem max(1rem, env(safe-area-inset-left, 0px)); background: var(--surface); border-bottom: 4px solid var(--brand-line);
}
.top { border-image: var(--brand-stripe) 1; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.15rem; color: var(--ink); text-decoration: none; margin: 0; }
.brand-dot { width: 1.1rem; height: 1.1rem; border-radius: 50%; background: var(--brand); box-shadow: .55rem 0 0 -.15rem var(--brand-2); margin-right: .45rem; }
/* The logo file has a white background, so it sits on a white tile in dark mode too. */
.brand-logo { height: 2.75rem; width: auto; display: block; background: #FFFFFF; border-radius: 6px; }
.brand-logo-large { height: 5rem; margin: 0 auto .5rem; }
.top nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; flex: 1; }
.top nav a { color: var(--muted); text-decoration: none; padding: .25rem 0; border-bottom: 2px solid transparent; }
.top nav a:hover { color: var(--ink); }
.top nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 700; }
.count { display: inline-block; min-width: 1.4em; padding: 0 .35em; border-radius: 1em; background: var(--brand); color: var(--brand-ink); font-size: .8rem; font-weight: 700; text-align: center; }
.signout { margin: 0; }

main { max-width: 60rem; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.hero { margin: .5rem 0 1.5rem; }
.lede { color: var(--muted); max-width: 42rem; margin: 0 0 1rem; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: .9rem; }
.nowrap { white-space: nowrap; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.page-head h1, .page-head form { margin: 0; }

/* messages */
.flash { padding: .7rem 1rem; border-radius: 6px; margin: 0 0 1rem; background: var(--ok-bg); }
.flash-error { background: var(--error-bg); }
.notice { padding: .7rem 1rem; border-left: 4px solid var(--u1); background: var(--notice-bg); border-radius: 0 6px 6px 0; margin: 0 0 .75rem; }
.empty { color: var(--muted); padding: 1.5rem 0; }
.error-text { color: var(--expired); }

/* the day dot */
.dot {
  flex: none; display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  width: 3.25rem; height: 3.25rem; border-radius: 50%;
  background: var(--ok); color: #fff; line-height: 1; text-align: center;
}
.dot b { font-size: 1.2rem; }
.dot small { font-size: .65rem; margin-top: .1rem; }
.dot.small { width: 1.6rem; height: 1.6rem; vertical-align: middle; margin-right: .35rem; }
.dot.small b { font-size: .75rem; }
.dot.small small { display: none; }
.dot.large { width: 4.5rem; height: 4.5rem; }
.dot.large b { font-size: 1.6rem; }
.dot-expired { background: var(--expired); }
.dot-u0 { background: var(--u0); }
.dot-u1 { background: var(--u1); }
.dot-u2 { background: var(--u2); }
.dot-u3 { background: var(--u3); }
.dot-none { background: transparent; color: var(--muted); border: 2px dashed var(--muted); }
@media (prefers-color-scheme: dark) { .dot:not(.dot-none) { color: #10181E; } }

/* rows */
.bucket h2 { display: flex; gap: .5rem; align-items: baseline; }
.rows { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.rows li + li { border-top: 1px solid var(--line); }
.row { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "dot main qty" "dot main date"; align-items: center; gap: 0 1rem; padding: .75rem 1rem; color: inherit; text-decoration: none; }
.row:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.row .dot { grid-area: dot; }
.row-main { grid-area: main; min-width: 0; }
.row-title { display: block; font-weight: 700; overflow-wrap: anywhere; }
.row-sub { display: block; color: var(--muted); font-size: .9rem; }
.row-qty { grid-area: qty; text-align: right; font-variant-numeric: tabular-nums; }
.row-date { grid-area: date; text-align: right; color: var(--muted); font-size: .9rem; }

/* forms */
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 700; font-size: .95rem; }
label small { font-weight: 400; color: var(--muted); }
input, select, textarea, button, .button { font: inherit; }
input, select, textarea {
  font-weight: 400; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--ink); min-height: 2.75rem; width: 100%;
}
button, .button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 2.75rem; padding: .5rem 1rem;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink);
  cursor: pointer; text-decoration: none; font-weight: 700;
}
button:hover, .button:hover { border-color: var(--muted); }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.danger { background: var(--expired); border-color: var(--expired); color: #fff; }
button.on { background: var(--u2); border-color: var(--u2); color: #fff; }
.linkish { background: none; border: 0; color: var(--accent); padding: .25rem; min-height: 0; font-weight: 400; text-decoration: underline; }
.stack { display: flex; flex-direction: column; gap: 1rem; max-width: 40rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.actions { margin: 1.25rem 0 0; }
.button-row { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1rem 0; }
.button-row form, form.inline { margin: 0; display: inline-flex; gap: .5rem; align-items: center; }
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: 1rem; }
.filters .grow, .lookup-row .grow { flex: 1 1 14rem; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 1rem; margin: 0; background: var(--surface); }
legend { font-weight: 700; padding: 0 .35rem; }
.lookup-row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.chosen { display: flex; justify-content: space-between; align-items: center; margin: 0; font-weight: 700; font-size: 1.1rem; }
.results { list-style: none; padding: 0; margin: .5rem 0 0; }
.results button { width: 100%; justify-content: space-between; text-align: left; font-weight: 400; margin-top: .35rem; gap: 1rem; }
.results .muted { font-size: .9rem; }
.camera { margin-top: .75rem; display: flex; flex-direction: column; gap: .5rem; }
.camera video { width: 100%; max-height: 50vh; border-radius: 8px; background: #000; object-fit: cover; }

.detail-head { display: flex; gap: 1rem; align-items: center; margin-bottom: 1.25rem; }
.detail-head h1 { margin: 0; }
.detail-head p { margin: .25rem 0 0; }
.req { font-weight: 400; color: var(--muted); font-size: .85rem; }
.bulk { margin-bottom: 1rem; }
.bulk-row { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; align-items: center; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; }
label.check input, .check-col input { width: 1.25rem; height: 1.25rem; min-height: 0; padding: 0; accent-color: var(--accent); }
.check-col { width: 2.5rem; }
tr.managed td:nth-child(2) { font-weight: 700; }
.danger-zone { margin-top: 2rem; max-width: 40rem; }
.danger-zone summary { cursor: pointer; color: var(--expired); font-weight: 700; }

/* tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: .9rem; color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.5rem; margin: 1rem 0; }
.facts dt { font-weight: 700; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.log { list-style: none; padding: 0; margin: 0; font-size: .95rem; }
.log li { padding: .4rem 0; border-bottom: 1px solid var(--line); }
.log time { color: var(--muted); margin-right: .5rem; font-variant-numeric: tabular-nums; }
.log-error { color: var(--expired); }

body.login main { min-height: 100%; display: grid; place-items: center; padding-top: 12vh; }
.login-card { display: flex; flex-direction: column; gap: 1rem; width: min(24rem, 100%); background: var(--surface); padding: 1.5rem; border-radius: 10px; border: 1px solid var(--line); }
.login-card h1 { margin: 0; }

@media (max-width: 48rem) {
  .top { justify-content: space-between; padding-bottom: 0; }
  .top nav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; gap: 1.1rem; padding-bottom: .5rem; scrollbar-width: none; }
  .top nav a { white-space: nowrap; }
}
@media (max-width: 40rem) {
  .two { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr; }
  .facts dd { margin-bottom: .5rem; }
  .row { gap: 0 .75rem; padding: .7rem .8rem; }
  h1 { font-size: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
