:root {
  --bg: #0a0c12;
  --bg-elev: #11141d;
  --bg-elev-2: #161a26;
  --border: #222838;
  --border-soft: #1a1f2b;
  --text: #e6e9f0;
  --text-dim: #8b93a7;
  --text-faint: #828ba1;
  --accent: #5b8cff;
  --up: #2ee6a6;
  --up-soft: rgba(46, 230, 166, 0.12);
  --down: #ff5d73;
  --down-soft: rgba(255, 93, 115, 0.12);
  --warn: #f5b740;
  --warn-soft: rgba(245, 183, 64, 0.12);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset, 0 8px 24px rgba(0, 0, 0, 0.35);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: 'SF Mono', ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(91, 140, 255, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.muted { color: var(--text-dim); }
.small { font-size: 0.72rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.up { color: var(--up); }
.down { color: var(--down); }

/* ── Layout shell ───────────────────────────────── */
.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 22px 48px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card {
  background: linear-gradient(180deg, var(--bg-elev), var(--bg-elev) 60%, #0f121a);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.card-head h2 {
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text);
}

/* ── Top bar ────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #7aa2ff);
  color: #08101f;
  font-weight: 800;
  font-size: 0.9rem;
}
.brand-text h1 { font-size: 1.05rem; font-weight: 700; letter-spacing: 0.2px; }
.brand-sub { font-size: 0.72rem; color: var(--text-dim); letter-spacing: 0.4px; }

.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.badge {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid transparent;
}
.badge-mode { background: var(--warn-soft); color: var(--warn); border-color: rgba(245, 183, 64, 0.3); }
.badge-mode.live { background: var(--down-soft); color: var(--down); border-color: rgba(255, 93, 115, 0.35); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  background: var(--bg-elev-2);
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.pill.running { color: var(--up); border-color: rgba(46, 230, 166, 0.35); background: var(--up-soft); }
.pill.running .dot { background: var(--up); animation: pulse 2s infinite; }
.pill.stopped { color: var(--text-dim); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.logout { color: var(--text-faint); font-size: 0.74rem; text-decoration: none; padding: 4px 6px; }
.logout:hover { color: var(--text); }

/* ── Buttons ────────────────────────────────────── */
.btn {
  font-family: var(--font);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 7px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:hover { background: #1d2230; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-ghost.start { color: var(--up); border-color: rgba(46, 230, 166, 0.35); background: var(--up-soft); }
.btn-ghost.start:hover { background: rgba(46, 230, 166, 0.2); }
.btn-ghost.stop { color: var(--down); border-color: rgba(255, 93, 115, 0.35); background: var(--down-soft); }
.btn-ghost.stop:hover { background: rgba(255, 93, 115, 0.2); }
.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #7aa2ff);
  color: #08101f;
  border: none;
  padding: 11px;
  font-size: 0.85rem;
}
.btn-primary:hover { filter: brightness(1.06); }

/* ── Banners ────────────────────────────────────── */
.banner {
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.banner-danger { background: var(--down-soft); color: var(--down); border-color: rgba(255, 93, 115, 0.35); }
.banner-warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(245, 183, 64, 0.3); }

/* ── Hero ───────────────────────────────────────── */
.hero {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 26px;
  flex-wrap: wrap;
}
.hero-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.hero-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
}
.hero-equity {
  font-family: var(--mono);
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}
.hero-sub { font-size: 0.85rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hero-pnl { font-family: var(--mono); font-weight: 700; }
.hero-sep { color: var(--text-faint); }

.hero-side {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  min-width: 180px;
  padding-left: 22px;
  border-left: 1px solid var(--border-soft);
}
.hero-side-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.hero-side-item .k { font-size: 0.75rem; color: var(--text-dim); }
.hero-side-item .v { font-family: var(--mono); font-size: 0.85rem; font-weight: 600; }

/* ── Chart ──────────────────────────────────────── */
.chart-card .chart-wrap { position: relative; padding: 14px 14px 10px; }
#equity-chart { display: block; width: 100%; height: 260px; }
.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  color: var(--text-faint);
  font-size: 0.85rem;
}

/* ── Stat grid ──────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}
.stat { padding: 14px 16px; display: flex; flex-direction: column; gap: 3px; }
.stat-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-dim); }
.stat-value { font-family: var(--mono); font-size: 1.32rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 0.7rem; }

/* ── Tables ─────────────────────────────────────── */
.tables {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.table-card { display: flex; flex-direction: column; min-width: 0; }
.chip {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-dim);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
}
.table-scroll { overflow-x: auto; overflow-y: auto; max-height: 360px; }
table { width: 100%; border-collapse: collapse; }
thead th {
  position: sticky;
  top: 0;
  background: var(--bg-elev);
  z-index: 1;
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-faint);
  font-weight: 600;
  text-align: left;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
thead th.num { text-align: right; }
tbody td {
  padding: 10px 16px;
  font-size: 0.78rem;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.018); }
.cell-game { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; color: var(--text-faint); padding: 26px 16px; font-size: 0.8rem; }

.tag {
  display: inline-block;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 5px;
  border: 1px solid transparent;
}
.tag-won { background: var(--up-soft); color: var(--up); border-color: rgba(46, 230, 166, 0.3); }
.tag-lost { background: var(--down-soft); color: var(--down); border-color: rgba(255, 93, 115, 0.3); }
.tag-void { background: var(--warn-soft); color: var(--warn); border-color: rgba(245, 183, 64, 0.3); }

/* ── How it works ───────────────────────────────── */
.how {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.6;
  padding: 4px 2px;
}
.how strong { color: var(--text); }

/* ── Login ──────────────────────────────────────── */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-box { width: 380px; max-width: 100%; padding: 32px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.login-brand h1 { font-size: 1.2rem; }
.login-tag { font-size: 0.8rem; margin-bottom: 20px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 0.72rem; color: var(--text-dim); margin-bottom: 6px; letter-spacing: 0.3px; }
.field input {
  width: 100%;
  padding: 11px 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus { border-color: var(--accent); }
.login-box .banner { margin-bottom: 14px; }

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 920px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .tables { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .shell { padding: 16px 14px 40px; gap: 14px; }
  .hero { flex-direction: column; gap: 16px; padding: 20px; }
  .hero-side { border-left: none; border-top: 1px solid var(--border-soft); padding-left: 0; padding-top: 14px; min-width: 0; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  #equity-chart { height: 220px; }
  .cell-game { max-width: 180px; }
  .topbar-right { width: 100%; justify-content: flex-start; }
}
@media (max-width: 380px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .hero-equity { font-size: 2.2rem; }
}

/* ensure the [hidden] attribute always wins over component display rules */
[hidden]{display:none !important;}
