:root {
  color-scheme: light dark;
  --bg: #f3f1ec;
  --surface: #faf9f6;
  --soft: #e9e6df;
  --ink: #26251f;
  --muted: #706d63;
  --line: #dcd8cc;
  --accent: #b5532a;
  --accent-hover: #9c4522;
  --on-accent: #fdfbf7;
  --ok: #3f7a55;
  --warn: #9a6b1e;
  --err: #a63d33;
  --code-bg: #2a2924;
  --code-ink: #e9e7dc;
  --code-mute: #8b887b;
  --code-key: #d9a27c;

  /* алиасы для старых inline-стилей */
  --bg-soft: var(--soft);
  --panel: var(--surface);
  --border: var(--line);
  --text: var(--ink);
  --green: var(--ok);
  --red: var(--err);
  --amber: var(--warn);
  --accent-2: var(--accent);

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --serif: "Iowan Old Style", "Charter", "Source Serif Pro", Georgia, "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1916;
    --surface: #211f1c;
    --soft: #2a2825;
    --ink: #e4e1d8;
    --muted: #9b978b;
    --line: #38362f;
    --accent: #d98a62;
    --accent-hover: #e6a07c;
    --on-accent: #1d1713;
    --ok: #7fb596;
    --warn: #cfa25e;
    --err: #d98279;
    --code-bg: #151412;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.6 var(--sans);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; transition: text-decoration-color .15s, color .15s; }
a:hover { color: var(--accent); text-decoration-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code, .mono { font-family: var(--mono); font-size: .88em; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px; }

/* ---------- шапка ---------- */
header.site { border-bottom: 1px solid var(--line); background: var(--bg); }
header.site .wrap { display: flex; align-items: center; gap: 20px; height: 58px; }
.logo {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-weight: 600; font-size: 15px; letter-spacing: -.01em;
  color: var(--ink); text-decoration: none;
}
.logo:hover { color: var(--ink); }
.logo .dot {
  width: 24px; height: 24px; flex: none; border-radius: 4px;
  background: var(--ink); color: var(--bg);
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
}
header.site nav { margin-left: auto; display: flex; gap: 22px; font-size: 14px; align-items: center; }
header.site nav a { color: var(--muted); text-decoration: none; }
header.site nav a:hover { color: var(--ink); }
header.site nav a.cta {
  color: var(--on-accent); background: var(--accent); padding: 6px 14px; border-radius: 6px; font-weight: 600;
}
header.site nav a.cta:hover { background: var(--accent-hover); color: var(--on-accent); }
header.site .right { margin-left: auto; display: flex; gap: 14px; align-items: center; font-size: 14px; }
header.site .right a { color: var(--muted); text-decoration: none; }
header.site .right a:hover { color: var(--ink); }

/* ---------- кнопки и формы ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--ink); border-radius: 6px;
  background: transparent; color: var(--ink);
  padding: 8px 16px; font: 500 14px/1.3 var(--sans);
  cursor: pointer; text-decoration: none;
  transition: background .12s, color .12s, border-color .12s;
}
.btn:hover { background: var(--ink); color: var(--bg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn.ghost { border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { border-color: var(--ink); background: transparent; color: var(--ink); }
.btn.small { padding: 4px 10px; font-size: 13px; border-radius: 5px; }
.btn.danger:hover { border-color: var(--err); color: var(--err); background: transparent; }
.btn:disabled { opacity: .45; cursor: default; pointer-events: none; }

label.field { display: block; margin-bottom: 14px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
label.field input, label.field select {
  display: block; width: 100%; margin-top: 6px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px; padding: 9px 11px;
  font: 14px var(--sans); outline: none; transition: border-color .12s;
}
label.field input:focus, label.field select:focus { border-color: var(--ink); }
.hint { font-size: 13px; color: var(--muted); margin-top: 12px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row label.field { margin-bottom: 0; min-width: 170px; }

.switch { position: relative; display: inline-block; width: 34px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; border-radius: 999px; cursor: pointer;
  background: var(--soft); border: 1px solid var(--line); transition: .15s;
}
.slider::before {
  content: ""; position: absolute; width: 14px; height: 14px; left: 2px; top: 2px;
  border-radius: 50%; background: var(--muted); transition: .15s;
}
.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(14px); background: var(--on-accent); }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- таблицы, бейджи ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font: 500 11.5px var(--mono); text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--ink);
}
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.empty { color: var(--muted); text-align: center; padding: 22px; }
.tbl { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: auto; }
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 4px;
  font: 500 12px var(--mono); border: 1px solid var(--line); color: var(--muted);
}
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.badge.err { color: var(--err); border-color: var(--err); }
.skeleton { color: var(--muted); }
.off { text-decoration: line-through; color: var(--muted); }
.dump { color: var(--ok); font-family: var(--mono); font-weight: 600; font-size: 13px; }

/* ---------- код ---------- */
pre.code {
  background: var(--code-bg); color: var(--code-ink);
  border-radius: 8px; padding: 16px 18px; overflow-x: auto;
  font: 13px/1.65 var(--mono); margin-top: 10px;
}
pre.code .c { color: var(--code-mute); }
pre.code .k { color: var(--code-key); }

/* ---------- лендинг ---------- */
.hero { padding: 84px 0 64px; border-bottom: 1px solid var(--line); }
.eyebrow { font: 500 12px var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--accent); margin-bottom: 18px; }
.hero h1 {
  font: 400 clamp(36px, 6.4vw, 66px)/1.04 var(--serif);
  letter-spacing: -.025em; max-width: 14ch;
}
.hero h1 em { font-style: italic; color: var(--accent); }
.hero p.sub { color: var(--muted); max-width: 56ch; margin-top: 22px; font-size: 17px; line-height: 1.55; }
.hero .actions { display: flex; gap: 12px; margin-top: 30px; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 34px; }
.chip {
  font: 12.5px var(--mono); color: var(--muted);
  border: 1px solid var(--line); border-radius: 4px; padding: 5px 10px; background: var(--surface);
}
.chip b { color: var(--ink); font-weight: 600; }

section.block { padding: 64px 0; border-bottom: 1px solid var(--line); }
.sec-head { display: grid; grid-template-columns: 90px 1fr; gap: 0 20px; margin-bottom: 32px; }
.sec-head .num { font: 500 13px var(--mono); color: var(--accent); padding-top: 10px; }
.sec-head h2 { font: 400 clamp(26px, 3.6vw, 36px)/1.15 var(--serif); letter-spacing: -.015em; }
.sec-head p.lead { grid-column: 2; color: var(--muted); max-width: 66ch; margin-top: 10px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid2 h3, .sub-h { font: 500 12px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 24px; position: relative; }
.card h3 { font: 500 12px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.card .price { font: 400 44px/1 var(--serif); margin: 14px 0 6px; letter-spacing: -.02em; }
.card .price small { font: 14px var(--sans); color: var(--muted); letter-spacing: 0; }
.card ul { list-style: none; margin-top: 16px; font-size: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.card ul li { padding: 5px 0 5px 20px; position: relative; }
.card ul li::before { content: "→"; position: absolute; left: 0; color: var(--accent); }
.card.featured { border-color: var(--ink); box-shadow: 5px 5px 0 var(--ink); }
.card .badge-top {
  position: absolute; top: -1px; right: 18px; transform: translateY(-50%);
  font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: .06em;
  background: var(--accent); color: var(--on-accent); padding: 3px 9px; border-radius: 3px;
}
.note {
  margin-top: 20px; border-left: 3px solid var(--accent);
  background: var(--surface); padding: 13px 18px; color: var(--muted); font-size: 14px; border-radius: 0 6px 6px 0;
}
.note b { color: var(--ink); }

footer.site { padding: 28px 0 56px; color: var(--muted); font-size: 13.5px; }
footer.site .wrap { display: flex; gap: 20px; flex-wrap: wrap; align-items: center; }
footer.site a { color: var(--muted); }
footer.site a:hover { color: var(--accent); }
footer.site .right { margin-left: auto; }

/* ---------- кабинет ---------- */
.auth-box { max-width: 420px; margin: 72px auto 0; padding: 0 20px; }
.auth-box .card h1 { font: 400 28px/1.15 var(--serif); letter-spacing: -.01em; margin-bottom: 8px; }
.oauth-btn { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 11px; font-size: 14.5px; width: 100%; }
.g-ico {
  width: 22px; height: 22px; border-radius: 4px; flex: none;
  display: grid; place-items: center; font: 700 11px var(--mono);
  background: var(--ink); color: var(--bg);
}
.g-ico.gh { background: var(--ink); }
.tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.tabs button { flex: 1; padding: 9px; border-radius: 6px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; }
.tabs button.on { border-color: var(--ink); color: var(--ink); }

main.cab { padding: 36px 24px 72px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0; margin-bottom: 28px; border: 1px solid var(--ink); border-radius: 8px; background: var(--surface); }
.stat { padding: 18px 20px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: none; }
.stat .v { font: 400 30px/1.1 var(--serif); letter-spacing: -.01em; }
.stat .v.mono { font-family: var(--serif); font-size: 30px; }
.stat .l { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.bar { height: 4px; border-radius: 2px; background: var(--soft); margin-top: 10px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ink); transition: width .3s; }
.bar i.warn { background: var(--warn); }
.bar i.bad { background: var(--err); }

section.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 24px 26px; margin-bottom: 24px; overflow-x: auto; }
section.panel h2 { font: 400 24px/1.2 var(--serif); letter-spacing: -.01em; margin-bottom: 6px; }
section.panel .sub { font-size: 13.5px; color: var(--muted); margin-bottom: 18px; max-width: 72ch; }
section.panel h3 { font: 500 12px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.plan { border: 1px solid var(--line); border-radius: 8px; padding: 18px; background: var(--bg); }
.plan h3 { margin-bottom: 8px; }
.plan-opt { border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; background: var(--surface); }

#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(16px);
  background: var(--ink); color: var(--bg); border-radius: 6px;
  padding: 10px 18px; font-size: 14px; opacity: 0; pointer-events: none;
  transition: .2s; max-width: 90vw; z-index: 50;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.ok { border-left: 4px solid var(--ok); }
#toast.err { border-left: 4px solid var(--err); }
dialog {
  background: var(--surface); color: var(--ink); border: 1px solid var(--ink);
  border-radius: 8px; padding: 24px; width: min(440px, 92vw);
  margin: auto; box-shadow: 6px 6px 0 var(--ink);
}
dialog::backdrop { background: rgba(10,10,8,.55); }
dialog h3 { font: 400 22px var(--serif); margin-bottom: 14px; }
.cab-foot { max-width: 1080px; margin: 0 auto; padding: 0 24px 44px; color: var(--muted); font-size: 13px; }
.cab-foot a { color: var(--muted); }

/* ---------- юридические страницы ---------- */
main.doc { max-width: 760px; margin: 0 auto; padding: 56px 24px 88px; }
main.doc h1 { font: 400 clamp(32px, 5vw, 46px)/1.08 var(--serif); letter-spacing: -.02em; margin-bottom: 10px; }
.updated { color: var(--muted); font: 13px var(--mono); margin-bottom: 36px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
main.doc h2 { font: 400 24px/1.2 var(--serif); margin: 40px 0 12px; letter-spacing: -.01em; }
main.doc h3 { font: 600 15px var(--sans); margin: 22px 0 8px; color: var(--ink); }
main.doc p, main.doc li { color: var(--ink); opacity: .86; line-height: 1.7; }
main.doc p { margin: 10px 0; }
main.doc ul, main.doc ol { padding-left: 22px; margin: 10px 0; }
main.doc li { margin: 5px 0; }
main.doc code, main.doc .mono { background: var(--soft); padding: 1px 6px; border-radius: 3px; }
main.doc table { margin: 14px 0; }
main.doc th, main.doc td { vertical-align: top; }
main.doc .note { margin: 18px 0; }

@media (max-width: 800px) {
  .grid2, .plans { grid-template-columns: 1fr; }
  .sec-head { grid-template-columns: 1fr; }
  .sec-head p.lead { grid-column: 1; }
  .sec-head .num { padding-top: 0; margin-bottom: 6px; }
  .hero { padding: 52px 0 44px; }
  section.block { padding: 44px 0; }
  header.site nav { gap: 14px; }
  header.site nav a:not(.cta) { display: none; }
  .stat { border-right: none; border-bottom: 1px solid var(--line); }
  .stat:last-child { border-bottom: none; }
  section.panel { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- утилиты, вынесенные из inline-стилей ---------- */
.lead-hint { margin: 0 0 18px; }
.hint-err { color: var(--err); }
.oauth-list { display: grid; gap: 10px; }
.oauth-btn.is-disabled { opacity: .45; pointer-events: none; }
.stat .v.cap { text-transform: capitalize; }
.row-top { margin-top: 18px; }
.row-mt { margin-top: 14px; }
.small-note { font-size: 13px; }
.plans-tight { gap: 10px; }
.plan-opt .btn { margin-top: 10px; }
.invoices { margin-top: 28px; }
.invoices .sub-h { margin-bottom: 10px; }
.reveal-key {
  display: block; word-break: break-all; background: var(--soft);
  padding: 12px 14px; border-radius: 6px; border: 1px solid var(--line); font-size: 13px;
}
.dlg-actions { display: flex; gap: 10px; margin-top: 16px; justify-content: flex-end; }
main.doc .tbl { margin: 14px 0; }
main.doc .tbl table { margin: 0; }
main > .hero { padding: 84px 0 64px; border-bottom: 1px solid var(--line); }
html { scroll-behavior: smooth; scroll-padding-top: 70px; }
header.site { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); }
section.block .grid2 > div { min-width: 0; }
.tbl table td, .tbl table th { white-space: nowrap; }
.tbl table td:first-child { white-space: normal; }
@media (max-width: 800px) { main > .hero { padding: 52px 0 44px; } }


/* ---------- адаптив таблиц кабинета: карточки на узких экранах ---------- */
@media (max-width: 900px) {
  table.rt, table.rt tbody, table.rt tr, table.rt td { display: block; width: 100%; }
  table.rt thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.rt tr { border: 1px solid var(--line); border-radius: 8px; padding: 6px 14px; margin-bottom: 12px; background: var(--bg); }
  table.rt tr:last-child td { border-bottom: 1px solid var(--line); }
  table.rt td { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line); text-align: right; white-space: normal; }
  table.rt td:last-child { border-bottom: none; }
  table.rt td::before { content: attr(data-label); flex: none; text-align: left; font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
  table.rt td.td-actions { justify-content: flex-end; }
  table.rt td.td-actions::before { content: none; }
  table.rt td.empty { display: block; text-align: center; }
  table.rt td.empty::before { content: none; }
  .row { align-items: stretch; }
  .row label.field { flex: 1 1 100%; min-width: 0; }
  .row .btn { width: 100%; }
  .plan-opt .btn { width: 100%; }
}
@media (max-width: 560px) {
  main.cab { padding: 22px 16px 56px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(odd) { border-right: 1px solid var(--line); }
  .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .stat:last-child { border-bottom: none; }
  .stat .v, .stat .v.mono { font-size: 24px; }
  header.site .wrap { gap: 10px; }
  #who { display: none !important; }
}


/* ---------- футер к низу, виджет Telegram ---------- */
body { display: flex; flex-direction: column; }
.wrap, .auth-box, main.doc { width: 100%; }
footer.site { margin-top: auto; border-top: 1px solid var(--line); padding: 22px 0 30px; }
.oauth-list > * { min-width: 0; }
#tg-widget-slot { display: flex; justify-content: center; align-items: center; min-height: 46px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
#tg-widget-slot:empty { display: none; }
#tg-widget-slot iframe { max-width: 100%; }
