/* ──────── Базовые переменные тем ──────── */
:root {
  --bg: #0f1320;
  --bg-elev: #1a1f33;
  --bg-card: #1e2438;
  --border: rgba(255, 255, 255, 0.08);
  --text: #eef0f7;
  --text-dim: #8b91a8;
  --text-faint: #5a607a;
  --accent: #6aa7ff;
  --accent-2: #a78bfa;
  /* Кнопка-«главное действие» (Установить подписку) и фон чипов. Вынесены в
     переменные ради скинов: в graphite главная кнопка белая, в aurora —
     градиент, и хардкод синего тут ломал бы обе. */
  --btn-primary-bg: #2f81f7;
  --btn-primary-fg: #ffffff;
  --chip-bg: #262d45;
  --bg-image: none;
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.16);
  --warning: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.4);
}

html[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --border: rgba(0, 0, 0, 0.06);
  --text: #1a1d2c;
  --text-dim: #5e667e;
  --text-faint: #98a0b8;
  --accent: #2563eb;
  --accent-2: #7c3aed;
  --btn-primary-bg: #2563eb;
  --btn-primary-fg: #ffffff;
  --chip-bg: #eef1f8;
  --bg-image: none;
  --success: #16a34a;
  --success-bg: rgba(22, 163, 74, 0.12);
  --shadow: 0 4px 16px -4px rgba(0, 0, 0, 0.08);
}

/* ──────── Скины (темы) Mini App ────────
   Тема выбирается в админке: Настройки → «Тема Mini App». Значение приезжает
   в /api/v1/miniapp/config полем `theme` и кладётся в <html data-skin="…">.
   Светлая/тёмная схема — отдельная ось (<html data-theme="dark|light">),
   поэтому каждый скин описан ДВАЖДЫ, целиком: селекторы [data-skin][data-theme]
   равны по весу, и «недосказанная» половина молча взяла бы цвета соседа.

   Правило палитры: поверхности (фон, карточки, чипы) почти нейтральные, с
   еле заметным оттенком; цвет темы живёт в акценте, главной кнопке и
   картинке шапки (`--hero-art`, файлы в miniapp/art/). Первый заход был
   другим — в цвет темы красилось всё подряд, и светлый «Изумруд» выглядел
   залитым зелёнкой, а не зелёной темой.

   Общие для обеих схем величины (тени, семантические цвета, картинка шапки)
   вынесены в блок [data-skin] без схемы — он слабее по весу, поэтому схема
   при желании его перебивает.

   ⚠️ Список id должен совпадать с MINIAPP_THEMES на бэке
   (brain/app/services/miniapp_theme.py) — иначе админ выберет тему, которой
   в CSS нет, и клиент увидит голый :root. Сторож — brain/tests/test_miniapp_theme.py. */

/* Семантика (успех/ошибка/предупреждение) от темы не зависит: зелёное
   «активна» и красное «истекла» должны читаться одинаково везде. */
html[data-theme="dark"] {
  --success: #4ade80;
  --success-bg: rgba(74, 222, 128, 0.15);
  --warning: #fbbf24;
  --danger: #fb7185;
  --shadow: 0 10px 30px -14px rgba(0, 0, 0, 0.7);
}
html[data-theme="light"] {
  --success: #16a34a;
  --success-bg: rgba(22, 163, 74, 0.12);
  --warning: #b45309;
  --danger: #dc2626;
  --shadow: 0 8px 24px -16px rgba(15, 23, 42, 0.35);
}


/* ── classic: то, что было до появления тем (спокойный синий) ── */
html[data-skin="classic"] { --hero-art: url("./art/classic.svg"); }
html[data-skin="classic"][data-theme="dark"] {
  --bg: #0d1017;
  --bg-image: radial-gradient(120% 55% at 50% 0%, rgba(45,110,220,0.16), transparent 70%);
  --bg-elev: #161b26;
  --bg-card: #171d29;
  --chip-bg: #1f2735;
  --border: rgba(255,255,255,0.08);
  --text: #eaeef5;
  --text-dim: #98a2b8;
  --text-faint: #6b7488;
  --accent: #4d9bff;
  --accent-2: #8b9dff;
  --btn-primary-bg: #2f81f7;
  --btn-primary-fg: #ffffff;
  --radius: 16px;
  --radius-sm: 11px;
}
html[data-skin="classic"][data-theme="light"] {
  --bg: #f5f6f9;
  --bg-image: radial-gradient(120% 55% at 50% 0%, rgba(37,99,235,0.10), transparent 70%);
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --chip-bg: #eef1f6;
  --border: rgba(15,23,42,0.08);
  --text: #12172a;
  --text-dim: #5b6478;
  --text-faint: #949cae;
  --accent: #2563eb;
  --accent-2: #4f46e5;
  --btn-primary-bg: #2563eb;
  --btn-primary-fg: #ffffff;
  --radius: 16px;
  --radius-sm: 11px;
}

/* ── graphite: чёрный фон, белая главная кнопка, фиолетовый акцент ── */
html[data-skin="graphite"] { --hero-art: url("./art/graphite.svg"); }
html[data-skin="graphite"][data-theme="dark"] {
  --bg: #000000;
  --bg-image: radial-gradient(120% 55% at 50% 0%, rgba(120,90,220,0.10), transparent 70%);
  --bg-elev: #121214;
  --bg-card: #1a1a1d;
  --chip-bg: #232326;
  --border: rgba(255,255,255,0.07);
  --text: #f5f5f7;
  --text-dim: #a1a1aa;
  --text-faint: #6f6f78;
  --accent: #a78bfa;
  --accent-2: #c084fc;
  --btn-primary-bg: #ffffff;
  --btn-primary-fg: #0a0a0b;
  --radius: 20px;
  --radius-sm: 14px;
}
html[data-skin="graphite"][data-theme="light"] {
  --bg: #f2f2f5;
  --bg-image: radial-gradient(120% 55% at 50% 0%, rgba(124,58,237,0.08), transparent 70%);
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --chip-bg: #ebebf0;
  --border: rgba(0,0,0,0.07);
  --text: #101014;
  --text-dim: #6b6b76;
  --text-faint: #9a9aa5;
  --accent: #7c3aed;
  --accent-2: #a855f7;
  --btn-primary-bg: #101014;
  --btn-primary-fg: #ffffff;
  --radius: 20px;
  --radius-sm: 14px;
}

/* ── aurora: фиолетово-розовый, градиентные кнопки ── */
html[data-skin="aurora"] { --hero-art: url("./art/aurora.svg"); }
html[data-skin="aurora"][data-theme="dark"] {
  --bg: #0e0a17;
  --bg-image: radial-gradient(120% 55% at 50% 0%, rgba(168,85,247,0.14), transparent 70%);
  --bg-elev: #171122;
  --bg-card: #1a1327;
  --chip-bg: #241a35;
  --border: rgba(255,255,255,0.09);
  --text: #f3effa;
  --text-dim: #a99dc0;
  --text-faint: #786d8e;
  --accent: #d97ef7;
  --accent-2: #a78bfa;
  --btn-primary-bg: linear-gradient(135deg,#a855f7,#ec4899);
  --btn-primary-fg: #ffffff;
  --radius: 18px;
  --radius-sm: 12px;
}
html[data-skin="aurora"][data-theme="light"] {
  --bg: #f7f5fb;
  --bg-image: radial-gradient(120% 55% at 50% 0%, rgba(168,85,247,0.10), transparent 70%);
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --chip-bg: #f0ecf8;
  --border: rgba(88,28,135,0.10);
  --text: #211a30;
  --text-dim: #6a6280;
  --text-faint: #9d97ae;
  --accent: #9333ea;
  --accent-2: #7c3aed;
  --btn-primary-bg: linear-gradient(135deg,#a855f7,#ec4899);
  --btn-primary-fg: #ffffff;
  --radius: 18px;
  --radius-sm: 12px;
}

/* ── ocean: глубокая синь с бирюзой ── */
html[data-skin="ocean"] { --hero-art: url("./art/ocean.svg"); }
html[data-skin="ocean"][data-theme="dark"] {
  --bg: #071016;
  --bg-image: radial-gradient(120% 55% at 50% 0%, rgba(14,165,233,0.14), transparent 70%);
  --bg-elev: #0e1a23;
  --bg-card: #101f2a;
  --chip-bg: #172b38;
  --border: rgba(255,255,255,0.08);
  --text: #e8f3fa;
  --text-dim: #93aab9;
  --text-faint: #667f8f;
  --accent: #38bdf8;
  --accent-2: #22d3ee;
  --btn-primary-bg: #0ea5e9;
  --btn-primary-fg: #04131c;
  --radius: 16px;
  --radius-sm: 11px;
}
html[data-skin="ocean"][data-theme="light"] {
  --bg: #f4f7fa;
  --bg-image: radial-gradient(120% 55% at 50% 0%, rgba(2,132,199,0.09), transparent 70%);
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --chip-bg: #eaf0f6;
  --border: rgba(2,132,199,0.10);
  --text: #0d1f2b;
  --text-dim: #556a7a;
  --text-faint: #8ea3b2;
  --accent: #0284c7;
  --accent-2: #0891b2;
  --btn-primary-bg: #0284c7;
  --btn-primary-fg: #ffffff;
  --radius: 16px;
  --radius-sm: 11px;
}

/* ── emerald: тёмно-зелёный с мятным акцентом ── */
html[data-skin="emerald"] { --hero-art: url("./art/emerald.svg"); }
html[data-skin="emerald"][data-theme="dark"] {
  --bg: #08110d;
  --bg-image: radial-gradient(120% 55% at 50% 0%, rgba(16,185,129,0.13), transparent 70%);
  --bg-elev: #101b16;
  --bg-card: #12201a;
  --chip-bg: #1a2c24;
  --border: rgba(255,255,255,0.08);
  --text: #e9f6f0;
  --text-dim: #97b3a8;
  --text-faint: #6a8479;
  --accent: #34d399;
  --accent-2: #a3e635;
  --btn-primary-bg: #10b981;
  --btn-primary-fg: #04140e;
  --radius: 16px;
  --radius-sm: 11px;
}
html[data-skin="emerald"][data-theme="light"] {
  --bg: #f5f7f6;
  --bg-image: radial-gradient(120% 55% at 50% 0%, rgba(5,150,105,0.09), transparent 70%);
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --chip-bg: #ecf1ee;
  --border: rgba(5,150,105,0.11);
  --text: #0d1f18;
  --text-dim: #577066;
  --text-faint: #8fa79c;
  --accent: #059669;
  --accent-2: #65a30d;
  --btn-primary-bg: #059669;
  --btn-primary-fg: #ffffff;
  --radius: 16px;
  --radius-sm: 11px;
}

/* ── sunset: тёплый тёмный, оранжево-розовый ── */
html[data-skin="sunset"] { --hero-art: url("./art/sunset.svg"); }
html[data-skin="sunset"][data-theme="dark"] {
  --bg: #120c09;
  --bg-image: radial-gradient(120% 55% at 50% 0%, rgba(249,115,22,0.14), transparent 70%);
  --bg-elev: #1e1512;
  --bg-card: #221814;
  --chip-bg: #2e211b;
  --border: rgba(255,255,255,0.09);
  --text: #fbefe8;
  --text-dim: #c0a598;
  --text-faint: #8e766a;
  --accent: #fb923c;
  --accent-2: #f472b6;
  --btn-primary-bg: linear-gradient(135deg,#f97316,#f43f5e);
  --btn-primary-fg: #ffffff;
  --radius: 18px;
  --radius-sm: 12px;
}
html[data-skin="sunset"][data-theme="light"] {
  --bg: #faf6f3;
  --bg-image: radial-gradient(120% 55% at 50% 0%, rgba(234,88,12,0.09), transparent 70%);
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --chip-bg: #f4ede8;
  --border: rgba(194,65,12,0.10);
  --text: #2a1a12;
  --text-dim: #74604f;
  --text-faint: #a6907f;
  --accent: #ea580c;
  --accent-2: #db2777;
  --btn-primary-bg: linear-gradient(135deg,#f97316,#f43f5e);
  --btn-primary-fg: #ffffff;
  --radius: 18px;
  --radius-sm: 12px;
}

/* ── snow: светлая всегда, независимо от темы клиента ── */
html[data-skin="snow"] { --hero-art: url("./art/snow.svg"); }
/* «Снег» светлый в обеих схемах — так тема и задумана;
   app.js для неё дополнительно держит data-theme="light". */
html[data-skin="snow"][data-theme="dark"],
html[data-skin="snow"][data-theme="light"] {
  --bg: #f4f5f8;
  --bg-image: radial-gradient(120% 55% at 50% 0%, rgba(79,70,229,0.08), transparent 70%);
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --chip-bg: #ecedf3;
  --border: rgba(15,23,42,0.08);
  --text: #0f172a;
  --text-dim: #64748b;
  --text-faint: #94a3b8;
  --accent: #4f46e5;
  --accent-2: #0ea5e9;
  --btn-primary-bg: #4f46e5;
  --btn-primary-fg: #ffffff;
  --radius: 16px;
  --radius-sm: 11px;
}

/* ── telegram: цвета берёт сам клиент Telegram (тут запасные) ── */
html[data-skin="telegram"] { --hero-art: url("./art/telegram.svg"); }
html[data-skin="telegram"][data-theme="dark"] {
  --bg: #17212b;
  --bg-image: radial-gradient(120% 55% at 50% 0%, rgba(82,136,193,0.12), transparent 70%);
  --bg-elev: #1d2733;
  --bg-card: #232e3c;
  --chip-bg: #2b3947;
  --border: rgba(255,255,255,0.08);
  --text: #ffffff;
  --text-dim: #8d9aa8;
  --text-faint: #6a7887;
  --accent: #64b5ef;
  --accent-2: #64b5ef;
  --btn-primary-bg: #5288c1;
  --btn-primary-fg: #ffffff;
  --radius: 14px;
  --radius-sm: 10px;
}
html[data-skin="telegram"][data-theme="light"] {
  --bg: #ffffff;
  --bg-image: radial-gradient(120% 55% at 50% 0%, rgba(51,144,236,0.08), transparent 70%);
  --bg-elev: #ffffff;
  --bg-card: #f4f4f5;
  --chip-bg: #ebedf0;
  --border: rgba(0,0,0,0.07);
  --text: #000000;
  --text-dim: #707579;
  --text-faint: #9a9fa3;
  --accent: #3390ec;
  --accent-2: #3390ec;
  --btn-primary-bg: #3390ec;
  --btn-primary-fg: #ffffff;
  --radius: 14px;
  --radius-sm: 10px;
}

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

/* Атрибут `hidden` обязан побеждать display из класса.
   У .expire-banner, .card-action и .chip он flex, а `[hidden]` из
   браузерной таблицы стилей слабее любого класса — поэтому баннер
   «Подписка истекает» висел у ВСЕХ клиентов, включая тех, у кого до конца
   подписки месяц: код его честно прятал (banner.hidden = true), а стиль
   возвращал обратно. Тем же были сломаны «Лимит устройств», карточка
   статистики и блок «Отправить на TV». */
[hidden] { display: none !important; }
html, body {
  margin: 0; padding: 0;
  background-color: var(--bg);
  background-image: var(--bg-image, none);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background .3s, color .3s;
}

/* ──────── Шапка с картинкой темы ────────
   Картинка у каждой темы своя (`--hero-art` → miniapp/art/<тема>.svg) и
   рисуется ТОЛЬКО тут, а не по всей странице: под текстом карточек любой
   фон-картинка мешает читать, а полоса сверху даёт теме лицо и не спорит
   с содержимым. Ниже картинка растворяется в фоне приложения, чтобы стык
   не выглядел приклеенным прямоугольником. */
.app-hero {
  position: relative;
  min-height: 148px;
  padding-bottom: 34px;
  background-color: var(--bg);
  background-image: var(--hero-art, none);
  background-size: cover;
  background-position: center top;
}
/* Тёмная вуаль под текстом: у светлых тем («Снег») картинка в середине
   яркая, и белый заголовок на ней терялся. */
.app-hero::before {
  content: '';
  position: absolute; left: 0; right: 0; top: 0;
  height: 96px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.38), transparent);
  pointer-events: none;
}
.app-hero::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 70px;
  background: linear-gradient(to bottom, transparent, var(--bg));
  pointer-events: none;
}
/* Картинки у всех тем тёмные (даже у светлых), поэтому текст в шапке —
   всегда светлый и не зависит от схемы. */
.app-hero .topbar h1 { color: #ffffff; }
.app-hero .topbar-user { color: rgba(255, 255, 255, 0.75); }

/* Карточка подписки наезжает на нижний край картинки. */
main { margin-top: -30px; position: relative; z-index: 1; }

/* ──────── Topbar ──────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 8px;
  position: relative; z-index: 1;
}
.topbar h1 { font-size: 19px; font-weight: 700; margin: 0; }
.theme-toggle {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 14px;
  cursor: pointer;
  color: inherit;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background .2s;
}
.theme-toggle .moon { display: none; }
html[data-theme="dark"] .theme-toggle .sun { display: none; }
html[data-theme="dark"] .theme-toggle .moon { display: inline; }

/* ──────── App container ──────── */
main {
  padding: 0 14px 32px;
  max-width: 540px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 12px 4px -6px;
}

/* ──────── Cards ──────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.status-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.status-row h2 {
  margin: 0; font-size: 24px; font-weight: 700;
}
.badge {
  font-size: 11px; font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  letter-spacing: .04em;
}
.badge-active {
  background: var(--success-bg);
  color: var(--success);
}
.badge-active::before {
  content: '●'; margin-right: 6px;
}
.badge-inactive {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
}

.grid-2 {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.mini-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.mini-label {
  font-size: 10px; font-weight: 700;
  letter-spacing: .06em;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.mini-label.accent { color: var(--accent); }
.mini-value {
  font-size: 18px; font-weight: 600;
  color: var(--text);
}

.expire-card {
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(135deg, rgba(106,167,255,.10), rgba(167,139,250,.07));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
}
.expire-card .right { text-align: right; }
.big-value {
  font-size: 22px; font-weight: 700;
  color: var(--text);
}
.big-value .unit { font-size: 13px; font-weight: 500; color: var(--text-dim); }

.traffic-row { margin-top: 12px; }
.traffic-bar {
  background: var(--bg-elev);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  margin: 6px 0;
}
.traffic-fill {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  height: 100%;
  border-radius: 999px;
  transition: width .4s;
}
.traffic-text { font-size: 12px; color: var(--text-dim); }

/* ──────── Hint card ──────── */
.hint-card {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.hint-title { font-weight: 600; font-size: 15px; }
.hint-sub { color: var(--text-dim); font-size: 12px; margin-top: 3px; }
.step-dots {
  display: flex; align-items: center; gap: 6px;
}
.dot {
  width: 26px; height: 26px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.arrow { color: var(--text-faint); font-size: 12px; }

/* ──────── Device list ──────── */
.device-list { padding: 6px; }
.device-row {
  width: 100%;
  display: flex; align-items: center; gap: 14px;
  background: transparent;
  border: none;
  padding: 12px 12px;
  border-radius: var(--radius-sm);
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
  transition: background .15s;
}
.device-row + .device-row { border-top: 1px solid var(--border); }

/* Группа: импорт подписки + кнопка скачать. */
.app-block {
  display: flex;
  align-items: stretch;
  border-top: 1px solid var(--border);
  gap: 4px;
}
.app-block:first-child { border-top: none; }
.app-block .device-row { flex: 1; border-top: none; }
.app-block .install-btn {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 0 14px;
  margin: 6px 6px 6px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.app-block .install-btn:hover, .app-block .install-btn:active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Описание тарифа под названием. */
.plan-desc {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 4px;
  line-height: 1.4;
}

/* ──────── Sheet redesign (Smartphone/PC/etc) ──────── */

/* Подсказка-карточка в верху sheet */
.hint-callout {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: rgba(56, 139, 253, 0.08);
  border: 1px solid rgba(56, 139, 253, 0.25);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 8px 0 14px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
}
.hint-callout b {
  color: #58a6ff;
  font-weight: 600;
}

/* Бейдж «ШАГ 2» */
.step-chip {
  display: inline-block;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  color: var(--text-faint);
  margin: 4px auto 8px;
}
.sheet-section-title {
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}
.sheet-section-sub {
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 14px;
  line-height: 1.4;
}

/* Карточка приложения с кнопкой «Открыть» */
.app-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  overflow: hidden;
}
.app-card.recommended {
  border-color: rgba(34, 197, 94, 0.4);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.15);
}
.app-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  cursor: pointer;
  transition: background .15s;
}
.app-row:hover, .app-row:active {
  background: rgba(255, 255, 255, 0.03);
}
.app-icon-box {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.app-name-box { flex: 1; min-width: 0; }
.app-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}
.app-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  background: rgba(34, 197, 94, 0.15);
  color: rgb(74, 222, 128);
  border-radius: 4px;
  padding: 2px 6px;
  letter-spacing: 0.3px;
}
/* «Открыть» теперь <a href="happ://..."> (нужен реальный user-gesture
   на ссылке с custom scheme — программный click не работает в Telegram
   WebView). Стилизуем как кнопку. */
.app-open-btn {
  background: #2f81f7;
  color: white;
  border: none;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 80px;
  text-align: center;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
}
.app-open-btn:hover { background: #4493f8; }
.app-open-btn:active { transform: scale(0.96); background: #1f6ddf; }
.app-open-btn:visited { color: white; }
.app-card-footer {
  padding: 0 12px 10px;
}
/* «Скачать <App>» — тоже <a href="https://..."> теперь. */
.app-install-link {
  background: transparent;
  border: none;
  color: var(--text-faint);
  font: inherit;
  font-size: 12px;
  padding: 4px 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
  display: inline-block;
}
.app-install-link:hover { color: #58a6ff; }
.app-install-link:visited { color: var(--text-faint); }

/* Дополнительные опции (копирование, QR) — отдельные карточки внизу sheet */
.sheet-extra {
  margin-top: 10px !important;
  width: 100%;
}

/* QR sheet */
.qr-wrap {
  display: flex;
  justify-content: center;
  padding: 20px 0 10px;
}
.qr-wrap img {
  width: 260px;
  height: 260px;
  border-radius: 12px;
  background: white;
  padding: 12px;
}
.qr-sub {
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 12px;
}
.device-row:hover, .device-row:active {
  background: var(--bg-elev);
}
.device-row.recommended {
  background: linear-gradient(90deg, rgba(34,197,94,.06), transparent);
}
.device-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.device-text { flex: 1; min-width: 0; }
.device-name { font-weight: 600; font-size: 15px; }
.device-badge {
  display: inline-block;
  font-size: 10px; font-weight: 700;
  background: var(--success-bg); color: var(--success);
  padding: 3px 7px;
  border-radius: 999px;
  margin-top: 4px;
}
.chevron {
  font-size: 22px; color: var(--text-faint);
  margin-left: 4px;
}

/* ──────── Action card (existing client / balance / support) ──────── */
.card-action {
  width: 100%;
  display: flex; align-items: center; gap: 14px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: background .15s, transform .12s;
}
.card-action:active { transform: scale(.99); }
.card-action-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--bg-elev);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.card-action-text { flex: 1; min-width: 0; }
.card-action-title { font-weight: 600; font-size: 15px; }
.card-action-sub { color: var(--text-dim); font-size: 12px; margin-top: 3px; }
.card-action.support .card-action-title { color: var(--accent); }

/* ──────── Plans ──────── */
.plans { display: flex; flex-direction: column; gap: 8px; padding: 8px; }
.plan {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform .12s, border-color .15s;
}
.plan:active { transform: scale(.99); }
.plan.popular {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(106,167,255,.06), rgba(167,139,250,.04));
}
.plan-info { flex: 1; min-width: 0; }
.plan-name { font-weight: 600; font-size: 15px; }
.plan-meta { color: var(--text-dim); font-size: 12px; margin-top: 3px; }
.plan-price {
  font-weight: 700; font-size: 17px;
  color: var(--accent);
}
/* Первый экран тарифов — только названия, поэтому строка ниже и без цены:
   шеврон говорит, что внутри есть карточка. */
.plan-chevron { color: var(--text-dim); font-size: 20px; line-height: 1; padding-left: 8px; }

.plan-back {
  align-self: flex-start;
  background: none; border: none; cursor: pointer;
  color: var(--accent); font-size: 14px; font-weight: 600;
  padding: 4px 2px;
}

.plan-card {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  border: 1px solid var(--border);
}
.plan-card-title { font-weight: 700; font-size: 18px; }
.plan-card-type { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.plan-card-desc { color: var(--text-dim); font-size: 13px; margin-top: 8px; }
.plan-card-label {
  color: var(--text-dim); font-size: 11px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  padding: 6px 4px 0;
}
.plan-features { margin: 10px 0 0; padding: 0; list-style: none; }
.plan-features li {
  font-size: 13px; line-height: 1.5;
  padding-left: 20px; position: relative;
}
.plan-features li::before {
  content: '✓';
  position: absolute; left: 2px;
  color: var(--accent); font-weight: 700;
}

.plan-popular-tag {
  display: inline-block;
  font-size: 10px; font-weight: 700;
  background: var(--accent); color: white;
  padding: 2px 7px; border-radius: 6px;
  margin-left: 6px;
  vertical-align: middle;
}

.loading {
  text-align: center; color: var(--text-dim); font-size: 13px;
  padding: 20px;
}

/* ──────── Animations ──────── */
.anim-in {
  animation: fade-up .4s cubic-bezier(.2,.8,.2,1) both;
  animation-delay: var(--delay, 0s);
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .anim-in { animation: none; }
  * { transition: none !important; }
}

/* ──────── Sheet (modal bottom) ──────── */
.sheet[hidden] { display: none; }
.sheet {
  position: fixed; inset: 0;
  z-index: 999;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.5);
  animation: fade-bg .25s both;
}
@keyframes fade-bg { from {opacity:0} to {opacity:1} }
.sheet-content {
  position: relative;
  width: 100%; max-width: 540px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  padding: 20px 16px 28px;
  animation: slide-up .3s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes slide-up { from {transform:translateY(20%)} to {transform:translateY(0)} }
.sheet-content h3 { margin: 0 0 14px; font-size: 18px; }
.sheet-close {
  position: absolute; top: 12px; right: 14px;
  background: transparent; border: none;
  font-size: 24px; color: var(--text-dim);
  cursor: pointer;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
}

/* ──────── Wizard: 3-step connection guide ──────── */
.wizard-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 0 16px;
  flex-wrap: nowrap;
}
.wizard-step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-faint);
  font-weight: 600;
  white-space: nowrap;
}
.wizard-step span {
  width: 22px; height: 22px;
  border-radius: 999px;
  background: var(--bg-elev);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  border: 1.5px solid var(--border);
  transition: all .2s;
}
.wizard-step.active { color: var(--accent); }
.wizard-step.active span {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(106, 167, 255, 0.18);
}
.wizard-step.done span {
  background: var(--success);
  color: white;
  border-color: var(--success);
}
.wizard-arrow {
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 600;
}

.wizard-pane { display: none; flex-direction: column; gap: 10px; }
.wizard-pane.active {
  display: flex;
  animation: fade-up .25s cubic-bezier(.2,.8,.2,1) both;
}

.wizard-nav-row {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}
.wizard-nav-btn {
  flex: 1;
  background: var(--accent);
  color: white;
  border: none;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 12px;
  cursor: pointer;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.wizard-nav-btn:active { transform: scale(0.97); }
.wizard-nav-btn.ghost {
  background: var(--bg-elev);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.wizard-nav-btn.primary { background: var(--accent); color: white; }

.wizard-done {
  text-align: center;
  padding: 32px 16px;
}
.wizard-done-icon {
  font-size: 64px;
  margin-bottom: 16px;
  animation: pop-in .4s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes pop-in {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}
.wizard-done-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 10px;
}
.wizard-done-sub {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 22px;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

/* ──────── Send-to-TV ──────── */
.sendtv-box {
  background: linear-gradient(135deg, rgba(106,167,255,.08), rgba(167,139,250,.06));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 8px;
}
.sendtv-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 6px;
}
.sendtv-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 12px;
  line-height: 1.5;
}
.sendtv-input-row {
  display: flex;
  gap: 8px;
}
.sendtv-input-row input {
  flex: 1;
  font-family: 'SF Mono', 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 4px;
  text-align: center;
  text-transform: uppercase;
  background: var(--bg-elev);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
  -webkit-appearance: none;
}
.sendtv-input-row input:focus { border-color: var(--accent); }
.sendtv-input-row button {
  background: var(--accent);
  color: white;
  border: none;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: all .15s;
}
.sendtv-input-row button:active { transform: scale(0.97); }
.sendtv-input-row button:disabled { opacity: 0.5; cursor: not-allowed; }
.sendtv-status {
  margin-top: 10px;
  font-size: 13px;
  min-height: 18px;
}
.sendtv-status.success { color: var(--success); }
.sendtv-status.error { color: var(--danger); }

/* ──────── Expire banner (3-1 days urgent CTA) ──────── */
.expire-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  background: linear-gradient(135deg, #ef4444, #f97316);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  font: inherit;
  text-align: left;
  box-shadow: 0 6px 20px -4px rgba(239, 68, 68, 0.5);
  transition: transform .15s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
}
.expire-banner.warn {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  box-shadow: 0 6px 20px -4px rgba(251, 191, 36, 0.45);
}
.expire-banner:active { transform: scale(0.98); }
.expire-banner-icon {
  font-size: 26px;
  animation: shake 1.8s ease-in-out infinite;
}
@keyframes shake {
  0%, 100% { transform: rotate(0deg); }
  10%, 30% { transform: rotate(-12deg); }
  20%, 40% { transform: rotate(10deg); }
  50% { transform: rotate(0deg); }
}
.expire-banner-text { flex: 1; min-width: 0; }
.expire-banner-title { font-weight: 700; font-size: 15px; margin-bottom: 2px; }
.expire-banner-sub { font-size: 12px; opacity: 0.92; line-height: 1.3; }
.expire-banner-action {
  font-weight: 700;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.18);
  padding: 8px 14px;
  border-radius: 10px;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}

/* ──────── Stats card (30-day stats) ──────── */
.stats-card {
  padding: 14px 16px;
}
.card-title-row {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
}
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat-mini {
  text-align: center;
  padding: 10px 6px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.stat-mini-value {
  font-size: 19px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
  margin-bottom: 4px;
}
.stat-mini-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ──────── Devices sheet ──────── */
/* ──────── Вкладка «Устройства» ──────── */
.devices-card { display: flex; flex-direction: column; gap: 10px; }
.devices-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
}
.devices-count { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.devices-limit-sub {
  flex: 1; min-width: 120px; text-align: right;
  font-size: 12px; color: var(--text-dim); line-height: 1.35;
}
.devices-hint { font-size: 11px; line-height: 1.4; color: var(--text-faint); }
.devices-note {
  font-size: 12px; line-height: 1.4;
  color: var(--text-dim);
  background: var(--chip-bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.devices-list { display: flex; flex-direction: column; gap: 6px; }
.device-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.device-item-current { border-color: var(--success); }
.device-item-icon {
  font-size: 20px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card);
  border-radius: 10px;
  flex-shrink: 0;
}
.device-item-text { flex: 1; min-width: 0; }
.device-item-ip {
  font-family: 'SF Mono', 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.device-item-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.device-item-time {
  font-size: 11px;
  color: var(--text-faint);
  flex-shrink: 0;
}
.devices-empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--text-dim);
  font-size: 13px;
}
.device-item-delete {
  flex-shrink: 0;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-faint);
  font-size: 15px;
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.device-item-delete:active { background: var(--bg-card); color: var(--danger); }

/* ──────── Hero-карточка: чипы + крупные кнопки ────────
   Раскладка повторяет привычную клиентам «карточку подписки»: строка чипов
   (трафик / устройства / локации), крупное «Осталось N дней», два действия
   в ряд и две широкие кнопки под ними. Все кнопки дёргают то, что в мини-аппе
   уже было (тарифы, устройства, мастер подключения, ссылка+QR) — новых
   экранов раскладка не вводит. */
.hero-card { padding: 18px; }

.hero-top {
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 14px;
}
.hero-plan-icon {
  width: 44px; height: 44px; flex: 0 0 44px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: var(--chip-bg);
  font-size: 22px;
}
.hero-plan { flex: 1; min-width: 0; }
.hero-plan-name {
  font-size: 22px; font-weight: 700; line-height: 1.15;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Бейдж статуса внутри hero — не пилюля, а подпись под названием тарифа.
   Цвет (зелёный/красный) остаётся от .badge-active / .badge-inactive. */
.hero-plan .badge {
  display: inline-block;
  background: transparent;
  padding: 0; margin-top: 2px;
  font-size: 13px; font-weight: 600; letter-spacing: 0;
  text-transform: lowercase;
}
.hero-plan .badge::before { content: none; }

.hero-until { text-align: right; flex: 0 0 auto; max-width: 45%; }
.hero-until-label { font-size: 12px; color: var(--text-dim); }
.hero-until-date { font-size: 15px; font-weight: 600; margin-top: 2px; }

.hero-chips {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.chip {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--chip-bg);
  border-radius: var(--radius-sm);
  padding: 12px 6px;
  min-width: 0;
}
.chip-ico { font-size: 15px; line-height: 1; }
#chip-devices-box { cursor: pointer; }
#chip-devices-box:active { background: var(--bg-elev); }
.chip-val {
  font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.hero-remain {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px;
  background: var(--chip-bg);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-top: 8px;
}
.hero-remain-label { font-size: 14px; color: var(--text-dim); }
.hero-remain-value { font-size: 22px; font-weight: 700; }
.hero-remain-value .unit { font-size: 13px; font-weight: 500; color: var(--text-dim); }

.hero-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-top: 8px;
}
.hero-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--chip-bg);
  color: var(--text);
  border: none;
  border-radius: var(--radius-sm);
  padding: 15px 12px;
  font-size: 15px; font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform .12s, opacity .15s;
}
.hero-btn:active { transform: scale(.98); opacity: .85; }
.hero-btn.wide { width: 100%; margin-top: 8px; }
.hero-btn.primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
}
/* В светлых скинах --bg-elev совпадает с фоном карточки, и вторая кнопка
   ряда без рамки выглядела бы дырой, а не кнопкой. */
.hero-btn.alt { background: var(--bg-elev); border: 1px solid var(--border); }
.hero-btn-ico { font-size: 16px; line-height: 1; }
.hero-btn[disabled] { opacity: .45; cursor: default; }

/* ──────── Нижняя навигация ────────
   Это не отдельные экраны, а прокрутка к уже существующим секциям — мини-апп
   остаётся одностраничным, поэтому переключение ничего не перерисовывает и не
   ломает мастер подключения. */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: grid;
  grid-auto-flow: column; grid-auto-columns: 1fr;
  gap: 2px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none;
  color: var(--text-faint);
  font-family: inherit; font-size: 10px; font-weight: 600;
  padding: 6px 2px;
  border-radius: 12px;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.tab-ico { font-size: 18px; line-height: 1; }
.tab > span:not(.tab-ico) {
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 360px) { .tab { font-size: 9px; padding: 6px 0; } }
.tab.active { color: var(--accent); background: var(--chip-bg); }

/* Место под таббар, чтобы последняя карточка не пряталась под ним. */
body.has-tabbar main { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }

/* ──────── Ключ / подписка / QR ──────── */
.sub-link-box {
  background: var(--chip-bg);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--text-dim);
  word-break: break-all;
  line-height: 1.45;
  max-height: 84px;
  overflow: auto;
  margin-bottom: 10px;
}

/* Мини-апп открыт в предпросмотре админки — рамка телефона уже есть у
   панели, а таббар и анимации там только мешают «прицелиться» в цвет. */
html[data-preview="1"] .anim-in { animation: none; }

/* Шапка: имя сервиса + под ним имя клиента (раньше оно занимало отдельную
   мини-карточку в статусе — hero её заменил). */
.topbar-titles { min-width: 0; }
.topbar-user {
  font-size: 12px; color: var(--text-dim);
  margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ──────── Докупка гигабайтов (sheet #traffic-sheet) ──────── */
/* Пакеты — сеткой по две кнопки в ряд, как в боте: список в столбик на
   пять позиций занимает весь экран и прячет кнопку оплаты под сгиб. */
.gb-kinds { display: flex; gap: 8px; margin-bottom: 12px; }
.gb-kind {
  flex: 1;
  background: var(--bg-elev);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.gb-kind.selected { border-color: var(--accent); color: var(--accent); }
.gb-kind-price { display: block; font-size: 11px; font-weight: 500; color: var(--text-dim); margin-top: 2px; }

.gb-info {
  font-size: 13px; line-height: 1.5;
  color: var(--text-dim);
  background: var(--chip-bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 12px;
}
.gb-info b { color: var(--text); }

.gb-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.gb-btn {
  background: var(--bg-elev);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.gb-btn span { display: block; font-size: 12px; font-weight: 500; color: var(--text-dim); margin-top: 2px; }
.gb-btn.selected { border-color: var(--accent); color: var(--accent); }
.gb-btn.selected span { color: var(--accent); }

.gb-custom { margin-bottom: 12px; }
.gb-custom input {
  width: 100%;
  background: var(--bg-elev);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.gb-custom input:focus { border-color: var(--accent); }

.gb-total {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}
.gb-note {
  font-size: 12px; line-height: 1.45;
  color: var(--text-faint);
  margin-top: 12px;
  text-align: center;
}

/* ─── История платежей ─── */
.pay-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.pay-item:first-child { border-top: none; }
.pay-item-main { flex: 1; min-width: 0; }
.pay-item-title {
  font-size: 14px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pay-item-date { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.pay-item-right { text-align: right; flex-shrink: 0; }
.pay-item-amount { font-size: 14px; font-weight: 600; }
.pay-item-status { font-size: 11px; margin-top: 2px; color: var(--text-dim); }
.pay-item-status.ok { color: var(--success, #22c55e); }
.pay-item-status.pending { color: var(--warning, #f59e0b); }
.pay-item-status.fail { color: var(--danger, #ef4444); }

/* ─── Экран входа (веб-версия) ─── */
/* Выше таббара (40) и шапки, но ниже модалок (999) — на экране входа их
   всё равно нет. Фон непрозрачный: под ним пустой каркас кабинета. */
body.auth-open { overflow: hidden; }
.auth-screen {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: var(--bg);
  overflow-y: auto;
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius, 18px);
  padding: 22px 18px 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .18);
}
.auth-brand { font-size: 20px; font-weight: 700; text-align: center; }
.auth-sub {
  font-size: 13px; color: var(--text-dim);
  text-align: center; margin-top: 4px; margin-bottom: 16px;
}
.auth-tabs {
  display: flex; gap: 4px; padding: 4px; margin-bottom: 14px;
  background: var(--bg-elev); border-radius: 12px;
}
.auth-tab {
  flex: 1; padding: 9px 0; border: none; border-radius: 9px;
  background: transparent; color: var(--text-dim);
  font-size: 14px; font-weight: 500; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.auth-tab.active { background: var(--bg-card); color: var(--text); font-weight: 600; }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form input {
  width: 100%; padding: 12px 14px;
  background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  font-size: 15px; outline: none;
}
.auth-form input:focus { border-color: var(--accent); }
.auth-error {
  font-size: 13px; color: var(--danger);
  background: var(--danger-bg, rgba(248, 113, 113, .12));
  border-radius: 10px; padding: 9px 12px;
}
.auth-link {
  display: block; width: 100%; margin-top: 10px;
  background: none; border: none; cursor: pointer;
  color: var(--text-dim); font-size: 13px; text-decoration: underline;
}
.auth-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0 12px; color: var(--text-faint); font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.auth-hint {
  margin-top: 8px; font-size: 12px;
  color: var(--text-faint); text-align: center;
}
.creds-sub { font-size: 13px; color: var(--text-dim); margin-bottom: 12px; }

/* ═════════════════ Кабинет на ПК ═════════════════
   Мини-апп нарисован под телефон, и на широком экране это было видно: шапка
   и таббар во всю ширину, содержимое узкой лентой посередине. На ПК тот же
   HTML раскладывается как обычная веб-панель — слева меню разделов, справа
   один раздел на весь экран.

   Ниже брейкпоинта ничего из этого не применяется: обёртки .view и .col
   прозрачные (display: contents), меню скрыто — телефонная вёрстка остаётся
   ровно такой, какой была. */
.view, .col { display: contents; }
.desk-nav { display: none; }
.view-title { display: none; }

@media (min-width: 1024px) {
  /* ── Каркас: фиксированное меню слева, контент справа ── */
  body {
    display: grid;
    grid-template-columns: 268px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    min-height: 100vh;
  }
  .desk-nav {
    display: flex;
    flex-direction: column;
    gap: 18px;
    grid-column: 1; grid-row: 1 / -1;
    position: sticky; top: 0;
    height: 100vh;
    padding: 22px 16px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    overflow-y: auto;
  }
  .app-hero { grid-column: 2; grid-row: 1; }
  main { grid-column: 2; grid-row: 2; }
  .tabbar { display: none; }
  body.has-tabbar main { padding-bottom: 40px; }

  /* ── Меню ── */
  .desk-brand { display: flex; align-items: center; gap: 12px; }
  .desk-logo {
    width: 40px; height: 40px; flex: 0 0 auto;
    display: flex; align-items: center; justify-content: center;
    border-radius: 12px;
    background: var(--accent); color: #fff;
    font-size: 18px; font-weight: 700;
  }
  .desk-brand-text { min-width: 0; }
  .desk-brand-name {
    font-size: 15px; font-weight: 700;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .desk-brand-user {
    font-size: 12px; color: var(--text-dim);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }

  .desk-status {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
  }
  .desk-status-plan { font-size: 13px; font-weight: 600; }
  .desk-status-days { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
  .desk-status-bar {
    height: 5px; margin: 10px 0 6px;
    border-radius: 999px; background: var(--chip-bg);
    overflow: hidden;
  }
  .desk-status-bar > div {
    height: 100%; width: 0;
    border-radius: 999px; background: var(--accent);
    transition: width .3s;
  }
  .desk-status-traffic { font-size: 11px; color: var(--text-faint); }

  .desk-menu { display: flex; flex-direction: column; gap: 2px; }
  .desk-foot {
    margin-top: auto;
    display: flex; flex-direction: column; gap: 2px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
  }
  .desk-item {
    display: flex; align-items: center; gap: 12px;
    width: 100%;
    padding: 11px 12px;
    border: none; border-radius: 12px;
    background: transparent; color: var(--text-dim);
    font-family: inherit; font-size: 14px; font-weight: 500;
    text-align: left; cursor: pointer;
    transition: background .15s, color .15s;
  }
  .desk-item:hover { background: var(--bg-elev); color: var(--text); }
  .desk-item.active { background: var(--chip-bg); color: var(--accent); font-weight: 600; }
  .desk-ico { font-size: 17px; line-height: 1; }

  /* ── Шапка контента: узкая полоса с названием раздела ── */
  .app-hero { min-height: 132px; }
  .topbar {
    max-width: 1120px; margin: 0 auto;
    padding: 22px 28px 10px;
  }
  /* Название сервиса и имя клиента переехали в меню — в шапке остаётся
     заголовок открытого раздела. */
  .app-hero .topbar h1, .topbar-user { display: none; }
  .view-title {
    display: block;
    font-size: 26px; font-weight: 700; color: #fff;
  }

  /* ── Контент: один раздел за раз ── */
  /* Ширина задаётся явно, а не через max-width: main — ячейка сетки, и
     доставшийся с телефона `margin: 0 auto` отключает растягивание, из-за
     чего колонка схлопывалась по содержимому (карточки в 540 px посреди
     монитора). */
  main {
    width: min(1120px, 100%);
    max-width: none;
    padding: 0 28px 40px;
    gap: 16px;
  }
  .view { display: none; }
  .view.active { display: flex; flex-direction: column; gap: 16px; }
  .col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

  /* Главная: слева карточка подписки, справа подключение. */
  .view[data-view="home"].active {
    display: grid;
    grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
    align-items: start;
    gap: 24px;
  }

  /* Списки и формы не растягиваем на весь монитор: строка платежа или поле
     ввода шириной в 1100 px читается плохо. Тарифы и «Главная» — исключение,
     они раскладываются плитками. */
  .view[data-view="devices"].active,
  .view[data-view="pay"].active,
  .view[data-view="profile"].active { max-width: 820px; }

  /* Первый заголовок раздела дублирует название в шапке — прячем. Внутри
     «Главной» заголовки лежат в колонках, а не прямыми детьми вида,
     поэтому «ПОДКЛЮЧЕНИЕ» остаётся на месте. */
  .view.active > .section-title:first-child { display: none; }
  .col-rest > .section-title:first-child { margin-top: 0; }

  /* Тарифы: на телефоне это строки списка, на ПК — карточки в ряд, как
     на любой странице с ценами. Кнопка нарисована псевдоэлементом: клик
     всё равно ловит вся карточка, а разметку тарифов рисует общий с
     телефоном код. */
  .plans {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: stretch;
  }
  .plans .plan {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 18px 18px 16px;
  }
  .plans .plan-price { font-size: 26px; }
  .plans .plan::after {
    content: 'Выбрать';
    display: block;
    width: 100%;
    margin-top: auto;
    padding: 10px 0;
    border-radius: 12px;
    background: var(--chip-bg); color: var(--accent);
    font-size: 14px; font-weight: 600; text-align: center;
  }
  .plans .plan.popular::after { background: var(--accent); color: #fff; }
  .plans .plan:hover::after { filter: brightness(1.06); }
  /* Карточка тарифа (название, описание, возможности) и «Все тарифы» —
     это заголовки экрана, а не плитки: они занимают всю ширину сетки,
     иначе описание встанет колонкой рядом с первым сроком. */
  .plans .plan-back,
  .plans .plan-card,
  .plans .plan-card-label { grid-column: 1 / -1; }
  /* В сетке карточка тарифа — не строка списка: шеврон там ни к чему,
     его роль играет кнопка «Выбрать». */
  .plans .plan-chevron { display: none; }
  .plans .plan-row::after { content: 'Подробнее'; }
  /* Выбор платформы — тоже в два столбца, но линейка-разделитель между
     соседями в сетке рвётся: даём каждой плитке рамку и промежуток. */
  .device-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .device-list .device-row {
    border: 1px solid var(--border);
    border-radius: 12px;
  }
  .device-row + .device-row { border-top: 1px solid var(--border); }

  /* Картинка темы на широком экране обрезается почти в ноль и выглядит
     случайным пятном — оставляем её узкой полосой под заголовок. */
  .app-hero {
    min-height: 118px;
    padding-bottom: 26px;
    background-position: center 30%;
  }

  /* Модалки по центру экрана, а не приклеены к нижнему краю. */
  .sheet { align-items: center; }
  .sheet-content { border-radius: 20px; max-height: 88vh; }

  /* Экран входа: сетка каркаса ему не нужна — он поверх всего. */
  .auth-screen { grid-column: 1 / -1; grid-row: 1 / -1; }
  .auth-card { max-width: 420px; padding: 28px 24px 22px; }
}

@media (min-width: 1440px) {
  .topbar { max-width: 1240px; }
  main { width: min(1240px, 100%); }
  /* На большом мониторе тарифы становятся тремя в ряд — иначе карточки
     растягиваются и выглядят пустыми. */
  .plans { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ─── DNS-профиль ─── */
.dns-sub { font-size: 13px; color: var(--text-dim); margin-bottom: 12px; }
.dns-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.dns-opt {
  display: flex; align-items: flex-start; gap: 10px;
  width: 100%; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg-elev); color: inherit;
  font: inherit; text-align: left; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dns-opt.active { border-color: var(--accent); background: var(--chip-bg); }
.dns-opt-mark { font-size: 14px; line-height: 1.3; color: var(--accent); width: 16px; flex: 0 0 auto; }
.dns-opt-text { min-width: 0; }
.dns-opt-label { font-size: 14px; font-weight: 500; }
.dns-opt-desc { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
#dns-custom {
  width: 100%; padding: 11px 12px; margin-bottom: 10px;
  background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  font-size: 14px; outline: none;
}

/* ──────── Половины подписки (VPN / обход) в шапке ──────── */
.sub-sections { display: grid; gap: 8px; margin-top: 12px; }
.sub-sections[hidden] { display: none; }
.sub-sec {
  background: var(--chip-bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.sub-sec.off { opacity: .75; }
.sub-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sub-sec-kind {
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-dim);
}
.sub-sec .badge { padding: 3px 8px; font-size: 10px; }
.sub-sec-plan { font-size: 15px; font-weight: 700; margin-top: 4px; }
.sub-sec-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* Название тарифа в шапке — до двух строк: длинное («MAX 90 Дней + Обход»)
   обрезалось многоточием на полуслове. */
.hero-plan-name {
  white-space: normal;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

/* ──────── Локации ──────── */
#chip-servers-box { cursor: pointer; }
#chip-servers-box:active { background: var(--bg-elev); }
.loc-group {
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-dim);
  margin: 12px 0 6px;
}
.loc-group:first-child { margin-top: 0; }
.loc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.loc-chip {
  font-size: 13px; font-weight: 500;
  background: var(--chip-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  white-space: nowrap;
}
.plan-locs { margin-top: 12px; }
.plan-locs-title { font-size: 12px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }
