/* StratPilot Bot panel, in the platform's colours and type (Inter, JetBrains Mono, served
   by the bot itself: the panel opens without reaching any other site). Each strategy is an
   instrument strip with its state lamp; one bold control, the emergency stop, held to
   confirm. */

@font-face {
  font-family: "Inter Variable";
  src: url("/fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono Variable";
  src: url("/fonts/mono.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

/* the platform's tokens (web/app/globals.css) */
:root {
  --bg: #05070d;
  --bg-2: #0a0e19;
  --panel: rgba(16, 21, 36, 0.72);
  --panel-solid: #0e1321;
  --panel-2: rgba(26, 33, 54, 0.7);
  --border: rgba(126, 146, 199, 0.16);
  --border-strong: rgba(126, 146, 199, 0.3);
  --text: #eef1f8;
  --muted: #8e98b3;
  --accent: #3f74ff;
  --accent-2: #6d4cff;
  --gold: #f5b82e;
  --gold-2: #ffd86b;
  --good: #25c98f;
  --bad: #f2566a;
  --warn: #f59e2e;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --glow-blue: rgba(63, 116, 255, 0.35);
  --glow-gold: rgba(245, 184, 46, 0.28);
  --grid-line: rgba(126, 146, 199, 0.06);
  --sheen: rgba(255, 255, 255, 0.16);
  --sans: "Inter Variable", Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --num: "JetBrains Mono Variable", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f7fc;
    --bg-2: #eaeef7;
    --panel: rgba(255, 255, 255, 0.82);
    --panel-solid: #ffffff;
    --panel-2: rgba(240, 244, 252, 0.9);
    --border: rgba(28, 44, 90, 0.1);
    --border-strong: rgba(28, 44, 90, 0.2);
    --text: #0d1220;
    --muted: #5a6680;
    --accent: #2458f5;
    --accent-2: #5b3ce8;
    --gold: #d9960b;
    --gold-2: #f5b82e;
    --good: #0f9f6e;
    --bad: #d93a4b;
    --warn: #c06f0a;
    --shadow: 0 18px 50px rgba(20, 34, 80, 0.1);
    --glow-blue: rgba(36, 88, 245, 0.16);
    --glow-gold: rgba(245, 184, 46, 0.2);
    --grid-line: rgba(28, 44, 90, 0.05);
    --sheen: rgba(255, 255, 255, 0.9);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--sans);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
/* the platform's night sky: two auroras and a faint grid */
body::before {
  content: ""; position: fixed; inset: -20vmax; z-index: -2; pointer-events: none;
  background:
    radial-gradient(40vmax 30vmax at 15% 10%, var(--glow-blue), transparent 60%),
    radial-gradient(35vmax 28vmax at 85% 20%, var(--glow-gold), transparent 60%),
    radial-gradient(45vmax 35vmax at 60% 100%, rgba(109, 76, 255, 0.16), transparent 60%);
  animation: aurora 26s ease-in-out infinite alternate;
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 30%, transparent 85%);
}
@keyframes aurora { to { transform: translate3d(-4vmax, 3vmax, 0) rotate(8deg); } }

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: color-mix(in srgb, var(--gold) 40%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.good { color: var(--good); }
.bad { color: var(--bad); }
[hidden] { display: none !important; }
.gold-text {
  background: linear-gradient(120deg, var(--gold-2), var(--gold) 45%, #e0801a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* glass, as the platform's panels: hairline light on the top edge */
.glass {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.glass::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(160deg, var(--sheen), transparent 40%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}

/* ---------- sign-in ---------- */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.gate-card { width: min(420px, 100%); border-radius: 22px; padding: 34px 28px 26px; }
.gate-logo {
  width: 64px; height: 73px; display: block; margin: 0 auto 18px;
  filter: drop-shadow(0 10px 28px var(--glow-gold));
}
.gate-card h1 { font-size: 1.6rem; font-weight: 700; margin: 0 0 6px; letter-spacing: -0.02em; text-align: center; }
.gate-card > p { margin: 0 0 24px; color: var(--muted); text-align: center; }
.forgot { margin-top: 16px; font-size: 14px; color: var(--muted); }
.forgot summary { cursor: pointer; text-align: center; }
.forgot p { margin: 10px 0 0; }
.gate-card > .gate-foot { display: flex; justify-content: center; margin: 18px 0 0; }

/* ---------- frame ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 22px;
  padding: 0 24px; height: 64px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 1.12rem; letter-spacing: -0.01em; white-space: nowrap; }
.brand img { width: 38px; height: 43px; }
.brand .bot { font-weight: 650; }
.top .spacer { flex: 1; }
.load { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.load-bar { width: 64px; height: 6px; border-radius: 3px; background: var(--panel-2); border: 1px solid var(--border); overflow: hidden; }
/* the fill takes the colour of its level: green, orange at 50 %, red at 100 % */
.load-bar i { display: block; height: 100%; border-radius: 3px; background: var(--level); box-shadow: 0 0 10px var(--level); }
.load .num { color: var(--level); font-weight: 600; }
.lang {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 12px; font-size: 13px; cursor: pointer; color: var(--muted);
}
.lang:hover { color: var(--text); border-color: var(--border-strong); }

.tabs { display: flex; gap: 4px; }
.tabs button {
  background: none; border: 1px solid transparent; padding: 7px 14px; border-radius: 10px;
  color: var(--muted); cursor: pointer; font-weight: 550;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-current="page"] {
  color: var(--text); background: var(--panel-2); border-color: var(--border);
  box-shadow: inset 0 -2px 0 var(--gold);
}

main { max-width: 1120px; margin: 0 auto; padding: 28px 24px 140px; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 18px; flex-wrap: wrap; }
.view-head h2 { margin: 0; font-size: 1.45rem; font-weight: 700; letter-spacing: -0.02em; }

.banner {
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  background: color-mix(in srgb, var(--gold) 9%, var(--panel));
  border-radius: 14px; padding: 11px 16px; margin-bottom: 14px; font-size: 14px;
}
.banner.red {
  border-color: color-mix(in srgb, var(--bad) 50%, transparent);
  background: color-mix(in srgb, var(--bad) 9%, var(--panel));
}

/* ---------- strategy strips ---------- */
.strips { display: grid; gap: 14px; }
.strip { border-radius: 18px; overflow: hidden; display: grid; grid-template-columns: 4px 1fr; }
.lamp { background: var(--border-strong); }
/* stopped: red, as the emergency stop (John 8/10: running and stopped strategies told
   apart at a glance) */
.strip[data-state="stopped"] .lamp { background: var(--bad); box-shadow: 0 0 18px var(--bad); }
.strip[data-state="loading"] .lamp { background: var(--gold); box-shadow: 0 0 18px var(--gold); animation: beat 1.4s ease-in-out infinite; }
.strip[data-state="loading"] .state { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 40%, transparent); }
.loading-line { display: flex; align-items: center; gap: 12px; margin: 14px 0 4px; padding: 14px 16px; border-radius: 14px;
  border: 1px dashed var(--border-strong); color: var(--muted); font-size: 15px; }
.spinner { width: 18px; height: 18px; flex: none; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--gold) 25%, transparent);
  border-top-color: var(--gold); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner.small { width: 12px; height: 12px; display: inline-block; vertical-align: -1px; border-width: 2px; }
.market-hint { font-weight: 400; color: var(--muted); min-height: 1em; }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.strip[data-state="running"] .lamp { background: var(--good); box-shadow: 0 0 18px var(--good); }
.strip[data-state="exits_only"] .lamp { background: var(--gold); box-shadow: 0 0 18px var(--gold); }
.strip[data-state="halted_for_day"] .lamp,
.strip[data-state="error"] .lamp { background: var(--warn); }
.strip[data-state="halted"] .lamp { background: var(--bad); box-shadow: 0 0 18px var(--bad); }
.strip-body { padding: 18px 20px; min-width: 0; }
.strip-head { display: flex; align-items: center; gap: 10px; }
.strip-head h3 { margin: 0; font-size: 1.12rem; font-weight: 650; letter-spacing: -0.015em; }
.strip-sub b { color: var(--text); font-weight: 600; }
.strip-sub { color: var(--muted); font-size: 13px; margin-top: 3px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.state {
  margin-left: auto; font-size: 12.5px; font-weight: 650; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 3px 11px 3px 9px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--muted);
}
.state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.strip[data-state="running"] .state { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.strip[data-state="running"] .state::before { animation: beat 2s ease-in-out infinite; }
.strip[data-state="exits_only"] .state { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 40%, transparent); }
.strip[data-state="halted_for_day"] .state,
.strip[data-state="error"] .state { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.strip[data-state="stopped"] .state { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.strip[data-state="halted"] .state { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
/* paused (John 12/10): its position and orders stay on the platform, « Démarrer » goes on:
   gold and still, as « exits only » (a strategy that holds without opening) */
.strip[data-state="paused"] .lamp { background: var(--gold); }
.strip[data-state="paused"] .state { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 40%, transparent); }
@keyframes beat { 50% { opacity: 0.35; } }

/* « Arrêter »: pause, or stop and close, each with what it does under it */
.stop-choice { display: grid; gap: 16px; }
.stop-choice .choice { display: grid; gap: 6px; }
.stop-choice .choice p { margin: 0; font-size: 14px; }
.stop-choice .hold { width: 100%; }

.readouts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 1px; margin: 16px 0;
  background: var(--border); border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
}
.readout { background: var(--panel-solid); padding: 10px 14px; min-width: 0; }
.readout > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.readout > b { display: block; font-size: 1.05rem; font-weight: 600; overflow-wrap: anywhere; }
.readout > small { display: block; font-size: 12px; margin-top: 2px; }
.readout > small.sub > span { display: block; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 14px 0; }
.pager .btn[disabled] { opacity: .4; pointer-events: none; }
.cmp { font-size: 13px; margin: -4px 0 12px; max-width: 80ch; }
.err-line { color: var(--warn); font-size: 13px; margin: -6px 0 12px; }
.warn-line { color: var(--gold); font-size: 13px; margin: -6px 0 12px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* buttons, as the platform's */
.btn {
  position: relative; overflow: hidden;
  border: 1px solid var(--border-strong); background: var(--panel-2);
  border-radius: 12px; padding: 8px 16px; cursor: pointer; font-weight: 600;
  min-height: 40px; transition: border-color 0.15s, box-shadow 0.2s, transform 0.15s;
}
.btn:hover { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; box-shadow: none; }
.btn.primary {
  background: linear-gradient(135deg, var(--gold-2), var(--gold) 55%, #e58b12);
  border-color: transparent; color: #0b0e17; box-shadow: 0 6px 22px var(--glow-gold);
}
.btn.primary::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.55) 50%, transparent 70%);
  transform: translateX(-120%); transition: transform 0.7s ease;
}
.btn.primary:hover { box-shadow: 0 10px 34px var(--glow-gold); border-color: transparent; }
.btn.primary:hover::after { transform: translateX(120%); }
.btn.go { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.btn.go:hover { box-shadow: 0 6px 22px color-mix(in srgb, var(--good) 25%, transparent); border-color: var(--good); }
.btn.quiet { background: none; border-color: transparent; color: var(--muted); }
.btn.quiet:hover { color: var(--text); border-color: var(--border); }
.btn.wide { width: 100%; }

details.more { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
details.more summary { cursor: pointer; color: var(--muted); font-size: 14px; font-weight: 550; }
details.more summary:hover { color: var(--text); }
details.more[open] summary { margin-bottom: 10px; color: var(--text); }

.empty { border-radius: 18px; padding: 34px 22px; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 16px; }

/* ---------- forms ---------- */
.form { display: grid; gap: 14px; }
.row2 { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; align-items: end; }
.row3 { display: grid; gap: 14px; grid-template-columns: repeat(3, 1fr); align-items: start; }
label.f, div.f { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
label.f small, div.f small { font-weight: 400; color: var(--muted); }
/* the "?" next to a field (as on the platform): its meaning, on hover or tap */
label.f, div.f, .f-head.limits-head { position: relative; }
.limits-head { margin: 4px 0 0; font-size: 15px; font-weight: 700; }
/* the strategy's inputs: two columns (one on a narrow phone), the script's groups separated
   by a thin line, check boxes in the grid like the other fields */
.inputs-box { display: grid; gap: 10px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.inputs-list { display: grid; gap: 10px 12px; grid-template-columns: 1fr 1fr; align-items: end; }
@media (max-width: 420px) { .inputs-list { grid-template-columns: 1fr; } .inputs-list .chk.long { grid-column: auto; } }
.inputs-list .ig-end, .inputs-list .ig, .inputs-list .inputs-note { grid-column: 1 / -1; }
/* « Périodes »: the script's period settings, together at the end */
.inputs-list .ig { margin: 6px 0 -2px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 14px; font-weight: 700; color: var(--text); }
.inputs-list .ig-end { width: 100%; margin: 2px 0; border: 0; border-top: 1px solid var(--border); }
.inputs-list label.f, .inputs-list div.f { gap: 4px; font-size: 13px; }
.inputs-list input[type="text"], .inputs-list input[type="number"], .inputs-list select {
  padding: 7px 10px; font-size: 14px; border-radius: 10px;
}
.inputs-list .chk { min-height: 37px; align-content: center; }
.inputs-list .chk.long { grid-column: span 2; }
.inputs-list .chk label.check { gap: 8px; font-size: 13px; }
.inputs-note { margin: 0; font-size: 14px; }
/* the trial of a heavy Python strategy and its gauge (share of the server) */
.measure-box { display: grid; gap: 10px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.share-field input[type="range"] { width: 100%; accent-color: var(--gold); }
.inputs-list .lib-item { grid-column: 1 / -1; display: grid; gap: 8px; justify-items: start; }
.inputs-list .lib-item textarea { min-height: 90px; }
.help {
  position: static; display: inline-flex; align-items: center; justify-content: center;
  width: 17px; height: 17px; margin-left: 6px; vertical-align: 1px;
  border-radius: 50%; border: 1px solid var(--border-strong); background: var(--panel-2);
  color: var(--muted); font-size: 11px; font-weight: 600; line-height: 1; cursor: help;
  transition: color 0.2s, border-color 0.2s;
}
.help:hover, .help:focus-visible, .help.open { color: var(--gold); border-color: var(--gold); outline: none; }
.help .bubble {
  /* under the field's title, as wide as the field: never cut by the sheet's edges */
  display: none; position: absolute; z-index: 60; top: 26px; left: 0; right: 0;
  background: var(--panel-solid, #11151f); border: 1px solid var(--border-strong); border-radius: 12px;
  padding: 11px 13px; color: var(--text); font-size: 13.5px; font-weight: 400; line-height: 1.5;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45); text-align: left; cursor: default;
}
.help:hover .bubble, .help:focus .bubble, .help.open .bubble { display: block; animation: pop 0.18s ease-out; }
@keyframes pop { from { transform: translateY(-4px); opacity: 0.6; } }
/* the position on a card: « Achat » on its line, the quantity and its unit together below */
.pos-amount { display: block; white-space: nowrap; }
.limit { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
input[type="text"], input[type="password"], input[type="number"], input[type="url"], select, textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--border-strong);
  border-radius: 12px; padding: 10px 12px; font-size: 15px; transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow-blue);
}
input[type="file"] { font-size: 14px; color: var(--muted); }
input[type="file"]::file-selector-button {
  border: 1px solid var(--border-strong); background: var(--panel-2); color: var(--text);
  border-radius: 10px; padding: 7px 12px; margin-right: 10px; cursor: pointer; font-weight: 600;
}
textarea { min-height: 120px; font-family: var(--num); font-size: 13px; resize: vertical; }
label.check { display: flex; gap: 10px; align-items: center; font-size: 14px; }
input[type="checkbox"] { accent-color: var(--gold); width: 18px; height: 18px; }
.form-err { color: var(--bad); font-size: 14px; margin: 0; }
.form-err:empty { display: none; }

.panel { border-radius: 18px; padding: 22px; margin-bottom: 18px; }
.panel h3 { margin: 0 0 6px; font-size: 1.08rem; font-weight: 650; }
.panel > p.muted { margin: 0 0 14px; font-size: 14px; max-width: 70ch; }
.secret {
  font-family: var(--num); font-size: 13px; word-break: break-all;
  background: var(--panel-2); border: 1px solid var(--border-strong); border-radius: 12px;
  padding: 10px 12px; margin: 8px 0;
}
.list { list-style: none; margin: 0 0 14px; padding: 0; }
.list li { display: flex; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.list li:first-child { border-top: 1px solid var(--border); }
.list li .grow { flex: 1; min-width: 0; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.cards li { border-radius: 16px; padding: 16px 18px; display: grid; gap: 6px; }
.cards .card-top { display: flex; gap: 8px; align-items: center; }
.cards b { font-size: 1.02rem; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; font-size: 14px; }
.tag { font-size: 12px; padding: 1px 9px; border-radius: 999px; border: 1px solid var(--border-strong); color: var(--muted); font-weight: 550; }
.tag.gold { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 50%, transparent); background: color-mix(in srgb, var(--gold) 8%, transparent); }

/* ---------- journal ---------- */
.journal-tools select { width: auto; }
.journal { list-style: none; margin: 0; padding: 4px 0; border-radius: 18px; }
.journal li {
  display: grid; grid-template-columns: 96px 110px 1fr; gap: 12px;
  padding: 8px 18px; border-bottom: 1px solid var(--border); font-size: 13.5px;
}
.journal li:last-child { border-bottom: 0; }
.journal time { color: var(--muted); font-size: 12.5px; }
.journal .who { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.journal .what::before {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; content: "";
  vertical-align: 1px; background: var(--border-strong);
}
.journal .k-order .what::before { background: var(--accent); }
.journal .k-execution .what::before { background: var(--good); }
.journal .k-warning .what::before { background: var(--warn); }
.journal .k-alert .what::before { background: var(--bad); }
.journal .k-command .what::before { background: var(--muted); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin: 12px 4px 0; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

/* ---------- emergency stop (held to confirm) ---------- */
.estop { position: fixed; z-index: 6; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); }
.hold {
  position: relative; overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--bad) 70%, #fff 10%);
  background: linear-gradient(135deg, #ff6b7e, var(--bad) 50%, #b8263a); color: #fff;
  border-radius: 999px; padding: 12px 22px; font-weight: 700; font-size: 15px;
  cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none;
  box-shadow: 0 10px 30px color-mix(in srgb, var(--bad) 40%, transparent);
}
.hold .fill { position: absolute; inset: 0; background: #7e1222; transform-origin: left; transform: scaleX(0); }
.hold.holding .fill { transform: scaleX(1); transition: transform var(--hold-ms, 1200ms) linear; }
.hold span { position: relative; }
.hold.small { padding: 8px 16px; font-size: 14px; box-shadow: none; min-height: 40px; }
.hold.outline { background: none; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 55%, transparent); }
.hold.outline .fill { background: var(--bad); }
.hold.outline.holding { color: #fff; }

/* ---------- sheet (forms over the page) ---------- */
.sheet-back {
  position: fixed; inset: 0; z-index: 20; background: rgb(3 5 12 / 0.62);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: min(640px, 100%); max-height: 92dvh; overflow: auto;
  background: var(--panel-solid); border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--border-strong);
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  animation: rise 200ms ease-out;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.sheet-head h3 { margin: 0; font-size: 1.2rem; font-weight: 700; letter-spacing: -0.015em; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }

#toast {
  position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 30;
  background: var(--panel-solid); border: 1px solid var(--border-strong); border-radius: 12px;
  box-shadow: var(--shadow); padding: 10px 18px; font-size: 14px; max-width: calc(100% - 32px);
  opacity: 0; pointer-events: none; transition: opacity 160ms;
}
#toast.on { opacity: 1; }
#toast.bad { border-color: var(--bad); }

/* ---------- small screens: tabs at the bottom, under the thumb ---------- */
@media (max-width: 760px) {
  .top { padding: 0 16px; height: 56px; }
  .top .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; gap: 2px;
    justify-content: space-around; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: var(--panel-solid); border-top: 1px solid var(--border);
  }
  .tabs button { flex: 1; padding: 10px 4px; font-size: 14px; }
  .load > span:first-child { display: none; }
  .load-bar { width: 40px; }
  main { padding: 20px 16px 150px; }
  .strip-body { padding: 16px; }
  .readouts { grid-template-columns: 1fr 1fr; }
  .readout:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .row2, .row3 { grid-template-columns: 1fr; }
  .journal li { grid-template-columns: auto 1fr; row-gap: 2px; padding: 9px 14px; }
  .journal time { white-space: nowrap; }
  .journal .what { grid-column: 1 / -1; }
}

@media (min-width: 761px) {
  .estop { position: static; }
  .estop .hold { box-shadow: none; padding: 8px 18px; font-size: 14px; }
  main { padding-bottom: 60px; }
  .sheet-back { align-items: center; }
  .sheet { border-radius: 22px; border: 1px solid var(--border-strong); }
}

@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
  .sheet { animation: none; }
  .strip[data-state="running"] .state::before { animation: none; }
  .hold.holding .fill { transition-timing-function: steps(4); }
  .btn.primary::after { display: none; }
}

/* market search: the list narrows at each letter typed */
.combo { position: relative; }
.combo-icon {
  position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%);
  fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; pointer-events: none;
}
.combo input[type="text"] { padding-left: 36px; font-family: var(--num); font-size: 14.5px; }
.combo input::placeholder { font-family: var(--sans); color: var(--muted); opacity: .8; }
.combo-list {
  position: absolute; z-index: 70; left: 0; right: 0; top: calc(100% + 6px);
  max-height: 290px; overflow-y: auto; margin: 0; padding: 6px; list-style: none;
  background: var(--panel-solid); border: 1px solid var(--border-strong); border-radius: 12px;
  box-shadow: var(--shadow); animation: pop 0.14s ease-out;
}
.combo-list[hidden] { display: none; }
.combo-list li {
  display: flex; align-items: baseline; gap: 12px; padding: 8px 10px; border-radius: 8px;
  cursor: pointer; min-width: 0;
}
.combo-list li b { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; }
.combo-list li span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-list li.on, .combo-list li[data-i]:hover { background: var(--panel-2); box-shadow: inset 2px 0 0 var(--gold); }
.combo-list li mark { background: none; color: var(--gold); }
.combo-list li.more { cursor: default; color: var(--muted); font-size: 13px; justify-content: center; }
.combo-list li em {
  margin-left: auto; font-style: normal; font-size: 11px; font-weight: 600; color: var(--muted);
  border: 1px solid var(--border-strong); border-radius: 6px; padding: 1px 6px; white-space: nowrap;
}
/* the "?" of a strategy's allocated capital: its bubble under it, not across the card */
.strip-sub .alloc { position: relative; display: inline-flex; align-items: center; gap: 4px; }
.strip-sub .alloc .help .bubble { left: auto; right: -8px; width: min(340px, 80vw); }
