:root {
  --bg: #f6f5f1; --surface: #ffffff; --ink: #1d1f1c; --muted: #5f645c; --line: #e2e0d8;
  --accent: #1f7a4d; --accent-ink: #ffffff; --accent-soft: #e3f1e9;
  --warn: #9a5b00; --warn-soft: #fbefd9; --bad: #a3271f; --bad-soft: #fbe5e3;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141614; --surface: #1d201d; --ink: #ecede8; --muted: #a2a79d; --line: #2e322d;
    --accent: #4cc38a; --accent-ink: #0d1a12; --accent-soft: #1d3327;
    --warn: #f0b45a; --warn-soft: #3a2c14; --bad: #f08a80; --bad-soft: #3a1c19;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
header.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 0; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; }
.brand .mark { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 800; font-size: 15px; }
nav.top a { color: var(--muted); text-decoration: none; margin-left: 16px; font-size: 15px; }
nav.top a:hover { color: var(--ink); }
.hero { padding: 40px 0 28px; }
.hero h1 { font-size: clamp(30px, 5vw, 46px); line-height: 1.1; margin: 0 0 14px; letter-spacing: -.02em; }
.hero p.lead { font-size: 19px; color: var(--muted); max-width: 640px; margin: 0 0 26px; }
.btns { display: flex; flex-wrap: wrap; gap: 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 20px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.small { padding: 6px 12px; font-size: 14px; border-radius: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 26px 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 6px; font-size: 17px; }
.card p { margin: 0; color: var(--muted); font-size: 15px; }
section { margin: 34px 0; }
section h2 { font-size: 24px; margin: 0 0 12px; letter-spacing: -.01em; }
.price { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px; }
.price .amount { font-size: 38px; font-weight: 800; letter-spacing: -.02em; }
.price ul { margin: 6px 0 0; padding-left: 20px; color: var(--muted); }
footer { border-top: 1px solid var(--line); margin-top: 48px; padding: 22px 0 36px; color: var(--muted); font-size: 14px; }
footer a { color: var(--muted); margin-right: 14px; }
.doc { max-width: 760px; }
.doc h1 { font-size: 30px; margin: 20px 0 6px; }
.doc h2 { font-size: 19px; margin: 26px 0 8px; }
.doc .note { background: var(--warn-soft); color: var(--warn); padding: 10px 14px; border-radius: 10px; font-size: 14px; }
input[type=text], input[type=search], input[type=number], input[type=password], select {
  font: inherit; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); width: 100%; min-width: 0; }
input.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .04em; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > input { flex: 1 1 220px; }
.msg { margin-top: 14px; padding: 12px 14px; border-radius: 10px; display: none; }
.msg.show { display: block; }
.msg.ok { background: var(--accent-soft); color: var(--accent); }
.msg.warn { background: var(--warn-soft); color: var(--warn); }
.msg.bad { background: var(--bad-soft); color: var(--bad); }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* админка */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 18px; }
.tabs button { font: inherit; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); cursor: pointer; }
.tabs button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi .v { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.kpi .l { color: var(--muted); font-size: 14px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th { color: var(--muted); font-weight: 600; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }
.bar { height: 8px; border-radius: 4px; background: var(--accent); min-width: 2px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.PREMIUM, .pill.succeeded { background: var(--accent-soft); color: var(--accent); }
.pill.TRIAL, .pill.pending, .pill.waiting_for_capture { background: var(--warn-soft); color: var(--warn); }
.pill.LIMITED, .pill.canceled, .pill.none { background: var(--bad-soft); color: var(--bad); }
tr.alert td { background: var(--bad-soft); }
@media (max-width: 640px) {
  nav.top a { margin-left: 10px; font-size: 14px; }
  .hero { padding-top: 22px; }
}

/* админка v3 */
.envbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg button { font: inherit; font-size: 14px; padding: 7px 14px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg button.on.test { background: var(--warn); color: #fff; }
.testbanner { display: none; background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 9px 14px; margin-bottom: 14px; font-size: 14px; font-weight: 600; }
body.test .testbanner { display: block; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 16px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.card h3 { margin-top: 0; }
.stack > * + * { margin-top: 14px; }
.copy { cursor: pointer; border-bottom: 1px dashed var(--muted); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ev-type { font-size: 12px; font-weight: 600; color: var(--muted); }
.ev-error td { background: var(--bad-soft); }
textarea { font: inherit; }

/* главный экран с фоном A&C Dev */
.hero-bg { position: relative; isolation: isolate; display: flex; flex-direction: column;
  min-height: min(100svh, 820px); color: #fff; background-color: #2a2c2d;
  background-image: url(/img/hero.jpg);
  background-image: image-set(url(/img/hero.webp) type("image/webp"), url(/img/hero.jpg) type("image/jpeg"));
  background-size: cover; background-position: left center; margin: 0; }
.hero-bg::before { content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(90deg, rgba(18,19,20,.88) 0%, rgba(18,19,20,.62) 30%, rgba(18,19,20,0) 52%),
              linear-gradient(180deg, rgba(18,19,20,.45) 0%, rgba(18,19,20,0) 22%); }
.hero-bg .wrap { width: 100%; max-width: none; padding: 0 clamp(16px, 4vw, 56px); }
.hero-bg header.top .brand, .hero-bg nav.top a { color: #fff; }
.hero-bg nav.top a { opacity: .85; }
.hero-bg nav.top a:hover { opacity: 1; color: #fff; }
.hero-content { margin-top: auto; margin-bottom: auto; padding-top: 24px; padding-bottom: 56px; }
.hero-content h1 { font-size: clamp(28px, 3.2vw, 44px); line-height: 1.12; letter-spacing: -.02em; margin: 0 0 14px; max-width: min(430px, 32vw); }
.hero-content .lead { font-size: 17px; color: rgba(255,255,255,.82); max-width: min(410px, 31vw); margin: 0 0 26px; }
.btn.ghost { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.55); color: #fff; backdrop-filter: blur(4px); }
@media (max-width: 820px) {
  .hero-bg { min-height: 100svh; background-color: #161718;
    background-image: url(/img/hero-m.jpg);
    background-image: image-set(url(/img/hero-m.webp) type("image/webp"), url(/img/hero-m.jpg) type("image/jpeg"));
    background-size: auto max(86%, 100vw * 1.79 * .86); background-position: center top; }
  .hero-bg::before { background: linear-gradient(180deg, rgba(18,19,20,.5) 0%, rgba(18,19,20,0) 16%, rgba(18,19,20,0) 52%, rgba(18,19,20,.9) 78%, rgba(18,19,20,.96) 100%); }
  .hero-content { margin-top: auto; margin-bottom: 0; padding-bottom: 32px; }
  .hero-content h1 { max-width: none; font-size: 28px; }
  .hero-content .lead { max-width: none; font-size: 16px; margin-bottom: 20px; }
}

/* главный экран админки */
.appcards { display: grid; gap: 14px; }
.appcard .apphead { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.appcard .apphead h3 { margin: 0; font-size: 20px; }
.envcols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.envcol { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.envcol.test { background: var(--warn-soft); border-color: transparent; }
.envhead { font-weight: 700; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mini { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; color: var(--muted); }
.mini b { color: var(--ink); }
.envcol .api { font-size: 12px; word-break: break-all; }
.envcol .api.copied { color: var(--accent); }
.envcol .btn { align-self: flex-start; }
.addcard { display: grid; place-items: center; min-height: 70px; text-decoration: none; color: var(--muted); font-weight: 600; border-style: dashed; }
.addcard:hover { color: var(--ink); }
#appname { font-size: 15px; }
@media (max-width: 720px) { .envcols { grid-template-columns: 1fr; } }
[hidden] { display: none !important; }
.linkbtn { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }

/* страница Диспетчера */
nav.top a[aria-current] { opacity: 1; font-weight: 600; }
.ink { color: var(--ink); }
.flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: center; gap: 10px; margin-top: 18px; }
.flow .arrow { font-size: 22px; color: var(--muted); }
.flow .step { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips span { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; font-size: 15px; }
.seg.periods { margin-bottom: 16px; max-width: 100%; overflow-x: auto; }
.seg.periods button { padding: 9px 16px; white-space: nowrap; }
.seg .off { font-size: 12px; font-weight: 700; color: var(--accent); }
.seg button.on .off { color: inherit; opacity: .85; }
.tiers { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 14px; }
.tier { display: flex; flex-direction: column; gap: 4px; }
.tier.pop { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tier .tname { font-weight: 700; font-size: 17px; }
.tier .tsize { color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.tier .amount { font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.tier .amount.small { font-size: 22px; }
.tier .per { font-size: 14px; font-weight: 400; }
.tier .btn { margin-top: 12px; align-self: flex-start; }
.cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.btn.soon { opacity: .6; cursor: default; pointer-events: none; }
@media (max-width: 640px) {
  .flow { grid-template-columns: 1fr; }
  .flow .arrow { transform: rotate(90deg); justify-self: center; line-height: 1; }
}
@media (max-width: 520px) {
  .seg.periods { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; }
  .seg.periods button { padding: 8px 4px; font-size: 13px; display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
}

/* переключатель приложений в шапке */
header.top { flex-wrap: wrap; }
.prodsw { display: inline-flex; gap: 4px; padding: 4px; border-radius: 14px; background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18); backdrop-filter: blur(6px); }
.prodsw a { display: flex; align-items: center; gap: 9px; padding: 5px 12px 5px 5px; border-radius: 10px;
  color: rgba(255,255,255,.75); text-decoration: none; transition: background .15s, color .15s; }
.prodsw a:hover { color: #fff; background: rgba(255,255,255,.08); }
.prodsw a.on { background: rgba(255,255,255,.95); color: #1d1f1c; }
.prodsw .mark { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; }
.prodsw a:not(.on) .mark { background: rgba(255,255,255,.16); }
.prodsw .pt { font-size: 15px; font-weight: 600; line-height: 1.2; }
@media (max-width: 520px) {
  .prodsw .pt { font-size: 14px; }
  .prodsw .mark { width: 28px; height: 28px; font-size: 12px; }
  nav.top a { margin-left: 8px; }
}

/* товары в админке */
.chip { display: inline-block; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 14px; margin: 0 6px 6px 0; }
.prod .pname { font-weight: 700; font-size: 17px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.prod.off { opacity: .65; }
.card.danger { border-color: var(--bad); }
.card.danger h3 { color: var(--bad); }
details.help summary { cursor: pointer; font-weight: 600; color: var(--accent); margin-top: 10px; }
details.card.help summary { margin-top: 0; }
details.help p, details.help li { font-size: 14px; color: var(--muted); }
details.help b { color: var(--ink); }
details.help ul { padding-left: 20px; }
details.help .tbl { margin: 8px 0; }
