:root {
  --bg: #f6f4ef; --card: #fff; --ink: #1f2a24; --muted: #6b746e; --line: #e2ded5;
  --brand: #2f6f4f; --brand-ink: #fff; --brand-soft: #e3efe8;
  --ok: #2f7d4f; --warn: #c27a00; --warn-soft: #fff1d6; --bad: #b3261e; --bad-soft: #fde4e1;
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816; --card: #1e2421; --ink: #e9eeea; --muted: #9aa49e; --line: #2e3632;
    --brand: #5fb38a; --brand-ink: #0d1a13; --brand-soft: #23362c;
    --ok: #6cc28f; --warn: #f0b04a; --warn-soft: #3a2e17; --bad: #ff8a80; --bad-soft: #3d1f1d;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
button, a, input, select, textarea { scroll-margin-bottom: 110px; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 18px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
a { color: var(--brand); }
h2 { font-size: 1.15rem; margin: 1.4rem 0 .6rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: .85rem; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  background: var(--brand); color: var(--brand-ink); padding: calc(12px + env(safe-area-inset-top)) 16px 12px; }
.top h1 { margin: 0; font-size: 1.3rem; font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { background: none; border: 0; color: inherit; padding: 0 4px 0 0; cursor: pointer; display: flex; }
.back .i { width: 28px; height: 28px; stroke-width: 2.4; }
main { max-width: 640px; margin: 0 auto; padding: 16px; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 10px;
  color: var(--muted); text-decoration: none; font-size: .8rem; }
.tabs a span { display: flex; }
.tabs a .i { width: 26px; height: 26px; }
.tabs a.on { color: var(--brand); font-weight: 600; }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 56px;
  padding: 12px 18px; border-radius: 14px; border: 0; background: var(--brand); color: var(--brand-ink);
  font: inherit; font-weight: 650; cursor: pointer; text-decoration: none; }
.btn + .btn { margin-top: 10px; }
.btn.big { min-height: 72px; font-size: 1.25rem; }
.btn.ghost { background: transparent; color: var(--brand); border: 2px solid var(--brand); }
.btn.ghost.light { color: #fff; border-color: #fff; }
.btn.quiet { background: transparent; color: var(--muted); min-height: 44px; font-weight: 500; }
.btn.danger { background: transparent; color: var(--bad); border: 2px solid var(--bad); }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; margin-top: 0 !important; }
input[type=date].in { min-width: 0; padding-left: 10px; padding-right: 8px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin: 0 -16px 12px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.chip { flex: none; border: 2px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px;
  padding: 8px 14px; font: inherit; font-size: .95rem; cursor: pointer; }
.chip.on { border-color: var(--brand); background: var(--brand-soft); font-weight: 600; }
.search { width: 100%; font: inherit; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--ink); margin-bottom: 12px; }

.item { display: flex; align-items: center; gap: 14px; background: var(--card); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 10px; text-decoration: none; color: inherit; border: 1px solid var(--line); }
.item .ic { width: 48px; height: 48px; border-radius: 14px; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; flex: none; }
.item .ic .i { width: 28px; height: 28px; }
.item .tx { flex: 1; min-width: 0; }
.item .nm { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .sub { color: var(--muted); font-size: .88rem; }
.badge { flex: none; border-radius: 10px; padding: 6px 10px; font-size: .85rem; font-weight: 700; text-align: center; min-width: 64px;
  background: var(--brand-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .ic .i { width: 48px; height: 48px; stroke-width: 1.6; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.hero { text-align: center; padding: 20px 16px; }
.hero .ic { width: 88px; height: 88px; margin: 0 auto; border-radius: 26px; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; }
.hero .ic .i { width: 52px; height: 52px; stroke-width: 1.7; }
.hero .nm { font-size: 1.5rem; font-weight: 700; margin: 6px 0 2px; }
.hero .badge { display: inline-block; font-size: 1rem; margin-top: 10px; padding: 8px 14px; }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; font-weight: 550; }

label.f { display: block; font-weight: 600; margin: 16px 0 6px; }
input.in, textarea.in, select.in { width: 100%; font: inherit; padding: 13px 14px; border-radius: 12px;
  border: 2px solid var(--line); background: var(--card); color: var(--ink); }
input.in:focus, textarea.in:focus { outline: none; border-color: var(--brand); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.pick { position: relative; border: 2px solid var(--line); background: var(--card); color: var(--ink); border-radius: 14px; padding: 10px 4px 8px;
  font: inherit; font-size: .8rem; line-height: 1.15; text-align: center; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.pick .i { width: 30px; height: 30px; stroke-width: 1.8; color: var(--brand); }
.pick .count { position: absolute; top: -8px; right: -6px; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px;
  background: var(--brand); color: var(--brand-ink); font-size: .9rem; display: flex; align-items: center; justify-content: center; }
.pick.on { border-color: var(--brand); background: var(--brand-soft); font-weight: 650; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.hint { font-size: .85rem; color: var(--muted); margin-top: 4px; }
details.more summary { cursor: pointer; color: var(--brand); font-weight: 600; margin: 16px 0 4px; }

.sheet { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--line); padding: 10px 6px; border-radius: 8px;
  max-width: 260px; margin: 0 auto; aspect-ratio: 210 / 297; grid-template-rows: repeat(6, 1fr); padding-top: 9%; padding-bottom: 9%; }
.sheet button { border: 0; border-radius: 4px; background: var(--card); color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer; }
.sheet button.skip { background: transparent; color: transparent; outline: 1px dashed var(--muted); }
.sheet button.use { background: var(--brand); color: var(--brand-ink); font-weight: 700; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 10px 0; }
.stepper button { width: 56px; height: 56px; border-radius: 50%; border: 2px solid var(--brand); background: var(--card); color: var(--brand); font-size: 1.6rem; cursor: pointer; }
.stepper b { font-size: 1.6rem; min-width: 3ch; text-align: center; }

.scanner { position: fixed; inset: 0; z-index: 20; background: #000; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanframe { position: absolute; left: 50%; top: 40%; width: min(70vw, 300px); aspect-ratio: 1; transform: translate(-50%, -50%);
  border: 4px solid #fff; border-radius: 24px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
.scanbar { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); color: #fff; text-align: center; }
.scanbar p { margin: 0 0 12px; font-size: 1.1rem; }
.codeform { display: flex; gap: 8px; margin-bottom: 12px; }
.codeform input { flex: 1; min-width: 0; font: inherit; font-size: 1.2rem; letter-spacing: .15em; text-transform: uppercase; padding: 12px; border-radius: 12px; border: 0; text-align: center; }
.codeform button { font: inherit; font-weight: 650; padding: 0 18px; border-radius: 12px; border: 0; background: var(--brand); color: var(--brand-ink); }

.toast { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  background: #222; color: #fff; padding: 12px 16px; border-radius: 12px; display: flex; gap: 16px; align-items: center;
  max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast button { background: none; border: 0; color: #9be3b9; font: inherit; font-weight: 700; cursor: pointer; }
.err { color: var(--bad); font-weight: 600; margin-top: 10px; }
.qrbox { text-align: center; }
.qrbox img { width: 200px; height: 200px; background: #fff; border-radius: 12px; }
.code { font-family: ui-monospace, monospace; font-size: 1.4rem; letter-spacing: .15em; font-weight: 700; }

.testbanner { background: #c2185b; color: #fff; text-align: center; font-weight: 700; font-size: .85rem; padding: 6px 12px; padding-top: calc(6px + env(safe-area-inset-top)); }
.testbanner + .top { padding-top: 12px; }

.i { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.25em; flex: none; }
.i.tiny { width: 1.05em; height: 1.05em; vertical-align: -0.18em; }
.btn .i { width: 1.35em; height: 1.35em; }
.chip .i { color: var(--brand); }
h2 .i { color: var(--brand); }
.plan { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 8px; }
.planrow { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.planrow > .i { width: 26px; height: 26px; color: var(--brand); }
.planrow span { flex: 1; font-weight: 600; }
.planrow b { min-width: 2ch; text-align: center; font-size: 1.15rem; }
.planrow button { width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--brand); background: var(--card); color: var(--brand); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.sheet button { display: flex; align-items: center; justify-content: center; }
.sheet button .i { width: 22px; height: 22px; }
.sub .i.tiny { opacity: .8; }

.sugg { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.sugg:empty { display: none; }
.sugg .chip { padding: 7px 12px; }
.sugg .chip small { color: var(--muted); font-weight: 600; }
.hint.stock { color: var(--warn); font-weight: 600; }
.warnbox { border: 2px solid var(--warn); background: var(--warn-soft); }
.warnbox .warnhead { display: flex; gap: 8px; align-items: flex-start; color: var(--warn); }
.warnbox .warnhead .i { width: 24px; height: 24px; margin-top: 1px; }
.warnbox .warnhead b { color: var(--ink); }
.warnbox p { margin: 8px 0; }
.warnbox .item { margin-bottom: 8px; }
.warnbox .btn small { font-weight: 500; opacity: .8; }
