:root {
  --bg: #f4f5f7; --card: #ffffff; --text: #1d2330; --muted: #677085; --line: #dfe3ea;
  --accent: #2463eb; --accent-text: #ffffff;
  --ok: #18794e; --ok-bg: #e6f4ec; --warn: #9a5b00; --warn-bg: #fdf1dc; --err: #b42318; --err-bg: #fdeceb;
  --full: #18794e; --empty: #c2410c; --worn: #b42318; --away: #6d4aff; --inst: #2463eb; --free: #9aa3b5;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151c; --card: #1b2029; --text: #e7eaf0; --muted: #98a1b3; --line: #2c3340;
    --accent: #5b8cff; --accent-text: #0b1020;
    --ok: #5fd39a; --ok-bg: #12301f; --warn: #f2b45a; --warn-bg: #33270f; --err: #ff8a80; --err-bg: #3a1714;
    --full: #5fd39a; --empty: #ff9f5a; --worn: #ff8a80; --away: #a993ff; --inst: #7ea6ff; --free: #59617a;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: 92px; }
a { color: var(--accent); }
header { background: var(--card); border-bottom: 1px solid var(--line); padding: 10px 16px;
  display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 5; }
header .brand { font-weight: 700; text-decoration: none; color: var(--text); flex: 1; }
header .who { color: var(--muted); font-size: 14px; }
nav.menu { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 16px; background: var(--card);
  border-bottom: 1px solid var(--line); }
nav.menu a { text-decoration: none; padding: 6px 10px; border-radius: 8px; color: var(--text); font-size: 14px;
  background: var(--bg); }
main { max-width: 860px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 18px; margin: 20px 0 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 12px 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.btn { display: inline-block; border: 0; border-radius: 12px; padding: 14px 18px; font-size: 17px; font-weight: 600;
  background: var(--accent); color: var(--accent-text); text-decoration: none; cursor: pointer; text-align: center; }
.btn.block { display: block; width: 100%; margin: 8px 0; }
.btn.secondary { background: var(--bg); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--err); color: #fff; }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 9px; }
.scanbar { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line); z-index: 6; }
.scanbar .btn { display: block; max-width: 828px; margin: 0 auto; font-size: 18px; }
.flash { border-radius: 12px; padding: 12px 14px; margin: 10px 0; }
.flash.ok, .box.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error, .box.error { background: var(--err-bg); color: var(--err); }
.flash.warn, .box.warn { background: var(--warn-bg); color: var(--warn); }
.box { border-radius: 14px; padding: 16px; margin: 12px 0; }
.bigcell { font-size: 88px; font-weight: 800; line-height: 1; text-align: center; margin: 10px 0 4px; }
.bigcell small { display: block; font-size: 16px; font-weight: 600; letter-spacing: .02em; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 13px; font-weight: 600;
  border: 1px solid currentColor; white-space: nowrap; }
.st-full { color: var(--full); } .st-empty { color: var(--empty); } .st-worn { color: var(--worn); }
.st-away { color: var(--away); } .st-installed { color: var(--inst); } .st-off { color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
.tablewrap { overflow-x: auto; }
label { display: block; font-weight: 600; margin: 12px 0 4px; font-size: 15px; }
input[type=text], input[type=password], input[type=number], input[type=email], select, textarea {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
  color: var(--text); font-size: 16px; }
textarea { min-height: 70px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 200px; }
.list a.item, .list div.item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px;
  border: 1px solid var(--line); margin: 8px 0; text-decoration: none; color: var(--text); background: var(--card); }
.list .num { font-size: 26px; font-weight: 800; min-width: 52px; text-align: center; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.cellbox { border-radius: 12px; padding: 8px; min-height: 84px; text-decoration: none; color: var(--text);
  border: 2px solid var(--free); background: var(--card); display: flex; flex-direction: column; }
.cellbox .n { font-size: 22px; font-weight: 800; }
.cellbox .m { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cellbox.full { border-color: var(--full); } .cellbox.empty { border-color: var(--empty); }
.cellbox.worn { border-color: var(--worn); } .cellbox.free { border-style: dashed; color: var(--muted); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; margin: 8px 0; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px;
  vertical-align: -1px; border: 2px solid; }
.stat { display: flex; gap: 8px; flex-wrap: wrap; }
.stat div { flex: 1 1 120px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.stat b { display: block; font-size: 24px; }
#reader { width: 100%; max-width: 480px; margin: 0 auto; border-radius: 14px; overflow: hidden; background: #000; }
details summary { cursor: pointer; font-weight: 600; margin: 8px 0; }
.inline { display: inline; }
