:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --ink: #111113;
  --ink-2: #3a3a3f;
  --muted: #6a6a70;
  --line: #e6e6e3;
  --line-2: #d6d6d2;
  --accent: #c0122c;
  --accent-ink: #ffffff;
  --accent-soft: #fbeef0;
  --ok: #147a3d;
  --ok-soft: #e9f6ee;
  --warn: #9a5b00;
  --warn-soft: #fdf3e2;
  --info: #1f4fb8;
  --info-soft: #ecf1fd;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(17,17,19,.04), 0 8px 24px -12px rgba(17,17,19,.12);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: clamp(28px, 4vw, 44px); font-weight: 700; }
h2 { font-size: 22px; font-weight: 650; }
h3 { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
.i { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 0.92em; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.92); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1180px; margin: 0 auto; padding: 0 20px; height: 64px; display: flex; align-items: center; gap: 24px; }
.topbar-in.wide, .main.wide { max-width: 1360px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: none; }
.brand img { height: 40px; width: auto; display: block; mix-blend-mode: multiply; }
.brand-tag { font-size: 12px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.nav { display: flex; gap: 2px; align-items: center; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 9px; text-decoration: none; color: var(--ink-2); font-weight: 500; font-size: 14px; white-space: nowrap; }
.nav a:hover { background: #f1f1ee; color: var(--ink); }
.nav a.active { background: var(--ink); color: #fff; }
.nav a .i { width: 16px; height: 16px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }
.usermenu { display: flex; align-items: center; gap: 4px; }
.usermenu-who { display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 4px 8px 4px 4px; border-radius: 10px; }
.usermenu-who:hover { background: #f1f1ee; }
.usermenu-text { display: flex; flex-direction: column; line-height: 1.2; }
.usermenu-text b { font-size: 13px; font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu-text small { font-size: 12px; color: var(--muted); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; }

.main { max-width: 1180px; margin: 0 auto; padding: 28px 20px 64px; }
.footer { border-top: 1px solid var(--line); background: var(--surface); }
.footer-in { max-width: 1180px; margin: 0 auto; padding: 22px 20px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 11px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer; background: var(--ink); color: #fff; transition: background .15s, border-color .15s, transform .05s; white-space: nowrap; }
.btn:hover { background: #2a2a2e; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .nav a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-accent { background: var(--accent); }
.btn-accent:hover { background: #a30f25; }
.btn-outline { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn-outline:hover { background: #f4f4f1; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: #f1f1ee; color: var(--ink); }
.btn-danger { background: var(--surface); color: var(--accent); border-color: #efc3ca; }
.btn-danger:hover { background: var(--accent-soft); }
.btn-ok { background: var(--ok); }
.btn-ok:hover { background: #0f6531; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn-lg { min-height: 52px; padding: 0 24px; font-size: 15px; border-radius: 13px; }
.btn-icon { min-height: 40px; width: 40px; padding: 0; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 28px; }
.page-head p { color: var(--muted); margin-top: 6px; }
.crumbs { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); text-decoration: none; margin-bottom: 10px; }
.crumbs:hover { color: var(--ink); }
.crumbs .i { width: 15px; height: 15px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.sticky { position: sticky; top: 84px; }

.stat { display: flex; flex-direction: column; gap: 6px; }
.stat small { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat b { font-size: 30px; letter-spacing: -0.03em; font-weight: 700; }
.stat a { font-size: 13px; color: var(--muted); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field small { color: var(--muted); font-size: 12px; }
.req::after { content: " *"; color: var(--accent); }
input[type=text], input[type=tel], input[type=date], input[type=number], input[type=search], input[type=url], input[type=email], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit; font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 90px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #bdbdb8; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(17,17,19,.08); outline: none; }
input[readonly] { background: #f6f6f4; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.fieldset { border: 0; padding: 0; margin: 0; }
.fieldset legend { float: left; width: 100%; font-weight: 650; font-size: 15px; margin-bottom: 12px; padding: 0; }
.fieldset legend + * { clear: both; }
.section + .section { border-top: 1px solid var(--line); padding-top: 22px; margin-top: 22px; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); cursor: pointer; background: var(--surface); }
.check:hover { border-color: #bdbdb8; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--ink); flex: none; }
.check b { font-weight: 600; font-size: 14px; display: block; }
.check small { color: var(--muted); font-size: 13px; }
.check:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: #efefec; border-radius: 12px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; border-radius: 9px; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--ink-2); }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.error-text { color: var(--accent); font-size: 13px; font-weight: 500; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fbfbfa; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafaf8; }
.table a.rowlink { text-decoration: none; font-weight: 600; }
.table a.rowlink:hover { text-decoration: underline; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.toolbar .search { position: relative; flex: 1; min-width: 220px; }
.toolbar .search .i { position: absolute; left: 12px; top: 13px; color: var(--muted); }
.toolbar .search input { padding-left: 38px; }
.toolbar select { width: auto; min-width: 160px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #efefec; color: var(--ink-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-issued, .badge-paid, .badge-superadmin { background: var(--ok-soft); color: var(--ok); }
.badge-revoked, .badge-cancelled { background: var(--accent-soft); color: var(--accent); }
.badge-awaiting_payment { background: #efefec; color: var(--muted); }
.badge-payment_claimed, .badge-admin { background: var(--warn-soft); color: var(--warn); }
.badge-operator { background: var(--info-soft); color: var(--info); }

.flash { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: 12px; margin-bottom: 20px; font-weight: 500; background: var(--ok-soft); color: var(--ok); border: 1px solid #cfe9d9; }
.flash-error { background: var(--accent-soft); color: var(--accent); border-color: #f3cdd3; }
.flash-info { background: var(--info-soft); color: var(--info); border-color: #d3def8; }

/* ---------- landing ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 40px; align-items: center; padding: 28px 0 44px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 5px 12px; margin-bottom: 18px; }
.eyebrow .i { width: 15px; height: 15px; }
.hero p.lead { font-size: 18px; color: var(--ink-2); margin: 18px 0 28px; max-width: 560px; }
.hero-visual { position: relative; }
.paper-svg { display: block; width: 100%; height: auto; aspect-ratio: 595 / 842; background: #fff; border-radius: 6px; box-shadow: 0 30px 60px -30px rgba(0,0,0,.35), 0 0 0 1px rgba(0,0,0,.06); }
.hero-visual .paper-svg { width: 78%; margin-left: auto; transform: rotate(2deg); }
.qr-badge { position: absolute; left: 0; bottom: 12%; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 14px 16px; display: flex; gap: 12px; align-items: center; border: 1px solid var(--line); max-width: 280px; }
.qr-badge .ok-dot { width: 40px; height: 40px; border-radius: 12px; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; flex: none; }
.qr-badge b { display: block; font-size: 14px; }
.qr-badge small { color: var(--muted); font-size: 12px; }

.section-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 56px 0 20px; }
.section-title p { color: var(--muted); max-width: 520px; margin-top: 6px; }
.feature { display: flex; flex-direction: column; gap: 10px; }
.feature .ic { width: 44px; height: 44px; border-radius: 12px; background: #f1f1ee; display: grid; place-items: center; }
.feature p { color: var(--muted); font-size: 14px; }
.steps { counter-reset: s; }
.step { position: relative; padding-top: 44px; }
.step::before { counter-increment: s; content: counter(s); position: absolute; top: 0; left: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.step p { color: var(--muted); font-size: 14px; margin-top: 6px; }
.verify-band { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 28px; align-items: center; background: var(--ink); color: #fff; border-radius: 20px; padding: 32px; margin-top: 56px; }
.verify-band p { color: #c9c9cc; margin-top: 8px; }
.verify-band input { background: #1d1d20; border-color: #3a3a3f; color: #fff; }
.verify-band input::placeholder { color: #8b8b90; }
.verify-band .btn { background: #fff; color: var(--ink); }
.verify-band .btn:hover { background: #e9e9e6; }
.verify-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; }
.contact-list { display: flex; flex-direction: column; gap: 14px; }
.contact-list div { display: flex; gap: 12px; align-items: flex-start; }
.contact-list .i { margin-top: 2px; color: var(--muted); }

/* ---------- verify page ---------- */
.verdict { display: flex; gap: 16px; align-items: center; padding: 20px 22px; border-radius: var(--radius); margin-bottom: 20px; }
.verdict .vicon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.verdict .vicon .i { width: 28px; height: 28px; }
.verdict h1 { font-size: 22px; }
.verdict p { margin-top: 4px; }
.verdict-ok { background: var(--ok-soft); border: 1px solid #cfe9d9; }
.verdict-ok .vicon { background: var(--ok); color: #fff; }
.verdict-bad { background: var(--accent-soft); border: 1px solid #f3cdd3; }
.verdict-bad .vicon { background: var(--accent); color: #fff; }
.verdict-warn { background: var(--warn-soft); border: 1px solid #f2dfbd; }
.verdict-warn .vicon { background: var(--warn); color: #fff; }
.dl { display: grid; grid-template-columns: minmax(140px, 220px) minmax(0, 1fr); gap: 0; font-size: 14px; }
.dl dt { color: var(--muted); padding: 10px 0; border-bottom: 1px solid var(--line); }
.dl dd { margin: 0; padding: 10px 0; border-bottom: 1px solid var(--line); font-weight: 600; overflow-wrap: anywhere; }
.dl dt:last-of-type, .dl dd:last-of-type { border-bottom: 0; }
.cert-paper { width: 100%; max-width: 640px; margin: 0 auto; }
.watermark-note { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; margin-top: 12px; justify-content: center; }

/* ---------- auth ---------- */
.auth-wrap { min-height: calc(100vh - 64px - 120px); display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { font-size: 26px; }
.auth-card .card { padding: 28px; }
.otp-input { letter-spacing: .5em; text-align: center; font-size: 22px !important; font-weight: 600; font-family: var(--mono); }
.tg-box { display: flex; flex-direction: column; gap: 14px; align-items: stretch; text-align: center; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line-2); border-top-color: var(--ink); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
[hidden] { display: none !important; }

/* ---------- order / payment ---------- */
.price-box { display: flex; flex-direction: column; gap: 10px; }
.price-line { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--ink-2); }
.price-line span:last-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
.price-total { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 4px; }
.price-total b { font-size: 28px; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.kaspi { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; align-items: center; }
.kaspi-qr { width: 220px; aspect-ratio: 1; border-radius: 16px; border: 1px solid var(--line); background: #fff; display: grid; place-items: center; overflow: hidden; padding: 10px; }
.kaspi-qr img { width: 100%; height: 100%; object-fit: contain; }
.kaspi-amount { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; }
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl { display: flex; gap: 12px; position: relative; padding-bottom: 18px; }
.tl:last-child { padding-bottom: 0; }
.tl::before { content: ""; position: absolute; left: 11px; top: 24px; bottom: 0; width: 2px; background: var(--line); }
.tl:last-child::before { display: none; }
.tl .dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line-2); background: #fff; flex: none; display: grid; place-items: center; }
.tl.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.tl.now .dot { border-color: var(--ink); box-shadow: inset 0 0 0 4px #fff, inset 0 0 0 12px var(--ink); }
.tl .dot .i { width: 14px; height: 14px; }
.tl b { font-size: 14px; display: block; }
.tl small { color: var(--muted); font-size: 13px; }

.cert-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.cert-card { display: flex; flex-direction: column; gap: 14px; }
.cert-card .num { font-family: var(--mono); font-weight: 600; font-size: 15px; }
.cert-card .meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; }
.cert-card .meta span:nth-child(odd) { color: var(--muted); }
.qr-mini { width: 96px; height: 96px; }
.qr-mini svg { width: 100%; height: 100%; }
.kv-inline { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.kv-inline b { color: var(--ink); font-weight: 600; }
.list-edit { display: grid; gap: 8px; }
.list-edit .le-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) 120px 40px; gap: 8px; align-items: center; }
.list-edit .le-head { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.formula { font-family: var(--mono); font-size: 13px; background: #f4f4f1; border-radius: 10px; padding: 12px 14px; color: var(--ink-2); line-height: 1.7; }

@media (max-width: 960px) {
  .hero, .verify-band, .split { grid-template-columns: 1fr; }
  .hero-visual { max-width: 420px; margin: 0 auto; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sticky { position: static; }
}
@media (max-width: 680px) {
  body { font-size: 15px; }
  .topbar-in { gap: 12px; padding: 0 16px; height: auto; min-height: 60px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
  .nav { order: 3; flex-basis: 100%; }
  .usermenu-text { display: none; }
  .main { padding: 20px 16px 48px; }
  .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: 1fr; }
  .verify-form { grid-template-columns: 1fr; }
  .kaspi { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .dl { grid-template-columns: 1fr; }
  .dl dt { border-bottom: 0; padding-bottom: 0; }
  .card { padding: 18px; }
  .list-edit .le-row { grid-template-columns: 1fr 1fr; }
  .list-edit .le-head { display: none; }
  .qr-badge { position: static; margin-top: 16px; }
}
@media print {
  .topbar, .footer, .no-print { display: none !important; }
  body { background: #fff; }
}
.kaspi-qr svg { width: 100%; height: 100%; display: block; }
.badge-refunded { background: var(--accent-soft); color: var(--accent); }

/* ---------- автоопределение в заявке ---------- */
.auto-chip { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 10px; background: var(--ok-soft); color: var(--ok); font-size: 13px; }
.auto-chip > span { display: flex; align-items: center; gap: 8px; }
.auto-chip .how { color: #3f6f52; }
.auto-chip button { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--ok); text-decoration: underline; cursor: pointer; }
.warn-chip { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 13px; }
.hint-line { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--muted); }
.hint-line .i { width: 16px; height: 16px; margin-top: 2px; }
.mono-input { font-family: var(--mono); letter-spacing: .02em; }
.ref-card { border-color: #f3cdd3; }
.switch { width: 44px; height: 26px; border-radius: 999px; background: #d6d6d2; position: relative; display: inline-block; transition: background .15s; }
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: left .15s; }
.switch-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-input:checked + .switch { background: var(--ok); }
.switch-input:checked + .switch::after { left: 21px; }
.switch-input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.faq details { border-bottom: 1px solid var(--line); padding: 18px 22px; }
.faq details:last-child { border-bottom: 0; }
.faq summary { cursor: pointer; font-weight: 650; font-size: 16px; }
.faq details p { margin-top: 10px; font-size: 15px; max-width: 820px; color: var(--muted); }
.ref-band { margin-top: 56px; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 28px; align-items: center; padding: 32px; border-color: #f3cdd3; }
.pos-frame { border: 1px solid var(--line-2); border-radius: 14px; overflow: hidden; background: #fff; }
.pos-frame-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: #fafaf8; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.pos-frame iframe { width: 100%; min-height: 440px; border: 0; display: block; }
@media (max-width: 960px) { .ref-band { grid-template-columns: 1fr; } }

/* ---------- Чат поддержки ---------- */
.nav-badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.nav-badge[hidden] { display: none; }
.chat { display: flex; flex-direction: column; min-height: 420px; }
.chat-feed { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 18px; max-height: 62vh; overflow-y: auto; background: #fafaf8; }
.chat-msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 78%; }
.chat-msg.mine { align-self: flex-end; align-items: flex-end; }
.chat-bubble { padding: 10px 14px; border-radius: 14px 14px 14px 4px; background: var(--surface); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.45; }
.chat-msg.mine .chat-bubble { background: var(--ink); color: #fff; border-color: var(--ink); border-radius: 14px 14px 4px 14px; }
.chat-meta { font-size: 12px; color: var(--muted); margin-top: 4px; padding: 0 4px; }
.chat-sys { align-self: center; font-size: 13px; color: var(--muted); background: #f1f1ee; border-radius: 999px; padding: 6px 12px; text-align: center; max-width: 90%; }
.chat-note { padding: 10px 18px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); background: var(--ok-soft); }
.chat-form { display: flex; gap: 10px; align-items: flex-end; padding: 14px; border-top: 1px solid var(--line); }
.chat-form textarea { min-height: 48px; max-height: 200px; }
.chat-err { padding: 0 14px 12px; color: var(--accent); font-size: 13px; }
.chat-list { display: flex; flex-direction: column; }
.chat-row { display: flex; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.chat-row:last-child { border-bottom: 0; }
.chat-row:hover { background: #fafaf8; }
.chat-row-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.chat-row-main .muted { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 12px; white-space: nowrap; }
.chat-unread { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; vertical-align: middle; }
.row-attn td { background: var(--accent-soft); }
@media (max-width: 640px) {
  .chat-msg { max-width: 92%; }
  .chat-feed { max-height: 58vh; padding: 12px; }
  .chat-form .hide-sm { display: none; }
}

/* ---------- Калькуляция: таблицы цен ---------- */
.price-table td { vertical-align: top; }
.price-table input { min-height: 40px; }
.price-table .pr-val { width: 150px; }
.price-table .pr-desc { font-size: 13px; color: var(--ink-2); min-width: 220px; }
.price-table .pr-act { width: 48px; text-align: right; }
@media (max-width: 680px) {
  .price-table thead { display: none; }
  .price-table, .price-table tbody, .price-table tr, .price-table td { display: block; width: 100%; }
  .price-table tr { position: relative; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .price-table td { border: 0; padding: 4px 0; }
  .price-table td[data-th]::before { content: attr(data-th); display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
  .price-table .pr-val, .price-table .pr-desc { width: 100%; min-width: 0; }
  .price-table .pr-act { position: absolute; top: 8px; right: 0; width: auto; }
  .price-table .pr-row:has([data-row-remove]) td:first-child { padding-right: 48px; }
}

/* ---------- Реферальная программа: баннер над первым экраном, карточка в кабинете ---------- */
.ref-top { display: flex; align-items: center; gap: 14px; margin: 4px 0 18px; padding: 14px 16px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid #f3cdd3; text-decoration: none; color: var(--ink); }
.ref-top:hover { border-color: var(--accent); }
.ref-top-ic { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 12px; background: var(--accent); color: #fff; }
.ref-top-ic .i { width: 22px; height: 22px; }
.ref-top-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ref-top-txt b { font-size: 16px; }
.ref-top-txt small { font-size: 13px; color: var(--ink-2); }
.ref-top-btn { flex: none; }
.ref-link-row { display: flex; gap: 10px; align-items: stretch; }
.ref-link-row input { flex: 1; min-width: 0; }
.ref-share { display: flex; gap: 10px; flex-wrap: wrap; }
.ref-stats { gap: 10px; }
.ref-stats .stat { padding: 14px; }
.ref-stats .stat b { font-size: 24px; }
.ref-stats .stat-ok { background: var(--ok-soft); border-color: #cfe9d9; }
.ref-stats .stat-ok small, .ref-stats .stat-ok b { color: var(--ok); }
@media (max-width: 680px) {
  .ref-top { flex-wrap: wrap; padding: 12px 14px; }
  .ref-top-btn { width: 100%; }
  .ref-link-row { flex-direction: column; }
  .ref-link-row .btn, .ref-share .btn { width: 100%; }
  .ref-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ref-stats .stat { padding: 10px; }
  .ref-stats .stat b { font-size: 18px; }
  .ref-stats .stat small { font-size: 11px; }
}

/* ---------- Мобильная вёрстка: общие страховки ---------- */
.split-400 { grid-template-columns: minmax(0, 1fr) 400px; }
@media (max-width: 960px) { .split-400 { grid-template-columns: 1fr; } }
@media (max-width: 680px) {
  /* Поля с заданной шириной не вылезают за экран; формы в строках переносятся. */
  main input, main select, main textarea, main form, main .search { max-width: 100%; }
  main .row > input, main .row > select, main .toolbar > input, main .toolbar > select { flex: 1 1 140px; }
  .page-head { align-items: flex-start; }
  .page-head .row { width: 100%; }
  .page-head .row .btn { flex: 1 1 auto; }
  .card { padding: 16px; }
  .card-flush { padding: 0; }
}

/* Таблицы на телефоне: строка = карточка, у ячейки подпись колонки (data-th проставляет app.js). */
@media (max-width: 680px) {
  .table.cardify thead { display: none; }
  .table.cardify, .table.cardify tbody, .table.cardify tr, .table.cardify td { display: block; width: 100%; }
  .table.cardify tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .table.cardify tr:last-child { border-bottom: 0; }
  .table.cardify td { border: 0; padding: 3px 0; text-align: left !important; white-space: normal; max-width: none !important; }
  .table.cardify td[data-th]:not([data-th=""])::before { content: attr(data-th); display: block; font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
  .table.cardify td:empty { display: none; }
  .table.cardify tbody tr:hover td { background: transparent; }
  .table-wrap:has(.table.cardify) { overflow: visible; }
}

/* Меню на телефоне: листается вбок, у края затухание — видно, что пункты продолжаются (nav-fade). */
@media (max-width: 680px) {
  .nav { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); padding-right: 24px; }
  .nav.at-end { -webkit-mask-image: none; mask-image: none; }
  .nav a { padding: 8px 10px; font-size: 13px; }
}

/* Колонки сеток не растягиваются длинным содержимым (превью сообщений, ссылки) — иначе страница шире экрана. */
.split > *, .grid-2 > *, .grid-3 > *, .grid-4 > *, .hero > * { min-width: 0; }
@media (max-width: 680px) {
  .hero .row .btn { flex: 1 1 100%; }
}
@media (max-width: 680px) {
  .table.cardify tr.row-attn { background: var(--accent-soft); }
  .table.cardify tr.row-attn td { background: transparent; }
}

/* ---------- Сканер QR на странице проверки ---------- */
.verify-band .qr-scan-btn { background: var(--accent); color: #fff; }
.verify-band .qr-scan-btn:hover { background: #a30f25; }
.qr-modal { position: fixed; inset: 0; z-index: 100; background: rgba(10,10,12,.72); display: flex; align-items: center; justify-content: center; padding: 16px; }
.qr-modal[hidden] { display: none; }
body.qr-open { overflow: hidden; }
.qr-sheet { width: 100%; max-width: 440px; background: var(--surface); border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.qr-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.qr-view { position: relative; aspect-ratio: 1 / 1; border-radius: 14px; overflow: hidden; background: #111; }
.qr-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.qr-frame { position: absolute; inset: 14%; border: 3px solid rgba(255,255,255,.9); border-radius: 16px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); pointer-events: none; }
.qr-msg { font-size: 14px; color: var(--muted); text-align: center; }
.qr-msg.bad { color: var(--accent); }
.qr-photo { cursor: pointer; }
@media (max-width: 680px) {
  .qr-modal { align-items: flex-end; padding: 0; }
  .qr-sheet { max-width: none; border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
  .verify-band .qr-scan-btn { width: 100%; }
}

/* ios-no-zoom: iPhone приближает страницу при фокусе на поле со шрифтом меньше 16px — страница «прыгает». */
@media (max-width: 680px) {
  input[type=text], input[type=tel], input[type=date], input[type=number], input[type=search], input[type=url], input[type=email], select, textarea { font-size: 16px; }
}
/* Ничего не вылезает за ширину экрана (повёрнутая картинка свидетельства и т. п.) — страницу нельзя сдвинуть вбок.
   clip, а не hidden: не создаёт контейнер прокрутки и не ломает липкую шапку. */
html, body { overflow-x: clip; }
@supports not (overflow-x: clip) { body { overflow-x: hidden; } }
@media (max-width: 680px) {
  .hero-visual .paper-svg { width: 92%; margin: 0 auto; transform: rotate(1deg); }
  .qr-badge { max-width: calc(100% - 8px); }
}

.ok-text { color: var(--ok) !important; font-weight: 600; }

.badge-foreign { background: #eef3fb; color: #2b4f86; border-color: #cfdcf0; }
