:root {
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-2: #eef2f0;
  --text: #15201b;
  --muted: #5f6f67;
  --line: #dde4e0;
  --brand: #0b6b3a;
  --brand-2: #12924f;
  --accent: #f5b301;
  --danger: #c0392b;
  --ok: #138a4a;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(10, 40, 25, .08);
  --tabs-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412;
    --surface: #18201c;
    --surface-2: #202a25;
    --text: #e8efeb;
    --muted: #9db0a6;
    --line: #2b3832;
    --brand: #22a862;
    --brand-2: #2fc275;
    --shadow: 0 6px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh; overscroll-behavior-y: contain;
}
#app { max-width: 560px; margin: 0 auto; padding: calc(12px + var(--safe-t)) 16px calc(var(--tabs-h) + 24px + var(--safe-b)); }
h1 { font-size: 26px; margin: 8px 0 16px; letter-spacing: -.3px; }
h2 { font-size: 19px; margin: 22px 0 10px; }
h3 { font-size: 16px; margin: 0 0 6px; }
p { margin: 0 0 10px; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }

.card {
  background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.list .item { display: flex; gap: 12px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line); }
.list .item:last-child { border-bottom: 0; }
.item .ic { width: 38px; height: 38px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; flex: none; font-size: 18px; }
button.item { width: 100%; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.chev::after { content: "›"; color: var(--muted); font-size: 22px; margin-left: auto; }

/* формы */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1.5px solid var(--line);
  border-radius: 12px; padding: 12px 14px; outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
textarea { min-height: 110px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; font-size: 14px; }
.check input { width: 20px; height: 20px; flex: none; margin-top: 1px; accent-color: var(--brand); }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; margin-bottom: 14px; }
.seg button { flex: 1; border: 0; background: none; color: var(--muted); font: inherit; font-size: 14px; padding: 8px 6px; border-radius: 10px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.08); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  border: 0; border-radius: 14px; padding: 14px 18px; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--brand); color: #fff; transition: transform .05s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.ghost { background: none; color: var(--brand); padding: 10px; }
.btn.danger { background: none; color: var(--danger); }
.btn.small { width: auto; padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btns { display: grid; gap: 10px; margin-top: 8px; }
.btns.two { grid-template-columns: 1fr 1fr; }

/* вход */
.hero { text-align: center; padding: 34px 6px 10px; }
.logo { width: 76px; height: 76px; margin: 0 auto 16px; border-radius: 22px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); display: grid; place-items: center; box-shadow: var(--shadow); }
.logo svg { width: 42px; height: 42px; fill: none; stroke: #fff; stroke-width: 2; }
.code-input { letter-spacing: 14px; text-align: center; font-size: 28px; font-weight: 700; }
.demo-hint { background: #fff6d6; color: #6b5200; border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
@media (prefers-color-scheme: dark) { .demo-hint { background: #3a3110; color: #f5dc8a; } }

/* бонусная карта */
.bcard {
  position: relative; border-radius: 22px; padding: 18px 18px 16px; color: #fff; overflow: hidden;
  background: radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--brand) 65%, #fff) 0%, var(--brand) 55%, color-mix(in srgb, var(--brand) 60%, #000) 100%);
  box-shadow: 0 14px 34px color-mix(in srgb, var(--brand) 35%, transparent); margin-bottom: 14px;
}
.bcard::after { content: ""; position: absolute; right: -40px; bottom: -60px; width: 200px; height: 200px; border-radius: 50%; background: rgba(255,255,255,.07); }
.bcard .brand { font-weight: 700; letter-spacing: .3px; opacity: .95; }
.bcard .label { font-size: 13px; opacity: .8; }
.bcard .points { font-size: 44px; font-weight: 800; line-height: 1.05; margin: 8px 0 2px; letter-spacing: -1px; }
.bcard .points small { font-size: 18px; font-weight: 600; opacity: .85; margin-left: 4px; }
.bcard .extra { font-size: 14px; opacity: .9; }
.barcode-box { background: #fff; border-radius: 14px; padding: 12px 12px 8px; margin-top: 14px; color: #111; cursor: pointer; position: relative; z-index: 1; }
.barcode-box svg { width: 100%; height: 72px; display: block; }
.barcode-box .num { text-align: center; font: 600 16px/1.6 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 2px; }
.card-pick { display: flex; gap: 8px; overflow-x: auto; margin: -4px 0 12px; }
.card-pick button { flex: none; }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--surface); border-radius: 14px; padding: 12px; box-shadow: var(--shadow); }
.kpi b { display: block; font-size: 18px; }
.kpi span { font-size: 12px; color: var(--muted); }

/* полноэкранный штрихкод */
.overlay { position: fixed; inset: 0; background: #fff; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; color: #111; }
.overlay svg { width: 100%; max-width: 640px; height: 32vh; }
.overlay .num { font: 700 24px ui-monospace, Menlo, Consolas, monospace; letter-spacing: 3px; margin-top: 14px; }
.overlay .hint { color: #555; margin-top: 18px; font-size: 14px; }

/* история */
.month { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 18px 4px 8px; }
.tx { display: flex; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.tx:last-child { border-bottom: 0; }
.tx .ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); flex: none; font-size: 18px; }
.tx .sum { text-align: right; white-space: nowrap; }
.plus { color: var(--ok); font-weight: 600; }
.minus { color: var(--danger); font-weight: 600; }
.tx-items { font-size: 14px; color: var(--muted); margin-top: 6px; }
.tx-items div { display: flex; justify-content: space-between; gap: 8px; }

.chart { width: 100%; height: 170px; }
.chart text { fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* АЗС */
#map { height: 52vh; min-height: 320px; border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; background: var(--surface-2); }
.st { padding: 14px 0; border-bottom: 1px solid var(--line); }
.st:last-child { border-bottom: 0; }
.prices { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.price { background: var(--surface-2); border-radius: 9px; padding: 4px 8px; font-size: 13px; }
.price b { margin-left: 4px; }
.star { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); padding: 2px 6px; }
.star.on { color: var(--accent); }
.dist { font-size: 13px; color: var(--brand); font-weight: 600; white-space: nowrap; }

/* новости */
.news h3 { margin-bottom: 4px; }
.news .date { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 20px; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: rgba(19,138,74,.12); color: var(--ok); }

/* вкладки */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.tabs[hidden] { display: none; }
.tabs button { flex: 1; max-width: 140px; height: var(--tabs-h); border: 0; background: none; color: var(--muted); font: inherit; font-size: 11px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer; }
.tabs svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button.on { color: var(--brand); }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 20px + var(--safe-b)); transform: translate(-50%, 20px); background: #1f2a24; color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 60; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.back { background: none; border: 0; color: var(--brand); font: inherit; font-size: 16px; padding: 6px 0; cursor: pointer; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.offline { background: #fff1e0; color: #7a4a00; border-radius: 12px; padding: 8px 12px; font-size: 13px; margin-bottom: 10px; }
@media (prefers-color-scheme: dark) { .offline { background: #3b2a12; color: #f3c98a; } }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.calc-out { font-size: 30px; font-weight: 800; text-align: center; margin: 6px 0 2px; }
