:root {
  --bg: #f6f1ea;
  --surface: #ffffff;
  --text: #2b2118;
  --muted: #7a6a5c;
  --accent: #6f4e37;
  --accent-text: #ffffff;
  --pos: #2e7d4f;
  --neg: #b3261e;
  --border: #e3d8cb;
  --ok-bg: #e3f3e8;
  --err-bg: #fbe4e2;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1814;
    --surface: #2a231d;
    --text: #f1e9e0;
    --muted: #b3a291;
    --accent: #c08a5b;
    --accent-text: #1d1814;
    --pos: #6cc58f;
    --neg: #ff8a80;
    --border: #3d332a;
    --ok-bg: #1f3a29;
    --err-bg: #4a2422;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.25rem; text-decoration: none; color: var(--text); }
.back { font-size: 1.1rem; text-decoration: none; }
.tag { background: var(--accent); color: var(--accent-text); padding: 2px 10px; border-radius: 999px; font-size: .85rem; }
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.6rem; margin: 8px 0 16px; }
h2 { font-size: 1.15rem; margin: 24px 0 8px; }

.grid { display: grid; gap: 12px; }
.grid.users { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.grid.products { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.grid.products form { margin: 0; }

.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 110px; width: 100%; padding: 16px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px;
  text-decoration: none; font: inherit; cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
}
.tile:active { transform: scale(.97); }
.tile:hover { box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.tile .name { font-size: 1.2rem; font-weight: 600; text-align: center; }
.tile.product { min-height: 130px; }
.tile .price { color: var(--muted); }

.pos { color: var(--pos); }
.neg { color: var(--neg); }

.userhead { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.balance { font-size: 1.8rem; font-weight: 700; }
.undo { margin: 0 0 12px; }

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; }
.flash.ok { background: var(--ok-bg); }
.flash.err { background: var(--err-bg); }

.btn {
  background: var(--accent); color: var(--accent-text); border: 0; border-radius: 8px;
  padding: 10px 16px; font: inherit; cursor: pointer;
}
.btn.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.small { padding: 4px 10px; font-size: .9rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; overflow-x: auto; }
.card h2 { margin-top: 4px; }
form.inline { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 0 0 8px; }
input { font: inherit; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.list td form { margin: 0; }
.num { text-align: right; white-space: nowrap; }
tr.cancelled td { text-decoration: line-through; color: var(--muted); }
tr.inactive td { color: var(--muted); }
.empty { color: var(--muted); }
.foot { margin-top: 32px; text-align: center; font-size: .9rem; }
.staging-banner { background: #f5c518; color: #2b2118; text-align: center; font-weight: 700; padding: 6px 12px; letter-spacing: .02em; }
