:root {
  --bg: #f6f7f9; --surface: #fff; --text: #1d2330; --muted: #5d6675;
  --border: #dde1e7; --accent: #2764c5; --low-bg: #fff4e5; --low: #b35900;
  --ok-bg: #e8f5ec; --ok: #1f7a3d;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c; --surface: #1d2129; --text: #e6e9ef; --muted: #9aa3b2;
    --border: #2e3440; --accent: #7aa7ff; --low-bg: #3a2a14; --low: #ffb35c;
    --ok-bg: #173022; --ok: #7fd49a;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.5 system-ui, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
header { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; align-items: center;
  padding: .75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--text); }
nav { display: flex; flex-wrap: wrap; gap: 1rem; }
main { max-width: 960px; margin: 0 auto; padding: 1rem; }
.message { background: var(--ok-bg); color: var(--ok); padding: .6rem .9rem; border-radius: 6px; }
.alert { background: var(--low-bg); color: var(--low); padding: .8rem 1rem; border-radius: 6px; font-weight: 600; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1rem 1.25rem; }
.card.low { border-color: var(--low); }
.card h2 { margin: 0 0 .25rem; font-size: 1.1rem; }
.big { font-size: 2.2rem; font-weight: 700; margin: 0; }
.big span { font-size: 1rem; font-weight: 400; color: var(--muted); }
dl { display: grid; grid-template-columns: auto 1fr; gap: .2rem 1rem; margin: .75rem 0 0; }
dt { color: var(--muted); }
dd { margin: 0; }
.status { margin: .75rem 0 0; color: var(--low); font-weight: 700; }
.history { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-top: 2rem; }
.history h3 { font-size: 1rem; margin: 0 0 .5rem; }
.history ul { list-style: none; padding: 0; margin: 0; }
.history li { padding: .4rem 0; border-top: 1px solid var(--border); font-size: .92rem; }
.help { color: var(--muted); }
.entry { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1rem 1.25rem; max-width: 520px; }
.entry div { margin-bottom: .9rem; }
.entry label { display: block; font-weight: 600; margin-bottom: .2rem; }
.entry input, .entry select { width: 100%; padding: .45rem .5rem; font: inherit;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }
.entry .helptext { color: var(--muted); font-size: .85rem; }
.errorlist { color: var(--low); margin: 0; padding-left: 1rem; }
button { font: inherit; padding: .5rem 1.25rem; border: 0; border-radius: 6px; background: var(--accent); color: #fff; cursor: pointer; margin-right: 1rem; }

/* Level meter: nights of supply, with the reorder point marked. */
:root { --good: #0ca30c; --warning: #fab219; --critical: #d03b3b; --track: #e6e9ee; }
@media (prefers-color-scheme: dark) { :root { --track: #2b313b; } }
.meter { margin: .75rem 0 .25rem; }
.meter-track { position: relative; height: 14px; background: var(--track); border-radius: 4px; }
.meter-fill { height: 100%; border-radius: 4px; min-width: 4px; }
.meter-good .meter-fill { background: var(--good); }
.meter-warning .meter-fill { background: var(--warning); }
.meter-critical .meter-fill { background: var(--critical); }
.meter-mark { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px;
  background: var(--text); border-radius: 1px; }
.meter-scale { position: relative; display: flex; justify-content: space-between;
  font-size: .75rem; color: var(--muted); margin-top: .2rem; height: 1.1rem; }
.meter-mark-label { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.meter-status { margin: .35rem 0 0; font-size: .9rem; font-weight: 600; }
.meter-status span { font-size: .8rem; }
.meter-good .meter-status span { color: var(--good); }
.meter-warning .meter-status span { color: var(--warning); }
.meter-critical .meter-status span { color: var(--critical); }

/* Account links in the header */
.account { margin-left: auto; display: flex; align-items: center; gap: .15rem; }
.account form { margin: 0; }
.account a, button.link { color: var(--muted); }
button.link { background: none; margin: 0; font-weight: 400; }

/* Deliveries on order: dashboard notice and supply cards */
.notice { background: var(--surface); border: 1px solid var(--border); padding: .6rem .9rem; border-radius: 6px; }
.on-order { display: flex; align-items: center; gap: .75rem; justify-content: space-between;
  margin-top: .9rem; padding-top: .75rem; border-top: 1px solid var(--border); font-size: .92rem; }
.on-order p { margin: 0; }
a.button { flex: none; padding: .35rem .9rem; border-radius: 6px; background: var(--accent); color: #fff; text-decoration: none; }

/* Dashboard groups and supplies table */
h2.group { font-size: 1.05rem; color: var(--muted); font-weight: 600; margin: 1.5rem 0 .6rem; }
h2.group:first-of-type { margin-top: .5rem; }
.card h3 { margin: 0 0 .25rem; font-size: 1.1rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: .55rem .9rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
tr.inactive td { color: var(--muted); }
.entry input[type="checkbox"] { width: auto; }

/* Stock count history */
table.counts td { vertical-align: top; }
table.counts td.date { font-weight: 600; }
table.counts td.notes { white-space: normal; min-width: 8rem; color: var(--muted); }
.sub { display: block; font-size: .82rem; color: var(--muted); }
.diff.under { color: var(--low); font-weight: 600; }
.diff.over { color: var(--ok); font-weight: 600; }
.pager { display: flex; gap: 1.25rem; align-items: center; justify-content: center; margin-top: 1rem; }
h3 .more { font-size: .85rem; font-weight: 400; margin-left: .4rem; }
table.counts th { white-space: normal; vertical-align: bottom; }

/* Delivery history */
table.deliveries td { vertical-align: top; }
table.deliveries td.date { font-weight: 600; }
table.deliveries .line { display: block; }
.entry .contents ul { margin: .2rem 0; padding-left: 1.2rem; }
.entry a.remove { float: right; color: var(--low); }

/* Pause history */
table.pauses td.date { font-weight: 600; }
table.pauses td.notes { white-space: normal; min-width: 8rem; color: var(--muted); }

/* Usage history */
table.usage th { white-space: normal; vertical-align: bottom; }
table.usage td { vertical-align: top; }
table.usage td.date { font-weight: 600; }
table.usage td.notes { white-space: normal; min-width: 8rem; color: var(--muted); }
table.usage tr.upcoming td { color: var(--muted); }
.tag { display: inline-block; margin-left: .35rem; padding: 0 .45rem; border-radius: 999px;
  font-size: .72rem; font-weight: 600; background: var(--ok-bg); color: var(--ok); vertical-align: middle; }
.tag.upcoming { background: var(--track); color: var(--muted); }

/* Header navigation and History menu */
.main-nav { align-items: center; gap: .15rem; }
.main-nav > a, .menu summary, .account a, button.link { padding: .35rem .7rem; border-radius: 6px;
  font: inherit; font-size: .95rem; line-height: 1.5; text-decoration: none; white-space: nowrap; cursor: pointer; }
.main-nav > a, .menu summary { color: var(--text); }
.main-nav > a:hover, .menu summary:hover, .menu[open] summary, .account a:hover, button.link:hover {
  background: var(--bg); color: var(--text); }
.main-nav > a[aria-current="page"], .menu summary.current { background: var(--bg); color: var(--accent); font-weight: 600; }
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: ' ▾'; font-size: .8em; text-decoration: none; display: inline-block; margin-left: .15rem; }
.menu[open] summary::after { content: ' ▴'; }
.menu-items { position: absolute; top: calc(100% + .4rem); left: 0; z-index: 10; min-width: 11rem;
  display: flex; flex-direction: column; padding: .35rem 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .12); }
.menu-items a { padding: .45rem .9rem; color: var(--text); text-decoration: none; white-space: nowrap; }
.menu-items a:hover, .menu-items a:focus-visible { background: var(--bg); }
.menu-items a[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* Radio button groups in forms */
.entry fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.entry legend { font-weight: 600; padding: 0; margin-bottom: .2rem; }
.entry fieldset div div { margin-bottom: .3rem; }
.entry fieldset label { display: flex; align-items: center; gap: .5rem; font-weight: 400; margin: 0; }
.entry input[type="radio"] { width: auto; margin: 0; }

/* '[2] bags every [7] days' usage input */
.every-days { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.entry .every-days input { width: 5rem; }
