:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --ink: #1b1c1f;
  --ink-2: #4a4d55;
  --muted: #6b6f78;
  --line: #e4e3df;
  --accent: #9a6b00;        /* gold, validated for chart use on light surfaces */
  --accent-ink: #ffffff;
  --accent-soft: #f6efdc;
  --good: #1f7a3d;
  --bad: #b3261e;
  --radius: 10px;
  --max: 1080px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1013;
    --surface: #15171c;
    --ink: #ecebe7;
    --ink-2: #c3c2bd;
    --muted: #9a9ca3;
    --line: #2a2d34;
    --accent: #b8860b;      /* validated for chart use on the dark surface */
    --accent-ink: #15171c;
    --accent-soft: #2a2416;
    --good: #5cc27f;
    --bad: #f07a72;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1013; --surface: #15171c; --ink: #ecebe7; --ink-2: #c3c2bd; --muted: #9a9ca3;
  --line: #2a2d34; --accent: #b8860b; --accent-ink: #15171c; --accent-soft: #2a2416;
  --good: #5cc27f; --bad: #f07a72; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 16px; }

header.site { border-bottom: 1px solid var(--line); background: var(--surface); }
header.site .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.logo { font-weight: 700; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.logo-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: inline-block; }
nav a { color: var(--ink-2); text-decoration: none; margin-left: 20px; font-size: 15px; }
nav a:hover { color: var(--ink); }

main { padding: 48px 0 64px; }
h1 { font-size: clamp(30px, 5vw, 46px); line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 16px; }
h2 { font-size: 24px; letter-spacing: -0.01em; margin: 48px 0 16px; }
h3 { font-size: 18px; margin: 0 0 8px; }
.lede { font-size: 19px; color: var(--ink-2); max-width: 640px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.btn {
  display: inline-block; border: 0; cursor: pointer; text-decoration: none;
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600;
  padding: 12px 22px; border-radius: 8px;
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }

.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); margin: 24px 0; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.tile .label { font-size: 13px; color: var(--muted); }
.tile .value { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }

.notice { background: var(--accent-soft); border-radius: var(--radius); padding: 16px 20px; color: var(--ink-2); font-size: 15px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
.pos { color: var(--good); font-weight: 600; }
.neg { color: var(--bad); font-weight: 600; }

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 280px; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .zero-line { stroke: var(--muted); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 12px; }
.chart .series { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 13px;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.12); white-space: nowrap; transform: translate(-50%, -120%);
}

.price { font-size: 44px; font-weight: 700; letter-spacing: -0.02em; }
ul.checks { padding-left: 20px; }
ul.checks li { margin: 6px 0; }
.steps { counter-reset: step; }
.steps .card h3::before { counter-increment: step; content: counter(step) ". "; color: var(--accent); }

footer.site { border-top: 1px solid var(--line); padding: 32px 0; font-size: 13px; color: var(--muted); }
footer.site a { color: var(--muted); }

@media (max-width: 560px) {
  nav a { margin-left: 0; margin-right: 16px; }
  main { padding-top: 32px; }
}

.site-banner { background: var(--bad); color: #fff; text-align: center; font-weight: 600; font-size: 14px; padding: 8px 16px; }

/* status page */
:root { --warn: #8a5a00; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --warn: #e0a84a; } }
:root[data-theme="dark"] { --warn: #e0a84a; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 15px; }
.chip.good { color: var(--good); }
.chip.bad { color: var(--bad); }
.chip.warn { color: var(--warn); }
.chip.idle { color: var(--muted); }
.tile .value-sm { margin: 6px 0 4px; }
.tile .err { word-break: break-word; margin-top: 4px; }
.facts { display: grid; grid-template-columns: minmax(140px, 260px) 1fr; gap: 12px 24px; margin: 0; }
.facts dt { color: var(--muted); font-size: 14px; }
.facts dd { margin: 0; }
@media (max-width: 560px) { .facts { grid-template-columns: 1fr; gap: 2px; } .facts dd { margin-bottom: 12px; } }

/* analytics page */
.controls { display: flex; flex-wrap: wrap; gap: 12px; margin: 24px 0 16px; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg-btn { padding: 8px 14px; font-size: 14px; color: var(--ink-2); text-decoration: none; border-right: 1px solid var(--line); }
.seg-btn:last-child { border-right: 0; }
.seg-btn:hover { color: var(--ink); background: var(--accent-soft); }
.seg-btn.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.pos-ink { color: var(--good); }
.neg-ink { color: var(--bad); }
.money { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 16px 20px; }
.money input { width: 110px; font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); }
.money p { flex-basis: 100%; margin: 4px 0 0; }
.outcome + .outcome { margin-top: 14px; }
.outcome-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 15px; }
.outcome-nums { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.meter { height: 8px; background: var(--line); border-radius: 4px; margin-top: 6px; overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 4px; }
/* Profit/loss fills: blue/red diverging pair, validated for colour-blind readers in both themes. */
:root { --profit: #2a78d6; --loss: #e34948; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --profit: #3987e5; --loss: #e66767; } }
:root[data-theme="dark"] { --profit: #3987e5; --loss: #e66767; }
.meter .good { background: var(--profit); }
.meter .bad { background: var(--loss); }
.chart .bar-pos { fill: var(--profit); }
.chart .bar-neg { fill: var(--loss); }
.small-chip { font-size: 13px; font-weight: 500; }
.table-wrap.flat { border: 0; }
details summary { cursor: pointer; color: var(--accent); }

/* login */
.login-page { min-height: 100vh; display: flex; }
.login-wrap { margin: auto; width: 100%; max-width: 400px; padding: 32px 16px; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 32px 28px; }
.login-logo { margin-bottom: 24px; }
.login-card h1 { font-size: 26px; margin: 0 0 4px; }
.login-card form { display: grid; gap: 6px; margin-top: 20px; }
.login-card label { font-size: 14px; font-weight: 600; margin-top: 10px; }
.login-card input[type=text], .login-card input[type=password] {
  font: inherit; width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink);
}
.login-card input:focus-visible, .pw-toggle:focus-visible, .login-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pw-field { position: relative; }
.pw-field input { padding-right: 68px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent;
  color: var(--accent); font: inherit; font-size: 14px; font-weight: 600; padding: 6px 8px; cursor: pointer; }
.login-card .remember { display: flex; align-items: center; gap: 8px; font-weight: 400; margin-top: 14px; }
.remember-hint { margin: 0 0 8px 24px; }
.login-btn { width: 100%; padding: 12px; margin-top: 6px; }
.login-error { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); border-radius: 8px;
  padding: 10px 12px; font-size: 14px; font-weight: 600; margin-top: 16px; }
.login-foot { text-align: center; margin-top: 16px; }
nav form { display: inline; }
.nav-btn { border: 0; background: none; font: inherit; font-size: 15px; color: var(--ink-2); cursor: pointer; margin-left: 20px; padding: 0; }
.nav-btn:hover { color: var(--ink); }
@media (max-width: 560px) { .nav-btn { margin-left: 0; } }

/* chart page */
.day-nav { display: inline-flex; align-items: stretch; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.day-nav .btn-edge { border-right: 1px solid var(--line); }
.day-nav .btn-edge:last-child { border-right: 0; border-left: 1px solid var(--line); }
.day-nav input[type=date] { font: inherit; font-size: 14px; border: 0; padding: 6px 10px; background: transparent; color: var(--ink); }
.chart-day { margin-top: 8px; }
.chart-card { padding: 16px; }
#price-chart { width: 100%; height: 460px; }
@media (max-width: 560px) { #price-chart { height: 340px; } }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; list-style: none; padding: 0; margin: 12px 0 4px; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 22px; height: 0; border-top: 2px solid; }
.key-range { border-top: 2px dashed var(--muted); }
.key-trigger { border-top: 2px dashed var(--accent); }
.key-entry { border-color: var(--ink); }
.key-sl { border-color: var(--loss); }
.key-tp { border-color: var(--profit); }
.key-plan-sl { border-top: 2px dashed var(--loss); }
.key-plan-tp { border-top: 2px dashed var(--profit); }
.plan-table table { font-size: 14px; }
.plan-table td { padding: 4px 8px 4px 0; }

/* live trade tracking */
.live-trade + .live-trade { margin-top: 16px; }
.live-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.live-pnl { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.live-pnl .small { display: block; font-size: 14px; font-weight: 600; }
.track { position: relative; height: 10px; background: var(--line); border-radius: 5px; margin: 18px 0 6px; }
.track-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px; background: var(--accent-soft); border: 1px solid var(--accent); }
.track-mark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink-2); }
.track-dot { position: absolute; top: 50%; width: 14px; height: 14px; margin-left: -7px; transform: translateY(-50%); border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.track-labels { display: flex; justify-content: space-between; color: var(--muted); font-variant-numeric: tabular-nums; flex-wrap: wrap; gap: 4px 12px; }
.live-tiles { margin: 14px 0 6px; }
