:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --card: 0 0% 100%;
  --border: 240 5.9% 90%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --accent: 240 4.8% 95.9%;
  --ring: 240 5.9% 10%;
  --destructive: 0 84.2% 60.2%;
  --radius: 0.5rem;
  --shadow: 0 1px 2px hsl(240 10% 3.9% / 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: 240 10% 3.9%;
    --foreground: 0 0% 98%;
    --muted: 240 3.7% 15.9%;
    --muted-foreground: 240 5% 64.9%;
    --card: 240 10% 3.9%;
    --border: 240 3.7% 15.9%;
    --primary: 0 0% 98%;
    --primary-foreground: 240 5.9% 10%;
    --accent: 240 3.7% 15.9%;
    --ring: 240 4.9% 83.9%;
    --shadow: 0 1px 2px hsl(0 0% 0% / 0.4);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 15px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

.shell {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid hsl(var(--border));
}

.brand {
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand:hover {
  text-decoration: none;
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.topbar nav a {
  padding: 0.35rem 0.7rem;
  border-radius: calc(var(--radius) - 2px);
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

.topbar nav a:hover {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
  text-decoration: none;
}

h1 {
  margin: 0 0 1rem;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

h2 {
  margin: 1.75rem 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.lead {
  margin: 0 0 1.25rem;
  color: hsl(var(--muted-foreground));
  max-width: 40rem;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.alert {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--muted));
}

.alert[role="status"] code {
  display: block;
  margin-top: 0.35rem;
  word-break: break-all;
}

.filters,
.stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: end;
  margin-bottom: 1.25rem;
}

.stack {
  flex-direction: column;
  align-items: stretch;
  max-width: 36rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
}

.inline {
  flex-direction: row;
  align-items: center;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid hsl(var(--border));
  margin-bottom: 1rem;
}

.tab-btn {
  padding: 0.55rem 0.9rem;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 0;
  background: transparent;
  color: hsl(var(--muted-foreground));
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.tab-btn:hover {
  color: hsl(var(--foreground));
  opacity: 1;
}

.tab-btn.active {
  color: hsl(var(--foreground));
  border-bottom-color: hsl(var(--foreground));
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem 1rem;
}

.tab-panel[hidden] {
  display: none;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  width: 100%;
  min-width: 10rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font: inherit;
}

textarea {
  min-height: 10rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
}

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  padding: 0.45rem 0.85rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
}

button:hover,
.btn:hover {
  opacity: 0.92;
  text-decoration: none;
}

.btn-ghost,
button.ghost {
  background: transparent;
  color: hsl(var(--foreground));
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  gap: 0.75rem;
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
}

.kpi {
  margin: 0;
  padding: 0.85rem 1rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
  box-shadow: var(--shadow);
}

.kpi-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.2;
}
.kpi {
  overflow: visible;
}

.kpi-value {
  font-variant-numeric: tabular-nums;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

th,
td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid hsl(var(--border));
  white-space: nowrap;
}

th {
  color: hsl(var(--muted-foreground));
  font-weight: 500;
  background: hsl(var(--muted));
}

tbody tr:hover {
  background: hsl(var(--accent));
}

/* .accounts-table (Cuentas): cada cuenta agrupa 1+ filas de config con
   rowspan en Nombre/Entorno/Saldo/API/Acciones -- esas celdas solo
   existen en el <tr> de la primera fila del grupo (ver accounts.html).
   Con el "tbody tr:hover" generico de arriba, pasar el mouse por esa
   primera fila resaltaba esas 5 columnas ademas de las suyas, pero
   pasarlo por cualquier otra fila del mismo grupo no resaltaba nada en
   ellas (le pertenecen a otro <tr>) -- inconsistente, la primera fila
   "agarraba" columnas que las demas no. Se limita el resaltado a las
   columnas propias de cada fila (nunca a las de rowspan) para que las
   filas de un mismo grupo se comporten todas igual, y se le da a las
   celdas con rowspan su propio hover puntual (una celda = una cuenta, no
   tiene sentido resaltar todo el grupo para eso). */
.accounts-table tbody tr:hover {
  background: transparent;
}
.accounts-table tbody tr:hover td:not([rowspan]) {
  background: hsl(var(--accent));
}
.accounts-table tbody td[rowspan]:hover {
  background: hsl(var(--accent));
}

tbody tr:last-child td {
  border-bottom: 0;
}
/* Celdas con rowspan que abarcan el ultimo grupo de una tabla agrupada
   (ver accounts.html): su borde inferior real cae en el limite del grupo,
   no de un <tr> puntual, asi que "tbody tr:last-child td" de arriba no las
   alcanza -- el template las marca a mano cuando el grupo es el ultimo. */
.no-border-bottom {
  border-bottom: 0;
}

.empty {
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

.badge {
  display: inline-flex;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: hsl(var(--muted));
  font-size: 0.75rem;
}

/* .shard-balances (Cuentas > columna Saldo): desglose por exchange shard
   de Kalshi (ver docs/api-doc/exchange-sharding.md) -- una linea por
   shard, mas compacta que celdas de tabla separadas ya que esta columna
   comparte fila con Nombre/Entorno via rowspan. Shard en $0 se atenua
   (.muted) para no competir visualmente con los que de verdad tienen
   plata. */
.shard-balances {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.78rem;
  white-space: nowrap;
}
.shard-balances .shard-name {
  color: hsl(var(--muted-foreground));
  margin-right: 0.3rem;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

button.linkish {
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  opacity: 0.85;
}
button.linkish:hover { opacity: 1; }
form.stack label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}
/* "form.stack label" (2 elementos + 1 clase) le gana en especificidad a
   ".inline" (1 clase sola) y lo pisaba con flex-direction:column --
   cualquier <label class="inline"> dentro de un <form class="stack">
   (login, cuentas, stop loss de strategy_config_form.html) terminaba
   apilado y centrado en vez de en una sola linea. Esta regla, mas
   especifica que las dos anteriores, restaura el layout en fila. */
form.stack label.inline {
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
}
/* Mismo problema de especificidad que ".inline" arriba: ".radio-row"
   (checkboxes de "Configuraciones BTC15 activas" en Editar cuenta) tiene
   su propio flex-direction:row, pero "form.stack label" (mas especifica)
   lo pisaba igual, dejando el checkbox en una linea y el nombre/"?"/
   Editar en la siguiente. */
form.stack label.radio-row {
  flex-direction: row;
  gap: 0.5rem;
}
form.stack input[type="text"],
form.stack input[type="password"] {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border, #ccc);
  border-radius: 6px;
  background: var(--bg, #fff);
  color: inherit;
}

.outcome-col {
  width: 2rem;
  text-align: center;
  padding-left: 0.5rem;
  padding-right: 0.25rem;
}
.outcome {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
}
button.outcome {
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
}
button.outcome:hover {
  opacity: 0.85;
  transform: scale(1.08);
}
button.outcome:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}
.outcome-win {
  color: #14532d;
  background: #86efac;
}
.outcome-loss {
  color: #7f1d1d;
  background: #fca5a5;
}
/* Empate: ya se sabe el resultado (cerrado, settlement con pnl conocido)
   y dio exactamente $0 -- ni gano ni perdio. Antes compartia el mismo
   icono/color que "abierta, sin decidir" -- ahora son estados distintos. */
.outcome-breakeven {
  color: #a1a1aa;
  background: #27272a;
}
/* Abierta: todavia sin decision (sigue corriendo, o cerro por otro motivo
   y el settlement/reconciliacion no le puso pnl todavia). */
.outcome-open {
  color: #78350f;
  background: #fde68a;
}

.api-test {
  white-space: nowrap;
}
.api-test .outcome {
  margin-right: 0.35rem;
  vertical-align: middle;
}
.api-test .muted {
  color: #71717a;
  font-size: 0.8rem;
}


.info-tip {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  cursor: help;
  outline: none;
}
.info-tip-icon {
  width: 1rem;
  height: 1rem;
  border-radius: 999px;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  font-size: 0.65rem;
  font-weight: 700;
  font-style: italic;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: hsl(var(--card));
}
.info-tip:hover .info-tip-icon,
.info-tip:focus .info-tip-icon {
  border-color: hsl(var(--foreground));
  color: hsl(var(--foreground));
}
/* Solo visible al hover/focus; el texto NO vive en el layout del KPI */
.info-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.5rem);
  transform: translateX(-50%);
  width: max-content;
  max-width: min(16rem, 70vw);
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  background: #fafafa;
  color: #18181b;
  font-size: 0.75rem;
  font-weight: 500;
  font-style: normal;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  clip-path: inset(50%);
}
.info-tip:hover::after,
.info-tip:focus::after {
  opacity: 1;
  visibility: visible;
  clip-path: none;
}
th .info-tip {
  margin-left: 0.15rem;
}
/* En cabeceras: tooltip hacia ABAJO (si va arriba lo tapa la sección de KPIs
   y overflow-x del table-wrap lo recorta). */
th .info-tip::after {
  top: calc(100% + 0.55rem);
  bottom: auto;
  z-index: 300;
}
.table-wrap {
  overflow-x: auto;
  /* visible en Y no funciona con overflow-x:auto en la mayoría de browsers */
}
.table-wrap thead th {
  position: relative;
  z-index: 2;
  white-space: nowrap;
  overflow: visible;
}
.table-wrap thead th:hover,
.table-wrap thead th:focus-within {
  z-index: 40;
}

.filters-grid label input,
.filters-grid label select {
  min-width: 8rem;
}

.shell-wide {
  max-width: none;
}

.pager {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
  font-size: 0.875rem;
}

.muted {
  color: hsl(var(--muted-foreground));
  font-size: 0.85rem;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
}

.nowrap {
  white-space: nowrap;
}

table.dense th,
table.dense td {
  font-size: 0.75rem;
  padding: 0.35rem 0.45rem;
}

td.ok {
  color: #15803d;
  font-weight: 600;
}

td.bad {
  color: #b91c1c;
  font-weight: 600;
}

@media (prefers-color-scheme: dark) {
  td.ok { color: #4ade80; }
  td.bad { color: #f87171; }
}

/* Modal detalle de sesión (panel) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: hsl(240 10% 3.9% / 0.55);
}
.modal-backdrop.is-open {
  display: flex;
}
.modal-panel {
  width: min(64rem, 100%);
  max-height: min(92vh, 56rem);
  overflow: auto;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 2px);
  background: hsl(var(--card));
  box-shadow: 0 24px 64px hsl(240 10% 3.9% / 0.35);
  padding: 1rem 1.15rem 1.25rem;
}
.modal-panel-sm {
  width: min(22rem, 100%);
  max-height: min(80vh, 30rem);
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}
.modal-head h2 {
  margin: 0;
  font-size: 1.05rem;
}
.modal-sub {
  margin: 0.25rem 0 0;
  color: hsl(var(--muted-foreground));
  font-size: 0.8rem;
}
.modal-close {
  flex-shrink: 0;
  min-width: 2.25rem;
  padding: 0.35rem 0.55rem;
  background: transparent;
  color: hsl(var(--foreground));
}
.modal-section {
  margin-top: 1.1rem;
}
.modal-section h3 {
  margin: 0 0 0.55rem;
  font-size: 0.85rem;
  font-weight: 600;
}
.modal-chart-wrap {
  position: relative;
  height: 18rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 0.5rem;
  background: hsl(var(--background));
}
.modal-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.55rem 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.config-grid li {
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  padding: 0.45rem 0.6rem;
  background: hsl(var(--muted));
}
.config-grid .cfg-k {
  display: block;
  color: hsl(var(--muted-foreground));
  font-size: 0.7rem;
  font-weight: 500;
}
.config-grid .cfg-v {
  display: block;
  margin-top: 0.1rem;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  font-weight: 600;
}
.signals-mini {
  margin: 0.65rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 8rem;
  overflow: auto;
  font-size: 0.78rem;
}
.signals-mini li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
}
.btn-sm {
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
}
td.side-match {
  color: #15803d;
  font-weight: 700;
}
td.side-miss {
  color: #b91c1c;
  font-weight: 700;
}
td.warn {
  color: #a16207;
  font-weight: 600;
}
td.skip {
  color: hsl(var(--muted-foreground));
  font-weight: 500;
}
.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.row-actions form {
  display: inline-flex;
  margin: 0;
}
.row-actions-stacked {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
}
.detail-cell {
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
}
.help-cell {
  max-width: 18rem;
  font-size: 0.78rem;
  line-height: 1.35;
  color: hsl(var(--muted-foreground));
}
.link-cell {
  font-size: 0.78rem;
}

/* Tabla de fallos Kalshi: texto multilínea, columnas fijas */
.rejections-table-wrap {
  overflow-x: auto;
}
.rejections-table {
  table-layout: fixed;
  width: 100%;
  min-width: 72rem;
}
.rejections-table th,
.rejections-table td {
  white-space: normal;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.4;
}
.rejections-table thead th {
  white-space: normal;
  font-size: 0.75rem;
  line-height: 1.3;
}
.rejections-table .col-when { width: 11%; }
.rejections-table .col-account { width: 9%; }
.rejections-table .col-event { width: 11%; }
.rejections-table .col-side { width: 5%; }
.rejections-table .col-outcome { width: 8%; }
.rejections-table .col-detail { width: 14%; }
.rejections-table .col-help { width: 24%; }
.rejections-table .col-timing { width: 12%; }
.rejections-table .col-links { width: 8%; }
.rejections-table .detail-cell {
  max-width: none;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  font-size: 0.72rem;
}
.rejections-table .help-cell {
  max-width: none;
  font-size: 0.78rem;
}
/* .timing-total/.timing-compact/.col-timing: compartidas entre la tabla de
   order-rejections y la de trades del dashboard (misma celda de tiempos,
   ver order_rejections_query.py::_timing_summary). No van escopeadas a
   .rejections-table para que apliquen tambien en #trades-table. */

/* .configs-table (Cuentas > Configuraciones BTC15): sin min-width a
   proposito -- a diferencia de .rejections-table, esta NO debe generar
   scroll horizontal nunca. table-layout:fixed + columnas en % reparten el
   ancho disponible del contenedor, y el Resumen (la celda mas larga, ver
   _config_view en app/routers/admin.py) hace wrap a varias lineas en vez
   de forzar el ancho de la tabla. */
.configs-table {
  table-layout: fixed;
  width: 100%;
}
.configs-table th,
.configs-table td {
  white-space: normal;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.4;
}
.configs-table .col-config-name { width: 20%; }
.configs-table .col-config-summary { width: 52%; }
.configs-table .col-config-accounts { width: 10%; }
.configs-table .col-config-actions { width: 18%; }
.col-timing {
  white-space: normal;
}
.timing-total {
  font-size: 0.82rem;
  font-weight: 600;
}
.timing-compact {
  font-size: 0.68rem;
  color: var(--muted, #8a8f98);
  /* timing_compact trae un "\n" por segmento (uno por linea) -- pre-line
     respeta esos saltos sin necesitar <br> en el HTML generado por JS. */
  white-space: pre-line;
  word-break: break-word;
  line-height: 1.35;
  margin-top: 0.15rem;
}
.timing-total-btn {
  border: none;
  background: transparent;
  padding: 0;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 0.15rem;
}
.timing-total-btn:hover,
.timing-total-btn:focus-visible {
  color: hsl(var(--primary));
}
.strategy-name {
  cursor: help;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 0.15rem;
}
.strategy-hover-tip {
  position: fixed;
  z-index: 400;
  max-width: min(18rem, 80vw);
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  background: #fafafa;
  color: #18181b;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
  white-space: pre-line;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}
.timing-modal-list {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 0.75rem;
}
.timing-modal-list dt {
  color: hsl(var(--muted-foreground));
  font-size: 0.78rem;
}
.timing-modal-list dd {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.rejections-table .link-cell {
  padding-top: 0.5rem;
}
.rejections-table .rej-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.rejections-table .rej-links a {
  display: inline-block;
}
@media (prefers-color-scheme: dark) {
  td.side-match { color: #4ade80; }
  td.side-miss { color: #f87171; }
}

.session-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}
.session-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--muted));
}
.session-badge.ok {
  color: #14532d;
  background: #86efac;
  border-color: #4ade80;
}
.session-badge.bad {
  color: #7f1d1d;
  background: #fca5a5;
  border-color: #f87171;
}
.session-badge.muted {
  color: hsl(var(--muted-foreground));
}
.entries-legend {
  margin: 0.65rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
}
.entries-legend li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: center;
  padding: 0.35rem 0.5rem;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
}
.entries-legend li.is-focused {
  border-color: #dc2626;
  background: rgba(220, 38, 38, 0.06);
}
.entries-legend li.is-rejection {
  border-color: #c4b5fd;
  background: rgba(196, 181, 253, 0.14);
}
.entry-swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 2px;
  flex-shrink: 0;
}
body.modal-open {
  overflow: hidden;
}

.panel-heading {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 1rem;
}
.panel-heading h1 {
  margin: 0;
}
.health-dot {
  position: relative;
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 999px;
  flex-shrink: 0;
  cursor: help;
  box-shadow: 0 0 0 2px hsl(var(--background));
}
.health-dot.health-ok {
  background: #22c55e;
}
.health-dot.health-bad {
  background: #ef4444;
}
.health-dot::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.45rem);
  transform: translateX(-50%);
  width: max-content;
  max-width: min(22rem, 70vw);
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  background: #fafafa;
  color: #18181b;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  z-index: 120;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}
.health-dot:hover::after,
.health-dot:focus::after {
  opacity: 1;
  visibility: visible;
}

.live-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 0.75rem;
  margin: 0 0 1rem;
}

.live-item {
  padding: 0.75rem 1rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
}

.live-label {
  display: block;
  margin-bottom: 0.2rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.live-value {
  display: block;
  font-size: 1.05rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

.live-meta {
  display: block;
  margin-top: 0.2rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.8rem;
  line-height: 1.3;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 0.65rem;
}

.table-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.table-title {
  margin: 0;
  font-size: 1.05rem;
}

.config-picker {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--muted));
}

.config-picker h2 {
  margin: 0 0 0.5rem;
}

.radio-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* .config-item (Editar cuenta > Configuraciones BTC15 activas): agrupa el
   checkbox de una config con su bloque de apuesta (.stake-override) para
   poder separar UNA config de la SIGUIENTE con una linea -- antes todo
   fluia con el mismo gap de .radio-list de arriba, asi que no se notaba
   donde terminaba una config y empezaba otra. Sin borde en la ultima
   (.config-item-last) para no duplicar el borde del .config-picker que ya
   envuelve toda la lista. */
.config-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid hsl(var(--border));
}
.config-item-last {
  padding-bottom: 0;
  border-bottom: 0;
}

.radio-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.5rem;
  font-weight: 400;
  color: hsl(var(--foreground));
}

.radio-row input[type="radio"],
.radio-row input[type="checkbox"] {
  margin-top: 0.2rem;
  flex-shrink: 0;
}

/* Popup "?" generico (mismo look que el de Tick Monitor): boton circular
   que abre un cuadro flotante con texto. Posicionado con JS (position:fixed,
   calculado con getBoundingClientRect del boton) en vez de position:absolute
   dentro de la celda, para que no lo recorte el overflow-x:auto de
   .table-wrap en las tablas. */
.help-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  margin-left: 0.35rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--muted-foreground));
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
}
.help-toggle:hover,
.help-toggle:focus-visible,
.help-toggle.is-active {
  border-color: hsl(var(--foreground));
  color: hsl(var(--foreground));
}
.floating-help-pop {
  position: fixed;
  z-index: 200;
  max-width: min(24rem, 90vw);
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--muted-foreground));
  font-size: 0.8rem;
  line-height: 1.45;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}
.floating-help-pop[hidden] { display: none; }
.section-heading-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.section-heading-row h1,
.section-heading-row h2 {
  margin: 0;
}

/* Input numerico inline de una sola linea (strategy_config_form.html: los
   3 checks de Stop loss + Edge minimo) -- angosto a proposito para que
   checkbox + texto + input + "?" quepan en una sola linea en vez de
   estirarse al ancho default de los inputs (10rem min-width). Selector mas
   especifico que la clase sola (que perdia contra el min-width:10rem
   generico de arriba, mas especifico por sus 2 pseudo-clases
   :not([type=...])) + min-width:0 explicito para que el 30% se respete de
   verdad incluso en un renglon angosto. */
form.stack label.inline input.inline-num {
  width: 30%;
  min-width: 0;
  flex: 0 0 auto;
}


/* Dos campos numéricos lado a lado (Ask Min/Max, T Min/Max en
   strategy_config_form.html). */
.field-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.field-row label {
  flex: 1;
  min-width: 9rem;
}

/* Take profit: 3 niveles combinables, cada uno en un solo renglon (Active +
   Cents + TMin + TMax). .field-row generico usa min-width:9rem por campo
   (pensado para 2 campos anchos como Ask Min/Max, T Min/Max) y con 4 campos
   cortos hace wrap; aca los campos son angostos y no deben estirarse, asi
   que .tp-row/.tp-field/.tp-num no reusan .field-row. */
.tp-row {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
form.stack label.tp-field {
  flex: 0 0 auto;
  min-width: 0;
  gap: 0.4rem;
  margin-bottom: 0;
  white-space: nowrap;
}
form.stack label.tp-field input.tp-num {
  width: 4.5rem;
  min-width: 0;
  flex: 0 0 auto;
}
