/* Everything about one bot: its page's tabs, the settings checks, the
   Improve tab, and the testing tools' tips. Kept apart from pages.css so
   the bot page can change without touching the other pages' styles. */

/* Tabs: Overview, Activity, Settings, Improve. They scroll sideways inside
   their own row on a narrow phone rather than pushing the page wider. */
.bot-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-4); overflow-x: auto; scrollbar-width: none; }
.bot-tabs::-webkit-scrollbar { display: none; }
.bot-tab { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; border: none; background: none; color: var(--color-text-muted); font-size: 0.9rem; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.bot-tab[aria-selected="true"] { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.bot-tab:hover { color: var(--color-text); }
.bot-tab:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; border-radius: var(--radius-sm); }
.bot-tab-badge { font-size: 0.68rem; min-width: 18px; padding: 0 6px; border-radius: 999px; background: var(--color-warning); color: #000; text-align: center; }
.bot-panel { min-width: 0; }
.bot-panel:focus-visible { outline: none; }
.bot-panel[hidden] { display: none; }

/* Cards and the figures at the top of Overview. */
.bot-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-4); margin-bottom: var(--space-4); min-width: 0; }
.bot-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.bot-tile { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-3); min-width: 0; }
.bot-tile-label { font-size: 0.7rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px; }
.bot-tile-value { font-size: 1.1rem; font-weight: 700; overflow-wrap: anywhere; }
.bot-tile-sub { font-size: 0.7rem; color: var(--color-text-muted); margin-top: 2px; }

/* "Next step: press Start", while a bot has never run. */
.next-step { border: 1px solid var(--color-success); background: var(--color-success-bg); border-radius: var(--radius-md); padding: var(--space-3); font-size: 0.85rem; margin-bottom: var(--space-4); line-height: 1.5; }
.next-step strong { color: var(--color-success); }

/* The Settings tab's notes on saving. */
.settings-locked, .settings-restart { font-size: 0.82rem; line-height: 1.5; padding: var(--space-3); border-radius: var(--radius-md); margin: 0 0 var(--space-3); max-width: 720px; }
.settings-locked { border: 1px solid var(--color-warning); background: var(--color-warning-bg); }
.settings-restart { border: 1px solid var(--color-info); background: var(--color-info-bg); }

/* Check these settings, and the measures every check shows. */
.check-panel { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-4); min-width: 0; }
.check-title { margin: 0; font-size: 0.95rem; font-weight: 700; }
.check-lead { font-size: 0.78rem; color: var(--color-text-muted); margin: 4px 0 var(--space-3); line-height: 1.5; }
.check-buttons { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.check-out { margin-top: var(--space-3); font-size: 0.85rem; min-width: 0; }
.check-window { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: var(--space-2) 0 0; }
.check-window-label { font-size: 0.78rem; color: var(--color-text-muted); margin-right: 2px; }
/* Finger-sized: these are pressed on phones as often as with a mouse. */
.check-window .toggle-btn { min-height: 40px; min-width: 40px; padding: 6px 12px; font-size: 0.8rem; }
.check-heading { margin: 0 0 var(--space-2); font-size: 0.82rem; line-height: 1.5; }
.check-shortened { display: block; margin-top: 4px; padding: 6px 8px; border-left: 3px solid var(--color-warning); background: var(--color-warning-bg); color: var(--color-text); font-size: 0.78rem; }
/* Test these settings: periods, progress, runs side by side and one run in full. */
.st-panel { display: flex; flex-direction: column; gap: var(--space-2); }
.st-custom { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--color-text-secondary); }
.st-custom input { width: 64px; min-height: 40px; padding: 4px 8px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-bg); color: var(--color-text); font-size: 0.85rem; }
.st-cap { margin: 0; font-size: 0.74rem; color: var(--color-text-muted); line-height: 1.4; }
.st-cap:empty { display: none; }
.st-panel .btn { min-height: 40px; padding: 8px 16px; font-size: 0.85rem; }
.st-status { font-size: 0.82rem; color: var(--color-text-secondary); min-height: 1em; }
.st-progress { display: flex; flex-direction: column; gap: 4px; }
.st-bar { height: 6px; border-radius: 3px; background: var(--color-bg-tertiary); overflow: hidden; }
.st-bar > span { display: block; height: 100%; background: var(--color-accent, #6366f1); transition: width 0.3s ease; }
.st-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.st-table td.st-latest, .st-table th.st-latest { background: var(--color-info-bg); }
/* Compare: a tick per run; a run left unticked is dimmed until the next test drops it. */
.st-keeps { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: var(--space-2); }
.st-keeps-label { font-size: 0.76rem; font-weight: 600; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.st-keep { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; font-size: 0.76rem; font-weight: 500; color: var(--color-text-secondary); cursor: pointer; }
.st-keep input { width: 18px; height: 18px; accent-color: var(--color-primary); }
.st-table .st-dropping { opacity: 0.55; }
.st-compare .bt-figure { margin-top: var(--space-3); }
.st-up { color: var(--color-success); }
.st-down { color: var(--color-danger); }
.st-muted { color: var(--color-text-muted); font-size: 0.78rem; }
.st-pick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--space-2); }
.st-pick .toggle-btn { min-height: 40px; font-size: 0.78rem; }
.st-h { margin: var(--space-3) 0 var(--space-1); font-size: 0.88rem; }
.st-changed { margin: 0 0 var(--space-2); font-size: 0.8rem; line-height: 1.5; overflow-wrap: anywhere; }
.st-detail .measures-wrap { margin-bottom: var(--space-3); }
.st-limits { font-size: 0.78rem; line-height: 1.5; padding: var(--space-2) var(--space-3); border-left: 3px solid var(--color-warning); background: var(--color-warning-bg); margin-bottom: var(--space-2); }
.st-limits ul, .st-how ul { margin: 4px 0 0; padding-left: 18px; }
.st-how { font-size: 0.78rem; color: var(--color-text-secondary); line-height: 1.5; }
.st-how summary { cursor: pointer; min-height: 32px; }
@media (max-width: 560px) {
  /* The tables stack on a phone: the caption spans the width above them. */
  .st-table caption { display: block; width: 100%; }
}
.ai-start { border: 1px dashed var(--color-border); border-radius: var(--radius-md); padding: var(--space-3); min-width: 0; }
.measures-wrap { min-width: 0; }
.measures { width: 100%; border-collapse: collapse; font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.measures caption { caption-side: top; text-align: left; font-size: 0.72rem; color: var(--color-text-muted); padding-bottom: 4px; }
.measures th, .measures td { padding: 5px 8px; border-bottom: 1px solid var(--color-border); text-align: right; }
.measures thead th { font-size: 0.7rem; font-weight: 600; color: var(--color-text-secondary); }
.measures th[scope="row"] { text-align: left; font-weight: 600; overflow-wrap: anywhere; }
.measures-note { display: block; font-size: 0.68rem; font-weight: 400; color: var(--color-text-muted); }
.measures-muted { color: var(--color-text-muted); text-align: left !important; }
.measures-yours { background: var(--color-info-bg); }
.measures-hold th[scope="row"] { font-weight: 400; color: var(--color-text-secondary); }
@media (max-width: 560px) {
  .measures thead { display: none; }
  .measures, .measures tbody, .measures tr { display: block; width: 100%; }
  .measures tr { padding: 6px 0; border-bottom: 1px solid var(--color-border); }
  .measures th[scope="row"] { display: block; border: none; padding: 0 0 2px; }
  .measures td { display: inline-flex; gap: 4px; align-items: baseline; border: none; padding: 2px 12px 2px 0; text-align: left; }
  .measures td::before { content: attr(data-label); font-size: 0.68rem; color: var(--color-text-secondary); }
  .measures td:empty { display: none; }
}

/* "Which tool?" on each testing tool. */
.which-tool { font-size: 0.75rem; color: var(--color-text-secondary); line-height: 1.5; margin: var(--space-2) 0 0; max-width: 80ch; }
.which-tool a { color: var(--color-accent); }

/* The Improve tab. */
.improve-advanced { font-size: 0.78rem; color: var(--color-text-secondary); margin: 0 0 var(--space-3); display: flex; gap: var(--space-2); align-items: baseline; flex-wrap: wrap; line-height: 1.5; }
.improve-card { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); margin-top: var(--space-3); background: var(--color-bg-secondary, var(--color-surface)); min-width: 0; }
.improve-off { margin-top: var(--space-2); }
.improve-h3 { margin: 0 0 var(--space-2); font-size: 0.85rem; font-weight: 700; }
.improve-best { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.improve-evidence { margin-top: var(--space-4); border-top: 1px solid var(--color-border); padding-top: var(--space-3); }
.improve-evidence > summary, .improve-more > summary { cursor: pointer; font-weight: 600; font-size: 0.85rem; color: var(--color-text-secondary); }
.improve-more { margin-bottom: var(--space-5); }
.improve-more[open] > summary { margin-bottom: var(--space-3); }

/* The leaderboard's extra columns, behind "Details". */
.lb-tools { display: flex; justify-content: flex-end; margin-bottom: var(--space-2); }
.lb-toggle { font-size: 0.72rem; padding: 3px 10px; }
.lb-toggle[aria-pressed="true"] { border-color: var(--color-accent); color: var(--color-accent); }
.shadow-table-wrap:not(.lb-show-details) .lb-detail { display: none; }

/* The glossary popover. */
.glossary-btn { background: none; border: none; padding: 0; color: var(--color-accent); font-size: 0.75rem; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.glossary-pop { max-width: min(440px, calc(100vw - 32px)); max-height: min(70vh, 560px); overflow: auto; margin: auto; padding: var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-text); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); }
.glossary-pop::backdrop { background: rgba(0, 0, 0, 0.35); }
.glossary-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-2); }
.glossary-close { background: none; border: 1px solid var(--color-border); border-radius: var(--radius-sm); color: var(--color-text-secondary); font-size: 0.72rem; padding: 2px 8px; cursor: pointer; }
.glossary-list { margin: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.glossary-list dt { font-weight: 700; font-size: 0.8rem; }
.glossary-list dd { margin: 0; font-size: 0.78rem; color: var(--color-text-secondary); line-height: 1.45; }

/* The Strategy Lab is the advanced rung of the ladder. */
.advanced-badge { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--color-text-secondary); color: var(--color-text-secondary); vertical-align: middle; }

/* The Cockpit layout on the bot page (2026-10-17): each tab in two columns
   on a wide screen, so it is about half as tall; one column on a phone. */
.bp-cols { display: grid; grid-template-columns: minmax(0, 1fr); column-gap: var(--space-4); align-items: start; }
.bp-col-main, .bp-col-side { min-width: 0; }
/* Save stays in reach at the bottom of the window while the settings scroll. */
.bp-save { position: sticky; bottom: 0; z-index: 4; background: var(--color-bg); padding: var(--space-3) 0; border-top: 1px solid var(--color-border); }
@media (min-width: 1101px) {
  body[data-route="bots"] .app-main-content { max-width: 1760px; }
  .bp-cols { grid-template-columns: minmax(0, 1fr) minmax(320px, 420px); }
  /* The main column first on screen, whatever the order in the page. */
  .bp-col-main { grid-column: 1; grid-row: 1; }
  .bp-col-side { grid-column: 2; grid-row: 1; }
  #edit-bot-form.bp-form { max-width: none !important; display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  #edit-bot-form.bp-form > #e-config-fields { display: contents; }
  #edit-bot-form.bp-form > [role="alert"], #edit-bot-form.bp-form > [role="status"], #edit-bot-form.bp-form > .bp-save { grid-column: 1 / -1; }
}
@media (max-width: 768px) {
  .bp-save { bottom: 62px; }
  /* On a phone the main things come first. */
  .bp-col-main { order: -1; }
  .bp-cols { display: flex; flex-direction: column; }
}

/* Overview and Activity on one screen (js/fit.js fitToWindow): the tiles stay,
   the two columns below them scroll inside themselves. */
@media (min-width: 1101px) and (min-height: 640px) {
  .bot-panel.fit > * { flex: none; }
  .bot-panel.fit > .bot-tiles { margin-bottom: 0; }
  .bot-panel.fit > .bp-cols { flex: 1; align-items: stretch; }
  /* Each column about a screen at most, scrolling inside past that; the page scrolls a little for the rest. */
  .bot-panel.fit > .bp-cols > .bp-col-main,
  .bot-panel.fit > .bp-cols > .bp-col-side { max-height: calc(100dvh - 140px); overflow: auto; padding-right: 2px; }
  .bot-panel.fit .bp-col-main > :last-child, .bot-panel.fit .bp-col-side > :last-child { margin-bottom: 0; }
}
/* Backtest: its periods in two rows, its result charted (js/backtest-chart.js), and the dialog it opens in. */
.st-row { margin-top: 0; }
.bt-tiles { margin: var(--space-2) 0 var(--space-3); grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2); }
@media (max-width: 640px) { .bt-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.bt-dialog .st-h { text-transform: none; letter-spacing: 0; font-size: 0.9rem; color: var(--color-text); margin-top: var(--space-2); }
.bt-tile { padding: var(--space-2) var(--space-3); }
.bt-tile .bot-tile-value { font-size: 1rem; }
.bt-figure { margin: 0 0 var(--space-3); padding: var(--space-2); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-bg); min-width: 0; }
.bt-caption { font-size: 0.75rem; font-weight: 600; color: var(--color-text-secondary); margin: 0 0 4px 4px; }
.bt-key { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; font-size: 0.74rem; color: var(--color-text-secondary); margin: 4px 4px 0; }
.bt-key span { display: inline-flex; align-items: center; gap: 5px; }
.bt-chart .bt-mark:hover polygon, .bt-chart .bt-mark:hover circle:last-child { stroke: var(--color-text); stroke-width: 1.2; }
.bt-open { min-height: 36px; padding: 6px 14px; font-size: 0.82rem; margin-left: auto; flex: none; }
.bt-dialog { max-width: 1000px; width: calc(100% - 32px); padding: var(--space-4); }
.bt-dialog-head { display: flex; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-2); }
.bt-dialog-head h2 { margin: 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.bt-dialog-sub { margin: 2px 0 0; font-size: 0.78rem; color: var(--color-text-muted); }
.bt-close { margin-left: auto; flex: none; min-height: 40px; }
.bt-dialog .st-panel { border: none; padding: 0; background: transparent; }
@media (max-width: 600px) {
  .bt-dialog { width: 100%; max-width: 100%; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; padding: var(--space-3); }
  .bt-figure { padding: 4px; }
}
.bt-dialog .st-panel > .check-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
