/* VerTrai — interface of the owner's program.
   Colours are tokens. Light is the theme; dark is an option the owner turns on
   (data-theme="dark" on <html>), never taken from the system setting. */

:root {
  --bg: #f2f5f3;
  --surface: #ffffff;
  --surface-2: #edf1ef;
  --ink: #15201b;
  --muted: #5a6962;
  --faint: #616e68;
  --line: #d9e1dd;
  --accent: #3fb98c;
  --accent-ink: #17744d;
  --accent-soft: #dff3e9;
  --on-accent: #06281a;
  --good: #17774e;
  --good-soft: #dcf1e6;
  --bad: #b0402b;
  --bad-soft: #fae6e1;
  --warn: #9a6a12;
  --warn-soft: #f7eed8;
  --shadow: 0 1px 2px rgb(20 32 27 / 6%), 0 4px 16px rgb(20 32 27 / 5%);
  --focus: 0 0 0 3px rgb(63 185 140 / 45%);
  --scroll-thumb: rgb(21 32 27 / 26%);
  --edge-shadow: rgb(20 32 27 / 16%);
  --control-line: #b5c3bc;
  /* A ticked box and a chosen circle: deep mint with a white mark, which
     reads at a glance (5.6:1), unlike a dark dot on bright mint. */
  --check-on: #17744d;
  --check-mark: #ffffff;

  --font: "Onest", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 10px;
  --r-sm: 7px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0d1210;
  --surface: #141b18;
  --surface-2: #1a2320;
  --ink: #e2eae6;
  --muted: #93a29b;
  --faint: #8a9a93;
  --line: #25302b;
  --accent: #4ac897;
  --accent-ink: #72dbb0;
  --accent-soft: #16332a;
  --on-accent: #04200f;
  --good: #55c690;
  --good-soft: #15302a;
  --bad: #ef7c64;
  --bad-soft: #3a1e18;
  --warn: #e2b25e;
  --warn-soft: #322914;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%);
  --focus: 0 0 0 3px rgb(74 200 151 / 40%);
  --scroll-thumb: rgb(255 255 255 / 22%);
  --edge-shadow: rgb(0 0 0 / 60%);
  --control-line: #46564f;
  --check-on: #4ac897;
  --check-mark: #04200f;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
/* Android paints a blue box over anything tapped; the pressed states here
   already show the tap. */
* { -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; font-weight: 600; }
h1 { font-size: 24px; letter-spacing: -0.01em; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--accent-ink); }

.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.good { color: var(--good); }
.bad { color: var(--bad); }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }

/* ---- boot / sign-in ---------------------------------------------------- */

.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.auth-card {
  width: min(400px, 100%);
  display: grid;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

.auth-card .brand { margin-bottom: 4px; }

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

.shell {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  min-height: 100vh;
}

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px 14px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  padding: 0 6px;
}

.brand img { width: 30px; height: 30px; }
/* «BETA» after the name: the product is still in beta. */
.beta { display: inline-flex; align-items: center; height: 18px; padding: 0 7px; margin-left: 2px; border-radius: 999px; font-family: var(--mono, monospace); font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; line-height: 1; color: var(--accent-ink); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); vertical-align: middle; }


.nav { display: flex; flex-direction: column; gap: 2px; }

.nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}

.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }

.side-foot { margin-top: auto; display: grid; gap: 8px; padding: 0 6px; }
.theme-toggle { justify-self: start; }

/* ---- bot switcher ---------------------------------------------------------
   Which bot this tab is on, and whether it trades real money, is the one thing
   the owner must never be unsure of: it sits at the top of the menu, and a
   live bot is marked in amber. */
.bot-switch-wrap { position: relative; }
.bot-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  white-space: normal;
}
.bot-switch:hover { background: var(--surface-2); }
.bot-switch.live { border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); background: var(--warn-soft); }
.bot-switch.watch { border: 1px dashed color-mix(in srgb, var(--warn) 55%, var(--line)); }
.bot-switch-text { display: grid; min-width: 0; line-height: 1.25; }
.bot-switch-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-switch-mode { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-switch.live .bot-switch-mode, .bot-switch-mode.live { color: var(--warn); font-weight: 600; }
.bot-switch-mode.watch { color: var(--warn); }
.bot-switch .chev { margin-left: auto; color: var(--muted); font-size: 12px; }

.bot-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 30;
  display: grid;
  gap: 2px;
  min-width: 240px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: 0 12px 32px rgb(20 32 27 / 16%);
}
.bot-menu.top { left: auto; width: min(300px, calc(100vw - 32px)); }
.bot-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--ink);
  text-decoration: none;
}
.bot-menu-item:hover { background: var(--surface-2); }
.bot-menu-item.current { background: var(--accent-soft); }
.bot-menu-item.plain { color: var(--accent-ink); font-weight: 500; font-size: 14px; }
.bot-menu-sep { height: 1px; margin: 4px 2px; background: var(--line); }

/* ---- the bots page ---------------------------------------------------------- */
.chip.mode.virtual { background: var(--surface-2); color: var(--muted); border-color: transparent; }
.chip.mode.live { background: var(--warn-soft); color: var(--warn); border-color: transparent; font-weight: 600; }
.chip.mode.watch { background: transparent; color: var(--warn); border: 1px dashed color-mix(in srgb, var(--warn) 55%, var(--line)); }

.bot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.bot-card {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.bot-card.live { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.bot-card.current { box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }
.bot-card p { margin: 0; }
.bot-card-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bot-card-head h3 { margin: 0; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-card-head .chip { margin-left: auto; flex: none; }
.bot-card-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 10px 0; border-block: 1px solid var(--line); }
.bot-card-nums .label { display: block; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.bot-card-nums strong { display: block; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot-card-nums > div { min-width: 0; }
.bot-card-actions { gap: 8px; }
.bot-more { position: relative; margin-left: auto; }
.bot-more > summary {
  list-style: none;
  cursor: pointer;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--muted);
}
.bot-more > summary::-webkit-details-marker { display: none; }
.bot-more[open] > summary { background: var(--surface-2); color: var(--ink); }
.bot-more-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 4px);
  z-index: 5;
  display: grid;
  min-width: 170px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  box-shadow: 0 10px 28px rgb(20 32 27 / 16%);
}
.bot-more-menu button { justify-content: flex-start; text-align: left; }
.account-field { margin-top: 10px; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.on { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.main {
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  padding: 28px 32px 120px;
  max-width: 1120px;
  width: 100%;
  display: grid;
  gap: 22px;
  align-content: start;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 20px;
  flex-wrap: wrap;
}

.page-head .lede { margin-top: 6px; color: var(--muted); max-width: 62ch; }

/* ---- surfaces ---------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px;
  display: grid;
  gap: 14px;
  min-width: 0;
  align-content: start;
  grid-template-columns: minmax(0, 1fr);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.stack { display: grid; gap: 16px; align-content: start; grid-template-columns: minmax(0, 1fr); min-width: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
  display: grid;
  gap: 4px;
}

.kpi .label { font-size: 12px; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; font-weight: 500; }
.kpi .value { font: 500 22px/1.2 var(--mono); font-variant-numeric: tabular-nums; }
.kpi .note { font-size: 12px; color: var(--faint); }

.empty {
  padding: 22px 12px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--r-sm);
}

/* ---- status bar -------------------------------------------------------- */

.control {
  display: flex;
  align-items: center;
  gap: 14px 20px;
  flex-wrap: wrap;
  justify-content: space-between;
}

.control-state { display: grid; gap: 6px; }
.control-state .big { font-size: 20px; font-weight: 600; display: flex; align-items: center; gap: 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.chip.ok { background: var(--good-soft); color: var(--good); border-color: transparent; }
.chip.no { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.accent { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.chip.long { background: var(--good-soft); color: var(--good); border-color: transparent; }
.chip.short { background: var(--bad-soft); color: var(--bad); border-color: transparent; }

/* ---- buttons & fields -------------------------------------------------- */

button, .btn {
  font: 500 14px/1 var(--font);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  min-height: 38px;
}

button:hover { background: var(--surface-2); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
button.primary:hover { filter: brightness(1.05); background: var(--accent); }
button.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
button.danger:hover { background: var(--bad-soft); }
button.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { background: var(--surface-2); color: var(--ink); }
button.small { min-height: 30px; padding: 6px 10px; font-size: 13px; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
/* Explanation on the left, action on the right; on a phone the explanation
   takes the whole line and the button sits under it at full width. */
.row.split { justify-content: space-between; }
.row.split > p { flex: 1 1 260px; margin: 0; }
@media (max-width: 760px) {
  .row.split > p { flex-basis: 100%; }
  .row.split > button { width: 100%; }
}
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

.field { display: grid; gap: 5px; min-width: 0; align-content: start; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 500; }
.field .hint { font-size: 12px; color: var(--faint); }

input, select, textarea {
  font: 400 15px/1.3 var(--font);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  min-height: 38px;
  width: 100%;
  min-width: 0;
}

/* Grows with the text, as on most sites (app.js has the fallback); no corner
   to drag. */
textarea { field-sizing: content; resize: none; min-height: 64px; max-height: max(50vh, 16em); overflow-y: auto; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
input[type="checkbox"]:focus, input[type="radio"]:focus { border-color: var(--accent); }
/* Checkboxes and radios are drawn here, not by the browser: the native ones
   ignore the dark theme's surface and show as a filled grey block on it. */
input[type="checkbox"], input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  min-height: 0;
  margin: 0;
  padding: 0; /* the shared input padding would blow the box up */
  flex: none;
  display: inline-grid;
  place-content: center;
  border: 1.5px solid var(--control-line);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]::after {
  content: "";
  width: 6px;
  height: 11px;
  margin-top: -2px;
  border: solid var(--check-mark);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.12s ease;
}
input[type="radio"]::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--check-on);
  transform: scale(0);
  transition: transform 0.12s ease;
}
/* A ticked box is filled; a chosen circle stays white inside, with a ring and
   a dot — the way every form shows a choice. */
input[type="checkbox"]:checked { background: var(--check-on); border-color: var(--check-on); }
input[type="radio"]:checked { background: var(--surface); border: 2px solid var(--check-on); }
input[type="checkbox"]:checked::after { transform: rotate(45deg) scale(1); }
input[type="radio"]:checked::after { transform: scale(1); }
input[type="checkbox"]:hover:not(:disabled), input[type="radio"]:hover:not(:disabled) { border-color: var(--accent); }
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline: none; box-shadow: var(--focus); }
input[type="checkbox"]:disabled, input[type="radio"]:disabled { opacity: 0.55; cursor: not-allowed; }

/* A label that wraps keeps its box next to the first line, not floating in
   the middle of the text. */
.check { display: inline-flex; align-items: flex-start; gap: 8px; cursor: pointer; line-height: 1.4; }
.check > input { margin-top: 1px; }
.check.one-line { align-items: center; }
.check.one-line > input { margin-top: 0; }

/* Filter bar: the control row on top, the switch under it, so a long label
   never pushes the buttons around. */
.filters { display: grid; gap: 10px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); }
.filters .row { align-items: center; }
.filters .check .hint { display: block; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }

.field > .segmented { justify-self: start; }
.segmented { display: inline-flex; max-width: 100%; border: 1px solid var(--line); border-radius: var(--r-sm); overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented button { border: 0; border-radius: 0; min-height: 34px; flex: none; }
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

.error {
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--bad-soft);
  color: var(--bad);
  font-size: 14px;
}

.notice {
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 14px;
}
/* A notice with a line of buttons under its text. */
.stack-tight { display: grid; gap: 8px; }

/* A verdict: good news in green, a warning stays amber, bad news in red. */
.notice.good { background: var(--good-soft); color: var(--good); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }

.code-box {
  font: 500 15px var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* The code the phone's camera reads: white quiet zone even in the dark theme. */
img.qr { background: #fff; padding: 8px; border-radius: var(--r-sm); image-rendering: pixelated; max-width: 100%; height: auto; }

/* A command to copy: one line that wraps instead of widening the card. */
.code-line {
  margin: 0;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-2, rgba(127, 127, 127, 0.1));
  font-family: var(--mono);
  white-space: pre-wrap;
  word-break: break-all;
  user-select: all;
}

/* ---- tables & lists ---------------------------------------------------- */

/* A table wider than the phone scrolls sideways; the shadow on the edge says
   so, because a touch screen shows no scrollbar until you drag. */
.table-wrap {
  overflow-x: auto;
  margin: 0 -2px;
  background:
    linear-gradient(to right, var(--surface) 40%, transparent) left center,
    linear-gradient(to left, var(--surface) 40%, transparent) right center,
    radial-gradient(farthest-side at 0 50%, var(--edge-shadow), transparent) left center,
    radial-gradient(farthest-side at 100% 50%, var(--edge-shadow), transparent) right center;
  background-repeat: no-repeat;
  background-size: 32px 100%, 32px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); letter-spacing: 0.03em; text-transform: uppercase; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }

.events { display: grid; gap: 0; max-height: 360px; overflow-y: auto; }
.events li { display: grid; grid-template-columns: 62px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.events li:last-child { border-bottom: 0; }
.events time { color: var(--faint); font-family: var(--mono); font-size: 12px; padding-top: 1px; }
ul.plain { list-style: none; margin: 0; padding: 0; }

/* ---- rules ------------------------------------------------------------- */

.rules { display: grid; gap: 12px; }

.rule {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 18px;
  display: grid;
  gap: 12px;
}

.rule-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rule-head h3 { font-size: 16px; }

.conds { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; counter-reset: c; }
.conds li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; font-size: 14px; }
.conds li::before {
  counter-increment: c;
  content: counter(c);
  font: 500 11px/20px var(--mono);
  width: 20px; height: 20px;
  text-align: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
}
.conds li.model::before { content: "?"; background: var(--accent-soft); color: var(--accent-ink); }

.exit-line { font-size: 13px; color: var(--muted); }

.templates { display: grid; gap: 14px; }
.tpl-group { display: grid; gap: 8px; }
.tpl-group > p { color: var(--muted); font-size: 14px; }
.tpl { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }

/* rule editor */

.editor { display: grid; gap: 16px; }

.cond-edit {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.cond-edit .row { align-items: flex-end; }
.cond-edit > .row:first-child { flex-wrap: nowrap; }
.cond-edit .cond-kind { flex: 1 1 auto; min-width: 0; }
/* On a phone the name of the condition needs the whole width, so the remove
   button moves into the corner of the card instead of stealing from it. */
@media (max-width: 760px) {
  .cond-edit { position: relative; }
  /* Only the small caption above the select steps aside for the button; the
     select itself keeps the full width, so the longest condition name
     («Цена вышла из диапазона») is never cut off. */
  .cond-edit > .row:first-child > .icon-btn { position: absolute; top: 10px; right: 10px; }
  .cond-edit .cond-kind > span { padding-right: 34px; }
  .cond-edit .cond-kind select { font-size: 15px; padding-inline: 10px 28px; }
}
.cond-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.cond-preview { font-size: 13px; color: var(--muted); }

/* ---- tickers ----------------------------------------------------------- */

.picked { display: flex; flex-wrap: wrap; gap: 8px; min-height: 36px; }

.pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px 5px 11px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font: 500 13px var(--mono);
}

.pick button { min-height: 22px; width: 22px; padding: 0; border-radius: 50%; border: 0; background: transparent; color: inherit; font-size: 15px; }
.pick button:hover { background: color-mix(in srgb, var(--accent) 25%, transparent); }

.catalog { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }

.stock {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
  min-height: 44px;
  white-space: normal;
}

/* A chosen share carries the same tick as a checkbox: colour alone is hard to
   read, and in the dark theme it is harder still. */
.stock::before {
  content: "";
  flex: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--control-line);
  border-radius: 5px;
  background: var(--surface);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 11px 11px;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.stock .t { font: 500 13px var(--mono); margin-right: auto; }
.stock .n { font-size: 13px; color: var(--muted); text-align: right; }
.stock[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.stock[aria-pressed="true"] .n { color: var(--accent-ink); }
.stock[aria-pressed="true"]::before {
  border-color: var(--accent);
  background-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.2 3.2L13 5' fill='none' stroke='%2306281a' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.stock:hover::before { border-color: var(--accent); }

.search { position: relative; }
.search input { padding-left: 36px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }

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

.journal { display: grid; gap: 8px; }

.entry { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); }
.entry[open] { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.entry summary {
  list-style: none;
  cursor: pointer;
  display: grid;
  grid-template-columns: 96px 64px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
}
.entry summary::-webkit-details-marker { display: none; }
.entry .when { font: 400 12px var(--mono); color: var(--muted); }
.entry .sym { font: 500 13px var(--mono); }
.entry .what { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry .what small { color: var(--muted); margin-left: 6px; }
.entry-body { padding: 4px 14px 14px; display: grid; gap: 10px; border-top: 1px solid var(--line); }
.entry-body .outcome { padding-top: 8px; }

.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.checks li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; font-size: 14px; }
.mark { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.mark.ok { background: var(--good-soft); color: var(--good); }
.mark.no { background: var(--bad-soft); color: var(--bad); }
.mark.skip { background: var(--surface-2); color: var(--faint); }
.checks .kind { font-weight: 500; }
.checks .detail { color: var(--muted); }

/* ---- backtest ---------------------------------------------------------- */

/* Which shares a rule covers: the switch, then the list when it is narrowed. */
.scope { display: grid; gap: 8px; }
.scope-list { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 8px 10px; background: var(--surface-2); border-radius: var(--r-sm); }
.scope-list .check { font-size: 13px; }

.pickers { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
/* The name of a rule takes the width it needs; notes about it wrap to the
   next line instead of being squeezed into a column of one word. */
.opt { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); cursor: pointer; min-height: 40px; }
.opt > span:not(.chip) { flex: 1 1 auto; min-width: 0; }
.opt > .muted { flex-basis: 100%; padding-left: 28px; }
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(64px, 170px) minmax(60px, 1fr) 124px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .val { text-align: right; white-space: nowrap; }
.bar-track { position: relative; height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.bar-track .zero { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--line); }
.bar-track .fill { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.bar-track .fill.pos { background: var(--good); }
.bar-track .fill.neg { background: var(--bad); }

.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- save bar, dialog, toast ------------------------------------------- */

.savebar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 10px 16px;
  /* Same colours as the page, lifted by a mint edge and a shadow: a black slab
     on a light page read as a foreign window. */
  background: var(--surface);
  color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: 12px;
  box-shadow: 0 10px 34px rgb(20 32 27 / 18%), 0 2px 6px rgb(20 32 27 / 8%);
  width: max-content;
  max-width: calc(100vw - 32px);
}

.savebar button { min-height: 34px; white-space: nowrap; }

/* Token field inside the broker steps: input and button on one line, one
   under the other on a phone. */
.token-row { display: flex; gap: 8px; margin: 8px 0 4px; flex-wrap: wrap; }
.token-row input { flex: 1 1 220px; min-width: 0; }

/* A number and its unit side by side; on a phone the unit goes under it. */
.unit-row { display: flex; gap: 8px; flex-wrap: wrap; }
.unit-row input { flex: 0 1 110px; min-width: 80px; }
.unit-row select { flex: 1 1 180px; min-width: 0; }
/* The unit stands beside its field, quietly: «1,5 × стоп», «3 ч». */
.unit-row .unit { align-self: center; color: var(--muted); font-size: 13px; white-space: nowrap; }

/* "Waiting for /start": the spinner beside the text, never above it. */
.waiting-row { display: flex; gap: 10px; align-items: flex-start; }
.waiting-row .spinner { margin-top: 3px; }
.savebar > span { flex: 0 1 auto; min-width: 0; }
.savebar > span { font-weight: 500; }
.savebar .ghost { color: var(--muted); }
.savebar .ghost:hover { background: var(--surface-2); color: var(--ink); }
:root[data-theme="dark"] .savebar { box-shadow: 0 10px 34px rgb(0 0 0 / 55%); }

dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  box-shadow: 0 20px 60px rgb(0 0 0 / 30%);
}

dialog::backdrop { background: rgb(8 14 12 / 50%); }
dialog.narrow { width: min(460px, calc(100vw - 32px)); }
.dialog-body { padding: 20px; display: grid; gap: 16px; }
.dialog-foot { position: sticky; bottom: 0; background: var(--surface); padding: 12px 20px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.dialog-foot-row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

.toast {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 30;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 20%);
  max-width: calc(100vw - 32px);
}

.toast.bad { background: var(--bad); color: #fff; }

.foot-note { font-size: 12px; color: var(--faint); max-width: 70ch; }

/* ---- narrow screens ---------------------------------------------------- */

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .shell { display: block; }
  .side { display: none; }
  .main { padding: 16px 16px 150px; gap: 18px; }
  h1 { font-size: 22px; }
  .card { padding: 14px; }
  .kpis { gap: 10px; }
  .kpi { padding: 12px; }
  .kpi .value { font-size: 17px; }
  .control { flex-direction: column; align-items: stretch; }
  .control > button { width: 100%; min-height: 46px; font-size: 16px; }
  /* A phone shows the ticker, then the rule on its own line — no cut-off words. */
  .entry summary { grid-template-columns: 52px minmax(0, 1fr) auto; gap: 4px 10px; padding: 10px 12px; align-items: start; }
  /* The time is what makes the journal readable, so on a phone it moves under
     the rule instead of disappearing. */
  .entry .when { grid-column: 2; grid-row: 2; font-size: 11px; }
  .entry .sym { grid-column: 1; grid-row: 1; padding-top: 1px; }
  .entry .what { grid-column: 2; grid-row: 1; }
  .entry summary > .chip { grid-column: 3; grid-row: 1; }
  .entry .what { white-space: normal; overflow: visible; font-size: 14px; line-height: 1.3; }
  .entry .what small { display: block; margin: 2px 0 0; }
  .entry summary .chip { align-self: start; }
  /* Period switcher: four equal parts across the width, nothing hidden. */
  .segmented { display: flex; width: 100%; overflow: visible; }
  .segmented button { flex: 1 1 0; min-width: 0; padding-inline: 4px; font-size: 12.5px; letter-spacing: -0.01em; }
  .bar-row { grid-template-columns: minmax(56px, 110px) minmax(40px, 1fr) 112px; }
  /* On a phone the bar goes full width: one line of text, then two equal
     buttons — never a narrow column of wrapped words. */
  .savebar {
    left: 10px;
    right: 10px;
    bottom: calc(74px + env(safe-area-inset-bottom));
    transform: none;
    width: auto;
    max-width: none;
    flex-wrap: wrap;
    gap: 8px 10px;
    padding: 12px;
  }
  .savebar > span { flex: 1 0 100%; font-size: 13px; }
  .savebar button { flex: 1 1 0; min-height: 44px; font-size: 15px; }
  input, select, textarea { font-size: 16px; } /* no zoom on focus in mobile browsers */
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
  * { scroll-behavior: auto; }
}

/* ---- navigation: side menu on wide screens, top bar + tab bar on phones -- */

.content { min-width: 0; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a { justify-content: flex-start; }

.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 10;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { padding: 0; font-size: 17px; }
.topbar .brand img { width: 26px; height: 26px; }
/* On a narrow phone the bot's name and state need the room: the badge
   shrinks and the logo yields to the word. */
.topbar .brand { gap: 7px; }
.topbar .beta { height: 16px; padding: 0 5px; font-size: 9px; margin-left: 0; }
@media (max-width: 400px) { .topbar .brand img { display: none; } }
.topbar .bot-switch-wrap { max-width: 62vw; }
.topbar .bot-switch { min-height: 40px; padding: 5px 10px; }

.tabbar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
}
.tabbar a {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 6px 2px;
  border-radius: var(--r-sm);
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  min-height: 52px;
  align-content: center;
}
.tabbar a[aria-current="page"] { color: var(--accent-ink); background: var(--accent-soft); }
.tabbar .ico { width: 22px; height: 22px; }

.back { color: var(--muted); text-decoration: none; font-size: 14px; justify-self: start; }
.back:hover { color: var(--ink); }

a.btn { text-decoration: none; }

/* ---- home ------------------------------------------------------------- */

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
/* The same tick as the checkboxes: a done step should read the same way as a
   ticked box, and a two-line step keeps its mark beside the first line. */
.steps li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; font-size: 15px; }
.steps li.done { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }
.steps .mark { margin-top: 1px; }
.steps .mark.ok { background: var(--accent); color: var(--on-accent); }
.steps .mark.skip { border: 1.5px solid var(--control-line); background: transparent; }

.control-state p { max-width: 60ch; }

.trades { display: grid; gap: 0; }
.trade { display: grid; gap: 4px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.trade:last-child { border-bottom: 0; }
.trade-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
/* The last line of an open trade: what it is worth now, and the button that
   closes this one trade only. */
.trade-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
button.ghost-danger { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
button.ghost-danger:hover { background: var(--bad-soft); }

.trade-nums { display: flex; gap: 6px 14px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
/* The time always starts its own line, so a list of trades reads as a column
   of equal rows instead of ragged two- and three-line blocks. */
.trade-nums .when-line { flex-basis: 100%; }

.kpi .value { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Four cards in a narrow window: «1 000 000 ₽» must fit whole, not end in «…». */
@media (min-width: 761px) and (max-width: 1180px) {
  .kpi .value { font-size: 18px; }
  .kpi { padding: 12px 12px; }
}
/* The «save» bar floats over the page; with it up, the page ends higher so
   the last card's buttons are never under it. */
body:has(.savebar:not([hidden])) .main { padding-bottom: 200px; }
@media (max-width: 760px) {
  body:has(.savebar:not([hidden])) .main { padding-bottom: 260px; }
}

/* ---- strategy ---------------------------------------------------------- */

.pick.static { padding: 5px 11px; flex-direction: column; align-items: flex-start; gap: 0; border-radius: var(--r-sm); }
.pick.static small { font: 400 11px var(--font); color: var(--muted); }
.cta { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }

/* ---- settings ---------------------------------------------------------- */

.plain-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.plain-fieldset:disabled { opacity: 0.6; }

.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.choice {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  align-items: start;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice > span { display: grid; gap: 2px; }
.choice input { margin-top: 2px; }

.big-check { align-items: flex-start; }
.big-check > span { display: grid; gap: 2px; }
.big-check input { margin-top: 2px; }

details.more { border-top: 1px dashed var(--line); padding-top: 10px; }
details.more > summary { cursor: pointer; color: var(--muted); font-size: 14px; font-weight: 500; }
details.more[open] > summary { margin-bottom: 12px; }
details.more > * + * { margin-top: 12px; }

/* Phones: these come last so they win over the base rules above. */
@media (max-width: 760px) {
  .topbar { display: flex; }
  .tabbar { display: grid; }
  .cta { grid-template-columns: minmax(0, 1fr); }
  .choices { grid-template-columns: minmax(0, 1fr); }
}

.hint { font-size: 12px; color: var(--faint); line-height: 1.4; }
.big-check .hint { font-size: 13px; color: var(--muted); }
.check input[type="checkbox"], .check input[type="radio"], .choice input { flex: none; }

.lines li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.lines li:last-child { border-bottom: 0; }
.line-name { display: grid; gap: 1px; min-width: 0; }
.line-name small { color: var(--muted); font-size: 12px; }
.trade-top .spacer { flex: 1; }

.connect { display: grid; gap: 10px; padding-top: 6px; border-top: 1px solid var(--line); }
.howto { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 14px; }
.howto code { font: 13px var(--mono); background: var(--surface-2); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
.check-result:empty { display: none; }

/* ---- scrollbars: invisible until used, as in the old project -------------
   The page's own bar shows only while it scrolls (script adds .is-scrolling
   and removes it a second later); inner areas also show it on hover. Thin,
   in the theme's colours. */

* { scrollbar-width: thin; scrollbar-color: transparent transparent; }
:not(html):hover, .is-scrolling { scrollbar-color: var(--scroll-thumb) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; background: transparent; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background: transparent; border-radius: 999px; }
:not(html):hover::-webkit-scrollbar-thumb, .is-scrolling::-webkit-scrollbar-thumb { background: var(--scroll-thumb); }
::-webkit-scrollbar-thumb:hover, ::-webkit-scrollbar-thumb:active { background: color-mix(in srgb, var(--accent) 55%, transparent); }
.segmented, .segmented:hover { scrollbar-width: none; }

.icon-btn { min-width: 38px; padding: 0; font-size: 16px; }

.auth-card code { font: 12px var(--mono); background: var(--surface-2); padding: 1px 4px; border-radius: 4px; word-break: break-all; }
.auth-card h1 + p { margin-top: 6px; }

/* Plain words from the AI about the day: a quiet block of text, wide enough
   to read but not as wide as the page. */
.explain {
  margin: 10px 0 0;
  max-width: 62ch;
  line-height: 1.55;
  white-space: pre-wrap;
}

/* Controls keep a readable width: a lone select used to stretch across the
   whole card while the number fields beside it stayed at 220px, and the two
   looked like they belonged to different programs. */
.field > input,
.field > select,
.field > .unit-row,
.field > .token-row {
  max-width: 420px;
}

/* A bot key is a long string, so its field is allowed to be wider than the
   rest — but not the width of the whole card. */
.token-row { max-width: 560px; }

/* The time field is drawn by the browser and comes out two pixels taller than
   the rest; the row then looks misaligned. */
input[type="time"] { min-height: 38px; height: 40px; }

/* The browser's little up/down arrows in a number field crowd the unit that
   stands next to it. */
input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { appearance: none; margin: 0; }

/* ---- what a finger can hit ------------------------------------------------
   Measured on a 375 px phone (2026-09-25): the small buttons came out 30 px
   tall, the "×" on a chosen share 22 px, and the links that act as buttons
   ("Все сделки", "← Стратегия") about 20 px. A finger needs about 44; below
   40 the tap misses. Only the target grows — the drawing stays as it is. */
@media (max-width: 760px) {
  button, .btn { min-height: 44px; }
  button.small { min-height: 40px; padding: 8px 12px; }
  .segmented button { min-height: 40px; }

  /* A link that does something gets the height of a button, without looking
     like one. */
  .back,
  .card-head a,
  .row > a:not(.btn),
  .kpi a {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
  }

  /* The cross that removes a chosen share. */
  .pick button,
  .picked button {
    min-width: 36px;
    min-height: 36px;
    margin: -7px -8px -7px 0;
  }

  /* "Ещё" over a bot's card opens its menu. */
  .bot-more > summary { min-height: 40px; display: inline-flex; align-items: center; }

  /* A fold's heading ("Дополнительно") is a control too, and it was 21 px. */
  details > summary { min-height: 40px; display: flex; align-items: center; }

  /* A single-line checkbox row — "Подключить ИИ" — was 22 px tall. */
  label.check { min-height: 40px; }

  /* The time of a journal row is secondary, but 11 px is unreadable on a
     phone held at arm's length. */
  .journal .when, .journal time, .journal .muted.small { font-size: 12px; }
}

/* The list's own arrow, not the operating system's: the native one is drawn
   by Windows in its own grey and sits at a different height from our fields,
   so a row of a select and two number fields never looked like one row.
   Marker: select-arrow. */
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%236b7c74' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
  padding-right: 34px;
}

/* ---- check on history: the verdict and the three insights ---------------- */

.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }

.card.verdict {
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  align-items: center;
  gap: 18px 28px;
  padding: 22px 24px;
}
.verdict-main { display: grid; gap: 6px; min-width: 0; }
.eyebrow { font-size: 13px; color: var(--muted); }
.verdict-sum { font: 500 36px/1.1 var(--mono); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.verdict-sub { color: var(--muted); font-size: 14px; }
.verdict-marks {
  list-style: none;
  margin: 0;
  padding: 2px 0 2px 24px;
  border-left: 1px solid var(--line);
  display: grid;
  gap: 10px;
}
.verdict-marks li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.verdict-marks .pip { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.verdict-marks li.good .pip { background: var(--good); }
.verdict-marks li.warn .pip { background: var(--warn); }
.verdict-marks li.bad .pip { background: var(--bad); }

.card.insight h2 { font-size: 15px; }
.insight .bar-row { grid-template-columns: minmax(64px, 96px) minmax(40px, 1fr) auto; }
.insight-note {
  font-size: 13.5px;
  line-height: 1.45;
  padding: 9px 12px;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  border-left: 3px solid var(--control-line);
  background: var(--surface-2);
}
.insight-note.good,
.insight-note.warn,
.insight-note.bad { color: var(--ink); }
.insight-note.good { border-left-color: var(--good); }
.insight-note.warn { border-left-color: var(--warn); }
.insight-note.bad { border-left-color: var(--bad); }

/* Random bots as dots on one axis, the owner's rules as a line through them. */
.strip {
  position: relative;
  height: 76px;
  border-bottom: 1px solid var(--line);
  margin-top: 4px;
}
.strip-zero { position: absolute; top: 18px; bottom: 0; border-left: 1px dashed var(--control-line); }
.strip-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--muted) 45%, transparent);
  transform: translate(-50%, -50%);
}
.strip-mark { position: absolute; top: 16px; bottom: 0; width: 2px; margin-left: -1px; background: var(--ink); border-radius: 1px; }
.strip-mark.good { background: var(--good); }
.strip-mark.bad { background: var(--bad); }
.strip-label {
  position: absolute;
  top: -17px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  color: inherit;
}
.strip-mark .strip-label { color: var(--ink); }
.strip-mark.good .strip-label { color: var(--good); }
.strip-mark.bad .strip-label { color: var(--bad); }
.strip-mark.edge-left .strip-label { left: 0; transform: none; }
.strip-mark.edge-right .strip-label { left: auto; right: 0; transform: none; }
.strip-axis { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--faint); margin-top: -6px; }
.strip-axis-mid { font-family: var(--font); }

.worst { display: grid; }
.worst-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.worst-row:first-child { border-top: 0; padding-top: 2px; }
.worst-label { font-size: 13px; color: var(--muted); }
.worst-value { font: 500 15px/1.3 var(--mono); text-align: right; white-space: nowrap; }
.worst-note { grid-column: 1 / -1; font-size: 12px; color: var(--faint); }

/* ---- the account's protection on the main screen ------------------------- */

.guard-stop {
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 14px;
}
.guard-stop strong { font-size: 15px; }
.meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px 20px; }
.meter { display: grid; gap: 6px; }
.meter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.meter-label { font-size: 13px; font-weight: 500; }
.meter-track { display: block; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: 3px; background: var(--accent); transition: width 0.3s ease; }
.meter-fill.warn { background: var(--warn); }
.meter-fill.bad { background: var(--bad); }
.meter-note { font-size: 12px; color: var(--faint); }
.guard-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.pips { display: flex; gap: 6px; }
.pip-dot { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--control-line); }
.pip-dot.on { background: var(--bad); border-color: var(--bad); }

@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .card.verdict { grid-template-columns: minmax(0, 1fr); padding: 18px; }
  .verdict-sum { font-size: 30px; }
  .verdict-marks { border-left: 0; border-top: 1px solid var(--line); padding: 14px 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .meter-fill { transition: none; }
}

/* ---- a trade on the chart ------------------------------------------------ */

dialog.trade-dialog { width: min(920px, calc(100vw - 24px)); }
.trade-body { gap: 12px; }
.trade-head { display: flex; align-items: flex-start; gap: 12px; }
.trade-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.trade-symbol { font-size: 20px; font-weight: 600; }
.trade-result { display: grid; justify-items: end; gap: 0; }
.trade-result strong { font-size: 22px; font-weight: 500; }
.icon-close {
  width: 34px; height: 34px; padding: 0; flex: none;
  border-radius: 50%; border-color: transparent; background: transparent;
  color: var(--muted); font-size: 22px; line-height: 1;
}
.icon-close:hover { background: var(--surface-2); color: var(--ink); }
.trade-when { margin-top: -6px; }
.trade-chart { min-height: 250px; }
.chart-wait { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 250px; color: var(--muted); font-size: 14px; }

.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.fact { background: var(--surface); padding: 10px 12px; display: grid; gap: 2px; }
.fact-label { font-size: 12px; color: var(--muted); }
.fact-value { font: 500 16px/1.3 var(--mono); }
.fact-note { font-size: 12px; color: var(--faint); }

.tc-wrap { position: relative; }
.tc { display: block; width: 100%; height: auto; touch-action: pan-y; user-select: none; }
.tc-grid { stroke: var(--line); stroke-width: 1; }
.tc-day { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.tc-axis { fill: var(--faint); font: 11px var(--mono); }
.tc-axis-day { fill: var(--muted); font-family: var(--font); font-weight: 600; }
.tc-zone { fill: color-mix(in srgb, var(--accent) 9%, transparent); }
.tc-zone.win { fill: color-mix(in srgb, var(--good) 9%, transparent); }
.tc-zone.loss { fill: color-mix(in srgb, var(--bad) 8%, transparent); }
.tc-level { stroke-width: 1.5; }
.tc-level.entry { stroke: var(--muted); stroke-dasharray: 1 3; stroke-linecap: round; }
.tc-level.stop { stroke: var(--bad); stroke-dasharray: 6 4; }
.tc-level.target { stroke: var(--good); stroke-dasharray: 6 4; }
.tc-candle line { stroke-width: 1; }
.tc-candle.up line { stroke: var(--good); }
.tc-candle.up rect { fill: var(--good); }
.tc-candle.down line { stroke: var(--bad); }
.tc-candle.down rect { fill: var(--bad); }
.tc-mark-in { stroke: var(--surface); stroke-width: 1.5; }
.tc-mark-in.long { fill: var(--good); }
.tc-mark-in.short { fill: var(--bad); }
.tc-dot { fill: var(--ink); stroke: var(--surface); stroke-width: 1.5; }
.tc-mark-out { stroke: var(--surface); stroke-width: 2.5; }
.tc-mark-out.win { fill: var(--good); }
.tc-mark-out.loss { fill: var(--bad); }
.tc-tag rect { fill: var(--surface-2); }
.tc-tag text { font: 500 11px var(--mono); fill: var(--ink); }
.tc-tag.stop rect { fill: var(--bad-soft); }
.tc-tag.stop text { fill: var(--bad); }
.tc-tag.target rect { fill: var(--good-soft); }
.tc-tag.target text { fill: var(--good); }
.tc-cross { stroke: var(--control-line); stroke-width: 1; pointer-events: none; }
.tc-tip {
  position: absolute; top: 10px; width: 136px; pointer-events: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  box-shadow: var(--shadow); padding: 8px 10px; font-size: 12px; display: grid; gap: 2px;
}
.tc-tip-head { color: var(--muted); margin-bottom: 2px; }
.tc-tip div:not(.tc-tip-head) { display: flex; justify-content: space-between; gap: 8px; }
.tc-tip span { color: var(--faint); }
.tc-tip b { font: 500 12px var(--mono); }

.trade.clickable, tr.clickable { cursor: pointer; }
.trade.clickable { border-radius: var(--r-sm); transition: background 0.15s ease; }
.trade.clickable:hover, tr.clickable:hover td { background: var(--surface-2); }
.trade.clickable:focus-visible, tr.clickable:focus-visible { outline: none; box-shadow: var(--focus); }
.row.tight { gap: 6px; flex-wrap: nowrap; }

@media (max-width: 760px) {
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trade-symbol { font-size: 18px; }
  .trade-result strong { font-size: 18px; }
}

/* ---- the result over time ------------------------------------------------ */

.eq-host { min-height: 180px; }
.eq { display: block; width: 100%; height: auto; touch-action: pan-y; user-select: none; }
.eq-zero { stroke: var(--control-line); stroke-width: 1; stroke-dasharray: 3 3; }
.eq-area.up { fill: color-mix(in srgb, var(--good) 16%, transparent); }
.eq-area.down { fill: color-mix(in srgb, var(--bad) 14%, transparent); }
.eq-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.eq-line.up { stroke: var(--good); }
.eq-line.down { stroke: var(--bad); }
.eq-end { stroke: var(--surface); stroke-width: 2; }
.eq-end.up { fill: var(--good); }
.eq-end.down { fill: var(--bad); }
.eq-hover { fill: var(--ink); stroke: var(--surface); stroke-width: 2; pointer-events: none; }
.eq-dd { fill: color-mix(in srgb, var(--bad) 6%, transparent); }
.eq-dd-label { fill: var(--bad); font: 500 11px var(--font); }
.eq-tip { width: 150px; }
.tc-tip b.good { color: var(--good); }
.tc-tip b.bad { color: var(--bad); }

.months { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.month {
  --k: 10%;
  display: grid; gap: 2px; padding: 9px 11px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.month.good { background: color-mix(in srgb, var(--good) var(--k), var(--surface)); }
.month.bad { background: color-mix(in srgb, var(--bad) var(--k), var(--surface)); }
.month-name { font-size: 12px; color: var(--muted); text-transform: capitalize; }
.month-net { font: 500 15px/1.3 var(--mono); }
.month-note { font-size: 11px; color: var(--faint); }

/* ---- comparing variants -------------------------------------------------- */

.variant-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: 8px; }
@media (max-width: 560px) {
  .variant-picks { display: flex; flex-wrap: wrap; gap: 6px; }
  .variant-pick { padding: 7px 12px 7px 9px; gap: 7px; border-radius: 999px; align-items: center; }
  .variant-pick input { margin: 0; }
  .variant-pick small { display: none; }
  .variant-pick strong { font-size: 14px; }
}
.variant-pick {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm); cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.variant-pick:hover { border-color: var(--control-line); }
.variant-pick:has(input:checked) { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); background: var(--accent-soft); }
.variant-pick input { margin-top: 2px; }
.variant-pick span { display: grid; gap: 1px; }
.variant-pick strong { font-size: 14px; font-weight: 500; }
.variant-pick small { font-size: 12px; color: var(--muted); }

.cmp table { min-width: 760px; }
.cmp td { vertical-align: middle; }
.cmp-name { display: grid; gap: 1px; }
.cmp-name strong { font-weight: 500; }
.cmp-name small { font-size: 12px; color: var(--faint); }
.cmp-diff { display: block; font-size: 11.5px; }
.cmp-base td { background: var(--surface-2); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }

/* On a phone each variant is a card of labelled figures. */
@media (max-width: 560px) {
  .cmp table { min-width: 0; }
  .cmp thead { display: none; }
  .cmp tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .cmp tr.cmp-base { background: var(--surface-2); padding: 12px; border-radius: var(--r-sm); border-bottom: 0; margin-bottom: 4px; }
  .cmp-base td { background: transparent; }
  .cmp td { display: grid; gap: 1px; padding: 0; border: 0; text-align: left; }
  .cmp td.r { text-align: left; }
  .cmp td[data-label]::before { content: attr(data-label); font: 12px var(--font); color: var(--muted); }
  .cmp td.cmp-name-cell { grid-column: 1 / -1; }
  .cmp td.cmp-apply { grid-column: 1 / -1; justify-items: start; }
  .cmp td.cmp-apply:empty { display: none; }
  .cmp td .tag { justify-self: start; }
}

/* ---- how an entry is made, and the bot's questions ------------------------ */

.field-title { font-size: 14px; font-weight: 500; }
.choices.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 760px) { .choices.three { grid-template-columns: minmax(0, 1fr); } }

.card.asks.waiting { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
.ask { display: flex; align-items: center; justify-content: space-between; gap: 12px 18px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--line); }
.card-head + .ask { border-top: 0; padding-top: 4px; }
.ask-main { display: grid; gap: 6px; min-width: 0; }
.ask-symbol { font-size: 17px; font-weight: 600; }
.ask-time { display: flex; align-items: center; gap: 8px; color: var(--warn); }
.ask-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); animation: ask-pulse 1.6s ease-in-out infinite; }
@keyframes ask-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.ask-actions { display: flex; gap: 8px; }
.ask-actions .primary { min-width: 108px; }
.ask-log { display: grid; gap: 6px; border-top: 1px solid var(--line); padding-top: 10px; }
.ask-log li { display: flex; align-items: center; gap: 10px; font-size: 13px; min-width: 0; }
.ask-log time { color: var(--faint); font: 12px var(--mono); }
.ask-note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
@media (max-width: 560px) {
  .ask-actions { width: 100%; }
  .ask-actions button { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { .ask-dot { animation: none; } }

/* A switched-off rule: still in the list, visibly not trading. */
.rule.off { border-style: dashed; }
.rule.off .conds, .rule.off .exit-line { opacity: 0.7; }
