/* Trader — dark product surface. Scene: phone or second monitor at the open,
   low ambient light, red/green states read at a glance. */

:root {
  --bg: oklch(0.16 0.012 250);
  --surface: oklch(0.20 0.014 250);
  --surface-2: oklch(0.24 0.016 250);
  --line: oklch(0.30 0.015 250);
  --ink: oklch(0.93 0.005 250);
  --ink-soft: oklch(0.72 0.010 250);
  --accent: oklch(0.82 0.13 85);          /* amber: actions + focus, not decoration */
  --accent-ink: oklch(0.22 0.05 85);
  --long: oklch(0.78 0.17 150);
  --long-dim: oklch(0.32 0.06 150);
  --short: oklch(0.70 0.19 25);
  --short-dim: oklch(0.32 0.08 25);
  --warn: oklch(0.80 0.14 70);
  --radius: 8px;
  --z-sticky: 10;
  --z-sheet: 20;
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  font-feature-settings: 'cv10';
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
.num { font-variant-numeric: tabular-nums; }
.up { color: var(--long); }
.down { color: var(--short); }

button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- shell ---------- */

.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1rem calc(0.6rem);
  background: color-mix(in oklch, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 650; letter-spacing: -0.01em; font-size: 1rem; display: flex; align-items: center; gap: 0.5rem; }
.brand svg { width: 20px; height: 20px; }

.market-state {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.8125rem; color: var(--ink-soft);
}
.market-state .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-soft); }
.market-state.open .dot { background: var(--long); }
.market-state.open { color: var(--long); }
.market-state.flat_window .dot { background: var(--warn); }
.market-state.flat_window { color: var(--warn); }

.tabs {
  position: sticky; top: 3.05rem; z-index: var(--z-sticky);
  display: flex; border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.tabs button {
  flex: 1; padding: 0.65rem 0; border: 0; background: none; cursor: pointer;
  color: var(--ink-soft); font-size: 0.9375rem; font-weight: 550;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 150ms ease-out;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

main { max-width: 900px; margin: 0 auto; padding: 1rem; }
section[hidden] { display: none; }

h2 { font-size: 0.8125rem; font-weight: 600; color: var(--ink-soft); margin: 1.4rem 0 0.5rem; }
h2:first-child { margin-top: 0.2rem; }

/* ---------- login ---------- */

.login {
  min-height: 92svh; display: grid; place-items: center; padding: 1rem;
}
.login form { width: min(340px, 100%); display: grid; gap: 0.7rem; }
.login .brand { font-size: 1.4rem; justify-content: center; margin-bottom: 0.8rem; }
.login .brand svg { width: 30px; height: 30px; }
.field { display: grid; gap: 0.25rem; }
.field label { font-size: 0.8125rem; color: var(--ink-soft); }
input[type="email"], input[type="password"], input[type="text"], input[type="number"], input[type="date"], select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.55rem 0.7rem; width: 100%;
}
input::placeholder { color: oklch(0.60 0.01 250); }

.btn {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius);
  padding: 0.55rem 0.9rem; cursor: pointer; font-weight: 550;
  transition: background 150ms ease-out, border-color 150ms ease-out;
}
.btn:hover { background: var(--line); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: color-mix(in oklch, var(--accent) 88%, white); }
.btn.danger { color: var(--short); border-color: var(--short-dim); background: none; }
.btn.small { padding: 0.3rem 0.6rem; font-size: 0.8125rem; }

.error { color: var(--short); font-size: 0.875rem; min-height: 1.2em; }

/* ---------- watchlist ---------- */

.watch-table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.watch-table th {
  text-align: right; font-size: 0.75rem; font-weight: 550; color: var(--ink-soft);
  padding: 0.3rem 0.5rem; border-bottom: 1px solid var(--line);
}
.watch-table th:first-child, .watch-table td:first-child { text-align: left; padding-left: 0.25rem; }
.watch-table td { padding: 0.45rem 0.5rem; text-align: right; border-bottom: 1px solid color-mix(in oklch, var(--line) 45%, transparent); }
.watch-table .sym { font-weight: 650; }
.watch-table .up { color: var(--long); }
.watch-table .down { color: var(--short); }
.watch-table .ctx { font-size: 0.75rem; color: var(--ink-soft); }
.watch-table tr { transition: background 150ms ease-out; }
.watch-table tbody tr:hover { background: color-mix(in oklch, var(--surface) 60%, transparent); }
.spark { width: 84px; height: 26px; }
.spark polyline { fill: none; stroke-width: 1.5; }
.rm-sym { border: 0; background: none; color: var(--ink-soft); cursor: pointer; padding: 0.1rem 0.3rem; border-radius: 4px; }
.rm-sym:hover { color: var(--short); }

.add-symbol { display: flex; gap: 0.5rem; margin-top: 0.6rem; }
.add-symbol input { width: 9rem; text-transform: uppercase; }

/* ---------- signals ---------- */

.signal {
  display: grid; grid-template-columns: auto 1fr auto; gap: 0.25rem 0.9rem;
  padding: 0.7rem 0.85rem; margin-bottom: 0.55rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.signal.long { border-color: color-mix(in oklch, var(--long) 35%, var(--line)); }
.signal.short { border-color: color-mix(in oklch, var(--short) 35%, var(--line)); }
.signal .head { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 0.55rem; flex-wrap: wrap; }
.signal .sym { font-weight: 700; font-size: 1.0625rem; }
.side-badge {
  font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 0.1rem 0.45rem; border-radius: 999px;
}
.side-badge.long { background: var(--long-dim); color: var(--long); }
.side-badge.short { background: var(--short-dim); color: var(--short); }
.signal .setup-name { color: var(--ink-soft); font-size: 0.8125rem; }
.signal .when { margin-left: auto; color: var(--ink-soft); font-size: 0.8125rem; }
.signal .levels { grid-column: 1 / -1; display: flex; gap: 1.1rem; flex-wrap: wrap; font-size: 0.9375rem; }
.signal .levels span b { font-weight: 400; color: var(--ink-soft); font-size: 0.75rem; display: block; }
.signal .note { grid-column: 1 / -1; color: var(--ink-soft); font-size: 0.8125rem; }
.signal .outcome { font-weight: 650; }
.signal .outcome.win { color: var(--long); }
.signal .outcome.loss { color: var(--short); }
.signal .actions { grid-column: 1 / -1; margin-top: 0.3rem; }
.signal.flash { animation: flash 900ms ease-out; }
.grade-badge {
  font-size: 0.6875rem; font-weight: 700; width: 1.25rem; height: 1.25rem;
  display: inline-grid; place-items: center; border-radius: 5px; align-self: center;
}
.grade-badge.g-A { background: var(--accent); color: var(--accent-ink); }
.grade-badge.g-B { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.grade-badge.g-C { background: none; color: var(--ink-soft); border: 1px solid var(--line); }
.signal .confluence { display: block; margin-top: 0.15rem; color: var(--accent); opacity: 0.85; }
.h2-note { font-weight: 400; text-transform: none; letter-spacing: 0; color: oklch(0.55 0.01 250); margin-left: 0.4rem; }
.gap-tag { font-size: 0.6875rem; font-weight: 600; padding: 0.05rem 0.35rem; border-radius: 999px; vertical-align: middle; }
.gap-tag.up { background: var(--long-dim); color: var(--long); }
.gap-tag.down { background: var(--short-dim); color: var(--short); }
.watch-table .hot { color: var(--accent); font-weight: 650; }
.movers { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0.5rem; }
.mover {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0.65rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 0.9rem;
}
.mover .sym { font-weight: 650; }
.mover .btn { margin-left: auto; }
.mover .hot { color: var(--accent); }
tr.suppressed td { opacity: 0.55; }
.sup-tag { font-size: 0.6875rem; color: var(--warn); font-weight: 600; }
@keyframes flash { from { background: color-mix(in oklch, var(--accent) 16%, var(--surface)); } to { background: var(--surface); } }

.empty {
  color: var(--ink-soft); font-size: 0.9375rem; padding: 1.1rem;
  border: 1px dashed var(--line); border-radius: var(--radius); text-align: center;
}

/* ---------- journal ---------- */

.trade-row {
  display: grid; grid-template-columns: 1fr auto; gap: 0.15rem 0.8rem;
  padding: 0.6rem 0.75rem; margin-bottom: 0.5rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.trade-row .line1 { display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; }
.trade-row .desc { font-weight: 600; }
.trade-row .meta { color: var(--ink-soft); font-size: 0.8125rem; }
.trade-row .pnl { font-weight: 650; align-self: center; text-align: right; }
.trade-row .pnl.win { color: var(--long); }
.trade-row .pnl.loss { color: var(--short); }

form.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0.6rem; align-items: end; }
form.grid .field.wide { grid-column: 1 / -1; }
details.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.6rem 0.85rem; margin-bottom: 0.8rem;
}
details.card summary { cursor: pointer; font-weight: 550; color: var(--ink-soft); }
details.card[open] summary { margin-bottom: 0.7rem; color: var(--ink); }

.close-form { grid-column: 1 / -1; display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-top: 0.4rem; }
.close-form input { width: 7rem; }
.close-form select { width: auto; }

/* ---------- stats ---------- */

.stat-strip { display: flex; gap: 1.6rem; flex-wrap: wrap; padding: 0.2rem 0.1rem 0.4rem; }
.stat-strip div { font-size: 1.125rem; font-weight: 650; }
.stat-strip div b { display: block; font-size: 0.75rem; font-weight: 500; color: var(--ink-soft); }
.stat-strip .win { color: var(--long); }
.stat-strip .loss { color: var(--short); }

.curve-wrap { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.6rem; background: var(--surface); }
.curve-wrap svg { width: 100%; height: 160px; display: block; }

table.plain { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.plain th { text-align: left; font-size: 0.75rem; color: var(--ink-soft); font-weight: 550; padding: 0.3rem 0.5rem; border-bottom: 1px solid var(--line); }
table.plain td { padding: 0.4rem 0.5rem; border-bottom: 1px solid color-mix(in oklch, var(--line) 45%, transparent); }
table.plain td.r { text-align: right; }
table.plain th.r { text-align: right; }

.disclaimer { color: var(--ink-soft); font-size: 0.75rem; margin: 2rem 0 1rem; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
@media (max-width: 480px) {
  main { padding: 0.75rem; }
  .watch-table .hide-sm { display: none; }
  .spark { width: 64px; }
}
