:root {
  --bg: #080b14;
  --bg-elevated: #0d1222;
  --glass: rgba(255,255,255,0.04);
  --glass-border: rgba(255,255,255,0.08);
  --purple: #7c5cff;
  --purple-bright: #9d7bff;
  --blue: #4facfe;
  --gradient: linear-gradient(135deg, var(--purple) 0%, var(--blue) 100%);
  --text: #e8eaf2;
  --text-dim: #8b92ab;
  --text-faint: #5a6178;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-glow: 0 0 40px rgba(124,92,255,0.15);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(124,92,255,0.15), transparent),
              radial-gradient(ellipse 60% 40% at 90% 10%, rgba(79,172,254,0.08), transparent),
              var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; }
input, textarea, select { font-family: inherit; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--glass-border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px 24px;
  font-weight: 700; font-size: 18px;
}
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gradient); box-shadow: 0 0 12px var(--purple); }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 14px; font-weight: 500;
  transition: all 0.15s ease;
}
.nav-item:hover { background: var(--glass); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(124,92,255,0.15), rgba(79,172,254,0.08));
  color: var(--text);
  border: 1px solid rgba(124,92,255,0.25);
}
.nav-item .icon { width: 18px; text-align: center; opacity: 0.8; }

.main { flex: 1; padding: 28px 36px; max-width: 1400px; }

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.topbar h1 { font-size: 22px; font-weight: 700; }
.topbar .sub { color: var(--text-dim); font-size: 14px; margin-top: 2px; }

/* ---------- Glass cards ---------- */
.card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 22px;
  backdrop-filter: blur(20px);
  transition: border-color 0.2s ease;
}
.card:hover { border-color: rgba(124,92,255,0.25); }

.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; overflow-x: auto; }
  .main { padding: 18px; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

.stat-card .label { color: var(--text-dim); font-size: 13px; font-weight: 500; }
.stat-card .value { font-size: 28px; font-weight: 700; margin-top: 6px; }
.stat-card .icon-badge {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--gradient); font-size: 16px; margin-bottom: 12px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; transition: all 0.15s ease;
}
.btn-primary { background: var(--gradient); color: #fff; box-shadow: var(--shadow-glow); }
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-secondary { background: var(--glass); border: 1px solid var(--glass-border); color: var(--text); }
.btn-secondary:hover { background: rgba(255,255,255,0.08); }
.btn-danger { background: rgba(248,113,113,0.12); color: var(--danger); border: 1px solid rgba(248,113,113,0.3); }
.btn-danger:hover { background: rgba(248,113,113,0.2); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-dim); margin-bottom: 7px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.03); border: 1px solid var(--glass-border);
  color: var(--text); font-size: 14px; transition: border-color 0.15s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(124,92,255,0.15);
}
.field .hint { font-size: 12px; color: var(--text-faint); margin-top: 6px; }
.field .error { font-size: 12px; color: var(--danger); margin-top: 6px; }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 420px; padding: 36px; }
.auth-card .logo { text-align: center; margin-bottom: 28px; }
.auth-card h2 { font-size: 22px; text-align: center; margin-bottom: 6px; }
.auth-card .sub { text-align: center; color: var(--text-dim); font-size: 14px; margin-bottom: 26px; }
.auth-footer { text-align: center; margin-top: 18px; font-size: 13px; color: var(--text-dim); }

/* ---------- Progress bars ---------- */
.progress-bar { height: 8px; border-radius: 4px; background: rgba(255,255,255,0.06); overflow: hidden; margin-top: 10px; }
.progress-fill { height: 100%; background: var(--gradient); border-radius: 4px; transition: width 0.4s ease; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-success { background: rgba(52,211,153,0.12); color: var(--success); }
.badge-warning { background: rgba(251,191,36,0.12); color: var(--warning); }
.badge-danger { background: rgba(248,113,113,0.12); color: var(--danger); }
.badge-neutral { background: var(--glass); color: var(--text-dim); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); padding: 10px 14px; border-bottom: 1px solid var(--glass-border); }
td { padding: 14px; border-bottom: 1px solid rgba(255,255,255,0.04); font-size: 14px; }
tr:hover td { background: rgba(255,255,255,0.015); }

/* ---------- File manager ---------- */
.file-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--radius-sm); }
.file-row:hover { background: var(--glass); }
.file-row .fname { flex: 1; font-size: 14px; }
.file-row .fsize { color: var(--text-faint); font-size: 12px; width: 80px; }

/* ---------- Empty states ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty-state .big-icon { font-size: 42px; margin-bottom: 14px; opacity: 0.6; }
.empty-state h3 { color: var(--text); margin-bottom: 8px; }

/* ---------- Toasts ---------- */
#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 999; }
.toast {
  padding: 14px 18px; border-radius: var(--radius-sm); background: var(--bg-elevated);
  border: 1px solid var(--glass-border); box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  font-size: 14px; min-width: 260px; animation: slideIn 0.25s ease;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---------- Loading ---------- */
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.2); border-top-color: #fff; border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--glass) 25%, rgba(255,255,255,0.08) 50%, var(--glass) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------- Modal ---------- */
.modal-backdrop { 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: 998; }
.modal { width: 100%; max-width: 460px; padding: 28px; animation: popIn 0.2s ease; }
@keyframes popIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
