/* ================================================================
   VPN Panel — Dark Cyberpunk / Terminal Aesthetic
   Mobile-first optimized
   ================================================================ */
:root {
  --bg:         #080d17;
  --bg2:        #0e1628;
  --bg3:        #151f35;
  --border:     #1e2d4a;
  --border2:    #2a3f66;
  --text:       #c8d6ef;
  --text2:      #7a93b8;
  --accent:     #2563eb;
  --accent-h:   #3b7cf6;
  --accent2:    #7c3aed;
  --green:      #10b981;
  --red:        #ef4444;
  --yellow:     #f59e0b;
  --font-mono:  'Space Mono', monospace;
  --font-body:  'IBM Plex Sans', sans-serif;
  --radius:     8px;
  --sidebar-w:  240px;
  --shadow:     0 4px 24px rgba(0,0,0,.4);
  --topbar-h:   56px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ================================================================
   МОБИЛЬНЫЙ ТОПБАР
   ================================================================ */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 200;
}
.mobile-topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: .9rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
}
.mobile-topbar-brand .brand-icon-m {
  font-size: 1.3rem;
  filter: drop-shadow(0 0 6px var(--accent));
}

/* Бургер */
.burger-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 8px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.burger-btn:hover { background: var(--border); }
.burger-btn span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform .25s, opacity .25s;
  pointer-events: none;
}
.burger-btn.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger-btn.is-open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.burger-btn.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ================================================================
   ОВЕРЛЕЙ
   ================================================================ */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 150;
  /* По умолчанию полностью скрыт и не перехватывает клики */
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-overlay.visible {
  opacity: 1;
  pointer-events: auto; /* перехватывает клики только когда виден */
}

/* ================================================================
   SIDEBAR
   ================================================================ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 160;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  will-change: transform;
}
.sidebar-brand {
  padding: 24px 20px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand-icon { font-size: 1.6rem; filter: drop-shadow(0 0 8px var(--accent)); }
.brand-name { font-family: var(--font-mono); font-size: .95rem; font-weight: 700; color: #fff; }

.nav-links {
  list-style: none;
  padding: 12px 0;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.nav-links li + li { margin-top: 2px; }
.nav-divider { height: 1px; background: var(--border); margin: 8px 16px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  color: var(--text2);
  text-decoration: none;
  font-size: .88rem;
  border-radius: var(--radius);
  margin: 0 8px;
  transition: background .15s, color .15s;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.nav-link svg {
  width: 17px; height: 17px;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; flex-shrink: 0;
  stroke-linecap: round; stroke-linejoin: round;
}
.nav-link:hover  { background: var(--bg3); color: var(--text); }
.nav-link.active {
  background: rgba(37,99,235,.15);
  color: #60a5fa;
  border-left: 2px solid var(--accent);
  margin-left: 6px;
}
.nav-admin   { color: #f59e0b; }
.nav-support { color: var(--green); }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}
.lang-switcher {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: .8rem;
  color: var(--text2);
}
.lang-switcher a {
  color: var(--text2);
  text-decoration: none;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color .15s;
  min-height: 32px;
  display: flex;
  align-items: center;
}
.lang-switcher a.active { color: var(--accent-h); font-weight: 600; }
.lang-switcher span { color: var(--border2); }
.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: rgba(239,68,68,.1);
  color: var(--red);
  border: 1px solid rgba(239,68,68,.25);
  border-radius: var(--radius);
  text-decoration: none;
  font-size: .85rem;
  transition: background .15s;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.logout-btn:hover { background: rgba(239,68,68,.2); }

/* ================================================================
   MAIN CONTENT
   ================================================================ */
.main-wrap {
  margin-left: var(--sidebar-w);
  padding: 32px;
  min-height: 100vh;
}
.page-header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.page-header h1 { font-family: var(--font-mono); font-size: 1.4rem; color: #fff; }
.page-header p  { color: var(--text2); margin-top: 4px; font-size: .9rem; }
.page-header.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

/* ================================================================
   AUTH
   ================================================================ */
.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
  background:
    radial-gradient(ellipse at 30% 40%, rgba(37,99,235,.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 70%, rgba(124,58,237,.06) 0%, transparent 50%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  box-shadow: var(--shadow);
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo .logo-icon { font-size: 2.5rem; display: block; margin-bottom: 8px; filter: drop-shadow(0 0 12px var(--accent)); }
.auth-logo h1 { font-family: var(--font-mono); font-size: 1.3rem; color: #fff; }
.auth-logo p  { color: var(--text2); font-size: .85rem; margin-top: 4px; }

/* ================================================================
   CARDS
   ================================================================ */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; }
.stat-card.blue::before   { background: var(--accent); }
.stat-card.purple::before { background: var(--accent2); }
.stat-card.green::before  { background: var(--green); }
.stat-card.yellow::before { background: var(--yellow); }
.stat-label { font-size: .78rem; color: var(--text2); text-transform: uppercase; letter-spacing: .08em; }
.stat-value { font-family: var(--font-mono); font-size: 1.8rem; color: #fff; margin-top: 6px; line-height: 1; }
.stat-sub   { font-size: .78rem; color: var(--text2); margin-top: 4px; }

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 8px;
  flex-wrap: wrap;
}
.card-title { font-family: var(--font-mono); font-size: .95rem; color: #fff; }

/* ================================================================
   FORMS
   ================================================================ */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .82rem; color: var(--text2); margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: max(.9rem, 16px);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  -webkit-appearance: none;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.form-control::placeholder { color: var(--text2); opacity: .6; }
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a93b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.captcha-row { display: flex; gap: 12px; align-items: flex-end; }
.captcha-img-wrap { flex-shrink: 0; cursor: pointer; touch-action: manipulation; }
.captcha-img-wrap img { border-radius: 6px; border: 1px solid var(--border2); display: block; height: 50px; }
.captcha-row .form-group { flex: 1; margin-bottom: 0; }

/* ================================================================
   BUTTONS
   ================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover   { background: var(--accent-h); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,.3); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border2); }
.btn-secondary:hover { background: var(--border); }
.btn-danger    { background: rgba(239,68,68,.15); color: var(--red);   border: 1px solid rgba(239,68,68,.3); }
.btn-danger:hover    { background: rgba(239,68,68,.25); }
.btn-success   { background: rgba(16,185,129,.15); color: var(--green); border: 1px solid rgba(16,185,129,.3); }
.btn-success:hover   { background: rgba(16,185,129,.25); }
.btn-sm   { padding: 6px 14px; font-size: .82rem; min-height: 36px; }
.btn-full { width: 100%; }

/* ================================================================
   ALERTS
   ================================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .88rem;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.5;
}
.alert-error   { background: rgba(239,68,68,.1);  border: 1px solid rgba(239,68,68,.3);  color: #fca5a5; }
.alert-success { background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.3); color: #6ee7b7; }
.alert-info    { background: rgba(37,99,235,.1);  border: 1px solid rgba(37,99,235,.3);  color: #93c5fd; }
.alert-warn    { background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); color: #fcd34d; }

/* ================================================================
   TABLES
   ================================================================ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; min-width: 480px; }
thead th {
  background: var(--bg3);
  padding: 12px 16px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .08em;
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg3); }
tbody td { padding: 12px 16px; font-size: .88rem; }

/* ================================================================
   BADGES
   ================================================================ */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}
.badge-green  { background: rgba(16,185,129,.15);  color: var(--green); }
.badge-red    { background: rgba(239,68,68,.15);   color: var(--red); }
.badge-yellow { background: rgba(245,158,11,.15);  color: var(--yellow); }
.badge-blue   { background: rgba(37,99,235,.15);   color: #60a5fa; }
.badge-gray   { background: rgba(120,130,150,.15); color: var(--text2); }
.badge-purple { background: rgba(124,58,237,.15);  color: #a78bfa; }

/* ================================================================
   VLESS BLOCK
   ================================================================ */
.vless-block {
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 12px 14px 44px;
  font-family: var(--font-mono);
  font-size: .75rem;
  color: #86efac;
  word-break: break-all;
  position: relative;
  line-height: 1.6;
}
.copy-btn {
  position: absolute;
  bottom: 8px; right: 8px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text2);
  padding: 5px 12px;
  border-radius: 4px;
  font-size: .75rem;
  cursor: pointer;
  transition: all .15s;
  touch-action: manipulation;
  min-height: 32px;
  -webkit-tap-highlight-color: transparent;
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ================================================================
   PLAN CARDS
   ================================================================ */
.plans-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.plan-card {
  background: var(--bg2);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  transition: border-color .2s, transform .2s;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.plan-card:hover    { border-color: var(--accent); transform: translateY(-3px); }
.plan-card.selected { border-color: var(--accent); background: rgba(37,99,235,.08); }
.plan-name  { font-family: var(--font-mono); font-size: 1rem; color: #fff; margin-bottom: 8px; }
.plan-price { font-family: var(--font-mono); font-size: 2rem; color: var(--accent); font-weight: 700; }
.plan-price-sub { font-size: .8rem; color: var(--text2); }
.plan-features { list-style: none; margin: 16px 0; font-size: .85rem; color: var(--text2); }
.plan-features li { padding: 4px 0; }
.plan-features li::before { content: '✓ '; color: var(--green); }

/* ================================================================
   TICKETS
   ================================================================ */
.ticket-msg { padding: 14px; border-radius: var(--radius); margin-bottom: 12px; }
.ticket-msg.user  { background: var(--bg3); border: 1px solid var(--border); }
.ticket-msg.staff { background: rgba(37,99,235,.08); border: 1px solid rgba(37,99,235,.2); }
.ticket-msg-header {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
  font-size: .78rem;
  color: var(--text2);
}
.ticket-msg-body { font-size: .9rem; white-space: pre-wrap; word-break: break-word; }

/* ================================================================
   WHEEL
   ================================================================ */
.wheel-container { display: flex; flex-direction: column; align-items: center; gap: 24px; }
canvas#wheel { border-radius: 50%; box-shadow: 0 0 40px rgba(37,99,235,.3); max-width: 100%; height: auto; }
#spin-btn {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  padding: 14px 48px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none; color: #fff;
  border-radius: 30px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  touch-action: manipulation;
  min-height: 52px;
  -webkit-tap-highlight-color: transparent;
}
#spin-btn:hover:not(:disabled) { transform: scale(1.05); box-shadow: 0 8px 24px rgba(37,99,235,.4); }
#spin-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ================================================================
   QUICK LINKS
   ================================================================ */
.quick-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-size: .85rem;
  text-align: center;
  transition: border-color .15s, background .15s, transform .15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.quick-link:hover     { border-color: var(--accent); background: rgba(37,99,235,.08); transform: translateY(-2px); }
.quick-link-icon      { font-size: 1.6rem; line-height: 1; }
.quick-link-val       { font-size: .78rem; font-family: var(--font-mono); }
.quick-link-disabled  { opacity: .45; pointer-events: none; }

/* ================================================================
   UTILS
   ================================================================ */
.text-muted  { color: var(--text2); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }  .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; } .gap-3 { gap: 16px; }
.mono { font-family: var(--font-mono); }
hr.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ================================================================
   RESPONSIVE — Tablet ≤ 900px
   ================================================================ */
@media (max-width: 900px) {
  :root { --sidebar-w: 220px; }
  .main-wrap { padding: 24px; }
  .cards-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
}

/* ================================================================
   RESPONSIVE — Mobile ≤ 768px
   ================================================================ */
@media (max-width: 768px) {
  .mobile-topbar { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    top: 0;
    height: 100dvh;
    width: min(var(--sidebar-w), 82vw);
    box-shadow: 4px 0 24px rgba(0,0,0,.5);
  }
  .sidebar.is-open { transform: translateX(0); }

  .sidebar-brand { display: none; }

  .main-wrap {
    margin-left: 0;
    padding: 16px;
    padding-top: calc(var(--topbar-h) + 16px);
  }

  .auth-wrap { padding: 12px; }
  .auth-card { padding: 24px 18px; }

  .cards-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 1.4rem; }

  .plans-grid { grid-template-columns: 1fr; }

  .page-header h1 { font-size: 1.15rem; }
  .page-header.flex-between { flex-direction: column; align-items: flex-start; gap: 10px; }

  .card { padding: 14px; }
  .card-header { gap: 6px; }

  .flex-between { flex-wrap: wrap; gap: 8px; }

  thead th { padding: 10px 12px; font-size: .7rem; }
  tbody td { padding: 10px 12px; font-size: .82rem; }

  .btn-primary:hover,
  .btn-secondary:hover,
  .btn-danger:hover,
  .btn-success:hover { transform: none; box-shadow: none; }
  .plan-card:hover  { transform: none; }
  .quick-link:hover { transform: none; }

  canvas#wheel { width: 280px !important; height: 280px !important; }
  #spin-btn { padding: 14px 32px; font-size: 1rem; }
}

/* ================================================================
   RESPONSIVE — Small phones ≤ 420px
   ================================================================ */
@media (max-width: 420px) {
  html { font-size: 14px; }
  .cards-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 20px 14px; }
  .captcha-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .captcha-img-wrap img { width: 100%; height: 52px; object-fit: cover; }
  canvas#wheel { width: 260px !important; height: 260px !important; }
  .vless-block { font-size: .68rem; }
}