:root {
  --bg: #f6f3ec;
  --surface: #fffdf8;
  --ink: #1d1b16;
  --muted: #6b665a;
  --line: #e4ded0;
  --accent: #1f4d3a;
  --accent-ink: #f6f3ec;
  --chip: #ece6d8;
  --ok: #2f6b3c;
  --ok-bg: #e3efe1;
  --low: #8a5a00;
  --low-bg: #f7ead0;
  --out: #8f2f24;
  --out-bg: #f6e1dc;
  --shadow: 0 1px 2px rgba(29, 27, 22, .05), 0 4px 16px rgba(29, 27, 22, .04);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14130f;
    --surface: #1c1a16;
    --ink: #efe9dc;
    --muted: #a39d8e;
    --line: #2f2c25;
    --accent: #8fc7a5;
    --accent-ink: #12130f;
    --chip: #27251f;
    --ok: #9fd3a8;
    --ok-bg: #1f2e22;
    --low: #f0c36b;
    --low-bg: #33290f;
    --out: #f0a092;
    --out-bg: #3a1e19;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 "IBM Plex Sans", system-ui, sans-serif;
}

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }

/* ── Notice bar ───────────────────────────────────────── */
.notice { background: var(--accent); color: var(--accent-ink); }
.notice[hidden] { display: none; }
.notice p { margin: 0; padding: 10px 0; font-size: 14px; font-weight: 500; text-align: center; letter-spacing: .01em; }

/* ── Masthead ───────────────────────────────────────────── */
.masthead { padding: 48px 0 28px; }
.masthead-inner { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.eyebrow {
  margin: 0 0 6px;
  font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent);
}
h1 {
  margin: 0;
  font: 700 clamp(32px, 6vw, 52px)/1.05 "Fraunces", Georgia, serif;
  letter-spacing: -.02em;
  text-wrap: balance;
}
.tagline { margin: 10px 0 0; color: var(--muted); max-width: 52ch; }
.stamp {
  display: flex; flex-direction: column; align-items: flex-end;
  padding: 10px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.stamp-label { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.stamp-date { font: 500 15px "IBM Plex Mono", ui-monospace, monospace; }

/* ── Toolbar ────────────────────────────────────────────── */
.toolbar {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}
.toolbar-inner { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.search {
  flex: 1 1 280px; display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; flex: none; }
.search input {
  flex: 1; min-width: 0; border: 0; background: none; color: inherit; font: inherit;
  padding: 10px 0; outline: none;
}
.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
select {
  font: inherit; font-size: 14px; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px;
}
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; user-select: none; white-space: nowrap; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }


/* ── Tabs ───────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tabs[hidden] { display: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  font: 500 15px "IBM Plex Sans", sans-serif; color: var(--muted);
  background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  padding: 8px 14px 10px; cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tab .n {
  font: 500 12px "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums;
  background: var(--chip); color: var(--muted); border-radius: 999px; padding: 1px 8px;
}
.tab[aria-selected="true"] .n { background: var(--accent); color: var(--accent-ink); }
select[hidden], .toggle[hidden] { display: none; }

.list-table { table-layout: auto; }
.list-table td { font-variant-numeric: tabular-nums; }

/* ── Inventory table ──────────────────────────────────── */
main.wrap { padding-top: 32px; padding-bottom: 24px; }
.section { margin-bottom: 36px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 12px; }
.section-head h2 { margin: 0; font: 600 24px/1.2 "Fraunces", Georgia, serif; letter-spacing: -.01em; }
.section-head .count { color: var(--muted); font-size: 14px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }

table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th.c-stock { width: 170px; }
th.c-price { width: 130px; }
th.c-market { width: 200px; }
thead th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  padding: 12px 20px; border-bottom: 1px solid var(--line);
}
tbody td { padding: 14px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--chip) 45%, transparent); }
th.num, td.num { text-align: right; }

.p-name { font-weight: 500; }

.price { font: 500 17px "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; white-space: nowrap; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: 13px; font-weight: 500; border-radius: 999px; padding: 3px 10px;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.low { color: var(--low); background: var(--low-bg); }
.badge.out { color: var(--out); background: var(--out-bg); }

.market {
  display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap;
  font: 500 14px "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums;
  color: var(--muted); text-decoration: none; border-bottom: 1px dotted var(--line);
}
a.market:hover { color: var(--accent); border-bottom-color: currentColor; }
.market.none { border: 0; }
.m-label { font: 600 10px "IBM Plex Sans", sans-serif; letter-spacing: .08em; text-transform: uppercase; display: none; }
.market-note { margin: 10px 4px 0; font-size: 13px; color: var(--muted); }

tr.is-out .p-name, tr.is-out .price { color: var(--muted); }
tr.is-out .price { text-decoration: line-through; text-decoration-thickness: 1px; }

.status { color: var(--muted); padding: 48px 0; text-align: center; }
.status.error { color: var(--out); }

.footer.wrap { border-top: 1px solid var(--line); padding-top: 20px; padding-bottom: 48px; color: var(--muted); font-size: 14px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.footer p { margin: 0; }

/* ── Phone layout: rows become stacked cards ───────────── */
@media (max-width: 640px) {
  .masthead { padding-top: 32px; }
  .stamp { align-items: flex-start; }
  .controls { width: 100%; justify-content: space-between; }
  table { table-layout: auto; }
  thead { display: none; }
  tbody tr { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  tbody tr:last-child { border-bottom: 0; }
  tbody td { padding: 0; border: 0; }
  td.c-product { grid-column: 1 / -1; }
  td.c-stock { align-self: center; }
  td.c-price { align-self: center; }
  td.c-market { grid-column: 1 / -1; grid-row: 3; text-align: left; }
  td.c-market .market.none { display: none; }
  .list-table tbody tr { display: block; }
  .list-table td { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
  .list-table td.c-first { display: block; padding-bottom: 6px; }
  .list-table td:not(.c-first)::before { content: attr(data-label); color: var(--muted); font-size: 13px; }
  .m-label { display: inline; }
}

/* ── Print: clean black-on-white price sheet ───────────── */
@media print {
  :root { --bg: #fff; --surface: #fff; --ink: #000; --muted: #444; --line: #ccc; --shadow: none; }
  .toolbar { display: none; }
  .notice { background: none; color: #000; border-bottom: 1px solid #000; }
  .masthead { padding: 0 0 16px; }
  .section { break-inside: avoid-page; }
  .card { border-radius: 0; }
  tbody tr:hover { background: none; }
}
