/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0a0b14;
  --bg2:       #0f1120;
  --bg3:       #161929;
  --surface:   #1a1d2e;
  --border:    rgba(255,255,255,0.08);
  --text:      #e8eaf0;
  --text2:     #8b90a8;
  --text3:     #5c6180;
  --accent:    #7c3aed;
  --accent2:   #4f46e5;
  --success:   #10b981;
  --danger:    #ef4444;
  --warning:   #f59e0b;
  --radius:    14px;
  --radius-sm: 8px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.6);
  font-size: 16px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
.link { color: var(--accent); }
.link:hover { text-decoration: underline; }
.hidden { display: none !important; }

/* ── Typography ────────────────────────────────────────────── */
.gradient-text {
  background: linear-gradient(135deg, #a78bfa, #6366f1, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px;
  border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.875rem; font-weight: 500;
  cursor: pointer; transition: all 0.18s ease;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 2px 12px rgba(124,58,237,0.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(124,58,237,0.5); }
.btn-primary:active { transform: translateY(0); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-ghost {
  background: rgba(255,255,255,0.05);
  color: var(--text2);
}
.btn-ghost:hover { background: rgba(255,255,255,0.09); color: var(--text); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-sm { padding: 6px 14px; font-size: 0.8125rem; }
.btn-lg { padding: 14px 32px; font-size: 1rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ── Header ────────────────────────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 48px;
  background: rgba(10,11,20,0.8);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
@media (max-width: 640px) { .header { padding: 14px 20px; } }

.logo {
  font-size: 1.125rem; font-weight: 700;
  background: linear-gradient(135deg, #a78bfa, #38bdf8);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.logo-center { text-align: center; margin-bottom: 8px; font-size: 1.25rem; }

nav { display: flex; align-items: center; gap: 24px; }
.nav-link { color: var(--text2); font-size: 0.875rem; transition: color 0.15s; }
.nav-link:hover { color: var(--text); }
.nav-user { font-size: 0.875rem; color: var(--text2); }

/* ── Hero ──────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 96px 24px 80px;
  max-width: 740px; margin: 0 auto;
}
.hero-badge {
  display: inline-block;
  padding: 4px 14px;
  background: rgba(124,58,237,0.15);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 99px;
  font-size: 0.8125rem; color: #a78bfa;
  margin-bottom: 24px;
}
.hero-title {
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  font-weight: 700; line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}
.hero-sub {
  font-size: 1.125rem; color: var(--text2);
  max-width: 480px; margin: 0 auto 36px;
}
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 48px; }

.hero-stats {
  display: flex; align-items: center; justify-content: center; gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 32px;
  max-width: 480px; margin: 0 auto;
}
.stat { display: flex; flex-direction: column; align-items: center; flex: 1; }
.stat-num { font-size: 1.125rem; font-weight: 600; color: var(--text); }
.stat-label { font-size: 0.75rem; color: var(--text3); margin-top: 2px; }
.stat-sep { width: 1px; height: 40px; background: var(--border); }

/* ── Sections ──────────────────────────────────────────────── */
.section { padding: 80px 24px; max-width: 1100px; margin: 0 auto; }
.section-title {
  font-size: 2rem; font-weight: 700; text-align: center;
  margin-bottom: 48px; letter-spacing: -0.02em;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  transition: border-color 0.2s, transform 0.2s;
}
.card:hover { border-color: rgba(124,58,237,0.4); transform: translateY(-2px); }
.card-icon { font-size: 1.75rem; margin-bottom: 14px; }
.card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
.card p { color: var(--text2); font-size: 0.875rem; line-height: 1.6; }

/* ── Tiers ──────────────────────────────────────────────────── */
.tiers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  max-width: 900px; margin: 0 auto;
}
.tier-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  text-align: center;
  position: relative;
  transition: border-color 0.2s, transform 0.2s;
}
.tier-card:hover { transform: translateY(-3px); }
.tier-card.featured {
  border-color: rgba(124,58,237,0.5);
  background: linear-gradient(135deg, rgba(124,58,237,0.1), rgba(79,70,229,0.1));
}
.tier-badge-label {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-size: 0.7rem; font-weight: 600;
  padding: 3px 12px; border-radius: 99px;
  letter-spacing: 0.05em;
}
.tier-name { font-size: 1.25rem; font-weight: 700; margin-bottom: 8px; }
.tier-speed { font-size: 2rem; font-weight: 700; margin: 12px 0 4px; }
.tier-speed-unit { font-size: 0.875rem; color: var(--text2); }
.tier-traffic { color: var(--text2); font-size: 0.875rem; margin: 8px 0 20px; }
.tier-features { list-style: none; text-align: left; margin-bottom: 24px; }
.tier-features li { padding: 6px 0; font-size: 0.875rem; color: var(--text2); }
.tier-features li::before { content: "✓ "; color: var(--success); font-weight: 600; }

.tier-loading { opacity: 0.4; }
.skeleton-line {
  height: 16px; background: var(--border);
  border-radius: 4px; margin: 12px 0;
  animation: pulse 1.5s ease-in-out infinite;
}
.skeleton-line.short { width: 60%; }
@keyframes pulse { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }

/* ── Footer ────────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 40px 24px;
  border-top: 1px solid var(--border);
  color: var(--text3);
  font-size: 0.875rem;
}
.footer .logo { display: block; margin-bottom: 8px; }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px;
  width: 100%; max-width: 420px;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: slide-up 0.2s ease;
}
.modal-sm { max-width: 360px; }
@keyframes slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none;
  color: var(--text3); font-size: 1rem; cursor: pointer;
  padding: 4px 8px; border-radius: 6px;
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-title { font-size: 1.375rem; font-weight: 700; margin-bottom: 24px; }
.modal-sub { color: var(--text2); font-size: 0.875rem; margin-bottom: 20px; }
.modal-hint { text-align: center; font-size: 0.8125rem; color: var(--text3); margin-top: 16px; }

.tab-bar {
  display: flex; gap: 4px;
  background: var(--bg3);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 28px;
}
.tab-btn {
  flex: 1; padding: 8px; border: none; border-radius: 7px;
  background: none; color: var(--text2);
  font-family: inherit; font-size: 0.875rem; cursor: pointer;
  transition: all 0.15s;
}
.tab-btn.active { background: var(--surface); color: var(--text); font-weight: 500; }

/* ── Form ───────────────────────────────────────────────────── */
.field { margin-bottom: 18px; }
.field label {
  display: block; font-size: 0.8125rem; font-weight: 500;
  color: var(--text2); margin-bottom: 6px;
}
.field label .hint { font-weight: 400; color: var(--text3); }
.field input {
  width: 100%; padding: 10px 14px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: inherit; font-size: 0.9rem;
  transition: border-color 0.15s;
  outline: none;
}
.field input:focus { border-color: var(--accent); }
.form-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.8125rem;
  margin-bottom: 14px;
}

/* ── Dashboard ──────────────────────────────────────────────── */
.dashboard {
  max-width: 800px; margin: 48px auto;
  padding: 0 24px;
  display: grid;
  gap: 20px;
}

.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.dash-card h3 {
  font-size: 0.875rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text2); margin-bottom: 18px;
}

/* Status */
.status-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.status-label { font-size: 0.8125rem; color: var(--text3); margin-bottom: 6px; }
.status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 99px;
  font-size: 0.8125rem; font-weight: 500;
}
.status-badge::before { content: "●"; font-size: 0.5rem; }
.status-inactive { background: rgba(107,114,128,0.15); color: #9ca3af; }
.status-active { background: rgba(16,185,129,0.15); color: #34d399; }
.status-inactive::before { color: #6b7280; }
.status-active::before { color: var(--success); animation: blink 2s ease-in-out infinite; }
@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:0.4; } }

.status-ip { font-size: 1.75rem; font-weight: 700; font-family: monospace; letter-spacing: -0.01em; }
.status-hint { font-size: 0.8125rem; color: var(--text3); }

.tier-badge {
  padding: 4px 12px; border-radius: 99px;
  font-size: 0.8125rem; font-weight: 600;
}

/* Traffic */
.traffic-bar-wrap { margin-bottom: 16px; }
.traffic-bar {
  height: 8px; background: var(--bg3);
  border-radius: 99px; overflow: hidden; margin-bottom: 8px;
}
.traffic-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 99px;
  transition: width 0.6s ease;
}
.traffic-fill.danger { background: var(--danger); }
.traffic-fill.warning { background: var(--warning); }
.traffic-labels {
  display: flex; justify-content: space-between;
  font-size: 0.8125rem; color: var(--text2);
}
.traffic-sub {
  display: flex; gap: 24px; flex-wrap: wrap;
  font-size: 0.875rem; color: var(--text2);
}
.traffic-sub .label { color: var(--text3); }

/* Config */
.config-placeholder {
  text-align: center; padding: 32px;
  color: var(--text2); font-size: 0.875rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.qr-container { text-align: center; margin-bottom: 20px; }
.qr-img {
  width: 180px; height: 180px;
  border-radius: var(--radius-sm);
  border: 3px solid var(--border);
}
.qr-hint { font-size: 0.8125rem; color: var(--text3); margin-top: 8px; }
.config-actions { display: flex; gap: 12px; margin-bottom: 20px; justify-content: center; }
.install-hint {
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  font-size: 0.8125rem;
}
.install-hint strong { display: block; margin-bottom: 8px; color: var(--text); }
.install-hint ol { padding-left: 18px; color: var(--text2); line-height: 2; }
#create-btn { margin-top: 16px; }

/* ── Admin ──────────────────────────────────────────────────── */
.admin-body { display: flex; min-height: 100vh; }

.admin-login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
}
.admin-login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 40px;
  width: 100%; max-width: 380px;
}
.admin-login-card h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 24px; }

.sidebar {
  width: 220px; min-height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex; flex-direction: column;
  flex-shrink: 0;
}
.sidebar-nav { margin-top: 32px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.sidebar-link {
  display: block; padding: 10px 14px;
  border-radius: 8px; cursor: pointer;
  font-size: 0.875rem; color: var(--text2);
  transition: all 0.15s;
}
.sidebar-link:hover, .sidebar-link.active {
  background: rgba(124,58,237,0.12);
  color: var(--text);
}
.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }

.admin-main { flex: 1; padding: 32px; overflow-x: hidden; }

.stats-bar {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-bottom: 32px;
}
@media (max-width: 900px) { .stats-bar { grid-template-columns: repeat(2,1fr); } }
.stat-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex; flex-direction: column;
}
.stat-chip span:first-child { font-size: 1.5rem; font-weight: 700; }
.stat-chip span:last-child { font-size: 0.75rem; color: var(--text3); margin-top: 2px; }

.admin-section h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 20px; }

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 16px; flex-wrap: wrap;
}
.section-actions { display: flex; align-items: center; gap: 10px; }
.search-input {
  padding: 7px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-family: inherit; font-size: 0.875rem;
  outline: none;
}
.search-input:focus { border-color: var(--accent); }

.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.admin-table {
  width: 100%; border-collapse: collapse;
  background: var(--surface);
}
.admin-table th {
  padding: 12px 16px; text-align: left;
  font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
}
.admin-table td {
  padding: 14px 16px;
  font-size: 0.875rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: rgba(255,255,255,0.02); }
.table-loading { text-align: center; color: var(--text3); padding: 40px !important; }

.user-cell { display: flex; flex-direction: column; }
.user-name { font-weight: 500; }
.user-meta { font-size: 0.75rem; color: var(--text3); }

.tier-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 99px;
  font-size: 0.75rem; font-weight: 600;
}
.tier-dot { width: 6px; height: 6px; border-radius: 50%; }

.traffic-mini { font-size: 0.8125rem; }
.traffic-mini-bar {
  height: 4px; background: var(--bg3);
  border-radius: 99px; overflow: hidden;
  margin-top: 4px; width: 80px;
}
.traffic-mini-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 99px;
}

.toggle-wrap { display: flex; }
.toggle {
  position: relative; width: 38px; height: 22px; cursor: pointer;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--bg3); border-radius: 99px;
  transition: background 0.2s;
}
.toggle-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--text3);
  transition: all 0.2s;
}
.toggle input:checked ~ .toggle-track { background: var(--success); }
.toggle input:checked ~ .toggle-thumb { transform: translateX(16px); background: #fff; }

.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-xs { padding: 4px 10px; font-size: 0.75rem; }

/* Tier modal */
.tier-options { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.tier-opt {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); font-family: inherit; font-size: 0.875rem;
  cursor: pointer; text-align: left; transition: border-color 0.15s;
}
.tier-opt:hover { border-color: var(--accent); }
.tier-opt small { margin-left: auto; color: var(--text3); font-size: 0.75rem; }
.tier-opt-pro { border-color: rgba(139,92,246,0.3); }

/* Toasts */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 2000;
  padding: 12px 20px; border-radius: 10px;
  font-size: 0.875rem; font-weight: 500;
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
@keyframes toast-in {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ── Tier breakdown ─────────────────────────────────────────── */
.tier-breakdown { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.tier-row { display: flex; align-items: center; gap: 12px; font-size: 0.875rem; }
.tier-row-name { width: 80px; color: var(--text2); }
.tier-row-count { width: 32px; font-weight: 600; }
.tier-row-bar {
  flex: 1; height: 6px; background: var(--bg3);
  border-radius: 99px; overflow: hidden;
}
.tier-row-fill { height: 100%; border-radius: 99px; }
