/* ==========================================================================
   Design system — the three families every screen builds from.

   Before this file there were six unrelated classes doing overlapping jobs
   (.cta, .chip-toggle, .period-btn, .relevance-toggle, .status-badge,
   .warrants-filter-reset), so a new screen had no way to know which to reuse
   and invented a seventh. They are replaced by three families crossed by
   three axes:

       family   .btn (actions) · .toggle (filters) · .tag (labels)
       tone     accent (default) · critical · warning · neutral · positive
       fill     soft (default, tinted) · solid (filled, white text)

   A tone is declared once, as a pair of custom properties, and every family
   reads them. Adding a tone means adding one rule here, not one rule per
   component.
   ========================================================================== */

/* Every family below sets an explicit `display`, and an author rule beats the
   browser's `[hidden] { display: none }`. Without this the relevance counters
   the portfolio hides at zero stay on screen showing "0" — which they did,
   quietly, long before these components existed. */
[hidden] {
  display: none !important;
}

:root {
  --tone-accent: var(--accent);
  --tone-critical: #d64545;
  --tone-warning: #e0a000;
  --tone-neutral: #8a8f98;
  --tone-positive: #2fa84f;
}

/* Every family resolves its colour through these two, so the tone modifiers
   below are written once and work on all three. */
.btn,
.toggle,
.tag {
  --tone: var(--tone-accent);
  --tone-fill: var(--accent-soft);
}

.tone-critical,
.btn--critical,
.toggle--critical,
.tag--critical {
  --tone: var(--tone-critical);
  --tone-fill: rgba(214, 69, 69, 0.16);
}

.tone-warning,
.btn--warning,
.toggle--warning,
.tag--warning {
  --tone: var(--tone-warning);
  --tone-fill: rgba(224, 160, 0, 0.18);
}

.tone-neutral,
.btn--neutral,
.toggle--neutral,
.tag--neutral {
  --tone: var(--tone-neutral);
  --tone-fill: var(--badge-empty-bg);
}

.tone-positive,
.btn--positive,
.toggle--positive,
.tag--positive {
  --tone: var(--tone-positive);
  --tone-fill: rgba(47, 168, 79, 0.16);
}

/* --------------------------------------------------------------------------
   .btn — something happens when you press it.
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-weight: 700;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  font-size: 0.95rem;
  padding: 12px 28px;
  border: none;
  box-shadow: var(--shadow);
}

.btn--primary:hover {
  transform: translateY(-1px);
}

.btn--quiet {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  padding: 7px 14px;
}

.btn--quiet:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   .toggle — turns a filter on and off. `.is-active` is the state class the
   screen scripts read, so it is the one name that must not drift.
   -------------------------------------------------------------------------- */

.toggle {
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.toggle:hover {
  color: var(--text);
  border-color: var(--text-muted);
  border-color: color-mix(in srgb, var(--text-muted) 45%, var(--border));
}

.toggle.is-active {
  background: var(--tone-fill);
  color: var(--tone);
  border-color: var(--tone);
  border-color: color-mix(in srgb, var(--tone) 45%, transparent);
}

/* Stacked variant: a label over a value, laid out in a grid rather than a row
   — the chart periods and the bot's range and trade filters. */
.toggle--tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  border-radius: 10px;
}

.toggle--tile:hover {
  border-color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}

.toggle--tile.is-active {
  border-color: var(--tone);
  background: var(--tone-fill);
}

.toggle-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
}

.toggle-value {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
}

.toggle-value-up {
  color: #00c853;
}

.toggle-value-down {
  color: #ff5252;
}

.toggle-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

/* --------------------------------------------------------------------------
   .tag — reads a value, never takes a click.
   -------------------------------------------------------------------------- */

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border-radius: 999px;
  background: var(--tone-fill);
  color: var(--tone);
  font-size: 0.72rem;
  padding: 2px 8px;
  letter-spacing: 0.02em;
}

/* Filled: the tone becomes the background and the text turns white. Used when
   the tag is the thing being counted rather than a note beside it. */
.tag--solid {
  background: var(--tone);
  color: #fff;
  box-shadow: 0 0 0 3px var(--tone-fill);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone) 16%, transparent);
}

.tag--status {
  padding: 2px 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tag--count {
  min-width: 26px;
  height: 22px;
  padding: 0 8px;
  font-size: 0.8rem;
}

/* A zero count still shows, greyed: hiding it would make the row jump as
   numbers come and go. */
.tag--count.is-empty {
  background: var(--badge-empty-bg);
  color: var(--badge-empty-text);
  box-shadow: none;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* --------------------------------------------------------------------------
   Focus is a system-wide guarantee, not a per-component decision.
   -------------------------------------------------------------------------- */

.btn:focus-visible,
.toggle:focus-visible,
.tag:focus-visible {
  outline: 2px solid var(--accent);
  outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Compartido entre pantallas: el titular de una cifra grande, la tabla de
   datos y los tonos de ganancia/pérdida. Vivían en la CSS de Operaciones
   hasta que IBroker Bot los reutilizó — una clase que usan dos pantallas no
   puede vivir en el fichero de una de ellas.
   -------------------------------------------------------------------------- */
/* Bot performance: the hero figure, the per-asset table and the range bar.
   .chart-summary and the .period-* buttons stay shared — the price chart and
   observability use the same shell. */
/* Operaciones — rendimiento del bot */
.bot-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bot-hero-label {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.bot-hero-value {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

/* Un punto por debajo del importe: acompaña a la cifra sin competir con ella,
   pero sigue leyéndose desde lejos. */
.bot-hero-pct {
  font-size: 0.75em;
  font-weight: 600;
}

.bot-hero-delta {
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* Verde y rojo no llevan solos el signo en ningún sitio: aquí siempre van con
   el "+"/"−" delante del número, y en los gráficos con el lado del eje cero. */
.pnl-up {
  color: #23913f;
}

.pnl-down {
  color: #c93b3b;
}

.table-scroll {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.data-table thead th {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
}

.data-table th[scope="row"],
.data-table thead th:first-child {
  text-align: left;
  font-weight: 600;
}

.data-table tbody tr + tr th,
.data-table tbody tr + tr td {
  border-top: 1px solid var(--border);
}

