/* Show Trades — web UI. Tokens follow the validated reference palette (light + dark selected separately). */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --s1: #2a78d6;   /* blue  — long / primary series */
  --s2: #eb6834;   /* orange — short / second series */
  --s3: #1baf7a;   /* aqua */
  --s4: #eda100;   /* yellow */
  --pos: #2a78d6;  /* diverging: gain */
  --neg: #e34948;  /* diverging: loss */
  --mid: #f0efec;  /* diverging midpoint */
  --wash: rgba(42, 120, 214, 0.10);
  --good: #006300;
  --warn: #9a6400;
  --crit: #d03b3b;
  --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #6da7ec; --seq-4: #3987e5; --seq-5: #256abf; --seq-6: #184f95; --seq-7: #0d366b;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781; --grid: #2c2c2a; --axis: #383835;
    --ring: rgba(255, 255, 255, 0.10);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --pos: #3987e5; --neg: #e66767; --mid: #383835; --wash: rgba(57, 135, 229, 0.14);
    --good: #0ca30c; --warn: #fab219; --crit: #e66767;
    --seq-1: #104281; --seq-2: #184f95; --seq-3: #1c5cab; --seq-4: #2a78d6; --seq-5: #5598e7; --seq-6: #86b6ef; --seq-7: #cde2fb;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781; --grid: #2c2c2a; --axis: #383835;
  --ring: rgba(255, 255, 255, 0.10);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --pos: #3987e5; --neg: #e66767; --mid: #383835; --wash: rgba(57, 135, 229, 0.14);
  --good: #0ca30c; --warn: #fab219; --crit: #e66767;
  --seq-1: #104281; --seq-2: #184f95; --seq-3: #1c5cab; --seq-4: #2a78d6; --seq-5: #5598e7; --seq-6: #86b6ef; --seq-7: #cde2fb;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--ink); font: 14px/1.45 var(--font); }
a { color: inherit; }
button, select, input { font: inherit; color: inherit; }

/* ---- top bar ---- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 56px; background: var(--surface); border-bottom: 1px solid var(--ring); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -0.01em; text-decoration: none; }
.brand svg { width: 22px; height: 22px; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { text-decoration: none; padding: 6px 12px; border-radius: 8px; color: var(--ink-2); white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.nav .sep { width: 1px; background: var(--ring); margin: 8px 6px; }
.badge-mode { font-size: 12px; color: var(--muted); border: 1px solid var(--ring); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.icon-btn { border: 1px solid var(--ring); background: var(--surface); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); }

main { max-width: 1320px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 4px 0 20px; }
.page-head h1 { font-size: 24px; line-height: 1.2; margin: 0; letter-spacing: -0.015em; }
.page-head .sub { color: var(--ink-2); margin-top: 4px; }
.crumbs { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.crumbs a { text-decoration: none; } .crumbs a:hover { text-decoration: underline; }

/* ---- filters row ---- */
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.seg { display: inline-flex; border: 1px solid var(--ring); border-radius: 9px; padding: 2px; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 7px; cursor: pointer; color: var(--ink-2); }
.seg button:hover { background: var(--surface-2); }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); font-weight: 600; }
select.ctl, input.ctl { border: 1px solid var(--ring); background: var(--surface); border-radius: 8px; padding: 6px 10px; }

/* ---- grid & cards ---- */
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.c12 { grid-column: span 12; } .c8 { grid-column: span 8; } .c7 { grid-column: span 7; } .c6 { grid-column: span 6; }
.c5 { grid-column: span 5; } .c4 { grid-column: span 4; } .c3 { grid-column: span 3; }
@media (max-width: 1100px) { .c8, .c7, .c6, .c5, .c4 { grid-column: span 12; } .c3 { grid-column: span 6; } }
@media (max-width: 640px) { main { padding: 16px; } .c3 { grid-column: span 12; } .topbar { padding: 0 16px; gap: 12px; } .badge-mode { display: none; } }

.card { background: var(--surface); border: 1px solid var(--ring); border-radius: var(--radius); padding: 16px 18px 14px; min-width: 0; position: relative; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card-title { font-weight: 600; font-size: 14px; }
.card-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card-tools { display: flex; gap: 6px; flex-shrink: 0; }
.tbtn { border: 1px solid var(--ring); background: transparent; border-radius: 7px; padding: 2px 8px; font-size: 12px; color: var(--ink-2); cursor: pointer; }
.tbtn:hover { background: var(--surface-2); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--ink-2); margin: -2px 0 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend i.line { height: 2px; width: 14px; border-radius: 2px; vertical-align: 3px; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.note { color: var(--ink-2); font-size: 12.5px; margin-top: 8px; }
.chart { width: 100%; position: relative; }
.chart svg { display: block; overflow: visible; }

/* ---- KPI tiles ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--ring); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { color: var(--ink-2); font-size: 12.5px; }
.kpi .value { font-size: 22px; font-weight: 600; margin-top: 4px; letter-spacing: -0.01em; }
.kpi .hint { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi.hero { grid-column: span 2; }
@media (min-width: 1101px) { .kpis-acc { grid-template-columns: 2fr repeat(5, 1fr); } .kpis-acc .kpi.hero { grid-column: auto; } }
.kpi.hero .value { font-size: 44px; line-height: 1.05; }
@media (max-width: 640px) { .kpi.hero { grid-column: span 1; } .kpi.hero .value { font-size: 34px; } }
.up { color: var(--good); } .down { color: var(--crit); }

/* ---- tables ---- */
.tbl-wrap { overflow-x: auto; margin: 0 -4px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 500; 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 td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl a { text-decoration: none; font-weight: 550; } .tbl a:hover { text-decoration: underline; }
.ts { font-variant-numeric: tabular-nums; }
.credit { color: var(--ink-2); font-size: 12px; text-decoration: underline; text-underline-offset: 2px; font-weight: 400; }
.credit:hover { color: var(--ink); }
.acc-card { cursor: pointer; }
.pill { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--ring); color: var(--ink-2); }
.pill.mt4, .pill.mt5, .pill.other { font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; color: var(--ink-2); font-size: 12.5px; }

/* ---- account cards ---- */
.acc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.acc-card { text-decoration: none; display: block; background: var(--surface); border: 1px solid var(--ring); border-radius: var(--radius); padding: 16px; transition: border-color .15s; }
.acc-card:hover { border-color: var(--axis); }
.acc-card .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.acc-card .name { font-weight: 600; }
.acc-card .gain { font-size: 26px; font-weight: 600; margin: 8px 0 2px; }
.acc-card .meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; font-size: 12.5px; }
.acc-card .meta b { display: block; font-weight: 600; font-size: 13.5px; color: var(--ink); }
.acc-card .meta span { color: var(--muted); }

/* ---- tooltip ---- */
#tip { position: fixed; z-index: 50; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--ring);
  box-shadow: 0 6px 24px rgba(0,0,0,.12); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; min-width: 120px; opacity: 0; transition: opacity .08s; }
#tip.on { opacity: 1; }
#tip .t-head { color: var(--muted); margin-bottom: 4px; }
#tip .t-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
#tip .t-row b { font-weight: 650; font-variant-numeric: tabular-nums; }
#tip .t-key { display: inline-block; width: 12px; height: 2px; border-radius: 2px; margin-right: 6px; vertical-align: 3px; }
#tip .t-name { color: var(--ink-2); }

.callout { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; color: var(--ink-2); font-size: 13px; }
.callout code, .card code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }
pre.cmd { background: var(--surface-2); padding: 10px 12px; border-radius: 8px; overflow-x: auto; font-size: 12.5px; margin: 8px 0 0; }
.loading { opacity: .55; transition: opacity .2s; }
.diagram text { font-family: var(--font); }
.split { display: flex; gap: 18px; flex-wrap: wrap; }
.stat-inline { min-width: 110px; }
.stat-inline .v { font-size: 18px; font-weight: 600; }
.stat-inline .l { color: var(--muted); font-size: 12px; }

/* ---- auth ---- */
.userbox { display: flex; align-items: center; gap: 8px; }
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--ring); background: var(--surface); color: var(--ink);
  border-radius: 8px; padding: 6px 12px; text-decoration: none; cursor: pointer; font-weight: 550; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.ghost { font-weight: 400; color: var(--ink-2); }
.user-chip { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--wash); color: var(--s1); font-weight: 650; font-size: 13px; object-fit: cover; }
.signin { max-width: 440px; margin: 48px auto; padding: 28px; }
.signin h1 { font-size: 22px; margin: 0 0 6px; }
.providers { display: grid; gap: 10px; margin-top: 20px; }
.provider { justify-content: center; padding: 10px 14px; }
.provider.github { background: #0b0b0b; color: #fff; border-color: #0b0b0b; }
.provider.github:hover { background: #2a2a28; }
@media (max-width: 640px) { .user-name { display: none; } }
.row-actions { display: inline-flex; gap: 6px; }
.btn.approve { background: var(--s1); color: #fff; border-color: var(--s1); }
.btn.approve:hover { filter: brightness(1.08); background: var(--s1); }
.callout.down { color: var(--crit); }
.nav-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--s2); color: #fff; font-size: 11px; font-weight: 650; text-align: center; line-height: 18px; }

/* admin forms (ShowMyTrades import) */
.form { display: grid; gap: 12px; }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.field { display: grid; gap: 4px; font-size: 13px; }
.field-l { color: var(--ink-2); font-weight: 600; font-size: 12.5px; }
.field-h { color: var(--muted); font-size: 12px; }
.ctl.wide, textarea.ctl { width: 100%; box-sizing: border-box; }
textarea.ctl { font: inherit; font-size: 13px; resize: vertical; min-height: 84px; color: var(--ink); background: var(--surface); border: 1px solid var(--ring); border-radius: 8px; padding: 8px 10px; }
input.ctl { color: var(--ink); font: inherit; font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); padding-bottom: 6px; }
.btn[disabled] { opacity: .55; cursor: default; }
.msg-area:empty { display: none; }
.msg-area { margin-bottom: 12px; }
.mono, pre.token { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
pre.token { background: var(--surface); border: 1px solid var(--ring); border-radius: 8px; padding: 8px 10px; margin: 6px 0 10px; white-space: pre-wrap; word-break: break-all; user-select: all; }
.pbar { display: inline-block; width: 90px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; vertical-align: middle; }
.pbar i { display: block; height: 100%; background: var(--s1); border-radius: 3px; }
.pager { justify-content: flex-end; margin-top: 10px; align-items: center; }
a.ext { text-decoration: none; color: var(--muted); }
.card-tools.wrap { flex-wrap: wrap; flex-shrink: 1; gap: 8px; align-items: center; justify-content: flex-end; }
@media (max-width: 700px) {
  .card-head:has(.card-tools.wrap) { flex-wrap: wrap; }
  .card-tools.wrap { width: 100%; justify-content: flex-start; }
  .card-tools.wrap input.ctl { flex: 1; min-width: 0; }
}
