*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --text: rgba(255, 255, 255, 0.96);
  --sub: rgba(235, 235, 245, 0.62);
  --line: rgba(255, 255, 255, 0.08);
  --edge: rgba(255, 255, 255, 0.11);
  --accent-edge: rgba(252, 165, 165, 0.42);
  --accent: #dc2626;
  --accent-hover: #ef4444;
  --accent-light: #fca5a5;
  --success: #4ade80;
  --warning: #fb923c;
  --danger: #f87171;
  --sidebar-w: 240px;
  --font: "Segoe UI Variable Text", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --transition: 0.2s ease;
  --radius: 14px;
  --radius-sm: 8px;
}

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: linear-gradient(145deg, #1a0505 0%, #0d0000 48%, #120404 100%);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-light); text-decoration: none; }
a:hover { color: #fecaca; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

.wall {
  position: fixed;
  inset: -100px;
  z-index: 0;
  filter: blur(90px) saturate(130%);
  pointer-events: none;
}
.wall i {
  position: absolute;
  border-radius: 50%;
  animation: drift 24s ease-in-out infinite alternate;
}
.wall i:nth-child(1) { width: 600px; height: 500px; left: -100px; top: -80px; background: #dc2626; opacity: 0.22; }
.wall i:nth-child(2) { width: 500px; height: 500px; right: -150px; top: 40%; background: #991b1b; opacity: 0.25; animation-delay: -8s; }
.wall i:nth-child(3) { width: 450px; height: 400px; left: 30%; bottom: -100px; background: #b91c1c; opacity: 0.15; animation-delay: -15s; }
@keyframes drift { to { transform: translate(40px, -30px) scale(1.1); } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px;
  border: none; border-radius: var(--radius-sm);
  font: inherit; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, #ef4444, #dc2626, #b91c1c);
  color: #fff;
}
.btn-primary:hover { box-shadow: 0 0 20px rgba(239, 68, 68, 0.4); }
.btn-primary:active { transform: scale(0.98); }
.btn-danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.3);
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.25); border-color: rgba(248, 113, 113, 0.45); }
.btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--sub);
  border: 1px solid var(--edge);
}
.btn-ghost:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.22); background: rgba(255, 255, 255, 0.1); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-toggle-key { min-width: 66px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; margin-bottom: 4px;
  font-size: 0.85rem; color: var(--sub); font-weight: 600;
}

input[type="text"], input[type="password"], input[type="number"],
input[type="search"], select, textarea {
  width: 100%; padding: 10px 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--edge);
  border-radius: var(--radius-sm);
  font: inherit; font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent-edge);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}
input::placeholder, textarea::placeholder { color: var(--sub); }
select { cursor: pointer; }
select option { background: #1a0505; color: var(--text); }

.login-screen {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
  z-index: 1;
}
.login-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.025) 45%, rgba(255, 255, 255, 0.05) 100%);
  backdrop-filter: blur(28px) saturate(170%);
  border: 1px solid var(--edge);
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 20px 50px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.4);
  padding: 40px 36px;
  width: 100%; max-width: 400px;
  text-align: center;
  animation: fadeUp 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.login-card::before {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.06) 45%, transparent 58%);
}
.login-logo { margin-bottom: 12px; }
.login-logo svg { filter: drop-shadow(0 0 10px rgba(252, 165, 165, 0.6)); }
.login-title {
  font: 700 1.5rem/1.3 var(--font-display);
  margin-bottom: 28px;
  background: linear-gradient(135deg, var(--accent-light), var(--accent-hover));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-error {
  background: rgba(248, 113, 113, 0.12);
  color: var(--danger);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 12px;
  border: 1px solid rgba(248, 113, 113, 0.2);
}
.login-card .form-group { text-align: left; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.admin-shell {
  position: relative;
  display: flex;
  min-height: 100vh;
  z-index: 1;
}

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.02) 100%);
  backdrop-filter: blur(28px) saturate(170%);
  border-right: 1px solid var(--edge);
  display: flex; flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 16px 16px;
  font: 700 1.05rem/1 var(--font-display);
  border-bottom: 1px solid var(--line);
}
.sidebar-brand svg { filter: drop-shadow(0 0 8px rgba(252, 165, 165, 0.5)); }
.sidebar-nav {
  list-style: none; padding: 8px 0; flex: 1;
}
.sidebar-nav li { padding: 2px 8px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  color: var(--sub);
  border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 600;
  transition: all var(--transition);
}
.nav-link:hover { color: var(--text); background: rgba(255, 255, 255, 0.07); }
.nav-link.active { color: var(--accent-light); background: rgba(220, 38, 38, 0.12); }
.nav-icon { display: inline-flex; align-items: center; justify-content: center; width: 20px; flex-shrink: 0; }
.nav-icon svg { width: 18px; height: 18px; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--line); }
.sidebar-footer .btn svg { width: 16px; height: 16px; }

.mobile-header {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  height: 52px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  backdrop-filter: blur(28px) saturate(170%);
  border-bottom: 1px solid var(--edge);
  align-items: center; padding: 0 16px; gap: 12px;
  z-index: 90;
}
.menu-toggle {
  background: none; border: none; color: var(--text);
  cursor: pointer; padding: 4px;
  display: inline-flex; align-items: center;
}
.menu-toggle svg { width: 22px; height: 22px; }
.mobile-title { font: 700 1rem/1 var(--font-display); }

.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 99;
}

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1; min-width: 0; padding: 32px;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-header h2 {
  font: 700 1.5rem/1.2 var(--font-display);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px; margin-bottom: 24px;
}
.stat-card {
  position: relative;
  overflow: hidden;
  text-align: center;
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--accent-edge);
  background: linear-gradient(135deg, rgba(252, 165, 165, 0.16) 0%, rgba(153, 27, 27, 0.08) 42%, rgba(0, 0, 0, 0.12) 70%, rgba(252, 165, 165, 0.06) 100%);
  backdrop-filter: blur(20px) saturate(150%);
  box-shadow: inset 0 1px 0 rgba(254, 202, 202, 0.2), 0 0 20px rgba(220, 38, 38, 0.08);
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card::before {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.04) 45%, transparent 58%);
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: inset 0 1px 0 rgba(254, 202, 202, 0.25), 0 0 28px rgba(220, 38, 38, 0.15), 0 8px 20px rgba(0, 0, 0, 0.4);
}
.stat-value {
  font: 800 2rem/1.1 var(--font-display);
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: 0.8rem; color: var(--sub);
  margin-top: 4px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600;
}
.stat-card.accent .stat-value { color: var(--accent-light); }
.stat-card.orange .stat-value { color: #fb923c; }
.stat-card.gold .stat-value { color: #fbbf24; }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.warning .stat-value { color: var(--warning); }

.filter-tabs {
  display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap;
}
.filter-tab {
  padding: 6px 16px; border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06); color: var(--sub);
  border: 1px solid var(--edge);
  font: inherit; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
}
.filter-tab:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.22); }
.filter-tab.active {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff; border-color: transparent;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.3);
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--edge);
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(20px);
}
table {
  width: 100%; border-collapse: collapse;
  font-size: 0.88rem;
}
thead { background: rgba(255, 255, 255, 0.04); }
th {
  padding: 12px 14px; text-align: left;
  font-weight: 600; color: var(--sub);
  font-size: 0.8rem; text-transform: uppercase;
  letter-spacing: 0.04em; white-space: nowrap;
}
td {
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}
tr:hover td { background: rgba(255, 255, 255, 0.04); }

.badge {
  display: inline-block; padding: 2px 10px;
  border-radius: 8px; font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.badge-unused { background: rgba(74, 222, 128, 0.15); color: var(--success); }
.badge-redeemed { background: rgba(96, 165, 250, 0.15); color: #60a5fa; }
.badge-disabled { background: rgba(248, 113, 113, 0.15); color: var(--danger); }
.badge-trial { background: rgba(251, 146, 60, 0.15); color: var(--warning); }
.badge-premium { background: rgba(252, 165, 165, 0.15); color: var(--accent-light); }
.badge-expired { background: rgba(161, 161, 170, 0.12); color: #a1a1aa; }

.key-masked {
  font-family: 'Courier New', monospace;
  cursor: pointer; padding: 2px 8px;
  background: rgba(255, 255, 255, 0.06); border-radius: 6px;
  font-size: 0.82rem; white-space: nowrap;
  transition: color var(--transition), background var(--transition);
}
.key-masked:hover { color: var(--accent-light); background: rgba(255, 255, 255, 0.1); }

.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; margin-top: 20px;
}
.pagination button {
  padding: 6px 14px; border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06); color: var(--sub);
  border: 1px solid var(--edge);
  font: inherit; font-size: 0.85rem; cursor: pointer;
  transition: all var(--transition);
}
.pagination button:hover:not(:disabled) {
  color: var(--text); border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .page-info { font-size: 0.85rem; color: var(--sub); }

.search-bar {
  display: flex; gap: 8px; align-items: center;
}
.search-bar input { max-width: 280px; }
.search-bar select { max-width: 200px; }

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}
.modal {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.025) 45%, rgba(255, 255, 255, 0.05) 100%);
  backdrop-filter: blur(28px) saturate(170%);
  border: 1px solid var(--edge);
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 20px 50px rgba(0, 0, 0, 0.6);
  padding: 28px; width: 100%; max-width: 440px;
}
.modal::before {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.06) 45%, transparent 58%);
}
.modal-lg { max-width: 560px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h3 { font: 700 1.15rem/1 var(--font-display); }
.modal-close {
  background: none; border: none; color: var(--sub);
  font-size: 1.5rem; cursor: pointer; padding: 0 4px;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text); }
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px;
}
.modal > h3:first-child { margin-bottom: 12px; font: 700 1.15rem/1 var(--font-display); }
.modal > p { color: var(--sub); line-height: 1.5; }

#keygen-result { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 16px; }
#keygen-result h4 { font: 600 0.95rem/1.2 var(--font-display); margin-bottom: 4px; }
.keygen-keys-list {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--edge);
  border-radius: var(--radius-sm);
  padding: 12px; margin: 12px 0; max-height: 200px; overflow-y: auto;
  font-family: 'Courier New', monospace; font-size: 0.82rem;
  line-height: 1.8;
}
.keygen-actions { display: flex; gap: 8px; }

.settings-section {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 45%, rgba(255, 255, 255, 0.04) 100%);
  backdrop-filter: blur(28px) saturate(170%);
  border: 1px solid var(--edge);
  border-radius: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 14px 34px rgba(0, 0, 0, 0.3);
  padding: 24px;
  margin-bottom: 20px;
}
.settings-section::before {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.04) 45%, transparent 58%);
}
.settings-section h3 {
  font: 700 1.05rem/1 var(--font-display);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.toggle-wrap { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.toggle {
  position: relative; width: 44px; height: 24px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.toggle.on {
  background: linear-gradient(135deg, #fecaca, #ef4444 60%, #b91c1c);
  border-color: var(--accent-edge);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.45);
}
.toggle::after {
  content: ''; position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: #a1a1aa; border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s, box-shadow 0.3s;
}
.toggle.on::after {
  transform: translateX(20px);
  background: #fff;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.5), 0 2px 4px rgba(0, 0, 0, 0.45);
}
.toggle-label { font-size: 0.9rem; font-weight: 600; }

.pricing-list { list-style: none; }
.pricing-list li {
  display: flex; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}
.pricing-list li:last-child { border-bottom: none; }
.pricing-list .price { color: var(--accent-light); font-weight: 600; }

.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.04));
  backdrop-filter: blur(28px) saturate(170%);
  border: 1px solid var(--edge);
  border-radius: 12px;
  padding: 12px 20px;
  color: var(--text);
  font-size: 0.88rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  z-index: 300;
  animation: toast-in 0.3s ease;
}
.toast.success { border-color: rgba(74, 222, 128, 0.4); }
.toast.error { border-color: rgba(248, 113, 113, 0.4); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2px solid var(--line);
  border-top-color: #ef4444;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  text-align: center; padding: 60px 20px; color: var(--sub);
}

.empty-state {
  text-align: center; padding: 48px 20px; color: var(--sub);
  font-size: 0.95rem;
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-header { display: flex; }
  .main-content { margin-left: 0; padding: 68px 16px 24px; }
  td { white-space: nowrap; }
  .stats-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.5rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .modal { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .wall i { animation: none; }
  * { transition-duration: 0s !important; animation-duration: 0s !important; }
}
