/* Дизайн BaobabStars в стиле BaobabVpn: тёмно-синее «звёздное» небо, карточки с тонкой рамкой,
   иконки в цветных квадратах, голубые кнопки со свечением, плавающее нижнее меню.
   Две темы, переключатель в шапке. Касания от 44px, SVG-иконки. */

/* Шрифты лежат рядом (Onest, кириллица + латиница; JetBrains Mono для цифр в админке), без Google Fonts. */
@font-face { font-family: "Onest"; font-weight: 400; font-display: swap; src: url("fonts/onest-cyrillic-400-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Onest"; font-weight: 400; font-display: swap; src: url("fonts/onest-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20BD, U+2190-21FF, U+2212, U+2215; }
@font-face { font-family: "Onest"; font-weight: 500; font-display: swap; src: url("fonts/onest-cyrillic-500-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Onest"; font-weight: 500; font-display: swap; src: url("fonts/onest-latin-500-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20BD, U+2190-21FF, U+2212, U+2215; }
@font-face { font-family: "Onest"; font-weight: 600; font-display: swap; src: url("fonts/onest-cyrillic-600-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Onest"; font-weight: 600; font-display: swap; src: url("fonts/onest-latin-600-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20BD, U+2190-21FF, U+2212, U+2215; }
@font-face { font-family: "Onest"; font-weight: 700; font-display: swap; src: url("fonts/onest-cyrillic-700-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Onest"; font-weight: 700; font-display: swap; src: url("fonts/onest-latin-700-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20BD, U+2190-21FF, U+2212, U+2215; }
@font-face { font-family: "JetBrains Mono"; font-weight: 700; font-display: swap; src: url("fonts/jetbrains-mono-latin-700-normal.woff2") format("woff2"); }

:root,
:root[data-theme="dark"],
.theme-snap[data-theme="dark"] {
  --bg: #0b1222;
  --surface: #121a2c;
  --surface-2: #19223a;
  --surface-3: #1f2a44;
  --border: #222d45;
  --border-strong: #2c3a57;
  --text: #f1f5f9;
  --text-muted: #8c99b0;
  --primary: #0ea5e9;
  --primary-2: #38bdf8;
  --on-primary: #04121f;
  --glow: 0 10px 28px -8px rgba(14, 165, 233, 0.65);
  --gold: #fbbf24;
  --violet: #a78bfa;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #f05252;
  --ring: #38bdf8;
  --star: rgba(255, 255, 255, 0.55);
  --tabbar-bg: #0f1729;
  color-scheme: dark;
}

:root[data-theme="light"],
.theme-snap[data-theme="light"] {
  --bg: #eef2f8;
  --surface: #ffffff;
  --surface-2: #f3f6fb;
  --surface-3: #e8eef7;
  --border: #dfe6f0;
  --border-strong: #cdd7e5;
  --text: #0b1222;
  --text-muted: #5e6b82;
  --primary: #0284c7;
  --primary-2: #0ea5e9;
  --on-primary: #ffffff;
  --glow: 0 10px 24px -10px rgba(2, 132, 199, 0.6);
  --gold: #d97706;
  --violet: #7c3aed;
  --success: #16a34a;
  --warning: #b45309;
  --danger: #dc2626;
  --ring: #0284c7;
  --star: rgba(30, 64, 120, 0.18);
  --tabbar-bg: #ffffff;
  color-scheme: light;
}

:root {
  --radius: 18px;
  --radius-md: 14px;
  --radius-sm: 11px;
  --gap: 10px;
  --tabbar-h: 62px;
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --font: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

* { box-sizing: border-box; }

html { background: var(--bg); }
body { background: transparent; } /* иначе фон body закрывает звёздное небо (z-index: -1) */

body {
  margin: 0;
  padding: 0 16px calc(var(--tabbar-h) + var(--safe-bottom) + 36px);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* Звёздное небо: несколько слоёв точек, фиксированных под контентом. */
.sky {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  transform: translateZ(0); will-change: transform; /* фон рисуется один раз и не перерисовывается при прокрутке */
  background-image:
    radial-gradient(1.5px 1.5px at 20px 30px, var(--star), transparent),
    radial-gradient(1px 1px at 90px 140px, var(--star), transparent),
    radial-gradient(2px 2px at 170px 60px, var(--star), transparent),
    radial-gradient(1px 1px at 240px 210px, var(--star), transparent),
    radial-gradient(1.5px 1.5px at 310px 110px, var(--star), transparent),
    radial-gradient(1px 1px at 60px 260px, var(--star), transparent),
    radial-gradient(1px 1px at 130px 330px, var(--star), transparent),
    radial-gradient(2px 2px at 280px 380px, var(--star), transparent),
    radial-gradient(1px 1px at 350px 290px, var(--star), transparent),
    radial-gradient(1.5px 1.5px at 200px 450px, var(--star), transparent),
    radial-gradient(1px 1px at 30px 420px, var(--star), transparent),
    radial-gradient(1px 1px at 330px 480px, var(--star), transparent);
  background-size: 380px 500px;
}
.sky::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 60% at 50% -10%, color-mix(in srgb, var(--primary) 12%, transparent), transparent 60%);
}

button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.icon { width: 20px; height: 20px; flex: none; display: block; }
.hidden { display: none !important; }
.grow { flex: 1; min-width: 0; }
.green { color: var(--success) !important; }
.blue { color: var(--primary-2) !important; }

/* --- Шапка ------------------------------------------------------------------------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0;
  margin: 0 -16px 4px; padding-left: 16px; padding-right: 16px;
  border-bottom: 1px solid var(--border);
  /* Шапка закреплена сверху и видна при прокрутке */
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(140%); backdrop-filter: blur(14px) saturate(140%);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-tile {
  width: 40px; height: 40px; flex: none; border-radius: 12px;
  display: grid; place-items: center;
  background: #0b1222; border: 1px solid var(--border-strong);
}
.brand-tile img { display: block; width: 28px; height: 28px; border-radius: 7px; }
.brand-name { font-weight: 600; font-size: 17px; letter-spacing: -0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 8px; }

.icon-btn {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}
.icon-btn:active { background: var(--surface-2); color: var(--text); }
.icon-btn .icon { width: 19px; height: 19px; }

/* --- Заголовки ---------------------------------------------------------------------- */

.hero-title, .page-title { font-weight: 700; letter-spacing: -0.4px; line-height: 1.2; }
.hero-title { font-size: 23px; margin: 18px 0 6px; }
.page-title { font-size: 22px; margin: 18px 0 14px; }
.hero-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; color: var(--text-muted); font-size: 14px; margin-bottom: 20px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; line-height: 24px; padding: 0 10px;
  border-radius: 999px; color: var(--primary-2);
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 40%, transparent);
}
.pill:empty { display: none; }
.pill .icon { width: 12px; height: 12px; fill: currentColor; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 2px 10px; color: var(--text-muted); font-size: 14px; font-weight: 500; }
.link { border: 0; background: none; color: var(--primary-2); font-size: 13px; display: inline-flex; align-items: center; gap: 4px; padding: 8px 0; }
.link .icon { width: 14px; height: 14px; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: var(--gap);
}
.card-title { font-weight: 600; font-size: 16px; margin-bottom: 12px; letter-spacing: -0.2px; }
.card-note { font-size: 13px; color: var(--text-muted); margin: -6px 0 12px; }

.tile-icon {
  width: 38px; height: 38px; flex: none; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-muted);
}
.tile-icon .icon { width: 19px; height: 19px; }
.tile-icon.gold { background: color-mix(in srgb, var(--gold) 16%, transparent); color: var(--gold); }
.tile-icon.gold .icon { fill: currentColor; }
.tile-icon.violet { background: color-mix(in srgb, var(--violet) 16%, transparent); color: var(--violet); }
.tile-icon.blue { background: color-mix(in srgb, var(--primary) 18%, transparent); color: var(--primary-2); }
.tile-icon.green { background: color-mix(in srgb, var(--success) 16%, transparent); color: var(--success); }
.tile-icon.red { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.tile-icon.amber { background: color-mix(in srgb, var(--warning) 16%, transparent); color: var(--warning); }

.product-card {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 14px; margin-bottom: var(--gap);
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color 0.2s var(--ease), transform 0.1s var(--ease);
}
.product-card:active { transform: scale(0.99); border-color: var(--border-strong); }
.product-card .grow { display: flex; flex-direction: column; gap: 2px; }
.product-name { font-weight: 600; font-size: 16px; letter-spacing: -0.2px; }
.product-sub { font-size: 13px; color: var(--text-muted); }
.chev { color: var(--text-muted); display: inline-flex; }
.chev .icon { width: 18px; height: 18px; }

.tiles { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--gap); margin-bottom: var(--gap); }
.tile {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px; text-align: left;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  min-width: 0;
}
.tile-label { display: flex; justify-content: space-between; align-items: center; color: var(--text-muted); font-size: 13px; }
.tile-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tile-row b { font-size: 19px; font-weight: 600; letter-spacing: -0.3px; min-width: 0; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-row small { display: block; color: var(--text-muted); font-size: 13px; }
.tile.wide { grid-column: span 2; }

/* --- Поля ------------------------------------------------------------------------- */

.field-label { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 10px; }
.field-label .icon { width: 16px; height: 16px; color: var(--primary-2); }

.input-row { display: flex; gap: 8px; }
.input-wrap { position: relative; flex: 1; min-width: 0; }
.input-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.input-icon .icon { width: 18px; height: 18px; }
.input-icon.gold { color: var(--gold); }
.input-icon.gold .icon { fill: currentColor; }

input {
  width: 100%; min-width: 0; height: 46px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 0 16px;
  font: inherit; font-size: 16px;
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.input-wrap input { padding-left: 42px; }
.amount input { font-size: 19px; font-weight: 700; }
input:focus { border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 22%, transparent); }
input::placeholder { color: var(--text-muted); }
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }

.search { margin-bottom: 14px; }
.search input { padding-left: 42px; height: 44px; }

.hint { font-size: 13px; color: var(--text-muted); margin-top: 8px; min-height: 20px; display: flex; align-items: center; gap: 6px; }
.hint .icon { width: 16px; height: 16px; }
.hint.ok { color: var(--success); }
.hint.bad { color: var(--danger); }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 44px; padding: 0 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-weight: 600; font-size: 15px;
  transition: background-color 0.2s var(--ease), opacity 0.2s var(--ease), transform 0.1s var(--ease), box-shadow 0.2s var(--ease);
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn .icon { width: 18px; height: 18px; }
.btn-primary { background: linear-gradient(180deg, var(--primary-2), var(--primary)); color: var(--on-primary); box-shadow: var(--glow); }
.btn-primary:disabled { opacity: 0.4; box-shadow: none; }
.btn-secondary { background: var(--surface-2); border-color: var(--border-strong); }
.btn-soft { background: color-mix(in srgb, var(--primary) 14%, var(--surface)); color: var(--primary-2); border-color: color-mix(in srgb, var(--primary) 22%, transparent); }
.btn-success { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, transparent); }
.btn-danger { background: transparent; border-color: color-mix(in srgb, var(--danger) 50%, transparent); color: var(--danger); }
.btn-info { background: var(--surface-2); border-color: var(--border-strong); }
.btn-block { width: 100%; min-height: 50px; font-size: 16px; border-radius: var(--radius); margin-bottom: var(--gap); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: var(--radius-sm); }

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

.segmented {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--gap);
}
.seg {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; border: 0; background: transparent;
  color: var(--text-muted); border-radius: var(--radius-sm);
  font-weight: 600; font-size: 14px;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}
.seg .icon { width: 16px; height: 16px; }
.seg.active { background: color-mix(in srgb, var(--primary) 16%, var(--surface-2)); color: var(--primary-2); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 35%, transparent); }
.seg.active[data-product="stars"] .icon { fill: currentColor; }

.presets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.preset {
  min-height: 40px; padding: 0 2px; font-size: 14px; white-space: nowrap;
  border: 1px solid var(--border-strong); background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-weight: 600; font-variant-numeric: tabular-nums;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.preset.active { border-color: var(--primary); color: var(--primary-2); background: color-mix(in srgb, var(--primary) 14%, var(--surface-2)); }

.months { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding-top: 12px; }
.month {
  position: relative; padding: 14px 6px 10px;
  border: 1px solid var(--border-strong); background: var(--surface-2);
  border-radius: var(--radius-md); text-align: center;
  transition: border-color 0.2s var(--ease);
}
.month b { display: block; font-size: 22px; line-height: 1.1; font-weight: 700; }
.month span { font-size: 12px; color: var(--text-muted); }
.month.active { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 14%, var(--surface-2)); }
.month.active b { color: var(--primary-2); }
.month .tag {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  font-size: 10px; font-weight: 700; line-height: 18px; padding: 0 7px; border-radius: 999px;
  background: var(--success); color: #04120a; white-space: nowrap;
}

.options { display: flex; flex-direction: column; gap: 8px; }
.option {
  display: flex; align-items: center; gap: 12px;
  min-height: 48px; padding: 0 12px;
  border: 1px solid var(--border-strong); background: var(--surface-2);
  border-radius: var(--radius-md); text-align: left;
  transition: border-color 0.2s var(--ease);
}
.option > .icon { color: var(--text-muted); }
.option .grow { font-weight: 600; }
.option .radio { width: 22px; height: 22px; border-radius: 50%; flex: none; border: 2px solid var(--border-strong); display: grid; place-items: center; }
.option.active { border-color: var(--primary); }
.option.active > .icon { color: var(--primary-2); }
.option.active .radio { border-color: var(--primary); background: var(--primary); color: var(--on-primary); }
.option.active .radio .icon { width: 14px; height: 14px; stroke-width: 3; }

.chips { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 34px; padding: 0 12px;
  border: 1px solid var(--border-strong); background: var(--surface);
  border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--text-muted); white-space: nowrap;
}
.chip.active { border-color: var(--primary); color: var(--primary-2); background: color-mix(in srgb, var(--primary) 14%, var(--surface)); }

/* --- Итог ------------------------------------------------------------------------- */

.summary-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; color: var(--text-muted); font-size: 14px; }
.summary-row.sub { margin-bottom: 8px; font-size: 14px; }
.summary-row .strike { text-decoration: line-through; }
.summary-row b { font-size: 24px; line-height: 1; font-weight: 700; color: var(--text); letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.summary .btn-block { margin-bottom: 0; }
.error { color: var(--danger); font-size: 14px; text-align: center; margin-top: 10px; }
.error:empty { display: none; }
.fineprint { font-size: 12px; color: var(--text-muted); text-align: center; margin-top: 12px; }
.fineprint.consent { margin-top: 8px; line-height: 1.45; }
.fineprint a { color: var(--primary-2); }
.mono { font-family: var(--mono); }

/* --- Списки ----------------------------------------------------------------------- */

.list { display: flex; flex-direction: column; gap: var(--gap); }
.item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px;
}
.item.col { flex-direction: column; align-items: stretch; gap: 10px; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.item-sub { font-size: 12px; margin-top: 2px; color: var(--text-muted); }
.item-price { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.item-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0 -14px -14px; padding: 10px 14px; border-top: 1px solid var(--border); }
.item code { font-size: 12px; color: var(--danger); word-break: break-word; white-space: pre-wrap; background: var(--surface-2); padding: 8px; border-radius: 10px; }

.status {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; line-height: 24px; padding: 0 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border-strong); white-space: nowrap;
}
.status .icon { width: 13px; height: 13px; }
.status.done { background: color-mix(in srgb, var(--success) 12%, transparent); color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, transparent); }
.status.error, .status.canceled { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.status.pending { background: color-mix(in srgb, var(--warning) 12%, transparent); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 40%, transparent); }
.status.paid, .status.processing { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary-2); border-color: color-mix(in srgb, var(--primary) 40%, transparent); }

.rank {
  width: 32px; height: 32px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
  font: 700 13px var(--mono);
  background: var(--surface-3); color: var(--text-muted);
}
.rank.r1 { background: linear-gradient(135deg, #fde68a, #f59e0b); color: #1c1203; }
.rank.r2 { background: linear-gradient(135deg, #f1f5f9, #94a3b8); color: #0b1222; }
.rank.r3 { background: linear-gradient(135deg, #fdba74, #c2410c); color: #fff; }
.rank:has(.animoji.live) { background: none; }
.rank .animoji { width: 32px; height: 32px; }

/* Анимированные эмодзи (animoji.js): пока анимация не загрузилась, виден обычный значок */
.animoji { display: inline-grid; place-items: center; width: 1.25em; height: 1.25em; vertical-align: -0.25em; line-height: 1; }
.animoji > * { grid-area: 1 / 1; }
.animoji.live > .animoji-fb { display: none; }
.animoji svg:not(.icon) { width: 100% !important; height: 100% !important; }
.tile-icon .animoji { width: 26px; height: 26px; }
.title-emoji .animoji-fb:empty, .title-emoji:not(.live) { display: none; }
.title-emoji.live { display: inline-grid; }

.empty { text-align: center; color: var(--text-muted); padding: 48px 16px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty .icon { width: 40px; height: 40px; opacity: 0.6; }

.skeleton { height: 72px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* --- Профиль ----------------------------------------------------------------------- */

.profile-head { display: flex; align-items: center; gap: 16px; }
.avatar {
  width: 50px; height: 50px; border-radius: 15px; flex: none; overflow: hidden;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary-2), #6366f1); color: #fff;
  font-weight: 700; font-size: 20px;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { font-weight: 700; font-size: 17px; letter-spacing: -0.3px; }

/* Группы пунктов, как разделы админки в BaobabVpn. */
.group {
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: var(--gap); overflow: hidden;
}
.group-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 16px; }
.badge-num {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff;
  background: linear-gradient(135deg, #34d399, #0ea5e9);
}
.badge-num.g2 { background: linear-gradient(135deg, #60a5fa, #f472b6); }
.badge-num.g3 { background: linear-gradient(135deg, #fbbf24, #f97316); }
.badge-num.g4 { background: linear-gradient(135deg, #a78bfa, #6366f1); }
.row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 48px; padding: 6px 14px;
  border: 0; background: transparent; text-align: left; font-size: 15px;
  transition: background-color 0.15s var(--ease);
}
.row:active { background: var(--surface-2); }
.row-icon {
  width: 30px; height: 30px; flex: none; border-radius: 9px;
  display: grid; place-items: center;
  border: 1px solid var(--border-strong); color: var(--primary-2);
}
.row-icon .icon { width: 16px; height: 16px; }
.row-icon.green { color: var(--success); }
.row-icon.amber { color: var(--warning); }
.row-icon.red { color: var(--danger); }
.row-icon.violet { color: var(--violet); }
.row-value { color: var(--text-muted); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-value.alert { color: var(--danger); font-weight: 600; }

/* --- Админка ---------------------------------------------------------------------- */

.mono-tiles { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin: 16px 0 18px; }
.mono-tile {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  background: var(--surface);
  min-width: 0;
}
.mono-tile > div { min-width: 0; }
.mono-tile > .icon { width: 20px; height: 20px; color: var(--text-muted); }
.mono-tile.green > .icon { color: var(--success); }
.mono-tile.blue > .icon { color: var(--primary-2); }
.mono-tile.amber > .icon { color: var(--warning); }
.mono-tile.red > .icon, .mono-tile.red b { color: var(--danger); }
.mono-tile b { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; font: 700 14px/1.3 var(--mono); }
.mono-tile span { display: block; font-size: 11px; color: var(--text-muted); }
.mono-tile .plus { display: inline-block; font: 700 11px var(--mono); color: var(--success); border: 1px solid color-mix(in srgb, var(--success) 45%, transparent); background: color-mix(in srgb, var(--success) 12%, transparent); border-radius: 6px; padding: 0 5px; line-height: 18px; }

.admin-title { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 12px; }
.admin-title h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; margin: 0; }
.online { display: inline-flex; align-items: center; gap: 7px; color: var(--text-muted); font-size: 13px; }
.online::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 8px var(--success); }
.online.off::before { background: var(--danger); box-shadow: 0 0 8px var(--danger); }

.back-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--primary-2); font-size: 14px; padding: 12px 0 0; min-height: 40px; }
.back-btn .icon { width: 18px; height: 18px; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.table td { padding: 10px 0; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: 0; }
.table td:not(:first-child) { text-align: right; padding-left: 8px; overflow-wrap: anywhere; }
.table .head td { font-size: 12px; color: var(--text-muted); }

.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.setting:last-child { border-bottom: 0; }
.setting-title { font-size: 14px; overflow-wrap: anywhere; flex: 1; min-width: 0; }
.setting input { width: 104px; height: 40px; flex: none; text-align: right; font-size: 16px; border-radius: var(--radius-sm); }
.setting input.wide { width: min(170px, 46%); text-align: left; }
.setting input.saved { border-color: var(--success); }

/* Свои картинки экранов бота */
.photo-setting { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.photo-setting:last-child { border-bottom: 0; }
.photo-setting.busy { opacity: 0.6; pointer-events: none; }
.photo-thumb { flex: none; width: 76px; height: 76px; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-3); overflow: hidden; display: grid; place-items: center; cursor: pointer; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-ph { color: var(--text-muted); display: grid; place-items: center; }
.photo-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.photo-body input { margin-top: 6px; height: 40px; font-size: 14px; border-radius: var(--radius-sm); }
.bc-photo-row { display: flex; gap: 8px; align-items: center; }
.bc-photo-row input { flex: 1; min-width: 0; }
.bc-photo-row .btn { flex: none; min-height: 44px; }

.switch { position: relative; width: 52px; height: 32px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); transition: background-color 0.2s var(--ease); pointer-events: none; }
.switch span::after { content: ""; position: absolute; width: 26px; height: 26px; left: 2px; top: 2px; border-radius: 50%; background: var(--text-muted); transition: transform 0.2s var(--ease), background-color 0.2s var(--ease); }
.switch input:checked + span { background: var(--success); border-color: var(--success); }
.switch input:checked + span::after { transform: translateX(20px); background: #fff; }
.switch input:focus-visible + span { outline: 2px solid var(--ring); outline-offset: 2px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* --- Нижнее меню: плавающая панель ------------------------------------------------- */

.tabbar {
  position: fixed; z-index: 20;
  left: 12px; right: 12px; bottom: calc(var(--safe-bottom) + 10px);
  display: flex; gap: 2px;
  height: var(--tabbar-h); padding: 6px;
  background: var(--tabbar-bg);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.6);
  transform: translateZ(0); /* своя GPU-слой: меню не перерисовывается при прокрутке */
}
.tab {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: transparent; border-radius: 17px;
  color: var(--text-muted);
  font-size: 11px; font-weight: 500;
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.tab .icon { width: 21px; height: 21px; stroke-width: 1.8; }
.tab span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tab.active { color: var(--primary-2); background: color-mix(in srgb, var(--primary) 18%, transparent); }

.toast {
  position: fixed; left: 16px; right: 16px;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 22px);
  animation: toast-in 0.25s var(--ease);
  z-index: 30;
  background: var(--text); color: var(--bg);
  border-radius: var(--radius-md); padding: 12px 16px;
  text-align: center; font-weight: 600; font-size: 14px;
}

/* --- Анимации ---------------------------------------------------------------------- */

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.18) translateY(-2px); } 100% { transform: scale(1); } }
@keyframes twinkle { from { opacity: 0.35; } to { opacity: 1; } }
@keyframes sheen { 0%, 70% { transform: translateX(-120%); } 100% { transform: translateX(220%); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.08); color: var(--primary-2); } 100% { transform: scale(1); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* Блоки экрана выезжают по очереди при каждом открытии вкладки. */
.panel:not(.hidden) > *,
.list > *, #admin-box > *, #admin-groups > *, #profile-box > *, #last-order > * { animation: rise 0.26s var(--ease) both; }
.panel:not(.hidden) > *:nth-child(2), .list > *:nth-child(2), #admin-box > *:nth-child(2), #admin-groups > *:nth-child(2), #profile-box > *:nth-child(2) { animation-delay: 0.02s; }
.panel:not(.hidden) > *:nth-child(3), .list > *:nth-child(3), #admin-box > *:nth-child(3), #admin-groups > *:nth-child(3), #profile-box > *:nth-child(3) { animation-delay: 0.04s; }
.panel:not(.hidden) > *:nth-child(4), .list > *:nth-child(4), #admin-box > *:nth-child(4), #profile-box > *:nth-child(4) { animation-delay: 0.06s; }
.panel:not(.hidden) > *:nth-child(5), .list > *:nth-child(5), #admin-box > *:nth-child(5), #profile-box > *:nth-child(5) { animation-delay: 0.08s; }
.panel:not(.hidden) > *:nth-child(6), .list > *:nth-child(6), #admin-box > *:nth-child(6), #profile-box > *:nth-child(6) { animation-delay: 0.1s; }
.panel:not(.hidden) > *:nth-child(n+7), .list > *:nth-child(n+7), #admin-box > *:nth-child(n+7) { animation-delay: 0.12s; }

.tab.active .icon { animation: pop 0.35s var(--ease); }
.tab:active { transform: scale(0.94); }
.product-card:active, .tile:active, .row:active, .preset:active, .month:active, .option:active { transform: scale(0.98); }
.tile, .preset, .month, .option { transition: transform 0.06s var(--ease), border-color 0.2s var(--ease), background-color 0.2s var(--ease); }

/* Звёзды мерцают: второй слой точек со сдвигом. */
.sky::before {
  content: ""; position: absolute; inset: 0;
  background-image: inherit; background-size: 380px 500px; background-position: 190px 250px;
  animation: twinkle 3.5s ease-in-out infinite alternate;
  will-change: opacity; /* мерцание только меняет прозрачность слоя, без перерисовки */
}

/* Блик по кнопке оплаты, когда она активна. */
.btn-primary { position: relative; overflow: hidden; }
.btn-primary:not(:disabled)::after {
  content: ""; position: absolute; inset: 0; width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  animation: sheen 3.2s ease-in-out infinite;
}
.bump { display: inline-block; animation: bump 0.35s var(--ease); }

/* Дальние звёзды: мелкий слой с другим шагом, чтобы узор не повторялся заметно */
.stars-far {
  position: absolute; inset: 0; opacity: 0.7;
  background-image:
    radial-gradient(1px 1px at 15px 40px, var(--star), transparent),
    radial-gradient(1px 1px at 75px 180px, var(--star), transparent),
    radial-gradient(1px 1px at 140px 95px, var(--star), transparent),
    radial-gradient(1.2px 1.2px at 205px 250px, var(--star), transparent),
    radial-gradient(1px 1px at 250px 20px, var(--star), transparent),
    radial-gradient(1px 1px at 40px 300px, var(--star), transparent),
    radial-gradient(1px 1px at 180px 330px, var(--star), transparent),
    radial-gradient(1px 1px at 110px 260px, var(--star), transparent);
  background-size: 270px 340px;
  animation: twinkle 5s ease-in-out infinite alternate-reverse;
  will-change: opacity;
}

/* Падающие звёзды: светящийся хвост летит по диагонали, потом долгая пауза */
.meteor {
  position: absolute; top: 0; left: 0; width: 120px; height: 1.5px; border-radius: 1px; opacity: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--star) 70%, transparent) 70%, var(--star));
  filter: drop-shadow(0 0 4px var(--star));
  transform-origin: 100% 50%;
  animation: meteor 9s linear infinite;
  will-change: transform, opacity;
}
.meteor::after {
  content: ""; position: absolute; right: -1px; top: 50%; width: 3px; height: 3px; border-radius: 50%;
  background: var(--star); transform: translateY(-50%); box-shadow: 0 0 6px 1px var(--star);
}
.m1 { --x: 62vw; --y: 6vh; animation-delay: 1.5s; }
.m2 { --x: 92vw; --y: 22vh; animation-delay: 5.5s; animation-duration: 11s; }
.m3 { --x: 40vw; --y: 2vh; animation-delay: 8s; animation-duration: 13s; }
.m4 { --x: 80vw; --y: 48vh; animation-delay: 3s; animation-duration: 15s; width: 80px; }
@keyframes meteor {
  0% { opacity: 0; transform: translate(var(--x), var(--y)) rotate(145deg) translateX(0); }
  2% { opacity: 1; }
  9% { opacity: 0; transform: translate(var(--x), var(--y)) rotate(145deg) translateX(340px); }
  100% { opacity: 0; transform: translate(var(--x), var(--y)) rotate(145deg) translateX(340px); }
}

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

@media (max-width: 360px) {
  body, .theme-snap :is(.list, #admin-box, #admin-groups, #profile-box, #last-order) > *,
.theme-snap .tab.active .icon, .theme-snap .bump, .theme-snap .btn-edit.open .btn-body { animation: none; }
.snap-body { padding-left: 12px; padding-right: 12px; }
  .topbar { margin-left: -12px; margin-right: -12px; padding-left: 12px; padding-right: 12px; }
  .tab { font-size: 10px; }
  .hero-title { font-size: 21px; }
  .presets { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 600px) {
  main { max-width: 560px; margin-left: auto; margin-right: auto; }
  .topbar > * { max-width: 560px; }
  .tabbar { max-width: 560px; margin: 0 auto; }
}
#last-order .item { margin-bottom: var(--gap); }

/* --- Свои кнопки в меню бота ------------------------------------------------------- */

.btn-edit { display: flex; flex-direction: column; gap: 8px; margin-bottom: 0; }
.btn-edit .item-head { margin-bottom: 2px; }
.btn-grid { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 8px; }
.btn-grid input[data-f="emoji"] { text-align: center; padding: 0; font-size: 20px; }
.btn-edit .setting { padding: 6px 0; }
.btn-edit .chips { margin: 2px 0 0; flex-wrap: wrap; overflow: visible; }
.icon-btn.sm { width: 34px; height: 34px; border-radius: 10px; }
.icon-btn.sm .icon { width: 16px; height: 16px; }
.icon-btn:disabled { opacity: 0.35; }
.icon-btn.danger { color: var(--danger); }
.tg-preview { display: flex; flex-direction: column; gap: 6px; }
.tg-row { display: flex; gap: 6px; }
.tg-btn {
  flex: 1; min-width: 0; text-align: center; font-size: 13px; font-weight: 600;
  padding: 9px 8px; border-radius: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: var(--surface-3); color: var(--text);
}
.pos-seg { margin: 2px 0 0; }
.pos-seg .seg { min-height: 36px; font-size: 13px; }
.tg-btn.std { background: transparent; border: 1px dashed var(--border-strong); color: var(--text-muted); font-weight: 500; }
.btn-list { gap: 8px; margin-bottom: var(--gap); }
.btn-edit { padding: 10px 10px 10px 12px; gap: 0; }
.btn-edit.off { opacity: 0.6; }
.btn-head { display: flex; align-items: center; gap: 8px; }
.btn-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 2px 0; text-align: left; }
.btn-toggle .grow { display: flex; flex-direction: column; min-width: 0; }
.btn-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-toggle .item-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-emoji { width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); font-size: 18px; }
.btn-body { display: none; flex-direction: column; gap: 8px; margin-top: 10px; }
.btn-edit.open .btn-body { display: flex; animation: rise 0.2s var(--ease); }
.btn-edit.open { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.btn-body .btn-danger { align-self: flex-start; }

/* --- Рассылки ------------------------------------------------------------------------ */

.bc-list { margin-top: var(--gap); gap: 8px; }
.bc-card { width: 100%; text-align: left; border: 1px solid var(--border); font: inherit; color: inherit; }
.bc-card .item-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-card .item-main { min-width: 0; }
.bc-stats { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-muted); }
.bc-stats .icon { width: 13px; height: 13px; }
.bc-progress { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin: 8px 0 4px; }
.bc-progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-2)); transition: width 0.4s var(--ease); }
.alert-text { color: var(--danger) !important; }
.bc-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.bc-form { display: flex; flex-direction: column; gap: 8px; }
.bc-form .field-label { margin: 6px 0 0; }
.bc-form .field-label:first-child { margin-top: 0; }
.bc-form .hint { margin-top: 0; min-height: 0; }
.bc-form .chips { margin-bottom: 0; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.bc-sub { margin-top: 4px !important; }
.bc-triggers { display: flex; flex-direction: column; gap: 6px; }
.bc-trigger {
  display: flex; flex-direction: column; gap: 2px; text-align: left; font: inherit; color: var(--text);
  padding: 10px 12px; border-radius: var(--radius-md); border: 1px solid var(--border-strong); background: var(--surface-2);
}
.bc-trigger b { font-size: 14px; font-weight: 600; }
.bc-trigger.active { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, var(--surface)); }
.bc-delay { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 8px; align-items: center; }
.bc-delay input { height: 40px; text-align: center; }
.bc-preview { background: var(--surface-2); border-radius: 14px 14px 14px 4px; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.bc-preview img { width: 100%; border-radius: 10px; display: block; }
.bc-pv-ph { display: flex; align-items: center; justify-content: center; gap: 6px; height: 120px; border-radius: 10px; background: var(--surface-3); color: var(--text-muted); font-size: 13px; }
.bc-pv-text { padding: 2px 6px; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; }
.bc-pv-text a { color: var(--primary-2); }
.bc-pv-text tg-spoiler { background: var(--surface-3); color: transparent; border-radius: 4px; }
.bc-pv-text blockquote { border-left: 3px solid var(--primary); padding-left: 8px; margin: 4px 0; }
.bc-actions { display: flex; flex-direction: column; gap: 8px; margin-top: var(--gap); }
.bc-actions .btn-sm { align-self: center; margin-top: 4px; }

/* Визуальный редактор текста рассылки */
.rte-tools { display: flex; gap: 6px; margin-bottom: 8px; }
.rte-btn {
  flex: 1 1 0; min-width: 34px; max-width: 48px; height: 36px; display: grid; place-items: center; border-radius: 10px; font: inherit; font-size: 16px;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
}
.rte-btn .icon { width: 17px; height: 17px; }
.rte-btn.active { border-color: var(--primary); color: var(--primary-2); background: color-mix(in srgb, var(--primary) 16%, var(--surface)); }
.rte-link { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; margin-bottom: 8px; }
.rte-link input { height: 40px; }
.rte-link .btn { min-height: 40px; }
.rte {
  min-height: 140px; max-height: 50vh; overflow-y: auto; padding: 12px 14px; outline: none;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  border-radius: var(--radius-md); font-size: 16px; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-wrap;
  -webkit-user-select: text; user-select: text;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.rte:focus { border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 22%, transparent); }
.rte.empty::before { content: attr(data-placeholder); color: var(--text-muted); pointer-events: none; }
.rte a, .bc-pv-text a { color: var(--primary-2); text-decoration: underline; }
.rte .tg-spoiler { background: color-mix(in srgb, var(--text-muted) 35%, transparent); border-radius: 4px; padding: 0 2px; }

/* Дата и время: на iPhone поле шире экрана, если не ограничить */
.bc-when { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.bc-form, .bc-form > * { min-width: 0; max-width: 100%; }
.bc-date { position: relative; display: block; min-width: 0; }
.bc-date .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-muted); pointer-events: none; }
.bc-date input { -webkit-appearance: none; appearance: none; display: block; width: 100%; min-width: 0; max-width: 100%; padding-left: 42px; text-align: left; }
.bc-date input::-webkit-date-and-time-value { text-align: left; }
.bc-delay .chips { margin: 0; }

/* Поля не мельче 16px: иначе iPhone приближает экран при вводе */
input, textarea, select, .rte { font-size: max(16px, 1em); }
main { overflow-x: clip; }

/* Кнопки под сообщением рассылки */
.bc-buttons { display: flex; flex-direction: column; gap: 8px; }
.bc-buttons:empty { display: none; }
.bc-btn-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 8px; border-radius: var(--radius-md); background: var(--surface-2); border: 1px solid var(--border); }
.bc-btn-fields { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.bc-btn-fields input { height: 40px; padding: 0 12px; background: var(--surface); }
.bc-btn-side { display: flex; flex-direction: column; gap: 6px; }
.bc-btn-target { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); padding: 0 4px; }
.bc-btn-target .icon { width: 14px; height: 14px; flex: none; color: var(--primary-2); }
.chip-add { border-style: dashed; display: inline-flex; align-items: center; gap: 4px; }
.chip-add .icon { width: 14px; height: 14px; }

/* --- Дашборд --------------------------------------------------------------------------- */

:root { --chart-1: #0b8fd0; --c-stars: #c47a0c; --c-premium: #8b5cf6; }
.dash-period { margin-bottom: 12px; }
#dash { transition: opacity 0.2s var(--ease); }
#dash.loading { opacity: 0.45; }
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: var(--gap); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg, 18px); padding: 12px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kpi-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.kpi-top .tile-icon { width: 28px; height: 28px; border-radius: 9px; flex: none; }
.kpi-top .tile-icon .icon { width: 15px; height: 15px; }
.kpi-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.kpi-foot { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-size: 12px; }
.kpi-note { color: var(--text-muted); }
.delta { font-weight: 600; }
.delta.up { color: var(--success); }
.delta.down { color: var(--danger); }
.delta.flat { color: var(--text-muted); font-weight: 500; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head b { font-size: 15px; }
.card-head .item-sub { display: inline-flex; align-items: center; gap: 2px; text-align: right; }
.card-head .item-sub .icon { width: 14px; height: 14px; }
.dash-metrics { margin-bottom: 8px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; overflow: visible; }
.dash-metrics .chip { padding: 0 4px; }
.chart { position: relative; width: 100%; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .grid.zero { stroke: var(--border-strong); }
.chart .tick { fill: var(--text-muted); font-size: 10px; font-family: inherit; font-variant-numeric: tabular-nums; }
.chart .bar { transition: opacity 0.15s var(--ease); }
.chart .bar.dim { opacity: 0.35; }
.chart-tip {
  position: absolute; top: -4px; transform: translate(-50%, -100%); pointer-events: none; z-index: 2;
  background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 10px; padding: 6px 10px;
  display: flex; flex-direction: column; align-items: center; white-space: nowrap; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.chart-tip b { font-size: 14px; font-variant-numeric: tabular-nums; }
.chart-tip span { font-size: 11px; color: var(--text-muted); }
.chart-placeholder { min-height: 170px; }
.home-chart { display: block; width: 100%; text-align: left; font: inherit; color: inherit; margin-bottom: var(--gap); }
.split { display: flex; gap: 2px; height: 14px; border-radius: 7px; overflow: hidden; margin-bottom: 12px; background: var(--surface-3); }
.split span { display: block; min-width: 0; }
.split-stars { background: var(--c-stars); }
.split-premium { background: var(--c-premium); }
.split-empty { flex: 1; }
.legend { display: flex; flex-direction: column; gap: 8px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.legend-row .key { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.legend-row b { font-variant-numeric: tabular-nums; }
.legend-row .item-sub { min-width: 92px; text-align: right; }
.legend-foot { margin-top: 10px; }
.hbar { margin-bottom: 10px; }
.hbar:last-child { margin-bottom: 0; }
.hbar-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 5px; }
.hbar-head b { font-variant-numeric: tabular-nums; font-weight: 600; }
.hbar-track { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.hbar-track span { display: block; height: 100%; border-radius: 4px; transition: width 0.5s var(--ease); }
.status-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.status-cell { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 10px; border-radius: var(--radius-md); background: var(--surface-2); }
.status-cell .status { font-size: 11px; }
.dash-sub { margin: 14px 0 8px; }
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; text-align: center; }
.mini-stats div { display: flex; flex-direction: column; gap: 2px; padding: 10px 4px; border-radius: var(--radius-md); background: var(--surface-2); }
.mini-stats b { font-size: 18px; font-variant-numeric: tabular-nums; }
.mini-stats span { font-size: 12px; color: var(--text-muted); }

/* Клавиатура открыта: нижнее меню уезжает вниз и не мешает вводу */
.tabbar { transition: transform 0.2s var(--ease), opacity 0.2s var(--ease); }
body.kb-open .tabbar { transform: translateY(calc(100% + 40px)); opacity: 0; pointer-events: none; }

/* Тему поменял Telegram: цвета плавно перетекают */
.theme-fade, .theme-fade *, .theme-fade *::before, .theme-fade *::after {
  transition: background-color 0.45s ease, color 0.45s ease, border-color 0.45s ease, fill 0.45s ease, stroke 0.45s ease, box-shadow 0.45s ease !important;
}
/* Тему поменяли кнопкой: копия страницы уже в новой теме раскрывается кругом от кнопки поверх старой */
.theme-snap {
  position: fixed; inset: 0; z-index: 9999; pointer-events: none; overflow: hidden;
  transform: translateZ(0); /* фиксированные элементы копии (небо, меню) встают относительно неё */
  background: var(--bg); color: var(--text);
  font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased;
  clip-path: circle(0px at 50% 0); will-change: clip-path;
}
.snap-body { padding: 0 16px calc(var(--tabbar-h) + var(--safe-bottom) + 36px); }

/* --- Платежи и платёжные методы ------------------------------------------------------ */

.pay-tiles .tile { cursor: pointer; transition: border-color 0.2s var(--ease); }
.pay-tile.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.pay-item { gap: 6px; }
.pay-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pay-provider { font-weight: 600; }
.pay-item .actions { flex-wrap: wrap; }
.pay-id { max-width: 100%; min-width: 0; }
.pay-id span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; max-width: 190px; }
.pm-card .btn-head .actions { align-items: center; }
.pm-card.off .btn-head .switch { opacity: 1; }
.pm-badges { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 2px; }
.pm-badge {
  font-size: 12px; padding: 2px 9px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-muted); border: 1px solid var(--border);
}
.pm-badge.on { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, transparent); }
.pm-badge.warn { background: color-mix(in srgb, var(--warning) 14%, transparent); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 40%, transparent); }
.pm-card .btn-body .field-label { margin: 6px 0 0; }
.pm-limits { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.pm-card .hint { align-items: flex-start; color: var(--warning); margin: 0; }
.pm-card .hint .icon { flex: none; margin-top: 1px; }
.switch input:disabled { cursor: not-allowed; }
.switch input:disabled + span { opacity: 0.5; }

/* Оферта и политика внутри Mini App */
.legal-doc { font-size: 14px; line-height: 1.55; }
.legal-doc h1 { font-size: 22px; line-height: 1.25; margin: 0 0 4px; }
.legal-doc h2 { font-size: 16px; margin: 20px 0 6px; padding-top: 14px; border-top: 1px solid var(--border); }
.legal-doc p, .legal-doc li { overflow-wrap: anywhere; margin: 0 0 8px; }
.legal-doc ul { padding-left: 20px; margin: 0 0 8px; }
.legal-doc .muted { color: var(--text-muted); font-size: 13px; }
.legal-doc a { color: var(--primary-2); }

/* --- Скидка постоянного покупателя и рефералы (профиль) ---------------------------------- */

.loyalty .card-head b, .referral .card-head b { display: inline-flex; align-items: center; gap: 8px; }
.loyalty .card-head .icon, .referral .card-head .icon { width: 18px; height: 18px; color: var(--gold); }
.pill.on { color: var(--success); background: color-mix(in srgb, var(--success) 14%, transparent); border-color: color-mix(in srgb, var(--success) 40%, transparent); }
.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin: 4px 0 10px; }
.progress i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--gold)); transition: width 0.4s ease; }
.levels { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.levels span { font-size: 12px; padding: 4px 8px; border-radius: 8px; background: var(--surface-2); color: var(--text-muted); }
.levels span.on { color: var(--success); background: color-mix(in srgb, var(--success) 12%, transparent); }
.ref-link {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  margin: 12px 0; padding: 12px 14px; border-radius: 12px; border: 1px dashed var(--border-strong);
  background: var(--surface-2); color: var(--text); font-size: 13px; text-align: left; min-height: 44px;
}
.ref-link .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ref-link .icon { width: 18px; height: 18px; flex: none; color: var(--primary-2); }
.ref-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.ref-stats div { display: flex; flex-direction: column; gap: 2px; padding: 10px; border-radius: 12px; background: var(--surface-2); min-width: 0; }
.ref-stats b { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref-stats span { font-size: 12px; color: var(--text-muted); }

/* --- Админка: здоровье, покупатели, промокоды, отчёт ------------------------------------- */

.health-banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; margin: 0 0 12px; font-size: 14px;
  background: color-mix(in srgb, var(--danger) 12%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); }
.health-banner.warn { background: color-mix(in srgb, var(--warning) 12%, transparent); border-color: color-mix(in srgb, var(--warning) 40%, transparent); }
.health-banner .icon { width: 20px; height: 20px; flex: none; color: var(--danger); }
.health-banner.warn .icon { color: var(--warning); }
.health-banner button { margin-left: auto; }
.cust-item { cursor: pointer; text-align: left; width: 100%; }
.cust-item .item-sub { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.note-area { width: 100%; min-height: 84px; resize: vertical; font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
.promo-code { font-family: var(--mono); font-weight: 700; letter-spacing: 0.5px; }
.promo-form { display: grid; gap: 10px; }
.promo-form .two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.promo-form input, .promo-form select { width: 100%; }
.report-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.report-table th { text-align: right; font-weight: 500; color: var(--text-muted); padding: 6px 4px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.report-table td { text-align: right; padding: 8px 4px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.report-table th:first-child, .report-table td:first-child { text-align: left; }
.report-scroll { overflow-x: auto; margin: 0 -4px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--primary-2); font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.item-sub > .icon { width: 13px; height: 13px; vertical-align: -2px; }
.cust-item.off { opacity: 0.6; }
.table .alert, .report-table .alert, b.alert, span.alert { color: var(--danger); }
.nowrap { white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.nowrap svg { width: 14px; height: 14px; }
