:root {
  --brand: #161514;
  --accent: #d7af25;
  --bg: #f3f4f6;
  --card: #fff;
  --text: #14171a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --err: #b42318;
  --ok: #067647;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 2px; }
.wrap { max-width: 480px; margin: 0 auto; padding: 16px 16px calc(28px + env(safe-area-inset-bottom)); }
.wrap.wide { max-width: 980px; }
.wrap.text { max-width: 720px; }
h1 { font-size: 24px; margin: 6px 0; line-height: 1.2; }
h2 { font-size: 18px; margin: 26px 0 10px; }
h2.flush { margin-top: 0; }
h3 { font-size: 16px; margin: 20px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 10px; }
.inline { display: inline; }

.hero { text-align: center; padding: 18px 0 6px; }
.logo-img { width: 72px; height: 72px; border-radius: 18px; display: block; margin: 0 auto 10px; }

/* обложка карты */
.cover {
  position: relative; overflow: hidden; border-radius: 18px; background: #161514;
  aspect-ratio: 984 / 627; box-shadow: 0 12px 30px rgba(0, 0, 0, .25);
}
.cover img { display: block; width: 100%; height: 100%; object-fit: cover; transform: scale(1.02); }
.cover.preview { max-width: 340px; margin: 0 auto 16px; border-radius: 14px; }
.cover-text { position: absolute; left: 6%; bottom: 10%; max-width: 50%; }
.cover-label {
  color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  font-size: clamp(10px, 2.6vw, 13px); margin-bottom: 4px;
}
.cover-name {
  color: #fff; font-weight: 800; line-height: 1.15; font-size: clamp(17px, 5.4vw, 26px);
  overflow-wrap: anywhere;
}

/* штрихкод */
.codes { background: var(--card); border-radius: var(--radius); padding: 20px 10px; margin-top: 16px; text-align: center; }
.bar.solo { margin: 4px auto 0; max-width: 520px; }
.bar.solo svg { width: 100%; height: 130px; display: block; }
.digits { font: 600 20px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 2px; margin-top: 8px; }
.digits.left { text-align: left; margin-top: 10px; }

.install { background: var(--card); border-radius: var(--radius); padding: 16px; margin-top: 16px; }
.install p { margin: 8px 0 0; }
.install .btn { margin-top: 12px; }
.foot { margin-top: 22px; }

/* формы и кнопки */
.form { display: grid; gap: 14px; background: var(--card); padding: 18px; border-radius: var(--radius); }
.stack { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
.opt { font-weight: 400; color: var(--muted); }
input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=hidden]) {
  font: inherit; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; width: 100%;
  color: var(--text);
}
input[type=color] { width: 100%; height: 46px; border: 1px solid var(--line); border-radius: 12px; padding: 4px; background: #fff; }
input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 15px; }
.check input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--brand); }
.btn {
  display: inline-block; font: inherit; font-weight: 700; border: 0; border-radius: 12px; padding: 13px 18px;
  background: var(--brand); color: #fff; cursor: pointer; text-decoration: none; text-align: center;
}
.btn.wide { width: 100%; }
.btn.danger { background: var(--err); }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 0; text-decoration: underline; text-decoration-color: var(--accent); }

.err { background: #fef3f2; color: var(--err); border-radius: 12px; padding: 12px 14px; margin: 12px 0; }
.ok { background: #ecfdf3; color: var(--ok); border-radius: 12px; padding: 12px 14px; margin: 12px 0; }
.form > .err, .form > .ok { margin: 0; }

/* вкладки на главной: «Новая карта» / «Уже есть карта» (без JavaScript) */
.tab-radio { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 8px 0 14px;
  background: #e4e6ea; border-radius: 14px;
}
.tabs label {
  display: block; text-align: center; padding: 11px 6px; border-radius: 11px; font-size: 15px; font-weight: 700;
  color: var(--muted); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
#tab-new:checked ~ .tabs label[for=tab-new],
#tab-have:checked ~ .tabs label[for=tab-have] { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
#tab-new:focus-visible ~ .tabs label[for=tab-new],
#tab-have:focus-visible ~ .tabs label[for=tab-have] { outline: 2px solid var(--accent); outline-offset: 1px; }
#tab-new:checked ~ .pane-have,
#tab-have:checked ~ .pane-new { display: none; }

/* касса и админка */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.panel { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.panel ul { margin: 8px 0; padding-left: 20px; }
.panel li { margin: 4px 0; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }
.big { font-size: 20px; font-weight: 700; }
.qr-img { display: block; margin: 14px auto 0; }
.flushp { margin: 0; }
input[type=file] { font: inherit; padding: 10px; border: 1px dashed var(--line); border-radius: 12px; background: #fafafa; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.stat { background: var(--card); border-radius: 14px; padding: 14px; display: grid; gap: 2px; }
.stat b { font-size: 28px; }
.tablewrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.grid2 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #111; color: #fff; padding: 11px 16px; border-radius: 12px; opacity: 0; transition: opacity .2s;
  pointer-events: none; max-width: 90vw; z-index: 10;
}
.toast.on { opacity: .94; }

/* плакат */
.poster { max-width: 760px; margin: 0 auto; padding: 36px 24px; text-align: center; }
.poster-cover { max-width: 560px; margin: 0 auto 22px; }
.poster h1 { font-size: 36px; }
.poster .lead { font-size: 20px; margin: 10px auto; max-width: 560px; }
.poster-qr svg { width: 300px; max-width: 80vw; height: auto; margin: 10px 0; }

@media (max-width: 640px) {
  .grid2 { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}
@media (display-mode: standalone) { .install { display: none; } }
@media print {
  body { background: #fff; }
  .noprint { display: none; }
  .cover { box-shadow: none; }
}
