:root {
  --bg: #0b1120;
  --bg-soft: #111827;
  --bg-card: #151c2c;
  --bg-hover: #1c2538;
  --border: #232c44;
  --text: #e6edf7;
  --text-soft: #94a3b8;
  --text-muted: #64748b;
  --primary: #0ea5e9;
  --primary-dark: #0284c7;
  --primary-soft: rgba(14, 165, 233, 0.12);
  --accent: #22d3ee;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --sidebar-w: 248px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  overflow-y: auto; z-index: 30;
}
.sidebar-brand {
  padding: 22px 20px 18px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: white; font-size: 18px;
}
.sidebar-brand .name { font-weight: 700; font-size: 16px; }
.sidebar-nav { padding: 12px 10px; flex: 1; }
.sidebar-nav .group-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); padding: 12px 12px 6px; font-weight: 600;
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-soft); font-weight: 500;
  transition: all 0.15s ease; margin-bottom: 2px;
}
.sidebar-link:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-link.active { background: var(--primary-soft); color: var(--primary); }
.sidebar-link .icon { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-footer { padding: 14px; border-top: 1px solid var(--border); }
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: var(--radius-sm);
}
.sidebar-user .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: white;
}
.sidebar-user .info { flex: 1; min-width: 0; }
.sidebar-user .info .email { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .info .balance { font-size: 11px; color: var(--primary); font-weight: 600; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px;
  background: rgba(17, 24, 39, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .title { font-size: 18px; font-weight: 700; }
.topbar .spacer { flex: 1; }
.topbar .balance-pill {
  background: var(--primary-soft); color: var(--primary);
  padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 13px;
}
.content { padding: 24px; max-width: 1200px; width: 100%; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; flex-direction: column; gap: 6px;
}
.stat-card .label { color: var(--text-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .value { font-size: 24px; font-weight: 800; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-hover);
  color: var(--text); font-weight: 600; font-size: 14px;
  transition: all 0.15s ease; text-decoration: none;
}
.btn:hover { background: var(--border); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-color: transparent; color: white;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-danger { background: var(--error); border-color: transparent; color: white; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-success { background: var(--success); border-color: transparent; color: white; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.input, .select, .textarea {
  width: 100%; padding: 10px 12px;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 14px;
  transition: border 0.15s ease;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); }
.label { display: block; font-size: 12px; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }
.field { margin-bottom: 14px; }

table { width: 100%; border-collapse: collapse; }
.table-wrap { overflow-x: auto; }
th, td { padding: 12px 14px; text-align: left; font-size: 13px; }
thead th {
  color: var(--text-muted); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:hover { background: var(--bg-hover); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700;
}
.badge-success { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-error { background: rgba(239, 68, 68, 0.15); color: var(--error); }
.badge-info { background: rgba(14, 165, 233, 0.15); color: var(--primary); }
.badge-muted { background: var(--bg-hover); color: var(--text-muted); }

.alert {
  padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px;
  margin-bottom: 14px; display: flex; align-items: center; gap: 10px;
}
.alert-error { background: rgba(239, 68, 68, 0.12); color: var(--error); border: 1px solid rgba(239, 68, 68, 0.3); }
.alert-success { background: rgba(34, 197, 94, 0.12); color: var(--success); border: 1px solid rgba(34, 197, 94, 0.3); }
.alert-info { background: var(--primary-soft); color: var(--primary); border: 1px solid rgba(14, 165, 233, 0.3); }

.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background:
    radial-gradient(1200px 600px at 10% 0%, rgba(14, 165, 233, 0.12), transparent 60%),
    radial-gradient(1000px 500px at 90% 100%, rgba(34, 211, 238, 0.1), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px; box-shadow: var(--shadow);
}
.auth-logo {
  width: 56px; height: 56px; border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: white; font-size: 24px; margin: 0 auto 18px;
}
.auth-title { text-align: center; font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.auth-sub { text-align: center; color: var(--text-muted); margin-bottom: 24px; font-size: 13px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.mobile-topbar-toggle {
  display: none;
  background: var(--bg-hover); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px; color: var(--text);
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .mobile-topbar-toggle { display: inline-flex; }
  .content { padding: 16px; }
}
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 25; display: none; }
.overlay.show { display: block; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto;
}
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.row { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-soft { color: var(--text-soft); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.font-800 { font-weight: 800; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.items-center { align-items: center; }
code { background: var(--bg-soft); padding: 2px 6px; border-radius: 4px; font-size: 13px; }
pre { background: var(--bg-soft); padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 12px; line-height: 1.5; }
