:root {
  --bg: #0b0d09;
  --surface: #171a14;
  --surface-2: #20241b;
  --surface-3: #2a3023;
  --line: #30362a;
  --text: #ffffff;
  --muted: #a5ad9a;
  --accent: #c8ff31;
  --accent-text: #000000;
  --ok: #30d158;
  --warn: #ffd60a;
  --danger: #ff453a;
  --radius-l: 22px;
  --radius-m: 16px;
  --radius-s: 12px;
  --pad: 16px;
}

:root[data-theme="light"] {
  --bg: #f4f6ef;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --surface-3: #f2f2f7;
  --line: #e2e2e7;
  --text: #0b0b0c;
  --muted: #6e6e73;
  --accent: #c8ff31;
  --accent-text: #101407;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

body { overscroll-behavior-y: none; }

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 var(--pad);
}

/* ---------------------------------------------------------------- шапка */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  /* --tg-top — место под кнопки Telegram: на телефоне они рисуются поверх шапки.
     Правое поле отодвигает круглые кнопки от края окна, нижнее — отделяет
     шапку от первого блока, иначе она на него налезает. */
  padding: calc(12px + var(--tg-top, 0px)) 10px 10px 0;
  margin-bottom: 10px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }

.brand-icon {
  width: 38px; height: 38px;
  flex: 0 0 38px;
  border-radius: 11px;
  background: var(--surface-3);
  display: grid; place-items: center;
  color: var(--text);
}

.brand-text { min-width: 0; }
/* Блоками, а не строками: иначе на широком экране подпись липнет к названию. */
.brand-title { display: block; font-weight: 640; font-size: 16px; letter-spacing: -0.2px; }
.brand-sub { display: block; color: var(--muted); font-size: 13px; }

.icon-btn {
  width: 38px; height: 38px;
  flex: 0 0 38px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text);
  display: grid; place-items: center;
  cursor: pointer;
}
.icon-btn:active { opacity: .7; }

/* ----------------------------------------------------------------- вид */

.view { flex: 1; padding-bottom: 96px; }
.loader { color: var(--muted); padding: 40px 0; text-align: center; }

h1 { font-size: 28px; line-height: 1.15; letter-spacing: -0.7px; margin: 0 0 8px; font-weight: 700; }
h2 { font-size: 20px; margin: 0 0 4px; letter-spacing: -0.3px; font-weight: 660; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 14px; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 12px; }

/* --------------------------------------------------------------- герой */

.hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 20px;
  margin-bottom: 14px;
}

.hero-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.eyebrow {
  font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted);
}
.badge {
  font-size: 11px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px;
}

.hero p { color: var(--muted); font-size: 15px; }

.cluster { display: flex; align-items: center; margin: 18px 0 20px; padding-left: 6px; }
.cluster .app-icon { margin-left: -10px; box-shadow: 0 0 0 4px var(--surface); }
.cluster .app-icon:first-child { margin-left: 0; }

/* -------------------------------------------------------------- кнопки */

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  border: 0;
  border-radius: var(--radius-m);
  padding: 16px 18px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity .15s ease;
}
.btn:active { opacity: .75; }
.btn[disabled] { opacity: .35; cursor: default; }

.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn-ghost { background: transparent; color: var(--muted); font-weight: 500; }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.btn-sm { padding: 11px 14px; font-size: 14px; border-radius: var(--radius-s); }

.cta-note { color: var(--muted); font-size: 12px; text-align: center; margin-top: 10px; }

/* ---------------------------------------------------------------- шаги */

.flowline {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--muted); font-size: 13px;
  padding: 14px 0 18px;
}
.flowline span.sep { opacity: .5; }
.flowline span.on { color: var(--text); }

.stepper { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 16px; scrollbar-width: none; }
.stepper::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: var(--radius-s);
  padding: 9px 14px;
  font-size: 13px;
  white-space: nowrap;
}
.chip.done { color: var(--text); }
.chip.active { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 600; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 13px; font-size: 13px;
  margin-bottom: 14px;
}
.pill.ok { color: var(--ok); }

/* -------------------------------------------------------------- карточки */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 18px;
  margin-bottom: 14px;
}
.card.tight { padding: 14px; }

.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.row:last-child { border-bottom: 0; }
.row .label { color: var(--muted); }
.row .value { font-weight: 600; text-align: right; }
/* UDID длиннее строки — переносим его, а не обрезаем. */
.row .value.mono {
  font-variant-numeric: tabular-nums;
  letter-spacing: .3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
  min-width: 0;
}

.product { display: flex; align-items: center; gap: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.product .app-icon { width: 46px; height: 46px; border-radius: 13px; font-size: 20px; }
.product .name { font-weight: 640; }
.product .sub { color: var(--muted); font-size: 13px; }

details.disclosure {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 14px;
  margin: 14px 0;
}
details.disclosure > summary {
  cursor: pointer; font-weight: 600; font-size: 15px; list-style: none;
  display: flex; align-items: center; gap: 8px;
}
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::before { content: "▸"; color: var(--muted); transition: transform .15s ease; }
details.disclosure[open] > summary::before { transform: rotate(90deg); }
details.disclosure .body { color: var(--muted); font-size: 14px; margin-top: 10px; white-space: pre-wrap; }

.path {
  background: var(--surface-3);
  border-radius: var(--radius-s);
  padding: 12px 14px;
  font-size: 14px;
  margin: 12px 0;
}
.path b { font-weight: 600; }
.path .sep { color: var(--muted); margin: 0 6px; }

/* ----------------------------------------------------------------- поля */

.field { margin-top: 18px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.field input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  color: var(--text);
  font-size: 22px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  padding: 16px;
  outline: none;
}
.field input:focus { border-color: var(--muted); }
/* UDID из 40 символов не влезает в крупный кегль на узком экране. */
.field input.udid {
  font-size: 14px;
  letter-spacing: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.field-foot { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 8px; }
.field-foot .count.full { color: var(--ok); }
.field-error { color: var(--danger); font-size: 13px; margin-top: 8px; }

.check {
  display: flex; align-items: flex-start; gap: 12px;
  margin: 18px 0;
  font-size: 14px;
  cursor: pointer;
}
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: 0 0 22px; margin: 0; }

.linkish { background: none; border: 0; color: var(--muted); font-size: 14px; padding: 8px 0; cursor: pointer; font-family: inherit; }
.linkish:active { opacity: .6; }

/* ------------------------------------------------------------- каталог */

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 8px 0 12px;
}
.section-head h2 { margin: 0; }
.section-head button { background: none; border: 0; color: var(--muted); font-size: 14px; cursor: pointer; font-family: inherit; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.app-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 14px;
  position: relative;
  min-height: 108px;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 2px;
}
.app-card .app-icon { margin-bottom: 10px; }
.app-card .name { font-size: 14px; font-weight: 600; letter-spacing: -0.2px; }
.app-card .cat { font-size: 12px; color: var(--muted); }
/* Описание услуги обязано быть видно покупателю, но карточку раздувать нельзя. */
.app-card .desc {
  font-size: 11px; line-height: 1.35; color: var(--muted);
  margin-top: 4px;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3;
  overflow: hidden;
}
.app-card .price { font-size: 12px; font-weight: 700; margin-top: 8px; }
.app-card .arrow { position: absolute; top: 12px; right: 12px; color: var(--muted); font-size: 13px; }

.app-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 18px;
  color: #fff;
  overflow: hidden;
  flex: 0 0 auto;
  position: relative;
}
.app-icon.dark { color: #000; }
/* Если в webapp/icons/<slug>.png нет файла, картинка удаляется и остаётся буква. */
.app-icon img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }

/* Длинные слова без пробелов (ссылка, UDID, вставленный текст) не должны
   растягивать карточку вбок. */
.body, .notice, .row .value, .doc p, .doc li { overflow-wrap: anywhere; }

.body { color: var(--muted); font-size: 14px; }

.filters { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 14px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters .chip { cursor: pointer; }

/* ------------------------------------------------------------ таймлайн */

.timeline { margin: 6px 0 4px; }
.tl {
  display: flex; gap: 14px; padding: 12px 0;
  align-items: flex-start;
}
.tl .dot {
  width: 26px; height: 26px; border-radius: 50%;
  flex: 0 0 26px;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  background: var(--surface-3); color: var(--muted);
}
.tl.done .dot { background: transparent; color: var(--ok); border: 1px solid var(--ok); }
.tl.active .dot { background: var(--accent); color: var(--accent-text); }
.tl .t { font-size: 15px; font-weight: 600; }
.tl .s { font-size: 13px; color: var(--muted); }
.tl.pending .t { color: var(--muted); font-weight: 500; }

/* ------------------------------------------------------------- о нас */

.doc-row {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 2px;
  border: 0; border-bottom: 1px solid var(--line);
  background: none;
  color: var(--text);
  font-family: inherit; font-size: 15px; text-align: left;
}
.doc-row:last-child { border-bottom: 0; }
.doc-row:not(.pending) { cursor: pointer; }
.doc-row:not(.pending):active { opacity: .7; }
.doc-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.doc-title { font-weight: 600; }
.doc-hint { color: var(--muted); font-size: 13px; }
.doc-flag {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
}
.doc-flag.open { border-color: transparent; font-size: 15px; }

.legal { color: var(--muted); font-size: 14px; line-height: 1.5; }

.product-desc { color: var(--muted); font-size: 14px; line-height: 1.5; padding-bottom: 12px; }

/* ----------------------------------------------------------- реквизиты */

.requisites { display: flex; flex-direction: column; }

.req-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.req-row:last-child { border-bottom: 0; }
.req-row.comment { border-top: 1px solid var(--line); border-bottom: 0; }

.req-icon {
  width: 38px; height: 38px;
  flex: 0 0 38px;
  border-radius: 11px;
  overflow: hidden;
  background: var(--surface-3);
  display: grid; place-items: center;
}
.req-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }

.req-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.req-label { color: var(--muted); font-size: 12px; }
.req-value {
  font-size: 16px; font-weight: 640; letter-spacing: .2px;
  overflow-wrap: anywhere;
}

.req-copy {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  display: grid; place-items: center;
  cursor: pointer;
}
.req-copy:active { transform: scale(.92); color: var(--accent); border-color: #c8ff3166; }

/* --------------------------------------------------------------- подвал */

/* Реквизиты и документы — на каждом экране витрины и на каждой странице. */
.footer {
  margin-top: 28px;
  padding: 18px 0 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}
.footer-links {
  display: flex; flex-wrap: wrap; gap: 4px 14px;
  margin-bottom: 10px;
}
.footer-links a, .footer-links .linkish {
  color: var(--text); font-size: 12px; padding: 2px 0;
  text-decoration: none; border-bottom: 1px solid var(--line);
}
.footer-links a:active, .footer-links .linkish:active { opacity: .6; }
.footer-line { margin-top: 2px; }
.footer-line.legal { font-size: 12px; }

/* ------------------------------------------------------- документ целиком */

.doc h1 { font-size: 24px; margin-bottom: 16px; }
.doc h2 { font-size: 17px; margin: 22px 0 8px; }
.doc p { font-size: 15px; line-height: 1.6; color: var(--text); }
.doc ul { margin: 0 0 12px; padding-left: 20px; }
.doc li { font-size: 15px; line-height: 1.6; margin-bottom: 6px; }

.notice {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 14px;
  color: var(--muted);
  font-size: 14px;
  margin: 14px 0;
}
.notice.warn { color: var(--warn); }

pre.instruction {
  white-space: pre-wrap;
  /* Инструкция может прийти одним длинным словом — без переноса она
     растягивала карточку и всю страницу вбок. */
  overflow-wrap: anywhere;
  font-family: inherit;
  font-size: 15px;
  margin: 0;
}

/* ------------------------------------------------------------- продавец */

.order-line {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 14px;
  margin-bottom: 10px;
  width: 100%;
  text-align: left;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
}
.order-line .code { font-weight: 650; font-size: 15px; }
.order-line .meta { color: var(--muted); font-size: 13px; }
.order-line .grow { flex: 1; min-width: 0; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: 0 0 8px; }
.status-dot.new, .status-dot.payment_check { background: var(--warn); }
.status-dot.paid, .status-dot.imei, .status-dot.installed { background: #0a84ff; }
.status-dot.done { background: var(--ok); }
.status-dot.cancelled { background: var(--danger); }

textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 14px;
  min-height: 120px;
  outline: none;
  resize: vertical;
}

.search {
  /* input по умолчанию строчный: без display: block его не выровнять автополями. */
  display: block;
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 13px 14px;
  outline: none;
  margin-bottom: 12px;
}

/* --------------------------------------------------------------- табы */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: space-around;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  z-index: 30;
}
.tabbar button {
  background: none; border: 0; cursor: pointer;
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 4px 10px;
  flex: 1;
}
.tabbar button.on { color: var(--text); }
.tabbar .dot-badge {
  position: absolute; margin: -2px 0 0 14px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--warn);
}

.backlink {
  background: none; border: 0; color: var(--muted);
  font-family: inherit; font-size: 15px;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0 14px; cursor: pointer;
}

/* --------------------------------------------------------------- тост */

.toast {
  position: fixed;
  left: 50%; bottom: calc(86px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius-m);
  font-size: 14px;
  max-width: 88%;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: var(--danger); color: var(--danger); }

/* ------------------------------------------------------------- переписка */

.chat-list { display: flex; flex-direction: column; gap: 8px; padding: 4px 0 8px; }

.chat-empty {
  color: var(--muted); font-size: 14px; text-align: center;
  padding: 32px 16px;
}

.msg {
  max-width: 82%;
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px 16px 16px 4px;
  padding: 10px 14px;
}
.msg.mine {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-text);
  border-color: transparent;
  border-radius: 16px 16px 4px 16px;
}
.msg-text { font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-time { font-size: 11px; opacity: .55; margin-top: 4px; text-align: right; }

.composer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex; gap: 10px; align-items: flex-end;
  padding: 10px var(--pad) calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  max-width: 560px;
  margin: 0 auto;
  z-index: 40;
}
.composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 140px;
  padding: 11px 14px;
  border-radius: 22px;
  resize: none;
}
.send-btn {
  width: 44px; height: 44px;
  flex: 0 0 44px;
  border: 0; border-radius: 50%;
  background: var(--accent); color: var(--accent-text);
  font-size: 20px; font-weight: 700;
  cursor: pointer;
}
.send-btn:active { opacity: .75; }

body.chat-mode .tabbar { display: none; }
body.chat-mode .view { padding-bottom: 110px; }

.count-badge {
  display: inline-grid; place-items: center;
  min-width: 20px; height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--danger);
  color: #fff;
  font-size: 12px; font-weight: 700;
  flex: 0 0 auto;
}

/* ------------------------------------------------------ переключатели */

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.switch-row:last-child { border-bottom: 0; }
.switch-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.switch-title { font-size: 15px; font-weight: 600; }
.switch-hint { font-size: 13px; color: var(--muted); }

.switch {
  appearance: none; -webkit-appearance: none;
  width: 50px; height: 30px;
  flex: 0 0 50px;
  border-radius: 15px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  position: relative;
  cursor: pointer;
  transition: background .18s ease;
  margin: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .18s ease, background .18s ease;
}
.switch:checked { background: var(--ok); border-color: transparent; }
.switch:checked::after { transform: translateX(20px); background: #fff; }

.guide {
  display: block;
  width: 100%;
  border-radius: var(--radius-m);
  margin-top: 12px;
  border: 1px solid var(--line);
}

/* iApki — фирменная палитра и мобильная витрина */
:root { --brand: #c8ff31; --radius-l: 26px; --radius-m: 18px; }
:root[data-theme="light"] { --line: #dce2d2; --surface-2: #edf1e6; --surface-3: #e5ebdb; --muted: #606955; }
body { background-image: radial-gradient(ellipse at 85% 0%, #c8ff310c, transparent 460px); }
.topbar { padding: calc(14px + var(--tg-top, 0px)) 12px 12px 0; margin-bottom: 12px; gap: 10px; }
a.brand { text-decoration: none; color: inherit; }
.brand-icon { width: 44px; height: 44px; flex-basis: 44px; border-radius: 14px; overflow: hidden; background: var(--brand); }
.brand-icon img { display: block; width: 100%; height: 100%; object-fit: cover; }
.brand-title { font-size: 23px; font-weight: 800; letter-spacing: -1px; }
.brand-sub { font-size: 12px; margin-top: 1px; }
.hero { position: relative; overflow: hidden; padding: 24px; background: radial-gradient(ellipse at 100% 0%, #c8ff3126, transparent 70%), var(--surface); border-color: #c8ff3140; }
.hero h1 { font-size: clamp(30px, 8.5vw, 40px); font-weight: 800; letter-spacing: -1.5px; line-height: 1.06; margin-bottom: 14px; }
.hero h1 em { color: var(--brand); font-style: normal; }
:root[data-theme="light"] .hero h1 em { color: #486500; }
.hero p { max-width: 340px; line-height: 1.55; font-size: 14px; }
.hero .badge { background: var(--brand); color: #101407; border: 0; font-weight: 800; padding: 5px 10px; }
.eyebrow { font-size: 10px; letter-spacing: 1.5px; font-weight: 600; }
.cluster { padding: 0; margin: 22px 0; gap: 8px; flex-wrap: wrap; }
.cluster .app-icon { width: 43px; height: 43px; margin: 0; box-shadow: 0 4px 10px #0003; border-radius: 13px; }
.btn { transition: transform .15s, opacity .15s, background .15s; }
.btn-primary { font-weight: 750; box-shadow: 0 5px 22px #c8ff3114; }
.btn:active { transform: scale(.98); }
.flowline { font-size: 11px; gap: 5px; padding: 5px 0 21px; flex-wrap: wrap; }
.flowline .sep { color: var(--brand); }
.section-head { margin-top: 8px; margin-bottom: 14px; gap: 8px; }
.section-head h2 { font-size: 19px; }
.section-head button { color: var(--text); font-size: 12px; padding: 8px 10px; border-radius: 12px; background: var(--surface-3); }
.grid { gap: 12px; }
.app-card { min-height: 146px; padding: 16px; background: linear-gradient(145deg, var(--surface-2), var(--surface)); border-radius: 22px; }
.app-card .app-icon { width: 52px; height: 52px; border-radius: 15px; margin-bottom: 12px; box-shadow: 0 4px 10px #0002; }
.app-card .name { font-size: 14px; line-height: 1.3; }
.app-card .cat { font-size: 11px; margin-top: 3px; }
.app-card .arrow { display: none; }
.filters .chip { font-family: inherit; min-height: 42px; border-radius: 14px; }
.tabbar { max-width: 560px; margin: 0 auto; padding-top: 10px; }
.tabbar button { gap: 5px; min-height: 49px; }
.tabbar button.on { color: var(--brand); }
:root[data-theme="light"] .tabbar button.on { color: #486500; }
.nav-icon { width: 22px; height: 22px; }
.tabbar button.on .nav-icon { filter: drop-shadow(0 0 8px #c8ff3133); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.search:focus, textarea:focus, .field input:focus { border-color: var(--accent); }
.switch:checked { background: var(--brand); }
.switch:checked::after { background: #101407; }
.card { box-shadow: 0 5px 22px #0000000a; }
@media (max-width: 350px) { .hero { padding: 18px; } .cluster { gap: 6px; } .cluster .app-icon { width: 36px; height: 36px; } .app-card { padding: 12px; } .brand-sub { font-size: 11px; } }

/* --------------------------------------------------------------- движение */

/* Появление экрана: класс навешивает render() только при смене экрана. */
@keyframes view-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}
.view.view-in { animation: view-in .34s cubic-bezier(.2, .7, .3, 1); }

/* Карточки каталога выкладываются волной: номер карточки — в --i. */
@keyframes card-in {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
}
.grid .app-card {
  animation: card-in .42s cubic-bezier(.2, .7, .3, 1) both;
  animation-delay: calc(var(--i, 0) * 28ms);
}

/* Нажатие: салатовая волна от точки касания — координаты ставит app.js. */
.btn { position: relative; overflow: hidden; isolation: isolate; }
.btn::after {
  content: "";
  position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), #c8ff3180, #c8ff3100 55%);
  opacity: 0;
}
@keyframes ripple {
  from { opacity: .95; transform: scale(.25); }
  to { opacity: 0; transform: scale(2.6); }
}
.btn.rippling::after { animation: ripple .55s ease-out; }
.btn-primary:active { box-shadow: 0 0 0 5px #c8ff312e, 0 6px 26px #c8ff3140; }

/* Блик по главной кнопке идёт сам: на телефоне наведения курсора нет. */
@keyframes sheen {
  0%, 62% { background-position: 135% 0; }
  100% { background-position: -35% 0; }
}
.btn-primary {
  background-image: linear-gradient(110deg, transparent 36%, #ffffff4d 47%, transparent 58%);
  background-size: 280% 100%;
  background-position: 135% 0;
  animation: sheen 6s ease-in-out infinite;
}

/* Иконки в шапке витрины качаются, каждая со своей задержкой. */
@keyframes float-soft {
  0%, 100% { transform: rotate(var(--tilt, 0deg)) translateY(var(--shift, 0px)); }
  50% { transform: rotate(var(--tilt, 0deg)) translateY(calc(var(--shift, 0px) - 9px)); }
}

/* Салатовое свечение медленно ходит по баннеру — под содержимым,
   иначе оно приглушает кнопку и текст. */
.hero::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: -30%; right: -10%;
  width: 380px; height: 380px;
  background: radial-gradient(circle, #c8ff3124, transparent 70%);
  pointer-events: none;
  animation: hero-glow 11s ease-in-out infinite alternate;
}
.hero > * { position: relative; z-index: 1; }
@keyframes hero-glow {
  to { transform: translate3d(-60px, 40px, 0) scale(1.15); }
}

/* Контент уходит под шапку не резко, а растворяясь. */
.topbar::after {
  content: "";
  position: absolute; left: 0; right: 0; top: 100%;
  /* Чуть ниже отступа под шапкой: растворяет уезжающий контент,
     но в покое не приглушает верх карточки. */
  height: 16px;
  background: linear-gradient(var(--bg), transparent);
  pointer-events: none;
}

.chip, .doc-row, .app-card, .order-line, .icon-btn, .tabbar button {
  transition: background .2s ease, border-color .2s ease, color .2s ease,
              transform .16s ease, box-shadow .25s ease;
}
.chip:active, .doc-row:not(.pending):active, .order-line:active { transform: scale(.97); }
.app-card:active { transform: scale(.985); }
.icon-btn:active, .tabbar button:active { transform: scale(.92); }

/* Активный фильтр — градиентом, а не заливкой. */
.filters .chip.active {
  background: linear-gradient(135deg, var(--accent), #c8ff31b0);
  box-shadow: 0 4px 16px #c8ff3126;
}

/* Курсор мыши: на телефоне эти правила не включаются. */
@media (hover: hover) and (pointer: fine) {
  .app-card:hover {
    transform: translateY(-3px);
    border-color: #c8ff3166;
    box-shadow: 0 12px 30px #c8ff310f;
  }
  .chip:hover:not(.active) { border-color: #c8ff3166; color: var(--text); }
  .req-copy:hover { color: var(--accent); border-color: #c8ff3166; background: var(--surface-3); }
  .doc-row:not(.pending):hover .doc-title, .order-line:hover .code { color: var(--accent); }
  .icon-btn:hover { background: var(--surface-2); box-shadow: 0 0 0 1px #c8ff3140; }
  .btn-secondary:hover, .btn-danger:hover { border-color: #c8ff3166; }
  .btn-primary:hover { box-shadow: 0 10px 32px #c8ff3140; }
  .footer-links a:hover, .footer-links .linkish:hover { color: var(--accent); border-bottom-color: #c8ff3166; }
}

/* Ряды фильтров тянутся мышью — курсор показывает, что их можно двигать. */
@media (hover: hover) and (pointer: fine) {
  .filters, .stepper { cursor: grab; }
}
.filters.dragging, .stepper.dragging { cursor: grabbing; user-select: none; }
.filters.dragging .chip { pointer-events: none; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

/* Экран загрузки со знаком iApki */
.loader { display: flex; flex-direction: column; align-items: center; gap: 14px; padding-top: 18vh; }
.loader img { border-radius: 18px; animation: loader-pulse 1.4s ease-in-out infinite; }
@keyframes loader-pulse { 50% { opacity: .55; transform: scale(.96); } }
@media (prefers-reduced-motion: reduce) { .loader img { animation: none; } }

/* Иконки в шапке витрины — мозаикой: разный размер и лёгкий наклон.
   Ряд не переносится: на экранах уже ~390px шестая плитка уезжала вниз. */
.cluster { flex-wrap: nowrap; gap: 8px; align-items: center; }
.cluster .app-icon {
  flex: 1 1 0;
  min-width: 0;
  height: auto;
  aspect-ratio: 1 / 1;
  max-width: 54px;
  border-radius: 26%;
  box-shadow: 0 6px 16px #00000040;
  transform: rotate(var(--tilt, 0deg)) translateY(var(--shift, 0px));
  animation: float-soft 7s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}
.cluster .app-icon:nth-child(1) { --tilt: -8deg; --shift: 4px; --delay: 0s; max-width: 58px; }
.cluster .app-icon:nth-child(2) { --tilt: 6deg; --shift: -6px; --delay: .8s; max-width: 46px; }
.cluster .app-icon:nth-child(3) { --tilt: -4deg; --shift: 6px; --delay: 1.6s; max-width: 54px; }
.cluster .app-icon:nth-child(4) { --tilt: 9deg; --shift: -3px; --delay: .4s; max-width: 44px; }
.cluster .app-icon:nth-child(5) { --tilt: -6deg; --shift: 7px; --delay: 2.2s; max-width: 56px; }
.cluster .app-icon:nth-child(6) { --tilt: 5deg; --shift: -5px; --delay: 1.2s; max-width: 48px; }

/* Кнопки подряд — с воздухом между ними (раньше слипались, например в «Помощи»). */
.btn + .btn { margin-top: 10px; }
.btn-row > .btn + .btn { margin-top: 0; }

/* Карточка приложения — кнопка: сбрасываем системный вид. */
button.app-card {
  font: inherit; color: inherit; text-align: left; width: 100%;
  cursor: pointer; -webkit-appearance: none; appearance: none;
  transition: transform .15s ease, border-color .15s ease;
}
button.app-card:active { transform: scale(.97); border-color: var(--accent); }
.app-card .name, .app-card .cat { display: block; }

/* Логотип в шапке — кнопка «на главную». */
button.brand {
  background: none; border: 0; padding: 0; margin: 0;
  font: inherit; color: inherit; text-align: left;
  cursor: pointer; -webkit-appearance: none; appearance: none;
}
button.brand .brand-text, button.brand .brand-title, button.brand .brand-sub { display: block; }
button.brand:active { opacity: .75; }

/* ------------------------------------------------------- версия для ПК */

/* Блок идёт последним: он должен перебивать правила выше. */
@media (min-width: 900px) {
  .shell { max-width: 1120px; padding: 0 32px; }
  /* Шапка — только логотип: со строкой разделов она выходила слишком толстой.
     Правое поле отодвигает кнопки помощи и переписки от края. */
  .topbar { order: 1; padding: calc(16px + var(--tg-top, 0px)) 40px 10px 0; margin-bottom: 8px; }
  .brand-title { font-size: 26px; }
  .brand-sub { font-size: 13px; }

  /* Нижняя панель на большом экране неуместна: разделы идут строкой слева
     под шапкой и уезжают вместе со страницей.
     У флекс-элементов z-index работает и без позиционирования — без сброса
     кнопки всплывали поверх шапки. */
  .tabbar {
    order: 2;
    position: static;
    z-index: auto;
    max-width: none;
    margin: 0;
    justify-content: flex-start;
    gap: 10px;
    padding: 0 0 20px;
    border-top: 0;
    background: none;
    backdrop-filter: none;
  }
  .tabbar button {
    flex: 0 0 auto;
    flex-direction: row;
    gap: 9px;
    min-height: 0;
    font-size: 14px;
    padding: 11px 18px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--line);
  }
  .tabbar button.on {
    background: linear-gradient(135deg, #c8ff3126, #c8ff3108);
    border-color: #c8ff3166;
  }
  .tabbar .dot-badge { position: static; margin: 0; }
  .view { order: 3; padding-bottom: 56px; }
  /* На страницах документов подвал — прямой потомок .shell: без явного
     порядка он оказался бы выше шапки. */
  .shell > .footer { order: 4; }

  /* Баннер по центру: на широком экране прижатый влево текст выглядит
     смещённым, а не выровненным. */
  .hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 52px 44px 46px;
  }
  .hero > .hero-head { width: auto; gap: 14px; margin-bottom: 22px; }
  .hero > h1 { font-size: 52px; }
  .hero > p { max-width: 560px; font-size: 16px; }
  .hero > .btn-primary { max-width: 420px; }
  .hero > .cta-note { text-align: center; }
  .hero::before { width: 520px; height: 520px; }

  /* Мозаика крупнее и вразнобой. */
  .hero > .cluster { width: auto; margin: 28px 0 32px; gap: 18px; justify-content: center; }
  .hero > .cluster .app-icon { flex: 0 0 auto; max-width: none; }
  .hero > .cluster .app-icon:nth-child(1) { width: 92px; }
  .hero > .cluster .app-icon:nth-child(2) { width: 68px; }
  .hero > .cluster .app-icon:nth-child(3) { width: 84px; }
  .hero > .cluster .app-icon:nth-child(4) { width: 62px; }
  .hero > .cluster .app-icon:nth-child(5) { width: 96px; }
  .hero > .cluster .app-icon:nth-child(6) { width: 74px; }

  .flowline { justify-content: center; font-size: 13px; gap: 8px; }
  .section-head h2 { font-size: 24px; }

  /* Каталог заполняет ширину: по четыре карточки в ряд. */
  .grid { grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 16px; }
  .app-card { min-height: 196px; }
  .app-card .name { font-size: 16px; }
  .app-card .desc { font-size: 12px; -webkit-line-clamp: 2; }
  .app-card .price { font-size: 14px; }
  .app-card .arrow { display: block; }

  /* Текст — колонкой по центру: во всю ширину монитора строки не читаются,
     а прижатые влево выглядят забытыми. Класс narrow ставит render()
     всем экранам, кроме витрины, где каталог занимает всю ширину. */
  .view.narrow > *, .doc, .card, .notice, .field, .chat-list, .composer,
  .view > .cta-note, .view > .mt, .view > .btn {
    max-width: 880px;
    margin-left: auto;
    margin-right: auto;
  }
  /* Строчные элементы (плашка статуса, кнопка-ссылка) автополями не
     выравниваются — сдвигаем их к левой границе той же колонки. */
  .view.narrow > .pill, .view.narrow > .linkish {
    display: flex;
    width: fit-content;
    margin-left: max(0px, calc((100% - 880px) / 2));
    margin-right: auto;
  }

  /* «Назад» — шаг из экрана, ему место у левого края, а не в колонке. */
  .view.narrow > .backlink, .doc > .backlink { margin-left: 0; }

  /* Фильтры помещаются целиком — прокручивать нечего. */
  .filters { flex-wrap: wrap; overflow: visible; padding-bottom: 18px; }
  .footer { max-width: none; }
  .footer-links { gap: 8px 20px; }
}
