:root {
  --bg: #f5f6f4; --card: #fff; --text: #1b1f1c; --muted: #66706a; --line: #dfe3df;
  --brand: #1f6f43; --brand-ink: #fff; --warn: #a15c00; --warn-bg: #fff4e0; --bad: #b3261e; --bad-bg: #fdecea;
  --ok: #1f6f43; --ok-bg: #e6f4ea; --chip: #eef1ee;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121513; --card: #1c201d; --text: #e8ece9; --muted: #9aa49e; --line: #2d332f;
    --brand: #3fa86f; --brand-ink: #08130c; --warn: #f0b35a; --warn-bg: #2e2412; --bad: #ff8a80; --bad-bg: #3a1a18;
    --ok: #7dd3a0; --ok-bg: #15301f; --chip: #262b27;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, Roboto, sans-serif; }
body { padding-bottom: env(safe-area-inset-bottom); }
header#top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--brand); color: var(--brand-ink);
}
header h1 { flex: 1; font-size: 18px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
button { font: inherit; cursor: pointer; }
.icon { background: none; border: 0; color: inherit; font-size: 24px; min-width: 40px; min-height: 40px; }
.badge-host { position: relative; }
.badge { position: absolute; top: 2px; right: 0; background: var(--bad); color: #fff; border-radius: 10px; font-size: 12px; padding: 0 6px; }
.net { width: 10px; height: 10px; border-radius: 50%; background: #bbb; }
.net.on { background: #7dff9f; } .net.off { background: #ff6b6b; }
main { padding: 12px; max-width: 900px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; overflow-x: auto; }
.tabs button { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 18px; padding: 6px 14px; white-space: nowrap; }
.tabs button.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
input, select, textarea {
  font: inherit; width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--text);
}
textarea { min-height: 70px; }
input[type=checkbox], input[type=radio] { width: auto; flex: none; }
label { display: block; margin: 8px 0 4px; font-size: 14px; color: var(--muted); }
.btn { display: inline-block; border: 0; border-radius: 10px; padding: 12px 16px; background: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.wide { width: 100%; }
.btn.ghost { background: var(--chip); color: var(--text); }
.btn.danger { background: var(--bad); color: #fff; }
.btn:disabled { opacity: .5; }
.list .item { display: flex; gap: 10px; align-items: center; padding: 12px; border-bottom: 1px solid var(--line); background: var(--card); }
.list .item:first-child { border-radius: 12px 12px 0 0; } .list .item:last-child { border-radius: 0 0 12px 12px; border-bottom: 0; }
.list { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; }
.item .name { font-weight: 600; }
.tag { display: inline-block; font-size: 12px; border-radius: 6px; padding: 1px 6px; background: var(--chip); color: var(--muted); margin-right: 4px; }
.tag.bad { background: var(--bad-bg); color: var(--bad); } .tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.plate { border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; font-weight: 600; }
.plate.bad { background: var(--bad-bg); color: var(--bad); } .plate.warn { background: var(--warn-bg); color: var(--warn); }
.plate.ok { background: var(--ok-bg); color: var(--ok); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
.kv b { text-align: right; }
.prod { padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--card); }
.prod .top { display: flex; gap: 8px; }
.prod .meta { font-size: 13px; color: var(--muted); }
.prod.in { background: var(--ok-bg); }
.qty { display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.qty button { width: 44px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--chip); color: var(--text); font-size: 20px; }
.qty input { width: 80px; text-align: center; }
.cartbar {
  position: sticky; bottom: 0; display: flex; gap: 10px; align-items: center; padding: 10px 12px;
  background: var(--card); border-top: 1px solid var(--line); margin: 0 -12px -12px;
}
/* сверху, под шапкой: внизу сообщение закрывало «Очистить»/«Отправить» */
#toast {
  position: fixed; left: 50%; top: 64px; transform: translateX(-50%); background: #222; color: #fff;
  padding: 10px 16px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; z-index: 20;
}
#toast.show { opacity: .95; }
.small-btn, .qty button.small-btn { width: auto; height: auto; min-height: 40px; padding: 6px 10px; font-size: 14px; font-weight: 500; }
.list .item { flex-wrap: wrap; }
.list .item > .grow { flex-basis: 60%; }
.tabs button { flex: 0 0 auto; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.section { font-weight: 700; margin: 14px 0 6px; }
@media (min-width: 700px) { .kv { grid-template-columns: 200px 1fr; } }

/* помощь: «? Помощь» в шапке (раздел роли) и «?» у заголовка экрана (ролик про экран) */
.ttl { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.ttl h1 { flex: 0 1 auto; min-width: 0; }
.help-btn { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px 0 6px; border-radius: 17px;
  background: rgba(255, 255, 255, .18); color: inherit; font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.help-btn::before { content: "?"; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px;
  border-radius: 50%; background: var(--brand-ink); color: var(--brand); font-weight: 800; font-size: 14px; }
.help-q { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid currentColor; color: inherit; font-weight: 700; font-size: 15px; text-decoration: none; opacity: .9; }
.help-q[hidden], .help-btn[hidden] { display: none; }
.help-item { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
.help-item:first-of-type { margin-top: 8px; }
.help-h { font-size: 18px; margin: 4px 0 10px; }
.help-video { width: 100%; max-height: 70vh; border-radius: 10px; background: #000; }
.help-steps { padding-left: 22px; margin: 10px 0; } .help-steps li { margin: 4px 0; }
