/* ═══════════════════════════════════════════════════════
   Elite Analytics — Admin Panel  ·  v3.0
   Design: Dark-first command center aesthetic
   Font: Geist Mono (labels) + Instrument Sans (body)
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&family=Geist+Mono:wght@400;500;600&display=swap');

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

/* ── TOKENS ─────────────────────────────── */
:root {
  --sidebar-w: 220px;
  --topbar-h: 56px;
  --radius:   10px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --font-body: 'Instrument Sans', system-ui, sans-serif;
  --font-mono: 'Geist Mono', 'SF Mono', monospace;
}

/* DARK (default) */
[data-theme="dark"] {
  --bg:          #070B10;
  --bg-1:        #0D1117;
  --bg-2:        #161B22;
  --bg-3:        #21262D;
  --bg-hover:    rgba(139,148,158,0.06);
  --border:      rgba(139,148,158,0.12);
  --border-hi:   rgba(139,148,158,0.22);
  --text:        #E6EDF3;
  --text-2:      #8B949E;
  --text-3:      #484F58;
  --accent:      #58A6FF;
  --accent-dim:  rgba(88,166,255,0.1);
  --accent-glow: rgba(88,166,255,0.25);
  --green:       #3FB950;
  --green-dim:   rgba(63,185,80,0.1);
  --red:         #F85149;
  --red-dim:     rgba(248,81,73,0.1);
  --amber:       #D29922;
  --amber-dim:   rgba(210,153,34,0.1);
  --purple:      #BC8CFF;
  --purple-dim:  rgba(188,140,255,0.1);
  --cyan:        #39D4C9;
  --cyan-dim:    rgba(57,212,201,0.1);
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.4);
  --shadow:      0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:   0 16px 48px rgba(0,0,0,0.6);
}

/* LIGHT */
[data-theme="light"] {
  --bg:          #F6F8FA;
  --bg-1:        #FFFFFF;
  --bg-2:        #F6F8FA;
  --bg-3:        #EAEEF2;
  --bg-hover:    rgba(31,35,40,0.04);
  --border:      rgba(31,35,40,0.12);
  --border-hi:   rgba(31,35,40,0.24);
  --text:        #1F2328;
  --text-2:      #636C76;
  --text-3:      #A8B1BA;
  --accent:      #0969DA;
  --accent-dim:  rgba(9,105,218,0.08);
  --accent-glow: rgba(9,105,218,0.2);
  --green:       #1A7F37;
  --green-dim:   rgba(26,127,55,0.08);
  --red:         #CF222E;
  --red-dim:     rgba(207,34,46,0.08);
  --amber:       #9A6700;
  --amber-dim:   rgba(154,103,0,0.08);
  --purple:      #8250DF;
  --purple-dim:  rgba(130,80,223,0.08);
  --cyan:        #0598AA;
  --cyan-dim:    rgba(5,152,170,0.08);
  --shadow-sm:   0 1px 3px rgba(31,35,40,0.08);
  --shadow:      0 4px 16px rgba(31,35,40,0.1);
  --shadow-lg:   0 16px 48px rgba(31,35,40,0.14);
}

/* ── BASE ────────────────────────────────── */
html { height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── LAYOUT ──────────────────────────────── */
.adm-layout {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: width 0.22s var(--ease), background 0.25s var(--ease);
  overflow: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-logo-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-glow);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--accent);
}
.sidebar-brand {
  display: flex; flex-direction: column; overflow: hidden;
}
.sidebar-brand-name {
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 600;
  color: var(--text); letter-spacing: 0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-brand-tag {
  font-family: var(--font-mono);
  font-size: 9px; font-weight: 500;
  color: var(--amber); letter-spacing: 0.1em;
  text-transform: uppercase; margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
  overflow-x: hidden;
}
.nav-group-label {
  font-family: var(--font-mono);
  font-size: 9px; font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.14em; text-transform: uppercase;
  padding: 8px 10px 4px;
  white-space: nowrap; overflow: hidden;
}
.nav-group-label:first-child { padding-top: 0; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  text-decoration: none;
  border: none; background: none;
  width: 100%; text-align: left;
  font-family: var(--font-body);
  transition: background 0.15s, color 0.15s;
  margin-bottom: 1px;
  white-space: nowrap; overflow: hidden;
}
.nav-item svg { flex-shrink: 0; }
.nav-item-label { overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}
.nav-item.active svg { color: var(--accent); }

.nav-divider {
  height: 1px; background: var(--border);
  margin: 8px 10px;
}

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── TOPBAR ──────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: var(--sidebar-w); right: 0;
  height: var(--topbar-h);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 16px;
  transition: left 0.22s var(--ease), background 0.25s var(--ease);
}
.topbar-title {
  flex: 1;
  display: flex; flex-direction: column;
}
.topbar-section-name {
  font-size: 15px; font-weight: 600;
  color: var(--text); letter-spacing: -0.01em;
  line-height: 1.2;
}
.topbar-section-desc {
  font-size: 11px; color: var(--text-2);
  font-family: var(--font-mono); margin-top: 1px;
}
.topbar-actions {
  display: flex; align-items: center; gap: 8px;
}

/* Mobile hamburger */
.topbar-toggle {
  display: none;
  width: 32px; height: 32px;
  align-items: center; justify-content: center;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--bg-2); color: var(--text-2);
  cursor: pointer; flex-shrink: 0;
}

/* ── MAIN ─────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  min-height: 100vh;
  transition: margin-left 0.22s var(--ease);
  flex: 1;
}
.main-inner {
  padding: 28px 28px 60px;
  max-width: 1440px;
}

/* ── SECTIONS ─────────────────────────────── */
.section { display: none; }
.section.active { display: block; }

/* ── STAT CHIPS ───────────────────────────── */
.stats-grid { display: grid; gap: 12px; }
.stats-grid-4 { grid-template-columns: repeat(4, 1fr); }
.stats-grid-3 { grid-template-columns: repeat(3, 1fr); }

.stat-chip {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative; overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.stat-chip::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  opacity: 0; transition: opacity 0.2s;
}
.stat-chip:hover { border-color: var(--border-hi); box-shadow: var(--shadow-sm); }
.stat-chip:hover::before { opacity: 1; }

.stat-chip-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.stat-chip-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.stat-chip-label {
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 500;
  color: var(--text-3); text-transform: uppercase; letter-spacing: 0.1em;
}
.stat-chip-value {
  font-size: 24px; font-weight: 700;
  letter-spacing: -0.03em; line-height: 1;
  margin-bottom: 4px;
}
.stat-chip-sub {
  font-family: var(--font-mono);
  font-size: 10px; color: var(--text-3);
}

/* ── CARDS ──────────────────────────────────── */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: background 0.25s;
}
.card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 16px; gap: 12px;
}
.card-title {
  font-size: 13px; font-weight: 600; color: var(--text);
}
.card-subtitle {
  font-family: var(--font-mono);
  font-size: 10px; color: var(--text-3); margin-top: 2px;
}

/* ── TABLES ──────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table thead tr {
  border-bottom: 1px solid var(--border);
}
.data-table th {
  text-align: left;
  padding: 9px 14px;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.08em;
  white-space: nowrap;
  background: var(--bg-2);
}
.data-table th:first-child { border-radius: var(--radius) 0 0 0; }
.data-table th:last-child  { border-radius: 0 var(--radius) 0 0; }
.data-table td {
  padding: 11px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr {
  transition: background 0.12s;
}
.data-table tbody tr:hover { background: var(--bg-hover); }

/* ── BADGES ──────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 100px;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 500;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-admin   { background: var(--amber-dim); color: var(--amber); border-color: rgba(210,153,34,0.2); }
.badge-user    { background: var(--accent-dim); color: var(--accent); border-color: var(--accent-glow); }
.badge-win     { background: var(--green-dim);  color: var(--green);  border-color: rgba(63,185,80,0.2); }
.badge-loss    { background: var(--red-dim);    color: var(--red);    border-color: rgba(248,81,73,0.2); }
.badge-pending { background: var(--amber-dim);  color: var(--amber);  border-color: rgba(210,153,34,0.2); }
.badge-active  { background: var(--green-dim);  color: var(--green);  border-color: rgba(63,185,80,0.2); }
.badge-inactive{ background: var(--bg-3);       color: var(--text-3); border-color: var(--border); }

/* ── INPUTS ──────────────────────────────────── */
.adm-input {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  outline: none;
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--font-body);
  transition: border-color 0.15s, box-shadow 0.15s;
  height: 36px;
}
.adm-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.adm-input::placeholder { color: var(--text-3); }

/* ── BUTTONS ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 14px; height: 32px;
  border-radius: var(--radius);
  font-size: 12px; font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer; border: none;
  transition: all 0.15s var(--ease);
  white-space: nowrap;
}
.btn-accent {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 0 var(--accent-glow);
}
.btn-accent:hover {
  opacity: 0.88;
  box-shadow: 0 0 0 4px var(--accent-dim);
}
.btn-secondary {
  background: var(--bg-3);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger  { background: var(--red-dim);   color: var(--red);   }
.btn-danger:hover  { background: rgba(248,81,73,0.18); }
.btn-success { background: var(--green-dim); color: var(--green); }
.btn-success:hover { background: rgba(63,185,80,0.18); }
.btn-primary { background: var(--accent-dim); color: var(--accent); }
.btn-primary:hover { background: rgba(88,166,255,0.18); }
.btn-ghost {
  background: transparent; color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-hi); }

/* icon-only buttons */
.btn-icon {
  width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  background: var(--bg-2); color: var(--text-2);
  border: 1px solid var(--border);
  cursor: pointer; transition: all 0.15s;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-hi); }

/* action row */
.action-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; height: 26px;
  border-radius: 6px;
  font-size: 11px; font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer; border: none;
  transition: all 0.12s;
}

/* ── AVATARS ─────────────────────────────────── */
.u-avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
  flex-shrink: 0;
  font-family: var(--font-mono);
}

/* ── PNL ─────────────────────────────────────── */
.pos { color: var(--green); font-weight: 600; }
.neg { color: var(--red);   font-weight: 600; }

/* ── SECTION HEADER ──────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.section-title {
  font-size: 18px; font-weight: 700;
  color: var(--text); letter-spacing: -0.02em;
}
.section-desc {
  font-family: var(--font-mono);
  font-size: 11px; color: var(--text-3); margin-top: 3px;
}

/* ── GRID LAYOUTS ────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.mb-3  { margin-bottom: 12px; }
.mb-4  { margin-bottom: 16px; }
.mb-5  { margin-bottom: 20px; }
.mb-6  { margin-bottom: 24px; }
.mt-4  { margin-top: 16px; }
.flex  { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.hidden { display: none !important; }
.overflow-x-auto { overflow-x: auto; }
.w-full { width: 100%; }
.text-mono { font-family: var(--font-mono); }

/* ── LOADING ─────────────────────────────────── */
.page-loader {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100vh; gap: 16px;
  color: var(--text-2);
  font-family: var(--font-mono); font-size: 12px;
}
.spinner {
  width: 28px; height: 28px;
  border: 2px solid var(--border-hi);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── MODALS ──────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--bg-1);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%; max-width: 520px;
  max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.22s var(--ease);
}
.modal-box h2 {
  font-size: 16px; font-weight: 700;
  letter-spacing: -0.02em; margin-bottom: 20px;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── DETAIL GROUPS ───────────────────────────── */
.detail-group {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden; margin-bottom: 12px;
}
.detail-group-header {
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 600;
  color: var(--accent); letter-spacing: 0.1em; text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  background: var(--bg-1);
}
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; }
.detail-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.detail-item:nth-child(odd) { border-right: 1px solid var(--border); }
.detail-item:last-child,
.detail-item:nth-last-child(2):nth-child(odd) { border-bottom: none; }
.detail-item-label {
  font-family: var(--font-mono);
  font-size: 9px; font-weight: 500;
  color: var(--text-3); text-transform: uppercase;
  letter-spacing: 0.08em; margin-bottom: 3px;
}
.detail-item-value {
  font-size: 14px; font-weight: 600; color: var(--text);
}

/* ── HEATMAP ─────────────────────────────────── */
.heatmap-wrap { overflow-x: auto; padding-bottom: 4px; }
.heatmap-grid {
  display: grid;
  grid-template-columns: 36px repeat(24, minmax(18px, 1fr));
  gap: 3px; min-width: 560px;
}
.heatmap-cell {
  aspect-ratio: 1; border-radius: 4px;
  transition: opacity 0.15s;
  cursor: default;
}
.heatmap-cell:hover { opacity: 0.75; }
.heatmap-label {
  font-family: var(--font-mono);
  font-size: 9px; color: var(--text-3);
  display: flex; align-items: center;
}
.heatmap-hour-label {
  font-family: var(--font-mono);
  font-size: 8px; color: var(--text-3); text-align: center;
}

/* ── THEME TOGGLE ────────────────────────────── */
.theme-toggle {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  border: none; background: none; width: 100%;
  text-align: left; font-family: var(--font-body);
  transition: background 0.15s, color 0.15s;
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--text); }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun  { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* ── TOPBAR STATUS DOT ───────────────────────── */
.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green);
  animation: dotPulse 3s ease infinite;
}
@keyframes dotPulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── FILTER BAR ──────────────────────────────── */
.filter-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  margin-bottom: 14px;
}
.filter-bar-label {
  font-family: var(--font-mono);
  font-size: 10px; color: var(--text-3);
  letter-spacing: 0.08em; text-transform: uppercase;
  white-space: nowrap;
}

/* ── PAGINATION ──────────────────────────────── */
.pagination-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; flex-wrap: wrap; gap: 8px;
}
.pagination-info {
  font-family: var(--font-mono);
  font-size: 11px; color: var(--text-3);
}

/* ── MOBILE BACKDROP ─────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 199;
}

/* ══ RESPONSIVE ══════════════════════════════ */
@media (max-width: 1280px) {
  .stats-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 220px; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.22s var(--ease), background 0.25s;
    box-shadow: none;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .sidebar-backdrop.visible { display: block; }

  .topbar { left: 0; }
  .topbar-toggle { display: flex; }

  .main { margin-left: 0; }
  .main-inner { padding: 16px 16px 48px; }

  .stats-grid-4,
  .stats-grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }

  .detail-grid { grid-template-columns: 1fr; }
  .detail-item:nth-child(odd) { border-right: none; }

  .filter-bar { padding: 10px 12px; }

  .section-header { margin-bottom: 16px; }
}

@media (max-width: 480px) {
  .stats-grid-4,
  .stats-grid-3 { grid-template-columns: 1fr; }
}
