:root {
  --bad-ink: #2a0806;
  --bg: #0d1117; --panel: #151b23; --panel-2: #1b2330; --line: #263040;
  --text: #e6edf3; --muted: #8b97a8; --accent: #3fb68b; --accent-ink: #062016;
  --warn: #e0a43a; --bad: #f0605a; --info: #5aa7f0; --preview: #b58cf0;
  --radius: 14px; color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f9; --panel: #ffffff; --panel-2: #f0f3f7; --line: #dde3eb;
    --text: #17202c; --muted: #5d6b7e; --accent: #187a58; --accent-ink: #ffffff;
    --warn: #a86a00; --bad: #c7322c; --bad-ink: #ffffff; --info: #1f6fc0; --preview: #7a4fc4; color-scheme: light;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
h1, h2 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* top bar */
.bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.brand img { border-radius: 7px; }
.bar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.bar-right form { margin: 0; }
.link { background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; padding: 6px 0; }
.link:hover { color: var(--text); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.good { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.chip.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.chip.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.chip.info { color: var(--info); border-color: color-mix(in srgb, var(--info) 40%, transparent); }

main { max-width: 1080px; margin: 0 auto; padding: 16px; display: grid; gap: 14px; }

/* alerts */
#alerts { display: grid; gap: 10px; }
#alerts:empty { display: none; }
.alert { border-radius: var(--radius); padding: 12px 14px; border: 1px solid; font-size: 14px; }
.alert b { display: block; margin-bottom: 2px; }
.alert.bad { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--panel)); }
.alert.warn { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, var(--panel)); }
.alert.info { border-color: var(--info); background: color-mix(in srgb, var(--info) 10%, var(--panel)); }
.alert.preview { border-color: var(--preview); background: color-mix(in srgb, var(--preview) 12%, var(--panel)); }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 760px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile, .card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.tile { padding: 12px 14px; min-width: 0; }
.label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.value { font-size: 20px; font-weight: 650; margin-top: 4px; overflow-wrap: anywhere; }
.value.good { color: var(--accent); } .value.warn { color: var(--warn); } .value.bad { color: var(--bad); }
.sub { font-size: 13px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }

.card { padding: 16px; display: grid; gap: 12px; min-width: 0; }
.card > p { margin: -6px 0 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }

/* signal + trade rows */
.list { display: grid; gap: 8px; }
.row {
  display: grid; gap: 6px 12px; padding: 12px; background: var(--panel-2); border-radius: 10px;
  grid-template-columns: auto 1fr auto; align-items: center;
}
.sym { font-weight: 700; font-size: 16px; }
.tag { font-size: 12px; color: var(--muted); }
.score { font-weight: 650; justify-self: end; }
.levels { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.levels div { min-width: 0; }
.levels span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.levels b { font-weight: 600; }
.why { grid-column: 1 / -1; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.stop { color: var(--bad); } .target { color: var(--accent); }
.empty { padding: 18px; text-align: center; color: var(--muted); background: var(--panel-2); border-radius: 10px; font-size: 14px; }

/* meters */
.meters { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .meters { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 960px) { .meters { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.meter-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; gap: 8px; }
.meter-top b { font-weight: 600; }
.track { height: 8px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.fill { height: 100%; width: 100%; border-radius: 99px; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .4s ease; }
.fill.warn { background: var(--warn); } .fill.bad { background: var(--bad); }

/* pause */
.pause-card { grid-template-columns: 1fr; align-items: center; }
@media (min-width: 640px) { .pause-card { grid-template-columns: 1fr auto; } }
.pause-card p { margin: 4px 0 0; }
.btn {
  font: inherit; font-weight: 650; padding: 12px 18px; min-height: 46px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

details.card > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "Show"; color: var(--muted); font-size: 13px; }
details.card[open] > summary::after { content: "Hide"; }
.config { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; margin: 0; font-size: 14px; }
.config dt { color: var(--muted); } .config dd { margin: 0; text-align: right; font-weight: 600; }

.acct-sum { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.acct-sum div { background: var(--panel-2); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.acct-sum span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.acct-sum b { font-size: 18px; font-weight: 650; }
.fx-card .up { color: var(--accent); } .fx-card .down { color: var(--bad); }
.pnl { justify-self: end; text-align: right; font-weight: 650; }
.pnl small { display: block; font-weight: 500; font-size: 12px; }
#acct-foot { margin: 0; }
/* stock board */
.board-tools { display: grid; gap: 8px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .board-tools { grid-template-columns: 1fr auto auto; align-items: center; } }
.board-tools input, .board-tools select {
  font: inherit; font-size: 16px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); min-width: 0;
}
.seg { display: flex; gap: 4px; background: var(--panel-2); border-radius: 10px; padding: 3px; overflow-x: auto; }
.seg button {
  font: inherit; font-size: 13px; font-weight: 600; border: 0; background: none; color: var(--muted);
  padding: 7px 11px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
.board { display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) { .board { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 960px) { .board { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.box {
  text-align: left; font: inherit; color: inherit; cursor: pointer; min-width: 0;
  background: var(--panel-2); border: 1px solid transparent; border-radius: 12px; padding: 10px 10px 8px;
  display: grid; gap: 2px; position: relative;
}
.box:hover { border-color: var(--line); }
.star {
  position: absolute; top: 4px; right: 4px; width: 36px; height: 36px; border: 0; border-radius: 9px;
  background: none; color: var(--muted); font-size: 19px; line-height: 1; cursor: pointer; opacity: .55;
}
.star:hover { background: var(--panel); opacity: 1; }
.star.on { color: var(--warn); opacity: 1; }
.star:focus-visible { outline: 2px solid var(--accent); opacity: 1; }
.box.off-list .box-sym, .box.off-list .box-price b { color: var(--muted); }
.bot-list-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.bot-list-actions { display: flex; gap: 14px; }
.bot-list-bar .warn-text { color: var(--warn); }
.box:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.box.has-signal { border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.box.stale { opacity: .6; }
.box-top { display: flex; align-items: baseline; gap: 6px; padding-right: 30px; }
.box-sym { font-weight: 700; }
.box-mkt { font-size: 11px; color: var(--muted); }
.box-name { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.box-price { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; margin-top: 2px; }
.box-price b { font-weight: 650; }
.box-price span { font-size: 13px; font-weight: 600; }
.spark { width: 100%; height: 32px; display: block; margin: 4px 0 2px; }
.spark-line { fill: none; stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.spark.up .spark-line { stroke: var(--accent); } .spark.down .spark-line { stroke: var(--bad); }
.spark.up .spark-area { fill: color-mix(in srgb, var(--accent) 14%, transparent); }
.spark.down .spark-area { fill: color-mix(in srgb, var(--bad) 14%, transparent); }
.badges { display: flex; gap: 4px; flex-wrap: wrap; }
.badge { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--panel); color: var(--muted); }
.badge.sig { background: var(--accent); color: var(--accent-ink); }
.badge.up { color: var(--accent); } .badge.down { color: var(--bad); }
.board-note { margin: 0; }
.search {
  font: inherit; font-size: 16px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); width: 100%;
}
.search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.results { display: grid; gap: 6px; }
.results:empty { display: none; }
.result {
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 2px 12px; align-items: center;
  padding: 8px 6px 8px 12px; border-radius: 10px; background: var(--panel-2); cursor: pointer; min-width: 0;
}
.result:hover { box-shadow: 0 0 0 1px var(--line); }
.result:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.result .r-sym { font-weight: 700; }
.result .r-name { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.result .r-price { text-align: right; font-weight: 600; white-space: nowrap; }
.result .r-price small { display: block; font-size: 12px; }
.result .badges { grid-column: 1 / 4; }
.result .badges:empty { display: none; }
.result .star { position: static; grid-row: 1 / 3; grid-column: 4; }
.clickable { cursor: pointer; }
.clickable:hover { box-shadow: 0 0 0 1px var(--line); }
.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* chart dialog */
dialog#chart-dlg {
  width: min(1000px, calc(100vw - 16px)); max-height: calc(100dvh - 16px); padding: 14px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); overflow-y: auto;
}
dialog#chart-dlg::backdrop { background: rgba(0, 0, 0, .55); }
.dlg-head { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: start; }
.dlg-title { display: flex; gap: 8px; align-items: center; font-size: 20px; font-weight: 700; }
.dlg-price { text-align: right; }
.dlg-price b { display: block; font-size: 20px; }
.dlg-price span { font-size: 13px; font-weight: 600; }
.icon-btn { font: inherit; font-size: 18px; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); cursor: pointer; }
.readout { font-size: 12px; color: var(--muted); margin: 10px 0 4px; min-height: 1.4em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
canvas.chart { width: 100%; height: min(58vh, 460px); display: block; touch-action: pan-y; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; color: var(--muted); }
.lg::before { content: ""; display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.lg.e20::before { background: var(--info); } .lg.e50::before { background: var(--warn); }
.lg.sig::before { background: linear-gradient(90deg, var(--bad) 50%, var(--accent) 50%); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.stats div { background: var(--panel-2); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.stats span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stats b { font-weight: 600; }
#ch-reason { margin: 10px 0 0; overflow-wrap: anywhere; }
.chart-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.chart-bar .legend { margin: 0; }
.lg.bb::before { background: color-mix(in srgb, var(--muted) 70%, transparent); }
#ch-sigs { margin-top: 10px; }
/* signal types */
.strategies { display: grid; gap: 8px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .strategies { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.strat { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: start; padding: 12px; border-radius: 10px; background: var(--panel-2); }
.strat b { font-weight: 650; }
.strat p { margin: 0; font-size: 13px; color: var(--muted); grid-column: 1; }
.strat .bt { font-size: 12px; color: var(--muted); grid-column: 1 / -1; }
.strat .bt b { font-weight: 600; color: var(--text); }
.switch { position: relative; width: 46px; height: 28px; grid-row: 1 / 3; grid-column: 2; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

footer { padding: 4px 2px 24px; }

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(380px, 100%); padding: 28px 22px; text-align: center; }
.login img { margin: 0 auto; border-radius: 12px; }
.login h1 { font-size: 22px; }
.login label { display: grid; gap: 6px; text-align: left; font-size: 13px; color: var(--muted); }
.login input {
  font: inherit; font-size: 16px; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text);
}
.login input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.msg { margin: 0; color: var(--bad); font-size: 14px; }

@media (max-width: 420px) {
  .bar #updated { display: none; }
  .levels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* news */
#news-filter { margin-bottom: 10px; }
.news { display: grid; gap: 8px; }
.news-item { padding: 8px 10px; border-radius: 10px; background: var(--panel-2); min-width: 0; }
.news-item.up { background: color-mix(in srgb, var(--accent) 7%, var(--panel-2)); }
.news-item.down { background: color-mix(in srgb, var(--bad) 7%, var(--panel-2)); }
.news-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 4px; }
.news-head .chip { font-size: 11px; padding: 1px 7px; }
.sym-chip { cursor: pointer; font-weight: 700; color: var(--text); background: none; font: inherit; font-size: 11px; }
.sym-chip::before { display: none; }
.news-title { display: block; color: var(--text); text-decoration: none; font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; }
a.news-title:hover { text-decoration: underline; }
#news-blocked { min-width: 0; max-width: 100%; }
.news-veto { min-width: 0; max-width: 100%; overflow: hidden; padding: 0 10px; margin-bottom: 10px; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--bad) 45%, transparent); }
.news-veto > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 8px 0; color: var(--bad); font-weight: 600; font-size: 14px; }
.news-veto > summary::-webkit-details-marker { display: none; }
.news-veto > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.news-veto .nv-line { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.news-veto .nv-why { flex: none; color: var(--muted); font-weight: 500; font-size: 13px; }
.news-veto[open] .nv-why { visibility: hidden; }
.news-veto[open] .nv-line { white-space: normal; }
.news-veto .nv-reason { color: var(--muted); overflow-wrap: anywhere; padding: 0 0 6px; }
.news-veto .nv-reason:last-child { padding-bottom: 10px; }
#ch-news { margin: 10px 0; }
.warn-text { color: var(--warn); }

.strat-group { border-top: 1px solid var(--line); }
.strat-group:first-child { border-top: 0; }
.strat-group > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 12px 2px; }
.strat-group > summary::-webkit-details-marker { display: none; }
.chev { flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s cubic-bezier(.16, 1, .3, 1); }
.strat-group[open] > summary .chev { transform: rotate(90deg); }
.strat-group > summary .sg-title { flex: 1; min-width: 0; }
.strat-group > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.strat-group .sg-note { margin: 0 0 10px; }
.strat-group > .strategies { padding-bottom: 12px; }
#news { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding-right: 2px; }
#strategies { display: block; }

/* risk limits form */
.risk-form { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.risk-form h3 { margin: 0 0 4px; font-size: 15px; }
.risk-fields { display: grid; gap: 10px; margin: 12px 0; grid-template-columns: 1fr; }
@media (min-width: 760px) { .risk-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.risk-field { display: grid; gap: 4px; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); min-width: 0; }
.risk-field.changed { box-shadow: 0 0 0 1px var(--warn); }
.rf-label { font-weight: 600; font-size: 14px; }
.rf-input { display: flex; align-items: center; gap: 6px; }
.rf-input input, .rf-input select { width: 100%; max-width: 180px; font: inherit; font-size: 16px; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.rf-unit { color: var(--muted); font-size: 14px; }
.rf-help { color: var(--muted); font-size: 12px; line-height: 1.35; }
.risk-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- live activity ---------- */
:root { --live: var(--accent); }
.bar { position: sticky; }
/* scan-cycle bar under the header: fills over the bot's 5-minute check cycle */
.pulse { position: absolute; left: 0; right: 0; bottom: -1px; height: 4px; overflow: hidden; background: color-mix(in srgb, var(--line) 70%, transparent); }
.pulse[data-state="live"] { --live: var(--accent); }
.pulse[data-state="waiting"] { --live: var(--info); }
.pulse[data-state="warn"] { --live: var(--warn); }
.pulse[data-state="bad"], .pulse[data-state="paused"] { --live: var(--bad); }
.pulse[data-state="idle"] { --live: var(--muted); }
.pulse-fill { position: absolute; inset: 0; background: var(--live); transform: scaleX(0); transform-origin: left; transition: background-color .4s; }
.pulse-fill::after { /* bright leading edge */
  content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 24px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--live) 30%, white));
}
.pulse[data-state="bad"] .pulse-fill::after, .pulse[data-state="paused"] .pulse-fill::after, .pulse[data-state="warn"] .pulse-fill::after { display: none; }
/* scanning: the bar shimmers until the scan lands */
.pulse.scanning .pulse-fill { transform: scaleX(1); background: linear-gradient(90deg, var(--live) 0 35%, color-mix(in srgb, var(--live) 35%, white) 50%, var(--live) 65% 100%); background-size: 300% 100%; animation: shimmer 1.1s linear infinite; }
.pulse.scanning .pulse-fill::after { display: none; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }
/* finished scan: one glint sweeps across */
.pulse-glint { position: absolute; top: 0; bottom: 0; width: 30%; left: -30%; opacity: 0; background: linear-gradient(90deg, transparent, white, transparent); mix-blend-mode: overlay; }
.pulse-glint.go { animation: glint .8s cubic-bezier(.16, 1, .3, 1); }
@keyframes glint { 0% { opacity: .9; transform: translateX(0); } 100% { opacity: 0; transform: translateX(440%); } }

/* heartbeat: the mode chip's dot breathes while the bot is alive */
.chip.alive::before { animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.45); opacity: .55; } }

/* countdown under the worker state */
.next { margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--muted); min-height: 1em; }
.next[data-state="live"] { color: var(--accent); }
.next[data-state="waiting"] { color: var(--info); }
.next[data-state="warn"] { color: var(--warn); }

/* tiles take a tint from their state */
.tile { transition: background-color .5s, border-color .5s; }
.tile[data-tone="good"] { background: color-mix(in srgb, var(--accent) 9%, var(--panel)); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.tile[data-tone="warn"] { background: color-mix(in srgb, var(--warn) 10%, var(--panel)); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.tile[data-tone="bad"] { background: color-mix(in srgb, var(--bad) 10%, var(--panel)); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }

/* changed numbers flash: green when they rose, red when they fell */
.flash-up, .flash-down { border-radius: 6px; animation: flash 1.4s cubic-bezier(.16, 1, .3, 1); }
.flash-up { --flash: var(--accent); }
.flash-down { --flash: var(--bad); }
@keyframes flash { 0% { background-color: color-mix(in srgb, var(--flash) 32%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--flash) 32%, transparent); } 100% { background-color: transparent; box-shadow: 0 0 0 4px transparent; } }

/* new signals and headlines arrive with a highlight that fades */
.is-new { animation: arrive .6s cubic-bezier(.16, 1, .3, 1), glow 3s ease-out; }
@keyframes arrive { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes glow { 0%, 30% { background-color: color-mix(in srgb, var(--info) 18%, var(--panel-2)); } }

/* buy / sell colour */
.side { display: inline-block; margin-left: 8px; vertical-align: 2px; font-size: 11px; font-weight: 700; letter-spacing: .02em; padding: 1px 7px; border-radius: 99px; }
.side.buy { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.side.sell { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.row.side-sell .score { color: var(--bad); }
.row.side-buy .score { color: var(--accent); }
.badge.sig.sell { background: var(--bad); color: var(--bad-ink); }

@media (prefers-reduced-motion: reduce) {
  .pulse.scanning .pulse-fill, .chip.alive::before, .pulse-glint.go { animation: none; }
  .is-new { animation: glow 3s ease-out; }
  .flash-up, .flash-down { animation-duration: 1.4s; }  /* colour only, nothing moves */
  .tile, .chev { transition: none; }
}

/* ---------- activity feed ---------- */
.activity { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 2px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.act { display: grid; grid-template-columns: 10px auto 1fr; gap: 10px; align-items: baseline; padding: 7px 8px; border-radius: 8px; font-size: 14px; line-height: 1.4; }
.act-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); align-self: center; }
.act-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.act-msg { min-width: 0; overflow-wrap: anywhere; }
.act.scan .act-dot { background: var(--info); }
.act.order { background: color-mix(in srgb, var(--accent) 12%, transparent); font-weight: 600; }
.act.order .act-dot { background: var(--accent); }
.act.refused .act-dot { background: var(--warn); }
.act.refused .act-msg { color: color-mix(in srgb, var(--text) 78%, var(--warn)); }
.act.warn .act-dot { background: var(--warn); }
.act.error .act-dot { background: var(--bad); }
.act.error .act-msg { color: var(--bad); }
/* the newest line's dot pings while the bot is alive */
.activity .act:first-child .act-dot { position: relative; }
.activity .act:first-child .act-dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: inherit; animation: ping 1.8s cubic-bezier(.16, 1, .3, 1) infinite; }
@keyframes ping { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(2.8); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .activity .act:first-child .act-dot::after { animation: none; } }

/* ---------- ticker tape: the whole board drifting past ---------- */
.tape { position: relative; overflow: hidden; height: 30px; border-bottom: 1px solid var(--line); background: var(--panel);
  mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent); -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent); }
.tape-track { display: flex; width: max-content; height: 100%; align-items: center; animation: tape var(--tape-s, 80s) linear infinite; }
.tape:hover .tape-track { animation-play-state: paused; }
@keyframes tape { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.tape-it { display: inline-flex; gap: 6px; align-items: baseline; padding: 0 14px; font-size: 13px; white-space: nowrap; cursor: pointer; border-radius: 6px; transition: background-color .6s; }
.tape-it b { font-weight: 650; letter-spacing: .01em; }
.tape-it .tp { color: var(--text); }
.tape-it .tc { font-size: 12px; }
.tape-it.up .tc { color: var(--accent); } .tape-it.down .tc { color: var(--bad); }
.tape-it.tick-up { animation: tickUp 1.4s cubic-bezier(.16, 1, .3, 1); }
.tape-it.tick-down { animation: tickDown 1.4s cubic-bezier(.16, 1, .3, 1); }
@keyframes tickUp { 0% { background: color-mix(in srgb, var(--accent) 35%, transparent); } 100% { background: transparent; } }
@keyframes tickDown { 0% { background: color-mix(in srgb, var(--bad) 35%, transparent); } 100% { background: transparent; } }
@media (prefers-reduced-motion: reduce) {
  .tape { overflow-x: auto; mask-image: none; -webkit-mask-image: none; }
  .tape-track { animation: none; }
  .tape-it.tick-up, .tape-it.tick-down { animation: none; }
}

/* ---------- trade it yourself ---------- */
.trade { margin-top: 14px; padding: 14px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 7%, var(--panel-2)); border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line)); transition: background-color .35s, border-color .35s; }
.trade.is-sell { background: color-mix(in srgb, var(--bad) 7%, var(--panel-2)); border-color: color-mix(in srgb, var(--bad) 28%, var(--line)); }
.trade-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.trade-head h3 { margin: 0; font-size: 17px; }
.trade p { margin: 6px 0 10px; }
.trade-side { margin-bottom: 10px; }
.trade-side button { flex: 1; }
.trade.is-sell .trade-side button.on { color: var(--bad); }
.trade:not(.is-sell) .trade-side button.on { color: var(--accent); }
.trade-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.trade-grid label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.trade-grid input { width: 100%; font: inherit; font-size: 16px; padding: 9px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.trade-grid input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.trade-sum { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; margin: 12px 0; font-size: 14px; }
.trade-sum div { display: flex; justify-content: space-between; gap: 8px; }
.trade-sum span { color: var(--muted); }
.trade-sum .wide { grid-column: 1 / -1; margin: 0; }
.trade-go { width: 100%; padding: 13px; font-size: 16px; font-weight: 650; position: relative; overflow: hidden; transition: background-color .25s, transform .15s; }
.trade.is-sell .trade-go { background: var(--bad); border-color: var(--bad); color: var(--bad-ink); }
.trade-go:active:not(:disabled) { transform: scale(.98); }
.trade-go.armed { background: var(--warn); border-color: var(--warn); color: #1d1300; }
.trade-go.armed::after { content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: currentColor; opacity: .5; transform-origin: left; animation: arm 5s linear forwards; }
@keyframes arm { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.trade-go.sent { animation: sent .9s cubic-bezier(.16, 1, .3, 1); }
@keyframes sent { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); } 100% { box-shadow: 0 0 0 16px transparent; } }
.ok-text { color: var(--accent); }
@media (max-width: 420px) { .trade-grid { grid-template-columns: 1fr 1fr; } .trade-grid label:first-child { grid-column: 1 / -1; } }

/* ---------- Scout: floating button ---------- */
.scout-fab { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 20;
  display: inline-flex; align-items: center; gap: 8px; padding: 12px 18px 12px 14px; border-radius: 999px; border: 0; cursor: pointer;
  font: inherit; font-weight: 650; font-size: 15px; color: var(--accent-ink); background: var(--accent);
  box-shadow: 0 6px 18px -4px rgba(0, 0, 0, .45), 0 2px 5px rgba(0, 0, 0, .25);
  transition: transform .3s cubic-bezier(.16, 1, .3, 1), opacity .25s; }
.scout-fab:hover { transform: translateY(-2px); }
.scout-fab:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
.scout-fab.hide { transform: translateY(140%); opacity: 0; pointer-events: none; }
.scout-fab .sweep { transform-origin: 12px 12px; animation: sweep 3.2s linear infinite; }
.scout-fab.busy .sweep { animation-duration: .9s; }
@keyframes sweep { to { transform: rotate(360deg); } }
.scout-fab::before { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); animation: beacon 3.2s cubic-bezier(.16, 1, .3, 1) infinite; }
@keyframes beacon { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 14px transparent; } }
main { padding-bottom: 84px; }

/* ---------- Scout: panel (bottom sheet on phones, side panel on wide screens) ---------- */
dialog.scout { position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: none; height: min(86dvh, 760px); padding: 0; z-index: 30;
  display: none; flex-direction: column; border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0;
  background: var(--panel); color: var(--text); box-shadow: 0 -18px 50px -12px rgba(0, 0, 0, .5);
  transform: translateY(105%); transition: transform .26s cubic-bezier(.4, 0, 1, 1); }
dialog.scout[open] { display: flex; }
dialog.scout.shown { transform: none; transition: transform .42s cubic-bezier(.16, 1, .3, 1); }
@media (min-width: 900px) {
  dialog.scout { inset: 12px 12px 12px auto; width: 430px; height: auto; border-radius: 18px; border-bottom: 1px solid var(--line); transform: translateX(110%); }
}
.scout-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 12px 16px; border-bottom: 1px solid var(--line); }
.scout-id { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.scout-name { font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.scout-head .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scout-orb { width: 34px; height: 34px; flex: none; border-radius: 50%; position: relative;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--accent) 40%, white), var(--accent) 55%, color-mix(in srgb, var(--accent) 60%, var(--info)));
  animation: orbBreathe 4s ease-in-out infinite; }
.scout-orb::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid transparent; border-top-color: var(--accent); border-right-color: color-mix(in srgb, var(--info) 70%, transparent); opacity: 0; transition: opacity .3s; }
.scout-orb.busy { animation-duration: 1.4s; }
.scout-orb.busy::after { opacity: 1; animation: sweep .9s linear infinite; }
@keyframes orbBreathe { 0%, 100% { transform: scale(1); filter: saturate(1); } 50% { transform: scale(.92); filter: saturate(1.35); } }

.scout-log { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 14px; line-height: 1.5; font-size: 15px; overflow-wrap: anywhere; animation: msgIn .38s cubic-bezier(.16, 1, .3, 1); }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--panel-2); border-bottom-left-radius: 4px; }
.msg.error { align-self: stretch; max-width: none; background: color-mix(in srgb, var(--bad) 12%, var(--panel-2)); color: var(--bad); font-size: 14px; }
.md p { margin: 0 0 .55em; } .md p:last-child, .md ul:last-child, .md ol:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: .2em 0 .6em; padding-left: 1.25em; } .md li { margin: .15em 0; }
.md h4 { margin: .5em 0 .3em; font-size: 15px; }
.md code { font-size: 13px; padding: 1px 5px; border-radius: 5px; background: var(--panel); }
.md a { color: var(--info); text-underline-offset: 2px; }
.msg.streaming .md > :last-child::after { content: ""; display: inline-block; width: 7px; height: 1em; margin-left: 3px; vertical-align: -2px; border-radius: 2px; background: var(--accent); animation: caret 1s steps(2) infinite; }
@keyframes caret { 50% { opacity: 0; } }
.step { align-self: flex-start; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding: 2px 4px; animation: msgIn .3s cubic-bezier(.16, 1, .3, 1); }
.step-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--info); animation: ping 1.4s cubic-bezier(.16, 1, .3, 1) infinite; box-shadow: 0 0 0 0 var(--info); }
.step.done .step-dot { animation: none; background: var(--muted); }
.step.done { opacity: .7; }

.scout-empty p { color: var(--muted); margin: 4px 0 14px; line-height: 1.55; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-q { font: inherit; font-size: 14px; padding: 9px 13px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); background: color-mix(in srgb, var(--accent) 9%, transparent); color: var(--text); cursor: pointer; text-align: left;
  animation: msgIn .45s cubic-bezier(.16, 1, .3, 1) backwards; transition: background-color .2s, transform .15s; }
.chip-q:nth-child(2) { animation-delay: .05s; } .chip-q:nth-child(3) { animation-delay: .1s; } .chip-q:nth-child(4) { animation-delay: .15s; }
.chip-q:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.chip-q:active { transform: scale(.97); }
.chip-q:disabled { opacity: .45; cursor: default; }

.proposal { align-self: stretch; padding: 12px 14px; border-radius: 14px; border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--line)); background: color-mix(in srgb, var(--warn) 9%, var(--panel-2)); animation: msgIn .4s cubic-bezier(.16, 1, .3, 1); }
.proposal.done { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: color-mix(in srgb, var(--accent) 9%, var(--panel-2)); }
.proposal.dismissed, .proposal.failed { opacity: .75; }
.proposal.failed { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.proposal.settle { animation: settle .6s cubic-bezier(.16, 1, .3, 1); }
@keyframes settle { 0% { transform: scale(.98); } 40% { transform: scale(1.01); } 100% { transform: none; } }
.p-head { display: grid; gap: 2px; }
.p-kind { font-size: 12px; font-weight: 650; color: var(--warn); }
.proposal.done .p-kind { color: var(--accent); }
.p-detail { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 8px 0; font-size: 14px; }
.p-detail dt { color: var(--muted); } .p-detail dd { margin: 0; font-weight: 600; }
.p-reason { font-size: 14px; color: color-mix(in srgb, var(--text) 85%, var(--muted)); margin-top: 6px; }
.p-foot { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.p-foot .btn { flex: 1; padding: 10px; }
.p-status { font-size: 13px; color: var(--muted); }
.p-status.done { color: var(--accent); } .p-status.failed { color: var(--bad); }

.scout-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); }
.scout-form textarea { flex: 1; resize: none; font: inherit; font-size: 16px; line-height: 1.4; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); max-height: 140px; }
.scout-form textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.scout-form .icon-btn { width: 44px; height: 44px; display: grid; place-items: center; flex: none; }
.scout-form .send { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.scout-form .send:disabled { opacity: .45; }
.mic.on { background: var(--bad); border-color: var(--bad); color: var(--bad-ink); animation: micPulse 1.2s ease-in-out infinite; }
@keyframes micPulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 50%, transparent); } 50% { box-shadow: 0 0 0 8px transparent; } }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }

@media (prefers-reduced-motion: reduce) {
  .scout-fab .sweep, .scout-fab::before, .scout-orb, .scout-orb.busy::after, .step-dot, .mic.on, .msg.streaming .md > :last-child::after { animation: none; }
  .msg, .step, .chip-q, .proposal, .proposal.settle { animation: none; }
  dialog.scout, dialog.scout.shown, .scout-fab { transition: none; }
  .trade-go.armed::after { animation: none; }
}
@media (max-width: 480px) { .trade-sum { grid-template-columns: 1fr; } .trade-sum b { white-space: nowrap; } }

/* trade straight from a signal */
.sig-acts { grid-column: 1 / -1; display: flex; gap: 8px; margin-top: 10px; }
.sig-acts .btn { white-space: nowrap; }
.sig-acts .btn { padding: 10px 14px; font-weight: 600; }
.sig-acts .sig-trade { flex: 1; }
.sig-trade.buy { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.sig-trade.sell { background: var(--bad); border-color: var(--bad); color: var(--bad-ink); }
.trade.focus-in { animation: focusIn 1.2s cubic-bezier(.16, 1, .3, 1); }
@keyframes focusIn { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent); } 25% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 45%, transparent); } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .trade.focus-in { animation: none; } }

/* a signal that has already been traded shows what happened instead of a Trade button */
.sig-done { flex: 1; display: grid; gap: 2px; padding: 9px 12px; border-radius: 10px; font-size: 14px; line-height: 1.35; min-width: 0; }
.sig-done b { font-weight: 650; }
.sig-done span { color: var(--muted); font-size: 13px; }
.sig-done.open { background: color-mix(in srgb, var(--accent) 14%, transparent); } .sig-done.open b { color: var(--accent); }
.sig-done.wait { background: color-mix(in srgb, var(--info) 14%, transparent); } .sig-done.wait b { color: var(--info); }
.sig-done.done { background: var(--panel-2); }
.sig-done.bad { background: color-mix(in srgb, var(--bad) 12%, transparent); } .sig-done.bad b { color: var(--bad); }
.sig-acts:has(.sig-done) { align-items: stretch; }
.sig-acts .sig-done ~ .btn { align-self: center; }
/* bot trades: live P/L on the right, like the real account */
.pl { display: grid; justify-items: end; gap: 0; text-align: right; }
.pl b { font-size: 19px; font-variant-numeric: tabular-nums; }
#bot-sum:empty { display: none; }
/* running total of the demo account, always visible in the sticky header */
.bar { flex-wrap: wrap; }
.bar-pnl { flex-basis: 100%; order: 5; display: flex; align-items: baseline; gap: 10px; padding: 2px 0 2px; font-variant-numeric: tabular-nums; }
.bar-pnl[hidden] { display: none; }
.bp-label { font-size: 12px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
#bp-val { font-size: 22px; font-weight: 750; letter-spacing: -.01em; }
.bp-pct { font-size: 16px; font-weight: 650; }
.bp-note { font-size: 12px; color: var(--muted); margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.bar-pnl .bp-label, #bp-val, .bp-pct { white-space: nowrap; flex: none; }
.bar-pnl { min-width: 0; max-width: 100%; }
.bp-note { flex: 1 1 0; text-align: right; }
/* ---------- What the bot is learning ---------- */
.learn-h { font-size: 13px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
.learn-types { display: grid; gap: 8px; margin-top: 10px; }
.lt { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); }
.lt-name { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.lt-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lt-side { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
.lt-side.buy { color: var(--accent); } .lt-side.sell { color: var(--bad); }
.lt-bar { grid-column: 1 / -1; height: 4px; border-radius: 4px; background: color-mix(in srgb, var(--line) 80%, transparent); overflow: hidden; }
.lt-bar span { display: block; height: 100%; background: var(--info); border-radius: 4px; transition: width .6s ease; }
.lt-stats { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 16px; font-variant-numeric: tabular-nums; }
.lt-stats em { font-style: normal; color: var(--muted); margin-right: 5px; }
.learn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.learn-grid div { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); font-variant-numeric: tabular-nums; }
.learn-grid span { font-size: 12px; color: var(--muted); }
.learn-recent { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.lr { display: grid; grid-template-columns: auto auto 1fr auto; align-items: baseline; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.lr .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.lr-acct { font-size: 11px; font-weight: 650; text-transform: uppercase; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line); }
.lr-acct.real { color: var(--warn); } .lr-acct.demo { color: var(--info); }
.lr-pl { white-space: nowrap; }
.learn-review-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.learn-review-head .btn { padding: 6px 12px; font-size: 13px; margin-top: 10px; }
.learn-review { font-size: 14px; line-height: 1.5; }
@media (prefers-reduced-motion: reduce) { .lt-bar span { transition: none; } }
.lr { grid-template-columns: auto 1fr auto; row-gap: 0; }
.lr > b:not(.lr-pl) { grid-column: 2; grid-row: 1; }
.lr .muted { grid-column: 2; grid-row: 2; }
.lr-pl { grid-column: 3; grid-row: 1 / span 2; align-self: center; }
.lr-acct { grid-row: 1 / span 2; align-self: center; }
/* ================= the fun layer ================= */
@font-face { font-family: "Outfit"; src: url("/static/outfit-latin.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
:root { --display: "Outfit", "Avenir Next", system-ui, sans-serif;
  --f1: #0f7c80; --f2: #2563b8; --f3: #6d3fb8; --f4: #b85410; --f-bad: #b8322c; --f-warn: #8a6a00; }
h2, .brand span, .tile .value, #bp-val, .bp-pct, .scout-title, .learn-h, .p-head b { font-family: var(--display); }
h2 { font-weight: 700; letter-spacing: -.01em; }
.brand span { font-weight: 700; letter-spacing: -.015em; }
#bp-val { font-weight: 800; }

/* colour tiles, one colour each, like the Growth Agents cards */
.tiles .tile { position: relative; overflow: hidden; color: #fff; border: 0; background: var(--tc, var(--f1));
  box-shadow: 0 1px 0 rgb(255 255 255 / .12) inset, 0 6px 18px -10px var(--tc, var(--f1)); }
#tile-worker { --tc: var(--f1); } #tile-market { --tc: var(--f2); } #tile-scan { --tc: var(--f3); } #tile-orders { --tc: var(--f4); }
.tiles .tile[data-tone="good"] { background: var(--tc); border: 0; }
.tiles .tile[data-tone="warn"] { --tc: var(--f-warn); background: var(--tc); border: 0; }
.tiles .tile[data-tone="bad"] { --tc: var(--f-bad); background: var(--tc); border: 0; }
.tiles .tile .label { color: rgb(255 255 255 / .82); }
.tiles .tile .value { color: #fff !important; font-weight: 750; }
.tiles .tile .sub, .tiles .tile .next { color: rgb(255 255 255 / .88) !important; }
.tile-ico { position: absolute; right: 8px; top: 6px; font-size: 30px; opacity: .9; transform: rotate(8deg); filter: drop-shadow(0 2px 4px rgb(0 0 0 / .25)); pointer-events: none; }
@media (max-width: 420px) { .tile-ico { font-size: 24px; } }

/* mascot + bell */
.mascot, .bell { background: none; border: 0; padding: 2px 4px; font-size: 24px; line-height: 1; cursor: pointer; position: relative; border-radius: 10px; }
.mascot:focus-visible, .bell:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bell { font-size: 20px; transform-origin: 50% 10%; }
.bell-n { position: absolute; top: -4px; right: -6px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--bad); color: #fff;
  font: 700 11px/17px var(--display); text-align: center; }
.bell-n[hidden] { display: none; }

/* toasts */
.fun-toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom, 0px)); z-index: 60;
  display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); pointer-events: none; }
.fun-toast { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px; background: var(--text, #e6edf3); color: var(--bg, #0d1117);
  font-weight: 600; box-shadow: 0 10px 30px -10px rgb(0 0 0 / .5); animation: funin .38s cubic-bezier(.2,1.5,.4,1); }
.fun-toast.good { background: var(--accent); color: var(--accent-ink, #04130b); }
.fun-toast.bad { background: var(--bad); color: #fff; }
.fun-toast.info { background: var(--f3); color: #fff; }
.fun-toast.out { opacity: 0; transform: translateY(10px) scale(.96); transition: opacity .35s, transform .35s; }
.ft-ico { font-size: 22px; }
@keyframes funin { from { transform: translateY(18px) scale(.9); opacity: 0; } }
.fx-confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 70; }

@media (prefers-reduced-motion: no-preference) {
  /* the worker tile breathes while the bot is running */
  #tile-worker[data-tone="good"] { animation: breathe 3s ease-in-out infinite; }
  @keyframes breathe { 50% { box-shadow: 0 0 0 3px rgb(255 255 255 / .18), 0 0 22px var(--f1); } }
  .tile-ico { animation: bob 4s ease-in-out infinite; }
  #tile-market .tile-ico { animation-name: spin-globe; animation-duration: 6s; }
  #tile-scan .tile-ico { animation-delay: -1s; } #tile-orders .tile-ico { animation-delay: -2s; }
  @keyframes bob { 50% { transform: rotate(-4deg) translateY(-3px); } }
  @keyframes spin-globe { 50% { transform: rotate(-10deg) scale(1.08); } }
  /* winning trades get a shine sweep now and then */
  .winning { position: relative; overflow: hidden; }
  .winning::after { content: ""; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(105deg, transparent 40%, rgb(255 255 255 / .14) 50%, transparent 60%); transform: translateX(-110%); animation: shine 5s ease-in-out infinite; }
  @keyframes shine { 0%, 62% { transform: translateX(-110%); } 85%, 100% { transform: translateX(110%); } }
  .mascot { animation: idle 6s ease-in-out infinite; }
  @keyframes idle { 0%, 90%, 100% { transform: none; } 93% { transform: rotate(-10deg); } 96% { transform: rotate(8deg); } }
}
.bar-real .bp-label { color: var(--warn); }
.bar-real { padding-top: 0; }
#br-val { font-family: var(--display); font-size: 22px; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; flex: none; }
@media (max-width: 440px) {
  .brand span { display: none; }
  .bar-right #updated { display: none; }
  .bar-pnl { padding: 0; }
}
/* contrast + neutral elevation (design check) */
.tiles .tile { box-shadow: 0 1px 0 rgb(255 255 255 / .12) inset, 0 6px 16px -10px rgb(0 0 0 / .55); }
.tiles .tile .label { color: #fff; opacity: 1; }
.tiles .tile .sub, .tiles .tile .next { color: #fff !important; }
@media (prefers-reduced-motion: no-preference) {
  @keyframes breathe { 50% { box-shadow: 0 0 0 3px rgb(255 255 255 / .22), 0 6px 16px -10px rgb(0 0 0 / .55); } }
}
/* the trading floor strip */
.crew { height: 70px; margin: 0 auto; max-width: 1200px; padding: 0 12px; }
.crew canvas { display: block; width: 100%; height: 70px; cursor: pointer; }
/* ---------- real money ---------- */
.trade-acct, .risk-acct { margin: 8px 0; }
.trade.is-real { border: 2px solid var(--bad); border-radius: 14px; padding: 10px; background: color-mix(in srgb, var(--bad) 6%, transparent); }
.trade-acct button[data-acct="real"].on, .risk-acct button[data-acct="real"].on { background: var(--bad); color: #fff; border-color: var(--bad); }
.risk-form.is-real { border: 1px solid color-mix(in srgb, var(--bad) 55%, transparent); border-radius: 12px; padding: 10px; background: color-mix(in srgb, var(--bad) 6%, transparent); }
.close-row { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.close-btn { padding: 6px 14px; font-size: 13px; }
.close-btn.armed { background: var(--warn); border-color: var(--warn); color: #1a1200; }
.close-btn.real.armed { background: var(--bad); border-color: var(--bad); color: #fff; }
.learn-more { margin-top: 10px; }
.learn-more > summary { cursor: pointer; padding: 8px 0; font-size: 14px; font-weight: 600; color: var(--muted); list-style: none; display: flex; align-items: center; gap: 8px; }
.learn-more > summary::-webkit-details-marker { display: none; }
.learn-more > summary::before { content: "▸"; transition: transform .2s; }
.learn-more[open] > summary::before { transform: rotate(90deg); }
@media (prefers-reduced-motion: reduce) { .learn-more > summary::before { transition: none; } }
.real-auto { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0 4px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--bad) 45%, var(--line)); background: color-mix(in srgb, var(--bad) 6%, var(--panel)); }
.real-auto[hidden] { display: none; }
.real-auto b { font-family: var(--display); margin-right: 8px; }
.real-auto p { margin: 6px 0 0; }
.real-auto .btn { flex: none; }
/* ---- performance + safety ---- */
.safety { display: grid; gap: 10px; margin: 10px 0 14px; }
.mood { display: flex; flex-wrap: wrap; gap: 8px; }
.mood-chip { display: inline-flex; gap: 6px; align-items: baseline; padding: 6px 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: 13px; }
.mood-chip.up b { color: var(--accent); } .mood-chip.down b { color: var(--bad); }
.brakes { display: grid; gap: 8px; }
.brake { padding: 10px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.brake.tripped { border-color: color-mix(in srgb, var(--bad) 55%, var(--line)); background: color-mix(in srgb, var(--bad) 8%, var(--panel-2)); }
.brake-top { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.brake-bar { height: 6px; border-radius: 3px; background: var(--line); margin-top: 8px; overflow: hidden; }
.brake-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--warn), var(--bad)); border-radius: 3px; transition: width .6s ease; }
.brake .btn { margin-top: 8px; }
.brake p { margin: 8px 0 0; }
.perf-seg { margin-bottom: 6px; }
.perf-chart { width: 100%; height: 160px; display: block; margin: 6px 0 12px; }
.perf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.perf-tile { padding: 10px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); display: grid; gap: 2px; }
.perf-tile span { font-size: 12px; color: var(--muted); }
.perf-tile b { font-family: var(--display); font-size: 17px; font-variant-numeric: tabular-nums; }
.perf-tile b.up { color: var(--accent); } .perf-tile b.down { color: var(--bad); }
.perf-tile small { font-size: 11px; }
@media (prefers-reduced-motion: reduce) { .brake-bar i { transition: none; } }
.perf-tile b { white-space: nowrap; font-size: clamp(14px, 4vw, 17px); }
/* ---- Stocks / FX switch ---- */
.view-seg { margin: 0 0 14px; }
.view-seg button { flex: 1; font-weight: 600; }
.view-seg small { font-weight: 500; margin-left: 4px; }
body:not(.view-fx) .fx-card { display: none; }
body.view-fx main > section:not(.fx-card):not(.pause-card) { display: none; }
.fx-pairs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.fx-pair { text-align: left; padding: 10px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); font: inherit; cursor: pointer; display: grid; gap: 4px; }
.fx-pair:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.fx-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; }
.fx-top b { font-family: var(--display); font-size: 15px; }
.fx-px { font-family: var(--display); font-size: 19px; font-variant-numeric: tabular-nums; }
.fx-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.fx-tags .trend { font-size: 11px; padding: 2px 6px; border-radius: 6px; background: var(--panel); border: 1px solid var(--line); }
.fx-tags .trend.up { color: var(--accent); } .fx-tags .trend.down { color: var(--bad); }
.fx-tags .badge { font-size: 11px; }
.fx-trade { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.fx-trade > div { display: grid; gap: 2px; min-width: 0; }
.fx-trade > b { font-variant-numeric: tabular-nums; flex: none; }
.fx-gate { display: grid; gap: 10px; margin: 10px 0; }
.gate-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: baseline; }
.gate-row .gate-bar, .gate-row > small { grid-column: 1 / -1; }
.gate-bar { height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.gate-bar i { display: block; height: 100%; background: var(--info); border-radius: 3px; }
.gate-row.earned .gate-bar i { background: var(--accent); }
.fx-note { margin: 10px 0 0; }
.fx-card .up { color: var(--accent); } .fx-card .down { color: var(--bad); }
/* ---- animated login ---- */
.login-body { position: relative; overflow: hidden; background: var(--bg); }
.login-sky { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }
.login-glow { position: fixed; inset: -20%; z-index: 0; pointer-events: none;
  background: radial-gradient(40% 35% at 50% 50%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%);
  animation: glow-breathe 6s ease-in-out infinite; }
.login { position: relative; z-index: 1; background: color-mix(in srgb, var(--panel) 82%, transparent);
  backdrop-filter: blur(10px) saturate(1.2); -webkit-backdrop-filter: blur(10px) saturate(1.2);
  box-shadow: 0 24px 60px rgb(0 0 0 / .35); animation: card-rise .7s cubic-bezier(.2, .8, .2, 1) both; }
.login > * { animation: item-in .5s ease both; }
.login > :nth-child(2) { animation-delay: .15s; } .login > :nth-child(3) { animation-delay: .22s; }
.login > :nth-child(4) { animation-delay: .29s; } .login > :nth-child(5) { animation-delay: .36s; }
.login > :nth-child(6) { animation-delay: .43s; } .login > :nth-child(7) { animation-delay: .5s; }
.login-logo { display: block; margin: 0 auto 4px; }
.ll-bg { fill: var(--bg); stroke: var(--line); }
.ll-line { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 60; stroke-dashoffset: 60; animation: ll-draw 1.1s .3s cubic-bezier(.6, 0, .2, 1) forwards; }
.ll-dot { fill: var(--text); opacity: 0; animation: ll-pop .35s 1.3s ease-out forwards; }
.ll-ring { fill: none; stroke: var(--accent); stroke-width: 2; opacity: 0; transform-origin: 51px 18px; animation: ll-ping 2.4s 1.6s ease-out infinite; }
.login-go { position: relative; overflow: hidden; }
.login-go::after { content: ''; position: absolute; inset: 0; transform: translateX(-120%);
  background: linear-gradient(100deg, transparent 30%, rgb(255 255 255 / .35) 50%, transparent 70%); animation: shimmer 3.5s 2s ease-in-out infinite; }
.login.sending .login-go::after { animation: shimmer .9s linear infinite; }
.login.sending .login-go span::after { content: '…'; }
@keyframes card-rise { from { opacity: 0; transform: translateY(24px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes item-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes ll-draw { to { stroke-dashoffset: 0; } }
@keyframes ll-pop { 0% { opacity: 0; transform: scale(.2); } 70% { opacity: 1; transform: scale(1.3); } 100% { opacity: 1; transform: scale(1); } }
.ll-dot { transform-origin: 51px 18px; }
@keyframes ll-ping { 0% { opacity: .8; transform: scale(1); } 100% { opacity: 0; transform: scale(3.2); } }
@keyframes shimmer { to { transform: translateX(120%); } }
@keyframes glow-breathe { 50% { transform: scale(1.08); opacity: .7; } }
@media (prefers-reduced-motion: reduce) {
  .login, .login > *, .login-glow, .login-go::after, .ll-ring { animation: none; }
  .ll-line { animation: none; stroke-dashoffset: 0; } .ll-dot { animation: none; opacity: 1; }
}
@media (max-width: 600px) { .login { background: color-mix(in srgb, var(--panel) 70%, transparent); } }
/* header totals: green when up, red when down */
.bar-pnl .up { color: var(--accent); } .bar-pnl .down { color: var(--bad); }
