/* ============================================================
   AntiBS 2 VPN — Личный кабинет
   Темы: violet (сине-фиолетовая), light (светлая), auto (Telegram)
   ============================================================ */

/* ---------- ТЕМА VIOLET (по умолчанию) ---------- */
html[data-theme="custom"] {}
html[data-theme="violet"], html {
  --bg: #0c0e1d;
  --card: #161a35;
  --text: #eceefc;
  --muted: #9aa0c3;
  --accent: #6366f1;
  --accent-2: #a855f7;
  --accent-text: #ffffff;
  --ok: #22c55e;
  --ok-text: #06210f;
  --ok-soft: rgba(34, 197, 94, .18);
  --ok-ink: #86efac;
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, .15);
  --danger-ink: #fca5a5;
  --warn: #f59e0b;
  --link-soft: rgba(99, 102, 241, .22);
  --link-ink: #b1b6fc;
  --line: rgba(255, 255, 255, .09);
  --line-soft: rgba(255, 255, 255, .06);
  --soft: rgba(255, 255, 255, .08);
  --soft-2: rgba(255, 255, 255, .05);
  --progress-bg: rgba(255, 255, 255, .09);
  --spin-track: rgba(255, 255, 255, .15);
  --toast-bg: rgba(16, 18, 38, .96);
  --toast-line: rgba(255, 255, 255, .1);
  --hero-a: rgba(99, 102, 241, .32);
  --hero-b: rgba(168, 85, 247, 0);
  --radius: 16px;
}

/* ---------- ТЕМА TEAL ---------- */
html[data-theme="teal"] {
  --bg: #06191a;
  --card: #0d2c2e;
  --text: #e7fffb;
  --muted: #7fb8b4;
  --accent: #2dd4bf;
  --accent-2: #14b8a6;
  --accent-text: #062422;
  --ok: #4ade80;
  --ok-text: #06210f;
  --ok-soft: rgba(45, 212, 191, .18);
  --ok-ink: #99f6e4;
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, .16);
  --danger-ink: #fecdd3;
  --warn: #fbbf24;
  --link-soft: rgba(45, 212, 191, .18);
  --link-ink: #99f6e4;
  --line: rgba(45, 212, 191, .16);
  --line-soft: rgba(45, 212, 191, .10);
  --soft: rgba(45, 212, 191, .10);
  --soft-2: rgba(45, 212, 191, .06);
  --progress-bg: rgba(45, 212, 191, .14);
  --spin-track: rgba(45, 212, 191, .22);
  --toast-bg: rgba(6, 25, 26, .96);
  --toast-line: rgba(45, 212, 191, .18);
  --hero-a: rgba(45, 212, 191, .28);
  --hero-b: rgba(20, 184, 166, 0);
  --radius: 16px;
}

/* ---------- ТЕМА LIGHT ---------- */
html[data-theme="light"] {
  --bg: #f5f6fc;
  --card: #ffffff;
  --text: #1e2235;
  --muted: #6b7192;
  --accent: #4f46e5;
  --accent-2: #9333ea;
  --accent-text: #ffffff;
  --ok: #16a34a;
  --ok-text: #ffffff;
  --ok-soft: rgba(22, 163, 74, .14);
  --ok-ink: #15803d;
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, .1);
  --danger-ink: #b91c1c;
  --warn: #d97706;
  --link-soft: rgba(79, 70, 229, .12);
  --link-ink: #4338ca;
  --line: rgba(30, 34, 53, .12);
  --line-soft: rgba(30, 34, 53, .08);
  --soft: rgba(30, 34, 53, .05);
  --soft-2: rgba(30, 34, 53, .03);
  --progress-bg: rgba(30, 34, 53, .08);
  --spin-track: rgba(30, 34, 53, .12);
  --toast-bg: rgba(255, 255, 255, .97);
  --toast-line: rgba(30, 34, 53, .12);
  --hero-a: rgba(99, 102, 241, .18);
  --hero-b: rgba(168, 85, 247, 0);
}

/* ---------- ТЕМА AUTO (как в Telegram) ---------- */
html[data-theme="auto"] {
  --bg: var(--tg-theme-bg-color, #0f1115);
  --card: var(--tg-theme-secondary-bg-color, #171a21);
  --text: var(--tg-theme-text-color, #f2f4f8);
  --muted: var(--tg-theme-hint-color, #8b93a7);
  --accent: var(--tg-theme-button-color, #3b82f6);
  --accent-2: var(--accent);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --ok: #22c55e;
  --ok-text: #06210f;
  --ok-soft: rgba(34, 197, 94, .18);
  --ok-ink: #86efac;
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, .15);
  --danger-ink: #fca5a5;
  --warn: #f59e0b;
  --link-soft: rgba(59, 130, 246, .18);
  --link-ink: #93c5fd;
  --line: rgba(127, 127, 127, .25);
  --line-soft: rgba(127, 127, 127, .15);
  --soft: rgba(127, 127, 127, .14);
  --soft-2: rgba(127, 127, 127, .09);
  --progress-bg: rgba(127, 127, 127, .18);
  --spin-track: rgba(127, 127, 127, .25);
  --toast-bg: rgba(20, 22, 28, .96);
  --toast-line: rgba(255, 255, 255, .1);
  --hero-a: rgba(59, 130, 246, .28);
  --hero-b: rgba(59, 130, 246, 0);
}

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

body {
  margin: 0;
  padding: 0 0 84px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.hidden { display: none !important; }

/* ---------- загрузка / ошибка ---------- */
.loader, .fatal {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}
.fatal h2 { color: var(--text); margin: 0; }
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--spin-track);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- шапка ---------- */
.hero {
  padding: 18px 16px 14px;
  background: linear-gradient(160deg, var(--hero-a), var(--hero-b) 70%), var(--card);
  border-radius: 0 0 24px 24px;
}
.hero-row { display: flex; justify-content: space-between; align-items: flex-start; }
.hero-label { color: var(--muted); font-size: 13px; }
.hero-balance { font-size: 30px; font-weight: 700; letter-spacing: -.5px; }
.hero-right { display: flex; align-items: center; gap: 10px; }
.hero-user { text-align: right; }
.hero-username { font-weight: 600; }
.hero-sub { color: var(--muted); font-size: 12px; }
.hero-actions { display: flex; gap: 10px; margin-top: 14px; }
.hero-actions .btn { flex: 1; }
.theme-btn { padding: 6px 10px; font-size: 16px; line-height: 1.2; flex: 0 0 auto; }

.banner {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--danger-soft);
  color: var(--danger-ink);
  font-size: 13px;
}

/* ---------- блоки ---------- */
.tab { padding: 14px 16px 8px; }
.title { font-size: 17px; margin: 4px 0 12px; }
.list { display: flex; flex-direction: column; gap: 12px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card-title { font-weight: 600; margin-bottom: 10px; }
.card-row { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.muted { color: var(--muted); font-size: 13px; }
.total { color: var(--muted); font-size: 13px; text-align: center; margin: 12px 0; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--link-soft);
  color: var(--link-ink);
}
.badge.trial { background: var(--ok-soft); color: var(--ok-ink); }

/* полоса трафика */
.progress { height: 8px; border-radius: 999px; background: var(--progress-bg); overflow: hidden; margin: 10px 0 6px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px; }
.progress.warn > i { background: var(--warn); }
.progress.crit > i { background: var(--danger); }

/* ---------- кнопки и поля ---------- */
.btn {
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--soft);
  cursor: pointer;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-text); }
.btn-ok { background: var(--ok); color: var(--ok-text); }
.btn-ghost { background: transparent; border: 1px solid var(--line); }
.btn-danger { background: var(--danger); color: #fff; }
.btn[disabled] { opacity: .5; }
.wide { width: 100%; margin-top: 12px; }
.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.btn-row .btn { flex: 1; }

.row { display: flex; gap: 8px; margin-top: 10px; }
.row input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--soft-2);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 14px;
}
.row input::placeholder { color: var(--muted); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* ---------- история ---------- */
.history { display: flex; flex-direction: column; gap: 8px; }
.history-item { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.history-item:last-child { border-bottom: 0; }
.plus { color: var(--ok); font-weight: 600; }
.minus { color: var(--danger); font-weight: 600; }

/* ---------- нижняя навигация ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line-soft);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbtn {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  padding: 9px 0 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}
.tabbtn span { font-size: 11px; }
.tabbtn.active { color: var(--text); }

/* ---------- тост ---------- */
.toast {
  position: fixed;
  left: 16px; right: 16px; bottom: 78px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--toast-bg);
  border: 1px solid var(--toast-line);
  color: var(--text);
  font-size: 14px;
  text-align: center;
  z-index: 50;
}
.toast.err { border-color: rgba(239, 68, 68, .5); color: var(--danger-ink); }
.toast.ok { border-color: rgba(34, 197, 94, .5); color: var(--ok-ink); }

/* --- устройства (чекбоксы) --- */
.chk-row{display:flex;gap:10px;align-items:center;padding:8px 0;border-bottom:1px solid rgba(128,128,128,.15)}
.chk-row input{flex:none;width:18px;height:18px;accent-color:var(--accent,#7c6cff)}
.chk-text{flex:1;word-break:break-word;font-size:13px}
.muted.small{font-size:12px}



/* --- page transitions + overlay loader --- */
@keyframes antibs-fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes antibs-spin { to { transform: rotate(360deg); } }
.tab-page:not(.hidden),
[id^="tab-"]:not(.hidden) {
  animation: antibs-fade-up .28s ease both;
}
.tabbtn, .tab, .bnav-item { transition: color .2s ease, background .2s ease, transform .15s ease; }
.tabbtn.active, .tab.active, .bnav-item.active { transform: translateY(-1px); }
.antibs-overlay {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8,10,18,.45); backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.antibs-overlay.show { opacity: 1; pointer-events: auto; }
.antibs-overlay .spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.18);
  border-top-color: #7c6cff;
  animation: antibs-spin .7s linear infinite;
}

details.fold { margin: 0; }
details.fold > summary {
  list-style: none; cursor: pointer; font-size: 17px; font-weight: 700;
  padding: 2px 0 8px; display: flex; align-items: center; gap: 8px;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "▸"; color: var(--accent); width: 16px; flex: 0 0 16px; }
details.fold[open] > summary::before { content: "▾"; }
details.fold > summary:hover { color: var(--accent); }
