/* ═══════════════════════════════════════════════════════
   API Driver v3 - License Manager - Design System
   Modern SaaS Dashboard Theme
   ═══════════════════════════════════════════════════════ */

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2236;
  --bg-card-hover: #1e2844;
  --bg-input: #0d1321;
  --bg-sidebar: #0c1222;

  --border-primary: #1e2d4a;
  --border-secondary: #2a3a5c;
  --border-active: #6366f1;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-accent: #a5b4fc;

  --accent-primary: #6366f1;
  --accent-primary-hover: #818cf8;
  --accent-secondary: #8b5cf6;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a78bfa 100%);

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.1);

  --sidebar-width: 260px;
  --sidebar-collapsed: 0px;
  --topbar-height: 64px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 30px rgba(99,102,241,0.15);

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-secondary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

::selection { background: rgba(99,102,241,0.3); color: #fff; }

a { color: var(--accent-primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--accent-primary-hover); }

/* ═══════════════════════════════════════
   AUTH SCREEN
   ═══════════════════════════════════════ */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: var(--bg-primary);
}

.auth-bg-effects {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.auth-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  animation: orbFloat 20s infinite ease-in-out;
}

.auth-orb-1 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #6366f1, transparent 70%);
  top: -100px; left: -100px;
}

.auth-orb-2 {
  width: 350px; height: 350px;
  background: radial-gradient(circle, #8b5cf6, transparent 70%);
  bottom: -80px; right: -80px;
  animation-delay: -7s;
}

.auth-orb-3 {
  width: 250px; height: 250px;
  background: radial-gradient(circle, #a78bfa, transparent 70%);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -14s;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -30px) scale(1.05); }
  50% { transform: translate(-20px, 20px) scale(0.95); }
  75% { transform: translate(20px, 10px) scale(1.02); }
}

.auth-card {
  position: relative;
  z-index: 1;
  background: rgba(26, 34, 54, 0.8);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  animation: cardAppear 0.6s ease-out;
}

@keyframes cardAppear {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-logo { text-align: center; margin-bottom: 2rem; }

.auth-logo-icon {
  width: 56px; height: 56px;
  margin: 0 auto 1rem;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 30px rgba(99,102,241,0.3);
}

.auth-logo-icon svg { width: 28px; height: 28px; color: #fff; }

.auth-logo h1 {
  font-size: 1.5rem; font-weight: 700; color: var(--text-primary);
  letter-spacing: -0.02em;
}

.auth-subtitle { color: var(--text-muted); font-size: 0.875rem; margin-top: 0.25rem; }

.auth-form { display: none; }
.auth-form.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-icon {
  position: relative;
}

.input-icon svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color var(--transition-fast);
}

.input-icon input {
  width: 100%;
  padding: 0.75rem 0.75rem 0.75rem 42px;
  background: var(--bg-input);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: all var(--transition-fast);
}

.input-icon input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.input-icon input:focus + svg,
.input-icon input:focus ~ svg { /* fallback */ }

.input-icon:has(input:focus) svg { color: var(--accent-primary); }

.auth-toggle {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.auth-toggle a { color: var(--accent-primary); font-weight: 500; }
.auth-toggle a:hover { color: var(--accent-primary-hover); text-decoration: underline; }

/* ═══════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}
.btn-primary:hover { box-shadow: 0 4px 16px rgba(99,102,241,0.4); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-secondary);
}
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--text-muted); }

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

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.1); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }

.btn-warning { background: var(--warning); color: #000; }

.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; }
.btn-sm svg { width: 14px; height: 14px; }

.btn-full { width: 100%; justify-content: center; padding: 0.8rem; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

.btn-icon {
  width: 34px; height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-primary);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn-icon:hover { border-color: var(--accent-primary); color: var(--accent-primary); background: var(--bg-card-hover); }
.btn-icon svg { width: 16px; height: 16px; }
.btn-icon.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn-icon.success:hover { border-color: var(--success); color: var(--success); }

/* ═══════════════════════════════════════
   APP LAYOUT
   ═══════════════════════════════════════ */
.app-screen {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-primary);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition-slow);
}

.sidebar-header {
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-primary);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-logo-icon {
  width: 38px; height: 38px;
  background: var(--accent-gradient);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-icon svg { width: 20px; height: 20px; color: #fff; }

.sidebar-brand { font-size: 1rem; font-weight: 700; color: var(--text-primary); display: block; line-height: 1.2; }
.sidebar-version { font-size: 0.7rem; color: var(--text-muted); }

.sidebar-toggle {
  display: none;
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 4px;
}
.sidebar-toggle svg { width: 20px; height: 20px; }

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.nav-section { margin-bottom: 1.5rem; }

.nav-section-title {
  display: block;
  padding: 0 1.25rem;
  margin-bottom: 0.5rem;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1.25rem;
  margin: 2px 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 450;
  transition: all var(--transition-fast);
  position: relative;
}

.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; opacity: 0.7; transition: opacity var(--transition-fast); }

.nav-item:hover { background: rgba(99,102,241,0.08); color: var(--text-primary); }
.nav-item:hover svg { opacity: 1; }

.nav-item.active {
  background: rgba(99,102,241,0.12);
  color: var(--accent-primary);
  font-weight: 500;
}
.nav-item.active svg { opacity: 1; color: var(--accent-primary); }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--accent-primary);
  border-radius: 0 3px 3px 0;
}

.sidebar-user {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.sidebar-user-info { display: flex; align-items: center; gap: 0.75rem; overflow: hidden; }

.sidebar-avatar {
  width: 36px; height: 36px;
  background: var(--accent-gradient);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.875rem;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-details { overflow: hidden; }
.sidebar-username { display: block; font-size: 0.875rem; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-role { display: block; font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.btn-logout {
  background: none; border: 1px solid var(--border-primary); border-radius: var(--radius-sm);
  color: var(--text-muted); cursor: pointer; padding: 6px;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}
.btn-logout svg { width: 18px; height: 18px; }
.btn-logout:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-height);
  background: rgba(10,14,23,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
}

.mobile-menu-btn {
  display: none;
  background: none; border: none; color: var(--text-secondary); cursor: pointer;
  padding: 4px;
}
.mobile-menu-btn svg { width: 24px; height: 24px; }

.page-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.topbar-right { display: flex; align-items: center; gap: 1rem; }

.credits-badge {
  display: none;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  background: rgba(99,102,241,0.1);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--accent-primary);
  font-weight: 500;
}
.credits-badge svg { width: 14px; height: 14px; }

.page-content { padding: 1.5rem; flex: 1; }

.page { display: none; animation: pageIn 0.3s ease; }
.page.active { display: block; }

@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ═══════════════════════════════════════
   CARDS
   ═══════════════════════════════════════ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 { font-size: 0.95rem; font-weight: 600; }

.card-body { padding: 1.5rem; }

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.stat-card:hover { border-color: var(--border-secondary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card:hover::after { opacity: 1; }

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }

.stat-icon.purple { background: rgba(99,102,241,0.12); color: var(--accent-primary); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.orange { background: var(--warning-bg); color: var(--warning); }
.stat-icon.red { background: var(--danger-bg); color: var(--danger); }
.stat-icon.blue { background: var(--info-bg); color: var(--info); }

.stat-info { flex: 1; }
.stat-label { font-size: 0.75rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--text-primary); line-height: 1.2; margin-top: 0.25rem; }

.dashboard-grid { display: grid; gap: 1.5rem; }

/* ═══════════════════════════════════════
   TABLES
   ═══════════════════════════════════════ */
.table-filters {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-box svg {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 34px;
  background: var(--bg-input);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-fast);
}

.search-box input:focus { border-color: var(--accent-primary); }

.select-filter {
  padding: 0.5rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  min-width: 160px;
}

.select-filter:focus { border-color: var(--accent-primary); }
.select-filter option { background: var(--bg-card); color: var(--text-primary); }

.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-primary);
  background: rgba(0,0,0,0.15);
  white-space: nowrap;
}

tbody td {
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-primary);
  vertical-align: middle;
}

tbody tr { transition: background var(--transition-fast); }
tbody tr:hover { background: rgba(99,102,241,0.04); }
tbody tr:last-child td { border-bottom: none; }

.key-cell {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.8rem;
  color: var(--text-accent);
  word-break: break-all;
  max-width: 200px;
}

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-active { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16,185,129,0.2); }
.badge-expired { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245,158,11,0.2); }
.badge-banned { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }
.badge-used { background: var(--info-bg); color: var(--info); border: 1px solid rgba(59,130,246,0.2); }
.badge-permanent { background: rgba(168,85,247,0.1); color: #a855f7; border: 1px solid rgba(168,85,247,0.2); }
.badge-admin { background: rgba(99,102,241,0.1); color: var(--accent-primary); border: 1px solid rgba(99,102,241,0.2); }
.badge-reseller { background: rgba(34,211,238,0.1); color: #22d3ee; border: 1px solid rgba(34,211,238,0.2); }

.actions-cell {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

/* ═══════════════════════════════════════
   PAGE HEADERS
   ═══════════════════════════════════════ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.page-header h3 { font-size: 1.1rem; font-weight: 600; }

/* ═══════════════════════════════════════
   APPS GRID
   ═══════════════════════════════════════ */
.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.app-card {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-normal);
}

.app-card:hover { border-color: var(--border-secondary); transform: translateY(-2px); box-shadow: var(--shadow-md); }

.app-card-header {
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--border-primary);
}

.app-logo {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.app-logo img { width: 100%; height: 100%; object-fit: cover; }
.app-logo-placeholder { font-size: 1.25rem; font-weight: 700; color: #fff; }

.app-card-info { flex: 1; overflow: hidden; }
.app-card-name { font-size: 1rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-card-desc { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.app-card-body { padding: 1.25rem; }

.app-config-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.app-config-item:last-child { border-bottom: none; }

.app-config-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.app-config-value { font-size: 0.8rem; font-family: monospace; color: var(--text-accent); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.app-card-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-primary);
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════
   MODALS
   ═══════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.active { display: flex; animation: fadeIn 0.2s ease; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.3s ease;
}

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

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-size: 1rem; font-weight: 600; }

.modal-close {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 1.5rem; line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}
.modal-close:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-body .form-group { margin-bottom: 1.25rem; }
.modal-body .form-group:last-child { margin-bottom: 0; }

.modal-body label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.modal-body input[type="text"],
.modal-body input[type="email"],
.modal-body input[type="password"],
.modal-body input[type="number"],
.modal-body textarea,
.modal-body select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--bg-input);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-fast);
}

.modal-body input:focus,
.modal-body textarea:focus,
.modal-body select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.modal-body textarea { resize: vertical; min-height: 80px; }

.modal-body select option { background: var(--bg-card); }

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-primary);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* File upload */
.file-upload {
  border: 2px dashed var(--border-secondary);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.file-upload:hover { border-color: var(--accent-primary); background: rgba(99,102,241,0.04); }
.file-upload.has-file { border-color: var(--success); border-style: solid; }

.file-upload input[type="file"] { display: none; }

.file-upload-icon { color: var(--text-muted); margin-bottom: 0.5rem; }
.file-upload-icon svg { width: 32px; height: 32px; }

.file-upload-text { font-size: 0.85rem; color: var(--text-secondary); }
.file-upload-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ═══════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════ */
#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 300px;
  max-width: 420px;
  pointer-events: all;
  animation: toastIn 0.4s ease;
  backdrop-filter: blur(12px);
}

.toast.removing { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(40px); } }

.toast-icon { flex-shrink: 0; width: 20px; height: 20px; }
.toast-message { font-size: 0.85rem; color: var(--text-primary); flex: 1; }

.toast.success { border-left: 3px solid var(--success); }
.toast.success .toast-icon { color: var(--success); }

.toast.error { border-left: 3px solid var(--danger); }
.toast.error .toast-icon { color: var(--danger); }

.toast.warning { border-left: 3px solid var(--warning); }
.toast.warning .toast-icon { color: var(--warning); }

.toast.info { border-left: 3px solid var(--info); }
.toast.info .toast-icon { color: var(--info); }

.toast-close {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 1.1rem; padding: 2px 6px;
}
.toast-close:hover { color: var(--text-primary); }

/* ═══════════════════════════════════════
   LOADING & EMPTY STATES
   ═══════════════════════════════════════ */
.loading-skeleton {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
}

.empty-state-icon { color: var(--text-muted); margin-bottom: 1rem; opacity: 0.5; }
.empty-state-icon svg { width: 48px; height: 48px; }

.empty-state h4 { font-size: 1rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.85rem; color: var(--text-muted); max-width: 360px; margin: 0 auto; }

/* Log item */
.log-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.log-item:last-child { border-bottom: none; }

.log-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}
.log-dot.login { background: var(--success); }
.log-dot.create { background: var(--info); }
.log-dot.delete { background: var(--danger); }
.log-dot.update { background: var(--warning); }
.log-dot.default { background: var(--text-muted); }

.log-content { flex: 1; }
.log-action { font-size: 0.85rem; color: var(--text-primary); font-weight: 500; }
.log-details { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.15rem; }
.log-time { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.2rem; }

/* copy button inline */
.copy-inline {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 2px 4px; font-size: 0.75rem; border-radius: 3px;
  transition: color var(--transition-fast);
}
.copy-inline:hover { color: var(--accent-primary); }

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .sidebar-toggle { display: block; }

  .main-content { margin-left: 0; }
  .mobile-menu-btn { display: block; }

  .topbar { padding: 0 1rem; }
  .page-content { padding: 1rem; }

  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

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

  .modal { max-width: 100%; margin: 0.5rem; }

  .table-filters { flex-direction: column; }
  .search-box { min-width: 100%; }
}

@media (max-width: 480px) {
  .auth-card { padding: 1.5rem; margin: 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { padding: 1rem; }
  .stat-value { font-size: 1.25rem; }
}

/* ── Helpers ── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-mono { font-family: monospace; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.gap-sm { gap: 0.5rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
