:root {
  --bg: #f9f7f4;
  --surface: #ffffff;
  --text: #1d2624;
  --muted: #5c6a66;
  --border: #e6ded5;
  --accent: #8a5320;
  --accent-text: #ffffff;
  --planned: #e9eef6;
  --ok: #dcefd9;
  --skipped: #eef0ee;
  --danger: #b3261e;
  --radius: 10px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1714;
    --surface: #24201c;
    --text: #e4ece9;
    --muted: #98a9a4;
    --border: #3a332c;
    --accent: #e3ab72;
    --accent-text: #1a1209;
    --planned: #232f3c;
    --ok: #1d3a31;
    --skipped: #29302e;
    --danger: #ef7d74;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

main { max-width: 72rem; margin: 0 auto; padding: 1.25rem 1rem 2rem; }
@media (min-width: 48rem) { main { padding: 2rem 1.5rem 3rem; } }
h1 { font-size: 1.4rem; line-height: 1.25; margin: 0 0 1rem; }
@media (min-width: 48rem) { h1 { font-size: 1.6rem; } }
h2 { font-size: 1.1rem; margin: 0 0 0.5rem; }
main > h2 { margin-top: 1.5rem; }
a { color: var(--accent); }

/* Phone: brand and sign out on the first row, the menu as one row of tabs below.
   Wider screens: everything on one row. */
.site-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1.5rem;
  padding: 0.6rem 1rem 0; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 0.55rem; color: var(--text); font-weight: 650; text-decoration: none; }
.brand img { width: 32px; height: 32px; }
.site-header nav {
  order: 3; flex-basis: 100%; display: flex; margin: 0 -0.6rem; padding: 0 0.6rem;
  overflow-x: auto; scrollbar-width: none;
}
.site-header nav::-webkit-scrollbar { display: none; }
.site-header nav a {
  flex: 1 0 auto; text-align: center; padding: 0.55rem 0.4rem; white-space: nowrap;
  color: var(--muted); font-weight: 500; font-size: 0.95rem; text-decoration: none;
  border-bottom: 2px solid transparent;
}
.site-header nav a:hover { color: var(--text); }
.site-header nav a.active { color: var(--accent); border-bottom-color: var(--accent); }
.site-header .link-button { padding: 0.4rem 0; }
.site-header form { display: flex; }
@media (min-width: 48rem) {
  .site-header { flex-wrap: nowrap; padding: 0 1.5rem; }
  .site-header nav { order: 0; flex: 1 1 auto; flex-basis: auto; margin: 0; padding: 0; }
  .site-header nav a { flex: 0 0 auto; padding: 1rem 0.75rem 0.9rem; }
}

.page-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}
.page-header h1 { margin: 0; flex: 1 1 12rem; }

.flash { padding: 0.6rem 0.9rem; border-radius: var(--radius); margin-bottom: 1rem; }
.flash-notice { background: var(--ok); }
.flash-alert, .errors { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--text); }
.errors { padding: 0.6rem 0.9rem; border-radius: var(--radius); }
.errors ul { margin: 0.25rem 0 0; padding-left: 1.2rem; }

.muted, .hint { color: var(--muted); }
.nowrap { white-space: nowrap; }
.hint { font-size: 0.9rem; margin: 0.25rem 0; }

.cards, .list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.6rem; }
.cards { grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); }
.card, .panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem;
}
.card p { margin: 0.3rem 0; }
.card h2 { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.panel { margin: 1rem 0; }
.panel > h2:first-child { margin-top: 0; }

/* Stock rows and list rows: name and counts, with actions that wrap below on phones. */
.stock-row, .need-row, .item-row {
  display: grid; grid-template-columns: 1fr auto; gap: 0.4rem 1rem; align-items: center;
  padding: 0.7rem 0; border-top: 1px solid var(--border);
}
.stock-row:first-of-type, .need-row:first-of-type, .item-row:first-of-type { border-top: 0; }
.stock-row .actions, .need-row .actions, .item-row .actions { grid-column: 1 / -1; margin-top: 0; }
@media (min-width: 48rem) {
  .stock-row .actions, .need-row .actions, .item-row .actions { grid-column: auto; justify-content: flex-end; }
}
.counts { font-variant-numeric: tabular-nums; white-space: nowrap; }
.count-box { display: inline-flex; flex-direction: column; align-items: center; min-width: 4.2rem; }
.count-box strong { font-size: 1.25rem; line-height: 1.1; }
.count-box span { font-size: 0.75rem; color: var(--muted); }
.inline-form { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.inline-form input[type="number"] { width: 4.5rem; }
.inline-form select { max-width: 14rem; }
.inline-form label { font-size: 0.85rem; color: var(--muted); }
details.more { grid-column: 1 / -1; }
details.more summary { color: var(--muted); cursor: pointer; font-size: 0.9rem; }
details.more .inline-form { margin: 0.5rem 0; }
.section-title { margin: 1.5rem 0 0.5rem; font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.event { padding: 0.6rem 0; border-top: 1px solid var(--border); }
.event:first-child { border-top: 0; }
.event p { margin: 0.1rem 0; }
.tree-depth-1 { padding-left: 1.25rem; }
.tree-depth-2 { padding-left: 2.5rem; }
.tree-depth-3 { padding-left: 3.75rem; }
.checks { display: flex; flex-direction: column; gap: 0.4rem; margin: 0.75rem 0; }

.badge {
  display: inline-block; padding: 0.05rem 0.5rem; border-radius: 999px; font-size: 0.8rem;
  border: 1px solid var(--border);
}
.badge-ok, .badge-in_cart, .badge-purchased { background: var(--ok); }
.badge-warn, .badge-pending { background: var(--planned); }
.badge-omitted, .badge-cancelled { background: var(--skipped); }

.actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.actions form { display: inline; }

button, input[type="submit"], .button {
  display: inline-block; padding: 0.5rem 1rem; border: 0; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-text); font: inherit; font-weight: 500;
  text-decoration: none; cursor: pointer;
}
.button-small, .button.button-small { padding: 0.25rem 0.7rem; font-size: 0.9rem; }
:is(a, button, input).button-secondary { background: var(--border); color: var(--text); }
:is(a, button, input).button-outline { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
:is(a, button, input).button-outline:hover { color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
:is(a, button, input).button-danger { background: var(--danger); color: #fff; }
.link-button { background: none; color: var(--muted); padding: 0; }
.icon { width: 1.15rem; height: 1.15rem; display: block; flex: none; }
:is(a, button).icon-button { display: inline-flex; align-items: center; justify-content: center; width: 2.4rem; height: 2.25rem; padding: 0; }
.site-header .sign-out { width: 2.25rem; border-radius: var(--radius); }
.site-header .sign-out:hover { color: var(--text); background: var(--border); }

input, select, textarea {
  font: inherit; color: inherit; background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; padding: 0.45rem 0.6rem; max-width: 100%;
}
.stacked { display: flex; flex-direction: column; gap: 0.4rem; max-width: 44rem; }
.stacked > label { font-weight: 500; margin-top: 0.5rem; }
.stacked > input[type="submit"] { align-self: flex-start; margin-top: 0.75rem; }
label.inline { display: inline-flex; align-items: center; gap: 0.35rem; margin-right: 1rem; font-weight: normal; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); margin: 0.75rem 0 0; padding: 0.75rem; }
legend { font-weight: 600; padding: 0 0.3rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin: 0.3rem 0; }
.row input:not([type="checkbox"]), .row select { flex: 1 1 8rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0.5rem 1rem; }
.grid > div { display: flex; flex-direction: column; gap: 0.2rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.filters input[type="search"] { flex: 1 1 14rem; }
/* Sign-in, password and consent pages: a centred card. */
.narrow {
  max-width: 26rem; margin: 0.5rem auto; padding: 1.5rem 1.25rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
}
@media (min-width: 48rem) { .narrow { margin-top: 3rem; padding: 2rem; box-shadow: 0 8px 30px rgb(0 0 0 / 0.06); } }
.narrow h1 { margin-bottom: 1rem; }
.narrow .stacked > input[type="submit"] { align-self: stretch; padding: 0.7rem 1rem; margin-top: 1rem; }
.narrow input:not([type="submit"]) { padding: 0.6rem 0.7rem; }
.narrow .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-top: 1.25rem; }
.narrow .actions input[type="submit"] { width: 100%; padding: 0.7rem 1rem; }
.flash:has(~ .narrow) { max-width: 26rem; margin: 0.5rem auto 0; }
@media (min-width: 48rem) { .flash:has(~ .narrow) { margin-top: 2rem; } .flash ~ .narrow { margin-top: 1rem; } }
.auth-intro { text-align: center; margin-bottom: 1.25rem; }
.auth-intro img { display: block; width: 88px; height: 88px; margin: 0 auto 0.75rem; }
.auth-intro h1 { margin: 0; }
.auth-intro p { margin: 0.25rem 0 0; }
.auth-links { text-align: center; margin: 1rem 0 0; font-size: 0.95rem; }

.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0.5rem; margin: 1rem 0 0; }
.facts div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem 0.7rem; }
.facts dt { color: var(--muted); font-size: 0.85rem; }
.facts dd { margin: 0; font-weight: 500; }
