/* ── Variables ── */
:root {
  --bg: #0a0f1e;
  --surface: #111827;
  --card: rgba(17,24,39,0.8);
  --border: rgba(255,255,255,0.08);
  --text: #f1f5f9;
  --dim: #64748b;
  --accent: #3b82f6;
  --accent-h: #2563eb;
  --green: #22c55e;
  --purple: #8b5cf6;
  --orange: #f59e0b;
  --red: #ef4444;
  --sidebar-w: 240px;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
}
[data-theme="light"] {
  --bg: #f1f5f9; --surface: #ffffff; --card: rgba(255,255,255,0.9);
  --border: rgba(0,0,0,0.08); --text: #0f172a; --dim: #64748b;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh;
  z-index: 100; transition: transform 0.25s;
}
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar-logo { display: flex; align-items: center; gap: 12px; padding: 24px 20px; font-weight: 700; font-size: 18px; }
.sidebar-nav { flex: 1; padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px;
  color: var(--dim); text-decoration: none; font-size: 14px; font-weight: 500; transition: 0.15s;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.nav-item.active { background: rgba(59,130,246,0.15); color: var(--accent); }
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.user-badge { display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg,#3b82f6,#8b5cf6); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: white; flex-shrink: 0; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11px; color: var(--dim); text-transform: capitalize; }
.btn-logout { display: block; text-align: center; padding: 8px; border-radius: 8px; background: rgba(239,68,68,0.1); color: var(--red); font-size: 13px; font-weight: 600; text-decoration: none; transition: 0.15s; }
.btn-logout:hover { background: rgba(239,68,68,0.2); }

/* ── Topbar ── */
.topbar { display: flex; align-items: center; gap: 16px; padding: 16px 24px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 50; }
.menu-toggle { display: none; background: none; border: none; cursor: pointer; color: var(--text); padding: 4px; }
.menu-toggle svg { width: 20px; height: 20px; }
.page-title { font-size: 18px; font-weight: 700; flex: 1; }
.theme-toggle { background: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; cursor: pointer; color: var(--dim); transition: 0.15s; }
.theme-toggle svg { width: 16px; height: 16px; display: block; }
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }
.content-area { padding: 24px; flex: 1; }

/* ── Glass ── */
.glass { background: var(--card); backdrop-filter: blur(20px); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ── Stats Grid ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { display: flex; align-items: center; gap: 16px; padding: 20px; }
.stat-icon { width: 48px; height: 48px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.blue { background: rgba(59,130,246,0.15); color: var(--accent); }
.stat-icon.green { background: rgba(34,197,94,0.15); color: var(--green); }
.stat-icon.purple { background: rgba(139,92,246,0.15); color: var(--purple); }
.stat-icon.orange { background: rgba(245,158,11,0.15); color: var(--orange); }
.stat-value { font-size: 24px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--dim); margin-top: 2px; }

/* ── Section Card ── */
.section-card { padding: 24px; margin-bottom: 24px; }
.section-title { font-size: 16px; font-weight: 700; margin-bottom: 20px; }
.section-subtitle { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Table ── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; padding: 10px 12px; color: var(--dim); font-weight: 600; border-bottom: 1px solid var(--border); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.data-table td { padding: 12px 12px; border-bottom: 1px solid rgba(255,255,255,0.04); vertical-align: middle; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.loading-row, .empty-row { text-align: center; color: var(--dim); padding: 32px !important; }
.lic-preview { font-size: 11px; color: var(--dim); }

/* ── Form ── */
.field { margin-bottom: 20px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--dim); margin-bottom: 8px; }
.field-hint { font-size: 12px; color: var(--dim); margin-top: 6px; }
input[type="text"], input[type="password"], input[type="email"] {
  width: 100%; padding: 11px 14px; background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px; font-family: inherit; outline: none; transition: 0.15s;
}
input:focus { border-color: var(--accent); background: rgba(59,130,246,0.05); }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer; transition: 0.15s; border: none; text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-h); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-ghost { background: rgba(255,255,255,0.05); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: rgba(255,255,255,0.1); }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-inline { background: none; border: 1px solid var(--border); border-radius: 4px; padding: 2px 8px; font-size: 11px; cursor: pointer; color: var(--dim); margin-left: 8px; transition: 0.15s; }
.btn-inline:hover { border-color: var(--accent); color: var(--accent); }

/* ── Badges ── */
.badge { display: inline-block; padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-blue { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-purple { background: rgba(139,92,246,0.15); color: #a78bfa; }
.badge-green { background: rgba(34,197,94,0.15); color: #4ade80; }
.badge-red { background: rgba(239,68,68,0.15); color: #f87171; }

/* ── Generator ── */
.gen-layout { display: grid; grid-template-columns: 1fr; gap: 24px; max-width: 760px; }
.input-row { display: flex; gap: 12px; }
.input-row input { flex: 1; }
.mode-selector { display: flex; gap: 12px; }
.mode-option {
  flex: 1; display: flex; align-items: center; gap: 14px; padding: 16px;
  border: 2px solid var(--border); border-radius: 10px; cursor: pointer; transition: 0.15s;
}
.mode-option.active { border-color: var(--accent); background: rgba(59,130,246,0.08); }
.mode-icon { font-size: 24px; }
.mode-name { font-weight: 700; font-size: 14px; }
.mode-desc { font-size: 12px; color: var(--dim); }
.license-box {
  background: #000; color: #22c55e; padding: 20px; border-radius: 10px;
  font-family: var(--mono); font-size: 13px; white-space: pre-wrap; word-break: break-all;
  line-height: 1.7; border: 1px solid rgba(34,197,94,0.2); max-height: 300px; overflow-y: auto;
}
.result-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.result-header .section-title { margin: 0; }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.qr-container { text-align: center; margin-top: 20px; }
.qr-container img { border-radius: 8px; border: 1px solid var(--border); }

/* ── Auth ── */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 420px; padding: 40px; }
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo h1 { font-size: 24px; font-weight: 800; margin: 12px 0 4px; }
.auth-logo p { color: var(--dim); font-size: 14px; }
.auth-form .field { margin-bottom: 16px; }
.auth-footer { text-align: center; font-size: 12px; color: var(--dim); margin-top: 24px; }
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-error { background: rgba(239,68,68,0.1); color: #f87171; border: 1px solid rgba(239,68,68,0.2); }

/* ── Settings ── */
.settings-layout { max-width: 800px; }
.field-row { display: flex; gap: 10px; flex-wrap: wrap; }
.field-row input { flex: 1; min-width: 140px; }
.stats-mini { display: flex; gap: 24px; flex-wrap: wrap; }
.stat-mini .stat-value { font-size: 28px; font-weight: 700; }
.stat-mini .stat-label { font-size: 12px; color: var(--dim); }

/* ── Toast ── */
#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
.toast { padding: 12px 20px; border-radius: 10px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow); animation: slideIn 0.2s ease; }
.toast-success { background: rgba(34,197,94,0.9); color: white; }
.toast-error { background: rgba(239,68,68,0.9); color: white; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Misc ── */
.empty-state { text-align: center; padding: 32px; color: var(--dim); font-size: 14px; }
.empty-state a { color: var(--accent); text-decoration: none; }
.dim { color: var(--dim); }
.hidden { display: none !important; }
code { font-family: var(--mono); background: rgba(255,255,255,0.06); padding: 2px 6px; border-radius: 4px; font-size: 12px; }
.table-toolbar { display: flex; gap: 12px; margin-bottom: 16px; align-items: center; }
.table-toolbar input { max-width: 300px; }
.pagination { display: flex; align-items: center; gap: 16px; justify-content: center; margin-top: 20px; }
#page-info { font-size: 13px; color: var(--dim); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: flex; }
  .mode-selector { flex-direction: column; }
  .input-row { flex-direction: column; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .content-area { padding: 16px; }
}
