:root {
  --bg: #0b1020;
  --bg-elevated: #121a2e;
  --surface: #161f35;
  --surface-2: #1c2742;
  --border: rgba(148, 163, 184, 0.12);
  --text: #eef2ff;
  --muted: #94a3b8;
  --accent: #8b5cf6;
  --accent-hover: #a78bfa;
  --accent-soft: rgba(139, 92, 246, 0.15);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --font: "Vazirmatn", "Tahoma", system-ui, sans-serif;
  --bottom-nav-h: 64px;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body.theme-jaysub {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}

a { color: var(--accent-hover); text-decoration: none; }
.muted { color: var(--muted); font-size: 0.88rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary, .btn.primary {
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  color: #fff;
}
.btn-primary:hover, .btn.primary:hover { filter: brightness(1.08); }
.btn-secondary, .btn.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn.block, .btn.full { width: 100%; }
.btn.small { padding: 0.4rem 0.75rem; font-size: 0.8rem; }

.ui-card, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.card-title, .ui-card .card-title { margin: 0 0 0.85rem; font-size: 1rem; font-weight: 600; }

.alert { padding: 0.75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: 0.88rem; }
.alert-error, .alert.error { background: rgba(239, 68, 68, 0.12); color: #fecaca; border: 1px solid rgba(239, 68, 68, 0.25); }

form.stack label {
  display: block;
  margin: 0.75rem 0 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}
form.stack input, form.stack select, form.stack textarea {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: inherit;
}
form.stack button { margin-top: 1rem; }

/* Login */
.login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.25rem;
  background: radial-gradient(ellipse at top, rgba(139, 92, 246, 0.12), transparent 55%), var(--bg);
}
.login-box {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.login-box h1 { margin: 0 0 0.5rem; text-align: center; font-size: 1.2rem; }
.login-hint { text-align: center; margin: 0 0 1rem; }
.login-box form.login-form label { display: block; margin: 0.75rem 0 0.3rem; font-size: 0.85rem; color: var(--muted); }
.login-box form.login-form input {
  width: 100%;
  padding: 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
}
.login-box form.login-form button { width: 100%; margin-top: 1rem; }

/* Admin layout */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  transform: translateX(0);
  transition: transform 0.2s ease;
}
.sidebar-brand {
  font-weight: 700;
  font-size: 1.15rem;
  padding: 0 0.75rem 1.25rem;
  color: var(--text);
}
.sidebar-brand span { color: var(--accent); font-weight: 500; font-size: 0.85rem; }
.sidebar-nav { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}
.sidebar-link:hover { background: var(--accent-soft); color: var(--text); }
.sidebar-link.active {
  background: var(--accent-soft);
  color: #fff;
  border: 1px solid rgba(139, 92, 246, 0.35);
}
.sidebar-link .ico { opacity: 0.85; width: 1.25rem; text-align: center; }
.sidebar-logout {
  margin-top: auto;
  padding: 0.75rem;
  text-align: center;
  color: var(--muted);
  border-top: 1px solid var(--border);
}
.admin-main {
  flex: 1;
  margin-right: 260px;
  min-width: 0;
}
.admin-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 16, 32, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.page-title { margin: 0; font-size: 1.1rem; font-weight: 600; }
.menu-toggle {
  display: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.4rem 0.65rem;
  cursor: pointer;
}
.admin-content { padding: 1.25rem; max-width: 1200px; }
.admin-mobile-nav {
  display: none;
  overflow-x: auto;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-mobile-nav a {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
}
.admin-mobile-nav a.active { background: var(--accent-soft); color: #fff; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}
.stat-label { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.35rem; }
.stat-value { font-size: 1.35rem; font-weight: 700; }
.stat-card.accent { border-color: rgba(139, 92, 246, 0.4); background: linear-gradient(145deg, var(--surface), rgba(139, 92, 246, 0.08)); }
.stat-card.tone-success .stat-value { color: #86efac; }
.stat-card.tone-danger .stat-value { color: #fca5a5; }

.customer-greeting { margin: 0 0 1rem; font-size: 0.95rem; color: var(--muted); }
.customer-greeting strong { color: var(--text); }

.more-menu { display: flex; flex-direction: column; gap: 0.35rem; }
.more-menu a {
  display: block;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.more-menu a:hover { background: var(--surface-2); border-color: var(--border); }
.more-menu a.danger { color: #fca5a5; margin-top: 0.5rem; text-align: center; border-color: rgba(239, 68, 68, 0.25); }

.toolbar { margin: 0 0 1rem; }
.inline-form { display: inline; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.data-table th, .data-table td {
  padding: 0.7rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}
.data-table th { color: var(--muted); font-weight: 500; font-size: 0.8rem; }
.table-mobile { display: none; }
.data-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  margin-bottom: 0.65rem;
}
.data-card-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.data-card-row:last-child { border-bottom: none; }
.data-card-row span:first-child { color: var(--muted); }

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}
.badge-success { background: rgba(34, 197, 94, 0.15); color: #86efac; }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }

.placeholder-page {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
}
.placeholder-page .big-ico { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.5; }

/* Customer mobile */
.customer-app.has-bottom-nav { padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0)); }
.customer-main { padding: 1rem; max-width: 520px; margin: 0 auto; }

.vpn-status-card {
  background: linear-gradient(160deg, var(--surface), rgba(139, 92, 246, 0.12));
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.vpn-status-card .status-dot {
  width: 12px; height: 12px; border-radius: 50%;
  display: inline-block; margin-left: 0.35rem;
}
.vpn-status-card .status-dot.on { background: var(--success); box-shadow: 0 0 12px var(--success); }
.vpn-status-card .status-dot.off { background: var(--danger); }
.vpn-status-card h2 { margin: 0.5rem 0 0.25rem; font-size: 1.1rem; }
.vpn-status-card p { margin: 0; color: var(--muted); font-size: 0.88rem; }

.quota-ring {
  margin: 1rem auto;
  width: 120px; height: 120px;
  border-radius: 50%;
  border: 6px solid var(--surface-2);
  border-top-color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-weight: 700;
}
.quota-ring small { font-size: 0.7rem; color: var(--muted); font-weight: 400; }

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin: 1rem 0;
}
.action-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 0.75rem;
  text-align: center;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.action-tile:hover { border-color: rgba(139, 92, 246, 0.45); background: var(--accent-soft); }
.action-tile .at-ico { font-size: 1.5rem; display: block; margin-bottom: 0.35rem; }
.action-tile span { font-size: 0.82rem; }

.progress {
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.75rem 0;
}
.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 999px;
  transition: width 0.35s ease;
}
.progress.warn > span { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.progress.danger > span { background: linear-gradient(90deg, var(--danger), #f87171); }

.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: var(--bottom-nav-h);
  padding-bottom: env(safe-area-inset-bottom, 0);
  background: rgba(18, 26, 46, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 50;
}
.bottom-nav-item {
  flex: 1;
  text-align: center;
  color: var(--muted);
  font-size: 0.68rem;
  padding: 0.35rem 0;
}
.bottom-nav-item .bn-icon { display: block; font-size: 1.15rem; margin-bottom: 0.15rem; }
.bottom-nav-item.active { color: var(--accent-hover); }

.list-menu { display: flex; flex-direction: column; gap: 0.5rem; }
.list-menu a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
}

@media (max-width: 900px) {
  .admin-sidebar {
    transform: translateX(100%);
  }
  body.sidebar-open .admin-sidebar { transform: translateX(0); }
  .admin-main { margin-right: 0; }
  .menu-toggle { display: block; }
  .admin-mobile-nav { display: flex; }
}

@media (max-width: 768px) {
  .table-desktop { display: none; }
  .table-mobile { display: block; }
}

@media (min-width: 769px) {
  .table-mobile { display: none; }
}
