/* Bảng thành tích trader (/traders.html) — trang công khai, không phụ thuộc Tabler.
   Màu dữ liệu: equity = blue (1 series); thắng/thua = blue <-> red (đã chạy
   validate_palette: light ΔE CVD 21.6, dark 19.2 — PASS). Chữ luôn dùng token ink,
   không dùng màu series. */

:root {
  color-scheme: light;
  --plane: #f6f6f3;
  --surface: #fcfcfb;
  --surface-2: #f1f0ec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 8px 24px rgba(11, 11, 11, 0.06);
  --series: #2a78d6;
  --series-soft: rgba(42, 120, 214, 0.10);
  --pos: #2a78d6;
  --neg: #e34948;
  --good-ink: #006300;
  --bad-ink: #b42b2b;
  --accent: #2a78d6;
  --demo-bg: #fff2d6;
  --demo-ink: #7a5200;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --ring: rgba(255, 255, 255, 0.10);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
    --series: #3987e5;
    --series-soft: rgba(57, 135, 229, 0.16);
    --pos: #3987e5;
    --neg: #e66767;
    --good-ink: #0ca30c;
    --bad-ink: #e66767;
    --accent: #3987e5;
    --demo-bg: #3a2c0a;
    --demo-ink: #f4c96b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --ring: rgba(255, 255, 255, 0.10);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --series: #3987e5;
  --series-soft: rgba(57, 135, 229, 0.16);
  --pos: #3987e5;
  --neg: #e66767;
  --good-ink: #0ca30c;
  --bad-ink: #e66767;
  --accent: #3987e5;
  --demo-bg: #3a2c0a;
  --demo-ink: #f4c96b;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--plane);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, select { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* ── Top bar ── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--plane) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--ring);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; text-decoration: none; letter-spacing: -0.01em; white-space: nowrap; min-width: 0; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 45%, var(--ink)));
  box-shadow: inset 0 0 0 1px var(--ring);
}
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--ring); background: var(--surface); cursor: pointer; color: var(--ink-2);
}
.icon-btn:hover { color: var(--ink); background: var(--surface-2); }
.btn-ghost {
  padding: 7px 14px; border-radius: 10px; border: 1px solid var(--ring); background: var(--surface);
  text-decoration: none; font-weight: 550; font-size: 14px; white-space: nowrap;
}
.btn-ghost:hover { background: var(--surface-2); }

/* ── Hero ── */
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; padding: 40px 0 24px; }
.eyebrow { margin: 0 0 6px; color: var(--accent); font-weight: 600; font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(28px, 4vw, 40px); line-height: 1.1; letter-spacing: -0.025em; font-weight: 700; }
.lede { margin: 10px 0 0; color: var(--ink-2); max-width: 560px; }
.controls { display: flex; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--ring); }
.seg button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer;
  color: var(--ink-2); font-size: 14px; font-weight: 550;
}
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12), inset 0 0 0 1px var(--ring); }
.select select {
  appearance: none; padding: 8px 34px 8px 12px; border-radius: 11px; border: 1px solid var(--ring);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%23898781' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat right 10px center;
  font-size: 14px; font-weight: 550; cursor: pointer;
}

/* ── KPI strip ── */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 32px; }
.kpi { background: var(--surface); border: 1px solid var(--ring); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .label { color: var(--ink-2); font-size: 13px; }
.kpi .value { font-size: 26px; font-weight: 680; letter-spacing: -0.02em; margin-top: 4px; }
.kpi .hint { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ── Board ── */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
h2 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr)); gap: 14px; }
.card {
  min-width: 0;
  position: relative; background: var(--surface); border: 1px solid var(--ring); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); cursor: pointer; text-align: left; width: 100%;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 35%, var(--ring)); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card.skeleton { height: 236px; cursor: default; background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%) 0 0/200% 100%; animation: shimmer 1.4s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }
.card-top { display: flex; align-items: center; gap: 12px; }
.rank {
  min-width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--ring);
}
.rank.r1 { background: linear-gradient(135deg, #f7d774, #d9a520); color: #3b2a00; border-color: transparent; }
.rank.r2 { background: linear-gradient(135deg, #e9ecef, #aeb4bb); color: #23272b; border-color: transparent; }
.rank.r3 { background: linear-gradient(135deg, #f1c6a0, #b97a45); color: #3a1d06; border-color: transparent; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-weight: 650; font-size: 14px; color: var(--ink);
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--ring);
}
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }
.ident { min-width: 0; flex: 1; }
.ident .name, .ident .meta, .roi .big, .roi .sub { display: block; }
.ident .name { font-weight: 640; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ident .meta { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge-demo {
  display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 10.5px; font-weight: 700;
  letter-spacing: .06em; background: var(--demo-bg); color: var(--demo-ink); vertical-align: 1px;
}
.roi { text-align: right; flex: none; }
.roi .big { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.roi .sub { font-size: 12.5px; color: var(--ink-2); }
.up { color: var(--good-ink); }
.down { color: var(--bad-ink); }
.spark { margin: 12px -4px 6px; height: 64px; }
.spark svg { display: block; width: 100%; height: 100%; overflow: visible; }

.wl { margin-top: 6px; }
.wl-bar { display: flex; gap: 2px; height: 8px; border-radius: 4px; overflow: hidden; background: var(--surface-2); }
.wl-bar span { display: block; height: 100%; }
.wl-bar .w { background: var(--pos); border-radius: 4px 0 0 4px; }
.wl-bar .l { background: var(--neg); border-radius: 0 4px 4px 0; }
.wl-text { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-2); margin-top: 6px; }
.wl-text b { color: var(--ink); font-weight: 650; }

.mini { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--grid); }
.mini div { min-width: 0; }
.mini .k { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.mini .v { font-weight: 640; font-size: 14px; }

.empty { grid-column: 1 / -1; padding: 48px 16px; text-align: center; color: var(--ink-2); background: var(--surface); border: 1px dashed var(--axis); border-radius: var(--radius); }

.disclaimer { color: var(--muted); font-size: 12.5px; margin: 32px 0 48px; max-width: 760px; }

/* ── Drawer ── */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.38); z-index: 40; animation: fade .2s ease; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: min(860px, 100%);
  background: var(--plane); border-left: 1px solid var(--ring); box-shadow: -12px 0 40px rgba(0,0,0,.18);
  display: flex; flex-direction: column; animation: slide .25s cubic-bezier(.2,.8,.2,1);
}
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--ring); background: var(--surface); }
.drawer-head .who { display: flex; gap: 14px; align-items: center; }
.drawer-head h2 { font-size: 20px; }
.drawer-head p { margin: 2px 0 0; }
.drawer-body { overflow-y: auto; padding: 18px 20px 32px; display: grid; gap: 14px; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--ring); border-radius: 12px; padding: 12px 14px; }
.tile .k { color: var(--ink-2); font-size: 12.5px; }
.tile .v { font-size: 20px; font-weight: 680; letter-spacing: -0.015em; margin-top: 2px; }
.tile .h { color: var(--muted); font-size: 11.5px; }
.panel { margin: 0; background: var(--surface); border: 1px solid var(--ring); border-radius: 12px; padding: 14px 16px; }
.panel h3 { margin: 0; font-size: 14.5px; }
.panel figcaption { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.panel > h3 { margin-bottom: 8px; }
.legend { display: inline-flex; gap: 14px; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw-pos { background: var(--pos); }
.sw-neg { background: var(--neg); }
.chart { position: relative; height: 220px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .axis-label { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; color: var(--muted); font-weight: 550; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.tbl td { padding: 7px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl-scroll { overflow-x: auto; }
.pill { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11.5px; font-weight: 650; background: var(--surface-2); color: var(--ink-2); }
.res { display: inline-flex; align-items: center; gap: 6px; }
.res i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

/* ── Tooltip ── */
.tooltip {
  position: fixed; z-index: 60; pointer-events: none; min-width: 140px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--ring); border-radius: 10px;
  padding: 8px 10px; font-size: 12.5px; box-shadow: var(--shadow); font-variant-numeric: tabular-nums;
}
.tooltip .t { color: var(--muted); font-size: 11.5px; margin-bottom: 2px; }
.tooltip .row { display: flex; justify-content: space-between; gap: 14px; }

@media (max-width: 860px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .brand { font-size: 14px; }
  .roi .big { font-size: 19px; }
  .card { padding: 16px 14px; }
  .card-top { gap: 10px; }
  .avatar { width: 34px; height: 34px; font-size: 12.5px; }
  .mini { grid-template-columns: repeat(2, 1fr); row-gap: 10px; }
  .hero { padding-top: 28px; }
  .kpi .value { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
