:root {
  --bg: #f4f6f5; --card: #fff; --ink: #16201b; --muted: #5f6b66; --line: #e2e7e4;
  --accent: #0b7a53; --accent-ink: #fff; --accent-soft: #e3f3ec;
  --deal: #c2410c; --deal-soft: #fff1e6; --warn: #b45309; --bad: #b91c1c; --bad-soft: #fdecec;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 10px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412; --card: #171e1b; --ink: #e7eeea; --muted: #9aa8a1; --line: #26302c;
    --accent: #34b37f; --accent-ink: #062016; --accent-soft: #15302a;
    --deal: #fb923c; --deal-soft: #33200f; --warn: #f59e0b; --bad: #f87171; --bad-soft: #3a1717;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.top { position: sticky; top: 0; z-index: 10; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); text-decoration: none; }
nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; }
nav a { padding: 7px 11px; border-radius: 999px; text-decoration: none; color: var(--muted); white-space: nowrap; font-weight: 500; }
nav a.on { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 640px) { .brand span { display: none; } .top { gap: 8px; } }

main { max-width: 980px; margin: 0 auto; padding: 16px 16px 80px; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }
h1 { font-size: 22px; margin: 4px 0 14px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 22px 0 10px; }
h3 { font-size: 15px; margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }

.btn { border: 1px solid var(--line); background: var(--card); padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.linkbtn { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font-weight: 600; }

.f { display: block; font-weight: 600; font-size: 14px; margin-bottom: 12px; }
.f > span.h { display: block; font-weight: 400; color: var(--muted); font-size: 13px; margin-top: 2px; }
input[type=text], input[type=password], input[type=email], input[type=number], input:not([type]), select, textarea {
  width: 100%; margin-top: 5px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.check { display: flex; gap: 8px; align-items: center; margin: 8px 0; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 11px; font-size: 13px; cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip.off { opacity: .55; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }

.store { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; color: #fff; white-space: nowrap; }
.deal { display: inline-block; background: var(--deal-soft); color: var(--deal); font-weight: 700; font-size: 12px; padding: 2px 8px; border-radius: 6px; }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 5px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.price { font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }
.was { text-decoration: line-through; color: var(--muted); font-size: 13px; margin-left: 4px; }
.unit { color: var(--muted); font-size: 12px; }

.item { cursor: pointer; display: flex; flex-direction: column; gap: 8px; }
.item:hover { border-color: var(--accent); }
.item .best { display: flex; gap: 10px; align-items: center; }
.item .best img { width: 52px; height: 52px; object-fit: contain; border-radius: 8px; background: #fff; flex: none; }
.item ul { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.item li { display: flex; gap: 6px; align-items: baseline; padding: 3px 0; border-top: 1px dashed var(--line); }
.item li .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.plist { display: flex; flex-direction: column; gap: 8px; }
.prod { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.prod img { width: 56px; height: 56px; object-fit: contain; border-radius: 8px; background: #fff; }
.prod .noimg { width: 56px; height: 56px; border-radius: 8px; background: var(--bg); }
.prod .nm { font-weight: 600; overflow-wrap: anywhere; }
.prod .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 3px; }
.prod .right { text-align: right; }
.prod.excluded { opacity: .5; }
.prod .acts { display: flex; gap: 4px; justify-content: flex-end; margin-top: 4px; }
.iconbtn { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 2px 8px; cursor: pointer; font-size: 13px; }
.iconbtn.sel { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.iconbtn.selx { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.spark { width: 100%; height: 60px; margin-top: 6px; }
.spark path.l { fill: none; stroke: var(--accent); stroke-width: 2; }
.spark path.e { fill: none; stroke: var(--deal); stroke-width: 1.5; stroke-dasharray: 3 3; }

table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.scroll { overflow-x: auto; }

.auth { max-width: 380px; margin: 8vh auto 0; }
.auth .logo { display: flex; justify-content: center; margin-bottom: 10px; }
.auth h1 { text-align: center; }
.codes { font-family: ui-monospace, Consolas, monospace; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--bg); padding: 12px; border-radius: 10px; }
.qr { display: flex; justify-content: center; background: #fff; border-radius: 12px; padding: 8px; }
.qr img { width: 220px; height: 220px; }
.secret { font-family: ui-monospace, Consolas, monospace; word-break: break-all; font-size: 13px; background: var(--bg); padding: 8px; border-radius: 8px; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; margin: 6px 0; }
.notice { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.notice.warn { background: var(--deal-soft); }
.copy { display: flex; gap: 6px; }
.copy input { margin: 0; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.ev { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ev .k { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); width: 70px; flex: none; padding-top: 2px; }
details > summary { cursor: pointer; font-weight: 600; margin: 10px 0; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; }

.onlist { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); }
.hint { font-size: 13px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 6px; }
.hint b { color: var(--ink); }
.save { display: inline-block; font-size: 12px; font-weight: 700; color: var(--accent); }
.lrow { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.lrow:last-child { border-bottom: 0; }
.lrow .what { font-weight: 700; min-width: 0; flex: 1; }
.lrow .m { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-weight: 400; font-size: 13px; margin-top: 4px; }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.scanbox { width: 100%; max-width: 440px; }
.scanwrap { position: relative; border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
.scanwrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanline { position: absolute; left: 10%; right: 10%; top: 50%; height: 2px; background: #ff3b30; box-shadow: 0 0 8px #ff3b30; }
.scanbox form input { flex: 1; margin: 0; }
