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

/* ── Variables ─────────────────────────────────────────────────── */
:root {
  --bg: #05020e;
  --bg2: #0a0618;
  --surface: rgba(10, 5, 24, 0.9);
  --surface2: rgba(14, 8, 32, 0.85);
  --border: rgba(110, 50, 200, 0.2);
  --border-hi: rgba(110, 50, 200, 0.4);
  --purple: #7c3aed;
  --purple-lt: #a78bfa;
  --purple-dim: rgba(124, 58, 237, 0.15);
  --green: #3cff8a;
  --green-dk: #00c96b;
  --green-dim: rgba(60, 255, 138, 0.12);
  --text: #ece8f5;
  --muted: #5a4e78;
  --danger: #ef4444;
  --warn: #fbbf24;
  --r: 14px;
  --r-sm: 8px;
  --font: 'Space Grotesk', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

/* ── Base ─────────────────────────────────────────────────────── */
html, body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

#bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
#app { position: relative; z-index: 1; min-height: 100vh; }

/* ── Scroll ────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(124,58,237,.3); border-radius: 3px; }

/* ── Nav ─────────────────────────────────────────────────────── */
nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(5,2,14,.85);
  backdrop-filter: blur(20px) saturate(1.5);
  border-bottom: 1px solid var(--border);
  padding: 0 48px;
}
.nav-inner {
  max-width: 1100px; margin: 0 auto;
  height: 60px;
  display: flex; align-items: center; justify-content: space-between;
}
.logo { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); text-decoration: none; }
.logo span { color: var(--green); }
.nav-right { display: flex; align-items: center; gap: 16px; }
.nav-user { font-size: 14px; color: var(--muted); font-weight: 500; }
.admin-link { display: none; }
.admin-link.visible { display: inline-flex; }

/* ── Buttons ─────────────────────────────────────────────────── */
button, .btn {
  font-family: var(--font); cursor: pointer; border: none; outline: none;
  font-size: 14px; font-weight: 600; transition: all .18s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none;
}
.btn-sm { padding: 7px 16px; border-radius: var(--r-sm); font-size: 13px; }
.btn-md { padding: 11px 24px; border-radius: var(--r-sm); }
.btn-lg { padding: 14px 32px; border-radius: var(--r); font-size: 16px; }

.btn-primary {
  background: linear-gradient(135deg, #1a6b3c, #0d4a28);
  color: #a8f0cc;
  border: 1px solid rgba(60,255,138,.22);
  box-shadow: 0 4px 16px rgba(13,74,40,.35);
}
.btn-primary:hover { filter: brightness(1.12); transform: translateY(-1px); }

.btn-purple {
  background: var(--purple-dim);
  color: var(--purple-lt);
  border: 1px solid rgba(124,58,237,.35);
}
.btn-purple:hover { background: rgba(124,58,237,.25); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-hi); }

.btn-ghost-sm {
  padding: 6px 14px; border-radius: var(--r-sm);
  background: transparent; color: var(--muted);
  border: 1px solid var(--border); font-size: 13px;
  font-weight: 500; cursor: pointer;
}
.btn-ghost-sm:hover { color: var(--text); border-color: var(--border-hi); }

.btn-danger {
  background: rgba(239,68,68,.15);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,.3);
}
.btn-danger:hover { background: rgba(239,68,68,.25); }

/* ── Form ─────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 600; color: #a89ab8; letter-spacing: .03em; }
.form-group .hint { font-size: 11px; color: var(--muted); }

input, select {
  width: 100%;
  padding: 11px 14px;
  background: rgba(7,3,15,.85);
  border: 1px solid rgba(100,50,180,.35);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus {
  border-color: rgba(124,58,237,.65);
  box-shadow: 0 0 0 3px rgba(124,58,237,.15);
}
input.error { border-color: rgba(239,68,68,.6); }
.error-msg { font-size: 12px; color: #fca5a5; margin-top: 2px; }

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  backdrop-filter: blur(16px);
  padding: 28px;
  box-shadow: 0 16px 48px rgba(0,0,0,.4);
}
.card-sm { padding: 20px; }

/* ── Pages ─────────────────────────────────────────────────────── */
.page {
  max-width: 1100px; margin: 0 auto;
  padding: 48px 24px;
}

/* ── Auth pages ─────────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface2);
  border: 1px solid rgba(100,50,180,.3);
  border-radius: 18px;
  padding: 40px 36px;
  backdrop-filter: blur(24px);
  box-shadow: 0 32px 80px rgba(0,0,0,.5), 0 0 60px rgba(124,58,237,.07);
}
.auth-card .card-glow {
  position: fixed; inset: 0; border-radius: 18px;
  background: conic-gradient(from 0deg at 50% 50%,
    transparent 0%, rgba(124,58,237,.4) 20%,
    rgba(60,255,138,.2) 40%, transparent 60%,
    rgba(124,58,237,.35) 80%, transparent 100%);
  z-index: -1; opacity: .4;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  padding: 1px;
  animation: spin 14s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.auth-title {
  font-size: 24px; font-weight: 700; letter-spacing: -0.03em;
  margin-bottom: 4px;
}
.auth-sub { font-size: 14px; color: var(--muted); margin-bottom: 32px; }
.auth-stack { display: flex; flex-direction: column; gap: 16px; }
.auth-divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--muted); font-size: 12px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  margin: 8px 0;
}
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Dashboard ─────────────────────────────────────────────────── */
.dash-header { margin-bottom: 40px; }
.dash-title { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; margin-bottom: 4px; }
.dash-sub { color: var(--muted); font-size: 14px; }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 32px; }
.stat-card {
  padding: 24px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
}
.stat-label { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; font-family: var(--mono); line-height: 1; }
.stat-value.green { color: var(--green); text-shadow: 0 0 20px rgba(60,255,138,.4); }
.stat-value.purple { color: var(--purple-lt); }
.stat-value.warn { color: var(--warn); }
.stat-change { font-size: 12px; margin-top: 4px; color: var(--green); font-weight: 600; }
.stat-change.neg { color: var(--danger); }

/* NAV card */
.nav-card {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 24px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px;
}
.nav-value { font-size: 32px; font-weight: 800; letter-spacing: -0.04em; color: var(--green); font-family: var(--mono); text-shadow: 0 0 24px rgba(60,255,138,.4); }
.nav-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.nav-date { font-size: 12px; color: var(--muted); }

/* Two-col layout */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

/* Deposit form */
.deposit-form { display: flex; gap: 10px; }
.deposit-form input { flex: 1; }
.deposit-form button { flex-shrink: 0; }

/* Table */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(100,50,180,.08);
  color: #c4b0f8;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(124,58,237,.06); }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
}
.badge-green { background: rgba(60,255,138,.12); color: #a8f0cc; border: 1px solid rgba(60,255,138,.2); }
.badge-purple { background: rgba(124,58,237,.12); color: var(--purple-lt); border: 1px solid rgba(124,58,237,.2); }
.badge-warn { background: rgba(251,191,36,.1); color: var(--warn); border: 1px solid rgba(251,191,36,.2); }

/* Section title */
.section-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 16px; }

/* ── Admin ─────────────────────────────────────────────────────── */
.admin-header { margin-bottom: 40px; }
.admin-users-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 32px; }
.admin-user-card {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  cursor: pointer;
  transition: border-color .2s, transform .2s;
}
.admin-user-card:hover { border-color: rgba(124,58,237,.5); transform: translateY(-2px); }
.admin-user-card .u-email { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.admin-user-card .u-meta { font-size: 12px; color: var(--muted); }
.admin-user-card .u-shares { font-size: 20px; font-weight: 700; color: var(--green); font-family: var(--mono); margin-top: 8px; }

/* Admin detail */
.admin-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.admin-section { margin-bottom: 0; }

/* NAV update form */
.nav-update { display: flex; gap: 10px; align-items: flex-end; }
.nav-update input { max-width: 140px; }

/* ── Toast ─────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(100px);
  padding: 12px 24px;
  background: var(--surface2);
  border: 1px solid var(--border-hi);
  border-radius: 100px;
  font-size: 14px; font-weight: 600;
  z-index: 999; pointer-events: none;
  transition: transform .3s ease, opacity .3s ease;
  opacity: 0;
  white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.ok { border-color: rgba(60,255,138,.4); color: #a8f0cc; }
.toast.err { border-color: rgba(239,68,68,.4); color: #fca5a5; }

/* ── Loading ────────────────────────────────────────────────────── */
.loading { display: flex; align-items: center; justify-content: center; padding: 60px; color: var(--muted); font-size: 14px; gap: 10px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--purple); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col, .admin-detail { grid-template-columns: 1fr; }
  .admin-users-grid { grid-template-columns: repeat(2, 1fr); }
  nav { padding: 0 24px; }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .admin-users-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 20px; }
}
