:root {
  --bg: #f6f7f6; --fg: #1c2321; --muted: #5d6b67; --card: #fff; --line: #dde3e1;
  --accent: #1f6f5c; --accent-fg: #fff; --accent-soft: #e3f1ec; --danger: #b3261e;
  --tabbar-h: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121614; --fg: #e4ebe8; --muted: #93a39e; --card: #1b211f; --line: #2c3532;
    --accent: #5cc3a5; --accent-fg: #0b1512; --accent-soft: #1d2f29; --danger: #f2827a; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 4px;
  min-height: 56px; padding: env(safe-area-inset-top) 16px 0; background: var(--bg); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 1.2rem; }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; margin-left: -8px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--fg); }
.icon-btn:active { background: var(--line); }

main { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px); }
section { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
h2 { margin: 0 0 8px; font-size: 1.05rem; }
.muted, .meta { color: var(--muted); font-size: .9rem; }
.meta { display: block; font-size: .85rem; }
label { display: block; margin: 12px 0; font-size: .9rem; color: var(--muted); }
input { display: block; width: 100%; margin-top: 4px; padding: 10px; font: inherit; color: var(--fg);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
button { font: inherit; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-fg); cursor: pointer; }
button.secondary { background: transparent; color: var(--accent); }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.small { padding: 4px 10px; font-size: .85rem; }
ul { list-style: none; padding: 0; margin: 0; }
li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
li:last-child { border-bottom: 0; }
li.revoked { opacity: .5; }
img.qr { display: block; width: 240px; max-width: 100%; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: 8px; }
#scan-video { width: 100%; border-radius: 8px; }
code { word-break: break-all; font-size: .85rem; }
.badge { font-size: .75rem; color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: 0 8px; margin-left: 6px; vertical-align: middle; }
.banner { background: var(--accent-soft); border-color: var(--accent); }
.banner p { margin-top: 0; }

/* Food (placeholder) */
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty h2 { color: var(--fg); margin-top: 8px; }

/* Settings */
.account { display: flex; align-items: center; gap: 12px; }
.avatar { display: grid; place-items: center; width: 48px; height: 48px; flex: none; border-radius: 50%;
  background: var(--accent); color: var(--accent-fg); font-weight: 600; font-size: 1.2rem; }
.account-name { font-weight: 600; }
.menu { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.menu a { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px;
  padding: 12px 16px; color: var(--fg); text-decoration: none; border-bottom: 1px solid var(--line); }
.menu a:last-child { border-bottom: 0; }
.menu a:active { background: var(--line); }
.menu a[hidden] { display: none; }
.menu svg { color: var(--muted); flex: none; }

/* User management */
.user { padding: 12px 0; border-bottom: 1px solid var(--line); }
.user:last-child { border-bottom: 0; }
.user h3 { display: flex; justify-content: space-between; align-items: center; margin: 0; font-size: 1rem; }
#admin-add input { flex: 1; min-width: 180px; margin: 0; }

/* Bottom tab bar */
.tabbar { position: fixed; z-index: 2; left: 0; right: 0; bottom: 0; display: flex; justify-content: center;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line); }
.tabbar[hidden] { display: none; }
.tabbar a { flex: 1; max-width: 200px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: .75rem; font-weight: 500; }
.tabbar a svg { padding: 4px 20px; border-radius: 16px; box-sizing: content-box; }
.tabbar a.active { color: var(--fg); }
.tabbar a.active svg { background: var(--accent-soft); color: var(--accent); }
