/* SwiftyVPN mini app.
   Палитра из логотипа-ласточки: индиго #6366f1 на кнопках, светлый барвинок #a5b4fc, дымка #f4f5ff.
   Принцип: цвет означает «нужно действие». Когда все в порядке, экран спокойный и индиго;
   янтарный и красный появляются только при проблеме. Схема выбирается атрибутом data-scheme
   на <html> (app.js), «Авто» следует теме Telegram или системы, но палитра всегда своя. */
:root {
  --page: #f4f5ff;
  --card: #ffffff;
  --text: #1e1b4b;
  --hint: #6b6f95;
  --line: rgba(30, 27, 75, .08);
  --accent: #5458ee;
  --accent-deep: #4f46e5;
  --accent-soft: #a5b4fc;
  --accent-tint: #eceeff;
  --button: #6366f1;
  --button-text: #ffffff;
  --seg-on: #ffffff;
  --amber: #9a5800;
  --amber-line: #e3901c;
  --red: #c8372f;
  --green: #1d7f55;
  --tint-amber: rgba(214, 140, 20, .13);
  --tint-red: rgba(200, 55, 47, .1);
  --tint-green: rgba(29, 127, 85, .1);
  --tint-gray: rgba(30, 27, 75, .06);
  --track: rgba(99, 102, 241, .22);
  --toast-bg: rgba(30, 27, 75, .94);
  --shadow: 0 1px 2px rgba(30, 27, 75, .04), 0 10px 28px rgba(30, 27, 75, .06);
  --edge: rgba(30, 27, 75, .05);
  --grad-button: linear-gradient(135deg, #5b5ff0, #7c82f6);
  --glow: 0 8px 20px rgba(99, 102, 241, .28);
  --grad-hero: radial-gradient(120% 90% at 100% 0%, rgba(255, 255, 255, .22), transparent 55%),
               linear-gradient(150deg, #4f46e5 0%, #6366f1 48%, #8b93f8 100%);
  --hero-glow: 0 16px 36px rgba(79, 70, 229, .30);
  --shine: linear-gradient(100deg, #4f46e5 0%, #6366f1 30%, #a5b4fc 50%, #6366f1 70%, #4f46e5 100%);
  color-scheme: light;
}
:root[data-scheme="dark"] {
  --page: #13122e;
  --card: #1d1b45;
  --text: #eeeeff;
  --hint: #a3a6cf;
  --line: rgba(238, 238, 255, .08);
  --accent: #a5b4fc;
  --accent-deep: #c7d2fe;
  --accent-soft: #4f52a8;
  --accent-tint: rgba(165, 180, 252, .14);
  --button: #8b93f8;
  --button-text: #14123a;
  --seg-on: #2e2c66;
  --amber: #f2b154;
  --amber-line: #f2b154;
  --red: #ff8a80;
  --green: #5fd3a0;
  --tint-amber: rgba(242, 177, 84, .13);
  --tint-red: rgba(255, 138, 128, .13);
  --tint-green: rgba(95, 211, 160, .12);
  --tint-gray: rgba(238, 238, 255, .07);
  --track: rgba(165, 180, 252, .24);
  --toast-bg: rgba(46, 44, 102, .97);
  --shadow: none;
  --edge: rgba(238, 238, 255, .06);
  --grad-button: linear-gradient(135deg, #8b93f8, #a5b4fc);
  --glow: 0 8px 22px rgba(139, 147, 248, .18);
  --grad-hero: radial-gradient(120% 90% at 100% 0%, rgba(255, 255, 255, .16), transparent 55%),
               linear-gradient(150deg, #4338ca 0%, #5458ee 50%, #7c82f6 100%);
  --hero-glow: 0 16px 36px rgba(0, 0, 0, .35);
  --shine: linear-gradient(100deg, #a5b4fc 0%, #c7d2fe 30%, #ffffff 50%, #c7d2fe 70%, #a5b4fc 100%);
  color-scheme: dark;
}
/* До запуска скрипта следуем системе, чтобы темная тема не мигала светлой. */
@media (prefers-color-scheme: dark) {
  :root:not([data-scheme]) {
    --page: #13122e; --card: #1d1b45; --text: #eeeeff; --hint: #a3a6cf; --line: rgba(238, 238, 255, .08);
    --accent: #a5b4fc; --button: #8b93f8; --button-text: #14123a; color-scheme: dark;
  }
}
:root {
  --display: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r-pass: 24px;
  --r-card: 18px;
  --r-ctl: 14px;
  --safe-top: max(env(safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
}

/* Плавная смена темы: класс ставится только на время переключения. */
html.theme-anim, html.theme-anim * {
  transition: background-color .3s ease, color .3s ease, border-color .3s ease, fill .3s ease, stroke .3s ease !important;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--page); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--text);
  font: 15px/1.5 var(--body);
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: anywhere;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
body.has-tabs { padding-bottom: calc(72px + var(--safe-bottom)); }
body:not(.has-tabs) { padding-bottom: var(--safe-bottom); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* --- каркас ---------------------------------------------------------------- */
.splash, .empty { padding: 44px 20px; text-align: center; color: var(--hint); }
.splash h2 { color: var(--text); margin: 16px 0 8px; font: 650 21px/1.25 var(--display); }
.splash p { margin: 4px auto; max-width: 30ch; }
.splash .gate-logo { width: 88px; height: 88px; object-fit: contain; }
.spinner {
  width: 26px; height: 26px; margin: 0 auto 12px; border-radius: 50%;
  border: 2.5px solid var(--track); border-top-color: var(--accent); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.page { max-width: 600px; margin: 0 auto; padding: calc(16px + var(--safe-top)) 20px 32px; }
@media (max-width: 360px) { .page { padding-left: 16px; padding-right: 16px; } }
.page-head { display: flex; align-items: center; gap: 10px; margin: 6px 0 4px; }
.page-head h1 { flex: 1; margin: 0; font: 700 26px/1.2 var(--display); letter-spacing: -.015em; }
.page-head .btn { width: auto; flex: none; padding: 7px 14px; }
.subtitle { color: var(--hint); font-size: 15px; margin: 0 0 4px; }

#topbar { position: sticky; top: 0; z-index: 5; background: var(--page); }
#topbar .inner { max-width: 600px; margin: 0 auto; padding: 8px 10px; display: flex; align-items: center; min-height: 44px; }
#topbar button { border: 0; background: none; color: var(--accent); padding: 6px 8px; font-size: 16px; cursor: pointer; }

.section { margin-top: 26px; }
.section-title {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  margin: 0 2px 12px; font: 700 21px/1.25 var(--display); letter-spacing: -.01em; color: var(--text);
}
.section-title .more { font: 500 14px/1.3 var(--body); color: var(--hint); }
.card { background: var(--card); border-radius: var(--r-card); padding: 16px; box-shadow: var(--shadow); border: 1px solid var(--edge); }
.card + .card { margin-top: 10px; }
.note { color: var(--hint); font-size: 14px; margin: 10px 2px 0; }
.card > .note:first-child { margin-top: 0; }

/* --- шапка клиента: логотип и приветствие ------------------------------------- */
.brand { display: flex; align-items: center; gap: 12px; margin: 4px 0 22px; }
.brand img { width: 52px; height: 52px; object-fit: contain; flex: none; }
.brand .titles { min-width: 0; flex: 1; }
/* Тема: круглая кнопка в правом верхнем углу шапки */
.theme-btn {
  flex: none; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--edge); background: var(--card); color: var(--accent); box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.theme-btn:active { transform: scale(.92); }
.theme-btn .ico { width: 20px; height: 20px; }
.page-head .theme-btn { margin-left: auto; }
.brand .word {
  display: block; font: 800 28px/1.1 var(--display); letter-spacing: -.02em;
  background: var(--shine); background-size: 250% 100%; -webkit-background-clip: text; background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent;
}
.brand .hello { display: block; margin-top: 3px; color: var(--hint); font-size: 14.5px; }
@media (prefers-reduced-motion: no-preference) {
  .brand .word { animation: shine 7s ease-in-out infinite; }
}
@keyframes shine { 0%, 100% { background-position: 100% 0; } 50% { background-position: 0 0; } }

/* --- ключ: «посадочный» блок со статусом и линией полета ---------------------- */
.pass { background: var(--card); border-radius: var(--r-pass); padding: 20px 20px 18px; box-shadow: var(--shadow); border: 1px solid var(--edge); }
/* Ключ работает: индиго-карточка с белым текстом, единственная яркая деталь экрана. */
.pass.hero { background: var(--grad-hero); color: #fff; border: 0; box-shadow: var(--hero-glow); }
.pass.hero .pass-top, .pass.hero .pass-top .name { color: rgba(255, 255, 255, .86); }
.pass.hero .where { background: rgba(255, 255, 255, .18); color: #fff; padding: 2px 10px; border-radius: 999px; font-size: 13px; }
.pass.hero .pass-title { color: #fff; }
.pass.hero .pass-detail { color: rgba(255, 255, 255, .92); }
.pass.hero .hint-line { color: rgba(255, 255, 255, .8); }
.pass.hero .swoosh .track { stroke: rgba(255, 255, 255, .45); }
.pass.hero .swoosh .left { stroke: #fff; }
.pass.hero .swoosh .end { fill: rgba(255, 255, 255, .25); stroke: #fff; }
.pass.hero.amber .swoosh .left, .pass.hero.amber .swoosh .end { stroke: #fcd34d; }
.pass.hero .swoosh-caption { color: rgba(255, 255, 255, .8); }
.pass.hero .btn { background: #fff; color: #4338ca; box-shadow: 0 6px 16px rgba(30, 27, 75, .18); }
.pass.hero .btn:active { background: #eef0ff; }
.pass.hero .btn.secondary { background: rgba(255, 255, 255, .18); color: #fff; box-shadow: none; }
.pass.hero .row-link { color: #fff; opacity: .9; }
.pass + .pass { margin-top: 12px; }
.pass-top { display: flex; align-items: baseline; gap: 10px; color: var(--hint); font-size: 14px; }
.pass-top .name { flex: 1 1 auto; color: var(--text); font-weight: 600; font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pass-top .where { flex: none; }
.pass-title { margin: 12px 0 0; font: 700 28px/1.15 var(--display); letter-spacing: -.02em; }
.pass-detail { margin-top: 6px; font-size: 16px; line-height: 1.4; }
.pass .hint-line { margin-top: 8px; font-size: 14px; color: var(--hint); }
/* Ждет оплаты или скоро срок: ключ подключен, поэтому заголовок обычный, янтарная только линия. */
.pass.red .pass-title { color: var(--red); }
.pass.muted .pass-title { color: var(--hint); }
.swoosh { display: block; width: 100%; height: 44px; margin: 14px 0 2px; overflow: visible; }
.swoosh .track { fill: none; stroke: var(--track); stroke-width: 3; stroke-linecap: round; stroke-dasharray: .5 6; }
.swoosh .left { fill: none; stroke: var(--accent); stroke-width: 3.5; stroke-linecap: round; }
.swoosh .end { fill: var(--card); stroke: var(--accent); stroke-width: 2.5; }
.pass.amber .swoosh .left, .pass.amber .swoosh .end { stroke: var(--amber-line); }
.swoosh-caption { display: flex; justify-content: space-between; font-size: 13px; color: var(--hint); font-variant-numeric: tabular-nums; }
.pass-actions { display: grid; gap: 8px; margin-top: 18px; }
.pass-actions .row-link { justify-self: center; }

.status { font-weight: 600; }
.status.amber { color: var(--amber); }
.status.red { color: var(--red); }
.status.muted { color: var(--hint); }
.term { margin-top: 8px; font-size: 15px; }
.hint-line { margin-top: 6px; font-size: 14px; color: var(--hint); }
.key-buttons { display: grid; gap: 8px; margin-top: 16px; }

/* Ключа еще нет: предложение создать */
.offer { background: var(--card); border-radius: var(--r-pass); padding: 22px 20px 20px; box-shadow: var(--shadow); border: 1px solid var(--edge); }
.offer h2 { margin: 0; font: 700 26px/1.2 var(--display); letter-spacing: -.015em; }
.offer p { margin: 8px 0 0; color: var(--hint); }
.price { margin: 18px 0 4px; font-size: 15px; color: var(--hint); }
.price b { font: 700 40px/1 var(--display); color: var(--text); letter-spacing: -.02em; margin-right: 6px; }
.ticks { list-style: none; margin: 16px 0 20px; padding: 0; }
.ticks li { display: flex; gap: 10px; padding: 5px 0; font-size: 15px; }
.ticks li .ico { color: var(--accent); width: 18px; height: 18px; margin-top: 2px; }
.offer .btn + .btn { margin-top: 8px; }
/* Совместимость со старыми экранами админа */
.hero-card { text-align: left; }
.hero-card h3 { margin: 0 0 6px; font: 650 20px/1.25 var(--display); }
.hero-card p { margin: 0 0 12px; color: var(--hint); }

/* Ответ администратора: заметная строка, без эмодзи */
.banner {
  display: flex; align-items: center; gap: 12px; width: 100%; margin: 0 0 14px; padding: 14px 16px;
  border: 0; border-radius: var(--r-card); background: var(--grad-button); color: var(--button-text); text-align: left; cursor: pointer; box-shadow: var(--glow);
}
.banner .main { flex: 1; min-width: 0; }
.banner .title { font-weight: 600; }
.banner .meta { font-size: 13.5px; opacity: .85; }
.banner .chevron { color: inherit; opacity: .8; }

/* сегменты: тема и вкладки инструкции */
.page > .segmented { margin-top: 16px; }
.segmented { display: flex; gap: 8px; }
.seg {
  flex: 1; min-width: 0; border: 0; cursor: pointer; color: var(--text); background: var(--tint-gray);
  padding: 9px 12px; border-radius: 999px; font-size: 14.5px; font-weight: 500; white-space: nowrap;
  transition: background-color .18s ease, color .18s ease, box-shadow .18s ease;
}
.seg.on { background: var(--grad-button); color: var(--button-text); font-weight: 600; box-shadow: var(--glow); }


/* шаги инструкции: настоящая последовательность, поэтому номера */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps > li { display: flex; gap: 14px; padding: 14px 0; }
.steps > li:first-child { padding-top: 2px; }
.steps > li:last-child { padding-bottom: 0; }
.steps > li + li { border-top: 1px solid var(--line); }
.steps .num {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-tint); color: var(--accent); font: 700 14px/1 var(--display);
}
.steps .body { flex: 1; min-width: 0; }
.steps .body b { display: block; font-weight: 600; margin: 3px 0 2px; }
.steps .body p { margin: 2px 0 0; color: var(--hint); font-size: 14.5px; }
.steps .body .btn { margin-top: 10px; }
.tips { margin: 0; padding: 0; list-style: none; }
.tips li { padding: 10px 0; font-size: 15px; }
.tips li + li { border-top: 1px solid var(--line); }

.connect { display: grid; gap: 8px; }
.reveal { margin-top: 4px; }

/* вопросы: переписка, как в Telegram */
.compose { padding: 12px; }
.compose textarea {
  display: block; width: 100%; min-height: 104px; padding: 4px 4px 0; border: 0; background: transparent;
  font-size: 16px; line-height: 1.45; resize: vertical; outline: none;
}
.compose textarea::placeholder { color: var(--hint); opacity: .8; }
.compose-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.compose-foot .btn { width: auto; padding-left: 22px; padding-right: 22px; min-height: 42px; }
.counter { color: var(--hint); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.thread { display: grid; gap: 8px; }
.thread + .thread { margin-top: 20px; }
.bubble { max-width: 86%; padding: 10px 14px; border-radius: 18px; white-space: pre-wrap; }
.bubble.mine { justify-self: end; background: var(--grad-button); color: var(--button-text); border-bottom-right-radius: 6px; }
.bubble.theirs { justify-self: start; background: var(--card); border-bottom-left-radius: 6px; box-shadow: var(--shadow); border: 1px solid var(--edge); }
.bubble .who { display: block; font-size: 12.5px; font-weight: 600; color: var(--accent); margin-bottom: 2px; white-space: normal; }
.bubble time { display: block; margin-top: 4px; font-size: 12px; opacity: .7; text-align: right; white-space: normal; }
.waiting { justify-self: start; color: var(--hint); font-size: 13.5px; padding-left: 4px; }
/* старые классы карточек вопросов (админ) */
.qa-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.qa-date { color: var(--hint); font-size: 13px; }
.qa-text { margin-top: 10px; white-space: pre-wrap; }
.answer { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--accent-tint); white-space: pre-wrap; }
.answer-label { font-size: 12.5px; color: var(--hint); margin-bottom: 4px; white-space: normal; }

/* --- списки и строки ------------------------------------------------------- */
.list { background: var(--card); border-radius: var(--r-card); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--edge); }
.row {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 13px 16px; border: 0; background: none; text-align: left; cursor: pointer;
  position: relative; min-height: 52px;
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 50px; right: 0; border-top: 1px solid var(--line); }
.list.plain .row + .row::before { left: 16px; }
.row:active { background: var(--tint-gray); }
.row .icon { width: 20px; flex: none; display: grid; place-items: center; color: var(--accent); font-size: 17px; }
.row .icon.boxed { width: 42px; height: 42px; border-radius: 13px; background: var(--accent-tint); }
.row .icon.boxed .ico { width: 21px; height: 21px; }
.list.boxed .row + .row::before { left: 72px; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 500; }
.row .meta { color: var(--hint); font-size: 13.5px; margin-top: 1px; }
.row .side { flex: none; text-align: right; font-size: 13.5px; color: var(--hint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.row .main, .row .side { overflow-wrap: normal; }
.chevron { flex: none; color: var(--hint); opacity: .55; display: grid; }
.chevron .ico { width: 16px; height: 16px; }
.row.static { cursor: default; }
.row.static:active { background: none; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; }
.kv:first-child { padding-top: 0; }
.kv:last-child { padding-bottom: 0; }
.kv + .kv { border-top: 1px solid var(--line); }
.kv .k { color: var(--hint); flex: none; }
.kv .v { text-align: right; min-width: 0; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500; background: var(--tint-gray); color: var(--text); white-space: nowrap;
}
.badge.red { background: var(--tint-red); color: var(--red); }
.badge.green { background: var(--tint-green); color: var(--green); }
.badge.amber { background: var(--tint-amber); color: var(--amber); }
.badge.blue { background: var(--accent-tint); color: var(--accent); }
/* Статусные цвета перекрывают цвет подписи в строках и карточках ключей. */
.red-text { color: var(--red) !important; }
.amber-text { color: var(--amber) !important; }
.green-text { color: var(--green) !important; }

/* --- сводка администратора ------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
.tile {
  background: var(--card); border-radius: var(--r-card); padding: 14px; cursor: pointer; box-shadow: var(--shadow); border: 1px solid var(--edge);
  display: flex; flex-direction: column; gap: 4px; min-height: 96px; overflow-wrap: normal; min-width: 0;
}
.tile .glyph { color: var(--accent); display: grid; }
.tile .glyph .ico { width: 22px; height: 22px; }
.tile b { font-size: 15.5px; line-height: 1.25; margin-top: 4px; }
.tile span { color: var(--hint); font-size: 13px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile-top { display: flex; align-items: center; justify-content: space-between; }
.tile .glyph { width: 40px; height: 40px; border-radius: 12px; background: var(--accent-tint); place-items: center; }
.tile .tile-count {
  min-width: 26px; height: 26px; padding: 0 8px; border-radius: 13px; display: grid; place-items: center; overflow: visible;
  background: var(--grad-button); color: var(--button-text); font-size: 13px; font-weight: 700; box-shadow: var(--glow);
}
.tile.hot { border-color: var(--accent-soft); }
.tile:active { opacity: .88; }

.totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.total { background: var(--card); border-radius: 16px; padding: 12px 4px; text-align: center; overflow-wrap: normal; cursor: pointer; box-shadow: var(--shadow); border: 1px solid var(--edge); }
div.total:not([role]) { cursor: default; }
.total b { display: block; font: 700 21px/1.2 var(--display); font-variant-numeric: tabular-nums; }
.total span { font-size: 12px; color: var(--hint); }

.server { display: block; width: 100%; border: 0; text-align: left; cursor: pointer; }
.server:active { opacity: .88; }
.server-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.server-head h3 { margin: 0; font: 650 17px/1.3 var(--display); flex: 1; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 6px; }
.stat b { display: block; font: 700 19px/1.2 var(--display); font-variant-numeric: tabular-nums; }
.stat span { font-size: 12.5px; color: var(--hint); }
.stat.alert b { color: var(--red); }
.stat.warn b { color: var(--amber); }

/* --- кнопки ---------------------------------------------------------------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 48px; padding: 10px 16px; border: 0; border-radius: var(--r-ctl); cursor: pointer;
  background: var(--grad-button); color: var(--button-text); font-weight: 600; font-size: 16px; box-shadow: var(--glow);
  transition: transform .08s ease, background-color .15s ease, opacity .15s ease, box-shadow .15s ease;
}
.btn:active { transform: scale(.985); box-shadow: none; }
.btn.big { min-height: 54px; font-size: 17px; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.secondary { background: var(--accent-tint); color: var(--accent); box-shadow: none; }
.btn.secondary:active, .btn.ghost:active { background: var(--track); }
.btn.ghost { background: transparent; color: var(--accent); box-shadow: none; }
.btn.danger { background: var(--tint-red); color: var(--red); box-shadow: none; }
.btn.danger:active { background: var(--tint-red); }
.btn.small { min-height: 36px; padding: 7px 8px; gap: 6px; font-size: 14px; font-weight: 500; border-radius: 11px; white-space: nowrap; overflow: hidden; }
.btn.small .ico { width: 16px; height: 16px; }
.btn.busy { opacity: .6; pointer-events: none; }
.btn.busy::after {
  content: ""; flex: none; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
.row-link { border: 0; background: none; color: var(--accent); font-size: 15px; font-weight: 500; padding: 8px 4px; cursor: pointer; }
.btns { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.btns > .btn:not(.small) { padding-left: 8px; padding-right: 8px; }
.btns.one { grid-template-columns: 1fr; }
.btns.three { grid-template-columns: repeat(3, 1fr); }
.btns .wide { grid-column: 1 / -1; }
.btn.two-line { flex-direction: column; gap: 1px; }
.btn.two-line small { font-weight: 400; font-size: 12.5px; opacity: .85; }
.key-head.link { cursor: pointer; }
.stack > * + * { margin-top: 8px; }

/* --- карточки ключей администратора --------------------------------------- */
.key-card { padding-bottom: 12px; }
.key-head { display: flex; align-items: center; gap: 8px; }
.key-head .label { flex: 1; font-weight: 600; min-width: 0; }
.key-lines { margin: 8px 0 12px; font-size: 13.5px; }
.key-lines div { color: var(--hint); }
.key-lines div b { color: var(--text); font-weight: 500; }
.server-group { margin: 16px 2px 8px; font-size: 14px; font-weight: 600; color: var(--hint); }
.server-group:first-child { margin-top: 0; }

/* --- формы ----------------------------------------------------------------- */
.search {
  width: 100%; padding: 13px 16px; border: 1px solid var(--edge); border-radius: 16px; background: var(--card);
  font-size: 16px; outline: none; box-shadow: var(--shadow);
}
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 12px 20px 2px; margin: 0 -20px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 14px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--card); color: var(--text); font-size: 14px;
}
.chip.on { background: var(--grad-button); color: var(--button-text); box-shadow: var(--glow); }
.chips.wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }

.field { display: block; margin-top: 16px; }
.field > span { display: block; font-size: 14px; color: var(--hint); margin: 0 2px 6px; }
.field input, .field select, .field textarea {
  display: block; width: 100%; padding: 12px 14px; border: 0; border-radius: var(--r-ctl);
  background: var(--card); font-size: 16px; outline: none; appearance: none; -webkit-appearance: none;
}
.card .field input, .card .field textarea { background: var(--page); }
.field input:focus, .field textarea:focus, .search:focus, .compose:focus-within { box-shadow: 0 0 0 2px var(--accent-soft); }
.field textarea { min-height: 76px; resize: vertical; }
.field ::placeholder, .search::placeholder { color: var(--hint); opacity: .75; }
.field .hint { font-size: 13px; color: var(--hint); margin: 6px 2px 0; }
.check { display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.check .main { flex: 1; }
.check + .check { border-top: 1px solid var(--line); }
.form-actions { margin-top: 24px; }
.form-actions.tight { margin-top: 10px; }

.secret {
  display: block; width: 100%; min-height: 96px; padding: 12px; border: 0; border-radius: 12px;
  background: var(--page); font: 12.5px/1.45 var(--mono); resize: none; word-break: break-all;
}
pre.config {
  margin: 8px 0 0; padding: 12px; border-radius: 12px; background: var(--page);
  font: 12px/1.45 var(--mono); white-space: pre-wrap; word-break: break-all;
}
details > summary { cursor: pointer; color: var(--accent); font-weight: 500; padding: 4px 0; }
details[open] > summary { margin-bottom: 10px; }
.key-actions { margin-top: 12px; }

.error-box { background: var(--tint-red); color: var(--red); border-radius: 12px; padding: 12px 14px; }

/* --- нижние вкладки и тосты ------------------------------------------------ */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  padding: 6px 8px calc(8px + var(--safe-bottom));
  background: var(--card);
  border-top: 1px solid var(--line);
}
#tabs .inner { display: flex; width: 100%; max-width: 600px; }
.tab {
  flex: 1; min-width: 0; border: 0; background: none; cursor: pointer; color: var(--hint);
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 5px 0 2px; font-size: 12px; position: relative;
  white-space: nowrap;
}
.tab .ico { width: 23px; height: 23px; }
.tab.on { color: var(--accent); font-weight: 600; }
.tab.on .ico { stroke-width: 2.1; fill: var(--accent-tint); }
.tab .count {
  position: absolute; top: 0; left: calc(50% + 7px); min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; line-height: 18px; font-weight: 600;
}

#toast {
  position: fixed; left: 50%; bottom: calc(88px + var(--safe-bottom)); z-index: 20;
  transform: translate(-50%, 10px); opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
  width: max-content; max-width: min(92vw, 420px); padding: 12px 18px; border-radius: 14px;
  background: var(--toast-bg); color: #fff; font-size: 14.5px; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: rgba(176, 40, 34, .96); }

/* Линия полета без анимации: анимированный пунктир в WebView может остаться на промежуточном
   кадре и показать неверный остаток срока. */
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  html.theme-anim, html.theme-anim * { transition: none !important; }
}
@media (min-width: 700px) {
  .page { padding-top: calc(28px + var(--safe-top)); }
}

/* Подсказка: серый блок со значком «i» */
.info { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 16px; background: var(--tint-gray); color: var(--hint); font-size: 14px; }
.info .ico { color: var(--hint); width: 20px; height: 20px; margin-top: 1px; }
.info .main { flex: 1; min-width: 0; }
.info .btn { margin-top: 10px; width: auto; min-height: 38px; padding: 8px 16px; font-size: 14.5px; }

/* --- профиль -------------------------------------------------------------- */
.member {
  position: relative; overflow: hidden; margin-top: 14px; padding: 22px 20px 18px; border-radius: var(--r-pass);
  background: var(--grad-hero); color: #fff; box-shadow: var(--hero-glow);
}
.member-mark { position: absolute; right: -28px; top: -18px; width: 150px; height: 150px; opacity: .16; filter: brightness(0) invert(1); pointer-events: none; }
.member-top { position: relative; display: flex; align-items: center; gap: 16px; }
.avatar {
  position: relative; width: 66px; height: 66px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, .16); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .7);
  font: 700 28px/1 var(--display); overflow: hidden;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.member-name { min-width: 0; }
.member-name b { display: block; font: 700 22px/1.2 var(--display); letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; }
.member-name span { display: block; margin-top: 3px; color: rgba(255, 255, 255, .8); font-size: 14.5px; }
.member-bottom {
  position: relative; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  margin-top: 20px; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .22);
}
.member-bottom span { display: block; color: rgba(255, 255, 255, .72); font-size: 13px; }
.member-bottom b { display: block; margin-top: 2px; font-size: 16px; font-weight: 600; }
.member-pill { flex: none; padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, .18); color: #fff !important; font-size: 13.5px !important; font-weight: 600; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.stat-tile {
  background: var(--card); border-radius: var(--r-card); padding: 14px 8px; text-align: center;
  box-shadow: var(--shadow); border: 1px solid var(--edge); overflow-wrap: normal;
}
.stat-tile b { display: block; font: 700 21px/1.2 var(--display); color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-tile span { display: block; margin-top: 2px; font-size: 12.5px; color: var(--hint); }
.setting { display: grid; gap: 14px; }
.setting-head { display: flex; align-items: center; gap: 14px; }
.setting-head .icon.boxed { width: 42px; height: 42px; border-radius: 13px; background: var(--accent-tint); color: var(--accent); display: grid; place-items: center; flex: none; }
.setting-head b { display: block; font-weight: 600; }
.setting-head span { display: block; font-size: 13.5px; color: var(--hint); }
.section-gap { margin-top: 10px; }
.colophon { margin: 28px 0 0; text-align: center; color: var(--hint); font-size: 13px; opacity: .7; }

/* --- шапка сводки админа -------------------------------------------------- */
.summary {
  position: relative; overflow: hidden; padding: 20px 20px 18px; border-radius: var(--r-pass);
  background: var(--grad-hero); color: #fff; box-shadow: var(--hero-glow);
}
.summary-label { position: relative; display: block; font-size: 14px; color: rgba(255, 255, 255, .82); }
.summary-sum { position: relative; display: block; margin-top: 4px; font: 800 40px/1.05 var(--display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.summary-split { position: relative; display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 14px; color: rgba(255, 255, 255, .86); }
.summary-pills { position: relative; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 18px; }
.summary-pill {
  padding: 10px 4px; border-radius: 16px; background: rgba(255, 255, 255, .16); text-align: center; overflow-wrap: normal;
}
.summary-pill[role] { cursor: pointer; }
.summary-pill[role]:active { background: rgba(255, 255, 255, .26); }
.summary-pill b { display: block; font: 700 19px/1.2 var(--display); font-variant-numeric: tabular-nums; }
.summary-pill span { display: block; margin-top: 1px; font-size: 11.5px; color: rgba(255, 255, 255, .8); }
.summary + .tiles { margin-top: 14px; }

/* Отвеченные вопросы у админа: переписка с клиентом внутри карточки */
.convo + .convo { margin-top: 12px; }
.convo-head { display: flex; align-items: center; gap: 10px; margin: -2px 0 12px; cursor: pointer; }
.convo-head b { flex: 1; min-width: 0; font-size: 16px; }
.convo-head span { color: var(--hint); font-size: 13.5px; }
.convo .bubble.theirs { background: var(--page); box-shadow: none; border: 0; }
.convo .bubble.mine .who { color: inherit; opacity: .85; }

/* Режим «смотрю как клиент» у админа */
.viewas { position: sticky; top: 0; z-index: 30; background: var(--grad-button); color: var(--button-text); }
.viewas .inner { max-width: 600px; margin: 0 auto; padding: calc(8px + var(--safe-top)) 16px 8px; display: flex; align-items: center; gap: 12px; font-size: 14px; }
.viewas .inner span { flex: 1; min-width: 0; }
.viewas button { flex: none; border: 0; border-radius: 999px; padding: 6px 14px; background: rgba(255, 255, 255, .22); color: inherit; font-weight: 600; cursor: pointer; }
body.viewing .page { padding-top: 16px; }
