/* ═══════════════════════════════════════════════════════════════
   Markets Analyzer — Design System v5 · Minimalista

   Principios:
   · El espacio separa, no las líneas. Bordes solo donde son necesarios.
   · Una sola tinta de acento, usada con moderación.
   · Sin degradados, sin brillos, sin sombras decorativas.
   · Jerarquía por tamaño y peso tipográfico, no por color.
   · El color se reserva para lo semántico: sube, baja, alerta.
   · Los datos mandan; el interfaz desaparece.

   Los nombres de las variables son API pública: app.js las usa en
   estilos inline. No renombrar.
   ═══════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ── Tokens · oscuro ─────────────────────────────────────────── */
:root {
  /* Superficies: grises neutros, sin azulado */
  --bg-0: #101012;
  --bg-1: #17171a;
  --bg-2: #1d1d21;
  --bg-3: #26262b;
  --border: #26262a;
  --border-strong: #35353b;

  /* Texto: contraste alto en lo principal, discreto en lo secundario */
  --text: #ededee;
  --text-soft: #9b9ba1;
  --muted: #6e6e75;

  /* Acento único y sobrio */
  --cyan: #e0a340;
  --cyan-soft: rgba(224, 163, 64, 0.10);
  --cyan-glow: rgba(224, 163, 64, 0.20);

  /* Semánticos: apagados, no fosforitos */
  --green: #3fb27f;
  --green-soft: rgba(63, 178, 127, 0.10);
  --red: #d9534f;
  --red-soft: rgba(217, 83, 79, 0.10);
  --yellow: #d6a419;
  --yellow-soft: rgba(214, 164, 25, 0.10);
  --orange: #d18b3c;
  --purple: #9b8cd4;
  --blue: #5a8dd6;

  /* Sin degradados reales: se mantienen planos por compatibilidad */
  --grad-accent: var(--cyan);
  --grad-hero: var(--bg-1);

  --shadow-sm: none;
  --shadow-md: 0 1px 3px rgba(0,0,0,0.28);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.40);

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;

  --sidebar-w: 216px;
  --topbar-h: 60px;
  --tabbar-h: 60px;
  --gutter: 28px;

  --ring: 0 0 0 3px rgba(224, 163, 64, 0.22);
  --mono: 'JetBrains Mono', 'SF Mono', Consolas, ui-monospace, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Tokens · claro ──────────────────────────────────────────── */
:root[data-theme="light"] {
  --bg-0: #fbfbfa;
  --bg-1: #ffffff;
  --bg-2: #f5f5f4;
  --bg-3: #ebebe9;
  --border: #e8e8e6;
  --border-strong: #d2d2cf;
  --text: #1a1a1c;
  --text-soft: #5c5c63;
  --muted: #8a8a91;
  --cyan: #a06a10;
  --cyan-soft: rgba(160, 106, 16, 0.07);
  --cyan-glow: rgba(160, 106, 16, 0.16);
  --green: #17805a;
  --green-soft: rgba(23, 128, 90, 0.08);
  --red: #b8393a;
  --red-soft: rgba(184, 57, 58, 0.08);
  --yellow: #8c6d0a;
  --yellow-soft: rgba(140, 109, 10, 0.08);
  /* Categóricos: solo estaban definidos en oscuro, así que en tema claro se
     pintaban en tono pastel sobre blanco (por debajo del 3:1 que WCAG pide a
     un objeto gráfico). Mismos nombres, versión legible sobre papel. */
  --orange: #b8631a;
  --purple: #6f52c9;
  --blue: #2f6fbf;
  --grad-hero: var(--bg-1);
  --shadow-md: 0 1px 3px rgba(26,26,28,0.06);
  --shadow-lg: 0 8px 32px rgba(26,26,28,0.10);
}

/* ── Base ────────────────────────────────────────────────────── */
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--sans);
  background: var(--bg-0);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}

a { color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border-strong); }
a:hover { border-bottom-color: var(--cyan); }
button { cursor: pointer; background: none; border: none; }
.hidden { display: none !important; }

td, th, .num, .mono, .value, .tk,
input[type="number"], input[type="search"] { font-variant-numeric: tabular-nums; }
.mono, .tk, td.num, th.num, .value { font-family: var(--mono); }

/* ── Accesibilidad ───────────────────────────────────────────── */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  background: var(--text); color: var(--bg-0);
  padding: 12px 20px; font-weight: 600;
}
.skip-link:focus { left: 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ═══════════════════════════════════════════════════════════════
   Shell
   ═══════════════════════════════════════════════════════════════ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--bg-0);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 200;
  transition: transform 0.2s ease;
}

.brand {
  display: flex; align-items: center; gap: 9px;
  padding: 0 22px; min-height: var(--topbar-h);
}
.brand-logo { font-size: 15px; opacity: .8; }
.brand-name { font-size: 14px; font-weight: 400; color: var(--text-soft); letter-spacing: -0.01em; }
.brand-name b { font-weight: 600; color: var(--text); }

.nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.nav-group { margin-bottom: 22px; }
.nav-group-label {
  font-size: 10px; font-weight: 500; text-transform: uppercase;
  letter-spacing: .1em; color: var(--muted);
  padding: 0 10px; margin-bottom: 8px;
}

.tab {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px; margin-bottom: 1px;
  border-radius: var(--r-sm);
  color: var(--text-soft);
  font-size: 13.5px; font-weight: 400; text-align: left;
  transition: color .12s, background .12s;
  /* .tab también se usa en un <a> (enlace a /dropship): anulamos el subrayado
     por borde que la regla global de `a` añade. En los <button> no cambia nada. */
  text-decoration: none; border-bottom: 0;
}
.tab-ico { font-size: 13px; width: 18px; text-align: center; flex: none; opacity: .6; }
.tab:hover { color: var(--text); background: var(--bg-2); }
.tab.active { color: var(--text); background: var(--bg-2); font-weight: 500; }
.tab.active .tab-ico { opacity: 1; }

.sidebar-footer {
  padding: 14px 18px;
  display: flex; align-items: center; gap: 8px;
  border-top: 1px solid var(--border);
}
.user-badge {
  flex: 1; min-width: 0; color: var(--muted); font-size: 12px;
  text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-badge:hover { color: var(--text); }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 190; }
.sidebar-overlay.show { display: block; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 150;
  min-height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 10px var(--gutter);
  background: var(--bg-0);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.menu-btn {
  display: none; color: var(--text-soft);
  font-size: 17px; padding: 8px 10px; line-height: 1;
}
.page-title {
  font-size: 15px; font-weight: 500; letter-spacing: -0.01em;
  margin-right: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.search { display: flex; gap: 8px; align-items: center; }
.search input, .search select {
  background: var(--bg-1); border: 1px solid var(--border);
  color: var(--text); padding: 8px 12px;
  border-radius: var(--r-sm); font-size: 13px; height: 36px;
  transition: border-color .15s;
}
.search input {
  width: 190px; text-transform: uppercase;
  font-weight: 500; font-family: var(--mono); letter-spacing: .02em;
}
.search input::placeholder {
  text-transform: none; font-weight: 400; font-family: var(--sans);
  letter-spacing: 0; color: var(--muted);
}
.search input:focus, .search select:focus {
  outline: none; border-color: var(--border-strong);
}

/* ── Botones ─────────────────────────────────────────────────── */
.btn {
  background: var(--text); color: var(--bg-0);
  font-weight: 500; font-size: 13px;
  padding: 0 18px; height: 36px;
  border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  white-space: nowrap;
  transition: opacity .15s;
}
.btn:hover:not(:disabled) { opacity: .85; }
.btn:disabled { opacity: .35; cursor: not-allowed; }

.btn-ghost {
  border: 1px solid var(--border); color: var(--text-soft);
  padding: 7px 14px; border-radius: var(--r-sm);
  font-size: 12.5px; font-weight: 400; white-space: nowrap;
  transition: border-color .15s, color .15s;
}
.btn-ghost:hover:not(:disabled) { border-color: var(--border-strong); color: var(--text); }
.btn-ghost:disabled { opacity: .4; cursor: not-allowed; }
.btn-danger { background: var(--red); color: #fff; }

/* ── Contenido ───────────────────────────────────────────────── */
.container {
  padding: 32px var(--gutter) 80px;
  max-width: 1360px; width: 100%; margin: 0 auto;
}
.panel { display: none; }
.panel.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ── Tipografía ──────────────────────────────────────────────── */
h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
h2 {
  margin: 0 0 24px; font-size: 20px; font-weight: 600; letter-spacing: -0.02em;
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
}
h3 {
  margin: 40px 0 14px; font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: .12em; color: var(--muted);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
h4 { font-size: 13px; font-weight: 500; color: var(--text-soft); margin: 18px 0 8px; }
p { margin-bottom: 10px; }
.sub { color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.win { color: var(--green); font-weight: 500; }
.loss { color: var(--red); font-weight: 500; }

.section-intro {
  padding: 0 0 20px; margin-bottom: 8px;
  font-size: 13.5px; line-height: 1.7; color: var(--text-soft);
  max-width: 78ch;
}
.section-intro b { color: var(--text); font-weight: 500; }

/* ── Guía plegable ───────────────────────────────────────────── */
.interp-guide {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.interp-guide > summary {
  cursor: pointer; padding: 14px 0;
  color: var(--text-soft); font-weight: 400; font-size: 13px;
  list-style: none; display: flex; align-items: center; gap: 8px;
}
.interp-guide > summary:hover { color: var(--text); }
.interp-guide > summary::-webkit-details-marker { display: none; }
.interp-guide > summary::after {
  content: '+'; font-size: 15px; margin-left: auto; color: var(--muted);
}
.interp-guide[open] > summary::after { content: '−'; }
.interp-body { padding: 0 0 22px; }
.interp-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 24px;
}
.interp-grid > div { font-size: 12.5px; line-height: 1.7; color: var(--muted); }
.interp-grid > div b { display: block; margin-bottom: 5px; color: var(--text); font-weight: 500; }

/* ── Tarjetas KPI: sin bordes, separadas por espacio ─────────── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px; margin-bottom: 28px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.card {
  background: var(--bg-0); padding: 18px 20px;
  transition: background .15s;
}
.card:hover { background: var(--bg-1); }
.card .label {
  color: var(--muted); font-size: 11px; font-weight: 400;
  letter-spacing: .02em; margin-bottom: 8px;
}
.card .value { font-size: 22px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.2; }
.card .sub { margin-top: 5px; font-size: 11.5px; }
/* El acento de estado es una barra fina, no un bloque de color */
.card.green .value { color: var(--green); }
.card.red .value { color: var(--red); }
.card.yellow .value { color: var(--yellow); }
.card.cyan .value { color: var(--text); }

/* ── Chips de resumen ────────────────────────────────────────── */
.stat-row {
  display: flex; gap: 0; flex-wrap: wrap; margin-bottom: 28px;
  border: 1px solid var(--border); border-radius: var(--r); overflow: hidden;
}
.stat-chip {
  padding: 14px 20px; min-width: 110px; flex: 1 1 auto;
  border-right: 1px solid var(--border);
}
.stat-chip:last-child { border-right: none; }
.stat-chip .k { font-size: 11px; color: var(--muted); font-weight: 400; }
.stat-chip .v { font-family: var(--mono); font-size: 19px; font-weight: 500; margin-top: 3px; }
.stat-chip.green .v { color: var(--green); }
.stat-chip.red .v { color: var(--red); }
.stat-chip.yellow .v { color: var(--yellow); }

/* ── Pastillas ───────────────────────────────────────────────── */
.signal-pill {
  display: inline-block; padding: 3px 9px; border-radius: var(--r-sm);
  font-size: 10.5px; font-weight: 500; letter-spacing: .02em; white-space: nowrap;
}
.signal-pill.green { background: var(--green-soft); color: var(--green); }
.signal-pill.red { background: var(--red-soft); color: var(--red); }
.signal-pill.yellow { background: var(--yellow-soft); color: var(--yellow); }
.signal-pill.gray { background: var(--bg-2); color: var(--muted); }
.signal-pill.cyan { background: var(--cyan-soft); color: var(--cyan); }

.tag {
  display: inline-block; background: var(--bg-2); color: var(--text-soft);
  padding: 3px 9px; border-radius: var(--r-sm); font-size: 11px; font-weight: 400;
}
.tags { display: flex; flex-wrap: wrap; gap: 5px; }

.confluence-badge {
  display: inline-block; padding: 2px 8px; border-radius: var(--r-sm);
  font-size: 10px; font-weight: 500; letter-spacing: .02em;
}
.confluence-badge.extrema { background: var(--green-soft); color: var(--green); }
.confluence-badge.alta { background: var(--green-soft); color: var(--green); }
.confluence-badge.media { background: var(--yellow-soft); color: var(--yellow); }
.confluence-badge.baja { background: var(--bg-2); color: var(--muted); }

/* ── Banner de acción: sin fondo, solo una línea de acento ───── */
.action-banner {
  border-left: 2px solid var(--border-strong);
  padding: 4px 0 4px 20px; margin-bottom: 28px;
  display: flex; align-items: flex-start; gap: 16px;
}
.action-banner.green { border-left-color: var(--green); }
.action-banner.red { border-left-color: var(--red); }
.action-banner.yellow { border-left-color: var(--yellow); }
.action-banner.gray { border-left-color: var(--border-strong); }
.action-icon { font-size: 20px; flex: none; opacity: .9; }
.action-text { flex: 1; min-width: 0; }
.action-text .title { font-size: 16px; font-weight: 600; margin-bottom: 4px; letter-spacing: -0.01em; }
.action-text .desc { font-size: 13px; color: var(--text-soft); line-height: 1.6; }

/* ═══════════════════════════════════════════════════════════════
   Tablas
   ═══════════════════════════════════════════════════════════════ */
.data-wrap {
  border: 1px solid var(--border); border-radius: var(--r);
  overflow: auto; max-height: 76vh; background: var(--bg-0);
  -webkit-overflow-scrolling: touch;
}
table.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; margin: 0; }
table.data-table thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--bg-0);
  border-bottom: 1px solid var(--border);
  padding: 0; white-space: nowrap;
  font-size: 11px; font-weight: 400; letter-spacing: .02em;
  color: var(--muted); text-align: left;
}
table.data-table thead th:not(:has(.th-btn)) { padding: 13px 16px; }
.th-btn {
  width: 100%; color: var(--muted);
  font-size: 11px; font-weight: 400; letter-spacing: .02em;
  padding: 13px 16px; text-align: left;
  display: flex; align-items: center; gap: 5px;
  transition: color .12s;
}
.th-btn:hover { color: var(--text); }
th[aria-sort="ascending"] .th-btn, th[aria-sort="descending"] .th-btn { color: var(--text); }
.th-arrow { font-size: 8px; opacity: .7; }
table.data-table th.num .th-btn { justify-content: flex-end; text-align: right; }
table.data-table th.num:not(:has(.th-btn)), table.data-table td.num { text-align: right; }

table.data-table tbody td {
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data-table tbody tr:hover td { background: var(--bg-1); }
table.data-table tbody tr.row-selected td { background: var(--bg-2); }
table.data-table tbody tr:last-child td { border-bottom: none; }

.tk { font-weight: 500; color: var(--text); font-size: 13.5px; letter-spacing: 0; }
.co-name {
  color: var(--muted); font-size: 11.5px; max-width: 190px; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
tr.detail-row td { background: var(--bg-1); padding: 28px; border-bottom: 1px solid var(--border); }

table:not(.data-table) {
  width: 100%; border-collapse: separate; border-spacing: 0;
  border: 1px solid var(--border); border-radius: var(--r);
  overflow: hidden; margin-bottom: 20px; font-size: 13px;
}
table:not(.data-table) th, table:not(.data-table) td {
  padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border);
}
table:not(.data-table) th {
  color: var(--muted); font-size: 11px; font-weight: 400; letter-spacing: .02em;
}
table:not(.data-table) tbody tr:last-child td { border-bottom: none; }
table:not(.data-table) tbody tr:hover td { background: var(--bg-1); }

/* ── Sparkline y score ───────────────────────────────────────── */
.spark { width: 100px; height: 26px; }
.spark-cell { display: flex; align-items: center; gap: 10px; }
.spark-chg { font-family: var(--mono); font-size: 11.5px; font-weight: 400; }

.score-cell { display: flex; align-items: center; gap: 9px; justify-content: flex-end; }
.score-num { font-family: var(--mono); font-weight: 500; min-width: 26px; text-align: right; }
.score-track { width: 38px; height: 3px; background: var(--bg-3); border-radius: 2px; overflow: hidden; flex: none; }
.score-fill { height: 100%; border-radius: 2px; }
.score-badge {
  background: var(--bg-2); color: var(--text);
  padding: 4px 11px; border-radius: var(--r-sm);
  font-family: var(--mono); font-weight: 500; font-size: 12.5px;
}

/* ── Filtros ─────────────────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 20px; align-items: flex-end; flex-wrap: wrap;
  padding: 0 0 22px; margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.filter-bar .fg { display: flex; flex-direction: column; gap: 6px; }
.filter-bar .fl, label.fl {
  font-size: 11px; letter-spacing: .02em; color: var(--muted); font-weight: 400;
}
.filter-bar input, .filter-bar select,
.port-input, .holding-input, .disc-select, .disc-text {
  background: var(--bg-0); border: 1px solid var(--border);
  color: var(--text); padding: 8px 11px;
  border-radius: var(--r-sm); font-size: 13px; height: 36px;
  transition: border-color .15s; min-width: 0;
}
.filter-bar input:focus, .filter-bar select:focus,
.port-input:focus, .holding-input:focus {
  outline: none; border-color: var(--border-strong);
}
.filter-bar select, select.port-input { cursor: pointer; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--cyan); cursor: pointer; }

.port-form-bar, .holding-form, .discover-toolbar {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 0 0 22px; margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.holding-form { margin-top: 18px; padding: 18px 0 0; border-bottom: none; border-top: 1px solid var(--border); }

/* ── Tarjetas de contenido ───────────────────────────────────── */
.port-card {
  border: 1px solid var(--border); border-radius: var(--r);
  padding: 24px; margin-bottom: 18px;
}
.port-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.port-name { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }

.candidates-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.candidate-card { background: var(--bg-0); padding: 20px; cursor: pointer; transition: background .15s; }
.candidate-card:hover { background: var(--bg-1); }
.candidate-card .ticker { font-size: 16px; font-weight: 500; font-family: var(--mono); }
.candidate-card .ticker-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.candidate-card .name { font-size: 12.5px; color: var(--text-soft); margin-bottom: 4px; }
.candidate-card .meta { font-size: 11.5px; color: var(--muted); margin-bottom: 12px; }
.candidate-card .metrics {
  display: grid; grid-template-columns: 1fr 1fr; gap: 5px 14px;
  font-size: 11.5px; color: var(--muted); padding-top: 12px; border-top: 1px solid var(--border);
}
.candidate-card .metrics b { color: var(--text); font-family: var(--mono); font-weight: 500; }

/* ── Desglose por pilar ──────────────────────────────────────── */
.bd-panel { padding-top: 4px; }
.bd-pillar { margin-bottom: 16px; }
.bd-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; margin-bottom: 6px; gap: 10px; color: var(--text-soft); }
.bd-head b { color: var(--text); font-family: var(--mono); font-weight: 500; }
.bd-bar { height: 3px; background: var(--bg-3); border-radius: 2px; overflow: hidden; }
.bd-fill { height: 100%; border-radius: 2px; }
.bd-metrics { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 7px; }
.bd-m { font-size: 11.5px; color: var(--muted); }
.bd-m b { color: var(--text-soft); font-family: var(--mono); font-weight: 400; }

/* ── Criterios ───────────────────────────────────────────────── */
.criterion-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 40px; }
.criterion {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--text-soft);
}
.criterion .pass { color: var(--green); font-weight: 400; }
.criterion .fail { color: var(--red); font-weight: 400; }

.verdict-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; margin-bottom: 28px; }
.verdict-item { border-left: 2px solid var(--border-strong); padding-left: 18px; }
.verdict-item.green { border-left-color: var(--green); }
.verdict-item.yellow { border-left-color: var(--yellow); }
.verdict-item.red { border-left-color: var(--red); }
.verdict-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 7px; }
.verdict-cat { font-size: 11px; color: var(--muted); letter-spacing: .02em; }
.verdict-text { font-size: 13px; line-height: 1.65; color: var(--text-soft); }

/* ── Gráficos ────────────────────────────────────────────────── */
.chart {
  border: 1px solid var(--border); border-radius: var(--r);
  padding: 10px; margin-bottom: 28px; min-height: 300px; overflow: hidden;
}

/* ── Estados ─────────────────────────────────────────────────── */
.loading { text-align: center; padding: 72px 20px; color: var(--muted); font-size: 13px; }
.loading::after { content: ''; }

.error-box {
  border-left: 2px solid var(--red);
  color: var(--red); padding: 4px 0 4px 18px;
  margin: 18px 0; font-size: 13px; line-height: 1.6;
}

.empty-state { text-align: center; padding: 80px 26px; }
.empty-state .ico { font-size: 30px; margin-bottom: 16px; opacity: .5; }
.empty-state .t { font-size: 16px; font-weight: 500; margin-bottom: 8px; }
.empty-state p { max-width: 500px; margin: 0 auto; }

.ml-progress {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 80px 20px; gap: 18px;
}
.ml-progress-icon { font-size: 24px; opacity: .6; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .35; } 50% { opacity: .8; } }
.ml-progress-title { font-size: 15px; font-weight: 500; }
.ml-progress-stage { font-size: 12.5px; color: var(--muted); text-align: center; min-height: 18px; max-width: 460px; }
.ml-progress-track { width: 100%; max-width: 320px; height: 2px; background: var(--bg-3); border-radius: 2px; overflow: hidden; }
.ml-progress-fill { height: 100%; background: var(--text-soft); transition: width .5s ease; min-width: 2px; }
.ml-progress-pct { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* ── Autocompletado ──────────────────────────────────────────── */
.ticker-box { position: relative; display: flex; }
.ticker-suggest {
  position: absolute; top: calc(100% + 6px); left: 0;
  min-width: 300px; max-width: 420px; max-height: 320px; overflow-y: auto;
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-lg); z-index: 300;
}
.suggest-item {
  display: flex; align-items: baseline; gap: 10px;
  padding: 11px 14px; cursor: pointer; font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover, .suggest-item.active { background: var(--bg-2); }
.suggest-sym { color: var(--text); font-weight: 500; font-family: var(--mono); min-width: 58px; }
.suggest-name { flex: 1; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-exch { color: var(--muted); font-size: 11px; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); width: 100%; max-width: 420px;
  max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; padding: 0; font-size: 15px; text-transform: none; letter-spacing: -0.01em; color: var(--text); font-weight: 500; }
.modal-close { color: var(--muted); font-size: 16px; padding: 4px 8px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; }
.modal-body input {
  width: 100%; background: var(--bg-0); border: 1px solid var(--border);
  color: var(--text); padding: 10px 13px; border-radius: var(--r-sm);
  margin-bottom: 12px; font-size: 13.5px;
}
.modal-body input:focus { outline: none; border-color: var(--border-strong); }
.modal-body .btn { width: 100%; }
.account-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--text-soft);
}
.account-row b { color: var(--text); font-family: var(--mono); font-weight: 500; }
.danger-zone { margin-top: 24px; }
.danger-zone summary { color: var(--red); font-size: 13px; cursor: pointer; padding: 8px 0; }
.account-msg { margin-top: 14px; font-size: 13px; text-align: center; }
.account-msg.ok { color: var(--green); }
.account-msg.err { color: var(--red); }

/* ── Login ───────────────────────────────────────────────────── */
.login-box { max-width: 340px; margin: 16vh auto 0; padding: 0 24px; }
.login-box h1 { margin-bottom: 32px; text-align: center; font-size: 20px; font-weight: 500; }
.login-box input {
  width: 100%; background: var(--bg-0); border: 1px solid var(--border);
  color: var(--text); padding: 12px 14px; border-radius: var(--r-sm);
  margin-bottom: 12px; font-size: 14px;
}
.login-box input:focus { outline: none; border-color: var(--border-strong); }
.login-box .btn { width: 100%; height: 44px; }
.login-error { color: var(--red); margin-top: 14px; text-align: center; font-size: 13px; }
.login-hint { color: var(--muted); font-size: 12px; margin: -4px 0 14px; line-height: 1.6; }
.login-toggle { text-align: center; margin-top: 20px; color: var(--muted); font-size: 13px; }
.link-btn { color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border-strong); padding: 0; }
.link-btn:hover { border-bottom-color: var(--text); }

/* ── Barra inferior móvil ────────────────────────────────────── */
.tabbar { display: none; }

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 5px; border: 3px solid var(--bg-0); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ═══════════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 1080px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); background: var(--bg-1); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; align-items: center; }
}

@media (max-width: 720px) {
  :root { --gutter: 18px; }

  .container { padding: 22px var(--gutter) calc(var(--tabbar-h) + 32px); }
  .topbar { padding: 10px var(--gutter); gap: 10px; }
  .page-title { font-size: 15px; flex: 1; }
  .search { flex: 1 1 100%; order: 3; }
  .search input { flex: 1; width: auto; min-width: 0; }

  h2 { font-size: 18px; margin-bottom: 18px; }
  h3 { margin: 30px 0 12px; }

  .cards { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 14px 15px; }
  .card .value { font-size: 18px; }
  .stat-chip { flex: 1 1 50%; min-width: 0; padding: 12px 15px; }
  .stat-chip:nth-child(2n) { border-right: none; }
  .stat-chip .v { font-size: 16px; }

  .filter-bar { gap: 14px; padding-bottom: 18px; }
  .filter-bar .fg { flex: 1 1 calc(50% - 7px); min-width: 0; }
  .filter-bar input, .filter-bar select, .filter-bar .btn, .filter-bar .btn-ghost { width: 100%; }
  .port-form-bar > *, .holding-form > * { flex: 1 1 100%; }

  .data-wrap { max-height: none; }
  table.data-table { font-size: 12px; }
  table.data-table thead th:first-child,
  table.data-table tbody td:first-child {
    position: sticky; left: 0; z-index: 2; background: var(--bg-0);
  }
  table.data-table thead th:first-child { z-index: 4; }
  table.data-table tbody tr:hover td:first-child { background: var(--bg-1); }
  table.data-table tbody td { padding: 11px 12px; }
  .th-btn, table.data-table thead th:not(:has(.th-btn)) { padding: 11px 12px; }
  .co-name { max-width: 120px; }
  .spark { width: 70px; height: 22px; }
  tr.detail-row td { padding: 20px 14px; }

  table:not(.data-table) { display: block; overflow-x: auto; white-space: nowrap; }

  .interp-grid, .criterion-list, .verdict-grid { grid-template-columns: 1fr; gap: 18px; }
  .candidates-grid { grid-template-columns: 1fr; }
  .action-banner { padding-left: 16px; gap: 12px; }
  .action-text .title { font-size: 15px; }
  .chart { min-height: 240px; }
  .login-box { margin: 8vh auto 0; }

  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 180;
    height: var(--tabbar-h);
    background: var(--bg-0);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar button {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 3px;
    color: var(--muted); font-size: 10px; font-weight: 400;
    padding: 8px 2px; min-height: 44px;
  }
  .tabbar button .ico { font-size: 16px; opacity: .55; }
  .tabbar button.active { color: var(--text); }
  .tabbar button.active .ico { opacity: 1; }
}

@media (max-width: 400px) {
  .cards { grid-template-columns: 1fr; }
  .stat-chip { flex: 1 1 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .stat-chip:last-child { border-bottom: none; }
  .filter-bar .fg { flex: 1 1 100%; }
}

@media (min-width: 1600px) { .container { max-width: 1440px; } }

@media print {
  .sidebar, .topbar, .tabbar, .filter-bar, .btn, .btn-ghost { display: none !important; }
  .main { margin: 0; }
  .data-wrap { max-height: none; overflow: visible; }
  body { background: #fff; color: #000; }
}

/* ═══════════════════════════════════════════════════════════════
   Sistema de ayuda contextual
   Un icono discreto junto a cualquier término. Al pasar el ratón o
   al pulsarlo (táctil / teclado) muestra qué significa. Es un
   <button> real para que funcione con teclado y lectores de pantalla.
   ═══════════════════════════════════════════════════════════════ */
.help {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; margin-left: 5px;
  border: 1px solid var(--border-strong); border-radius: 50%;
  color: var(--muted); font-size: 9.5px; font-weight: 600;
  line-height: 1; vertical-align: middle; flex: none;
  transition: color .12s, border-color .12s;
}
.help:hover, .help[aria-expanded="true"] { color: var(--text); border-color: var(--text-soft); }

.help-pop {
  position: fixed; z-index: 500;
  max-width: 330px;
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  padding: 14px 16px;
  font-size: 12.5px; line-height: 1.65; color: var(--text-soft);
  font-weight: 400; text-transform: none; letter-spacing: 0;
}
.help-pop .h {
  display: block; color: var(--text); font-weight: 500;
  font-size: 13px; margin-bottom: 6px;
}
.help-pop .ex {
  display: block; margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border);
  color: var(--muted); font-size: 11.5px;
}
.help-pop code {
  font-family: var(--mono); font-size: 11.5px;
  background: var(--bg-2); padding: 1px 5px; border-radius: 3px; color: var(--text);
}

/* En móvil ocupa el ancho disponible, anclado abajo */
@media (max-width: 720px) {
  .help-pop {
    left: 12px !important; right: 12px !important;
    max-width: none; width: auto;
  }
  .help { width: 18px; height: 18px; font-size: 11px; }
}

/* ═══════════════════════════════════════════════════════════════
   Densidad de terminal
   La firma de una terminal financiera es ver MUCHOS datos a la vez.
   Se comprime la retícula sin renunciar al cromado sobrio: menos
   altura de fila, números monoespaciados y color solo como dato.
   ═══════════════════════════════════════════════════════════════ */
table.data-table.dense thead th { font-size: 10px; }
table.data-table.dense thead th:not(:has(.th-btn)) { padding: 8px 11px; }
table.data-table.dense .th-btn { padding: 8px 11px; font-size: 10px; }
table.data-table.dense tbody td { padding: 7px 11px; font-size: 12.5px; line-height: 1.35; }
table.data-table.dense .tk { font-size: 12.5px; }
table.data-table.dense .co-name { font-size: 10.5px; margin-top: 1px; max-width: 150px; }
table.data-table.dense tbody tr { border-left: 2px solid transparent; }
/* Franja lateral: estado de la fila de un vistazo, sin leerla */
table.data-table.dense tbody tr.rank-a { border-left-color: var(--green); }
table.data-table.dense tbody tr.rank-b { border-left-color: var(--yellow); }
table.data-table.dense tbody tr.rank-c { border-left-color: var(--border-strong); }
table.data-table.dense tbody tr.rank-warn { border-left-color: var(--red); }

/* Celda-mapa de calor: la intensidad del fondo ES el dato.
   Permite comparar una columna entera de un barrido visual. */
.heat { position: relative; }
.heat > .v { position: relative; z-index: 1; }
.heat > .bg {
  position: absolute; inset: 2px 3px; border-radius: 3px;
  z-index: 0; pointer-events: none;
}

/* Barra compacta dentro de celda (score, pilar) */
.minibar {
  display: inline-block; vertical-align: middle;
  width: 34px; height: 3px; margin-left: 6px;
  background: var(--bg-3); border-radius: 2px; overflow: hidden;
}
.minibar > i { display: block; height: 100%; border-radius: 2px; }

/* Cabecera compacta de valor: ticker, precio y variación en una línea */
.row-ident { display: flex; align-items: baseline; gap: 7px; }
.row-ident .tk { flex: none; }
.row-ident .chg { font-family: var(--mono); font-size: 11px; }

/* Rejilla de métricas dentro de fila desplegada */
.mgrid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: var(--r); overflow: hidden;
  margin-bottom: 18px;
}
.mgrid > div { background: var(--bg-0); padding: 11px 13px; }
.mgrid .k { font-size: 10.5px; color: var(--muted); margin-bottom: 3px; }
.mgrid .v { font-family: var(--mono); font-size: 15px; font-weight: 500; }
.mgrid .n { font-size: 10.5px; color: var(--muted); margin-top: 2px; }

@media (max-width: 720px) {
  table.data-table.dense tbody td { padding: 7px 9px; font-size: 11.5px; }
  .minibar { width: 22px; }
  .mgrid { grid-template-columns: repeat(2, 1fr); }
}

/* ═══════════════════════════════════════════════════════════════
   Capa fluida — v6
   La app deja de "cambiar de página": el contexto se abre encima
   de lo que estabas mirando y se cierra devolviéndote donde estabas.
   Nada de recargas, nada de perder el sitio.
   ═══════════════════════════════════════════════════════════════ */

/* ── Cajón lateral ────────────────────────────────────────────
   Abre la ficha de un valor sin abandonar la tabla que estabas
   leyendo. Es el patrón central del rediseño. */
.drawer-scrim {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0; pointer-events: none;
  transition: opacity .18s ease;
  backdrop-filter: blur(1.5px);
}
.drawer-scrim.open { opacity: 1; pointer-events: auto; }
:root[data-theme="light"] .drawer-scrim { background: rgba(26, 26, 28, 0.28); }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 401;
  width: min(760px, 100vw);
  background: var(--bg-0);
  border-left: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .22s cubic-bezier(.32, .72, 0, 1);
  will-change: transform;
}
.drawer.open { transform: translateX(0); }

.drawer-head {
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px 0 20px; min-height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-0);
  flex: none;
}
.drawer-head .tk { font-size: 16px; font-weight: 600; font-family: var(--mono); }
.drawer-head .co-name {
  font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.drawer-head .spacer { flex: 1; }
.drawer-close {
  width: 30px; height: 30px; flex: none;
  border-radius: var(--r-sm); color: var(--text-soft);
  display: grid; place-items: center; font-size: 15px;
}
.drawer-close:hover { background: var(--bg-2); color: var(--text); }

/* Pestañas internas del cajón: cambian el contenido sin volver a
   pedir nada al servidor si ya está en memoria. */
.drawer-tabs {
  display: flex; gap: 2px; padding: 0 12px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none; flex: none;
}
.drawer-tabs::-webkit-scrollbar { display: none; }
.drawer-tab {
  padding: 10px 12px; font-size: 12px; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap;
  transition: color .12s, border-color .12s;
}
.drawer-tab:hover { color: var(--text); }
.drawer-tab[aria-selected="true"] {
  color: var(--text); border-bottom-color: var(--cyan); font-weight: 500;
}

.drawer-body { flex: 1; overflow-y: auto; padding: 20px; overscroll-behavior: contain; }
.drawer-body > h3:first-child { margin-top: 0; }

@media (max-width: 720px) {
  .drawer { width: 100vw; border-left: none; }
  .drawer-body { padding: 16px 14px; }
}

/* ── Paleta de comandos (Ctrl/Cmd + K) ────────────────────────
   Ir a cualquier sección o valor sin tocar el ratón. */
.cmdk-scrim {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0, 0, 0, 0.5);
  display: grid; place-items: start center; padding-top: 12vh;
  opacity: 0; pointer-events: none; transition: opacity .14s ease;
}
.cmdk-scrim.open { opacity: 1; pointer-events: auto; }
.cmdk {
  width: min(560px, 92vw);
  background: var(--bg-1); border: 1px solid var(--border-strong);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(-6px) scale(.99);
  transition: transform .14s ease;
}
.cmdk-scrim.open .cmdk { transform: none; }
.cmdk input {
  width: 100%; padding: 15px 18px; font-size: 15px;
  background: transparent; border: none; border-bottom: 1px solid var(--border);
  outline: none;
}
.cmdk input::placeholder { color: var(--muted); }
.cmdk-list { max-height: 46vh; overflow-y: auto; padding: 6px; }
.cmdk-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%; padding: 9px 12px; border-radius: var(--r-sm);
  font-size: 13.5px; color: var(--text-soft); text-align: left;
}
.cmdk-item .ico { width: 18px; text-align: center; opacity: .65; flex: none; }
.cmdk-item .cm-sub { font-size: 11px; color: var(--muted); margin-left: auto; }
.cmdk-item[aria-selected="true"] { background: var(--bg-2); color: var(--text); }
.cmdk-empty { padding: 22px; text-align: center; color: var(--muted); font-size: 13px; }
.cmdk-foot {
  display: flex; gap: 14px; padding: 8px 14px;
  border-top: 1px solid var(--border); font-size: 10.5px; color: var(--muted);
}
.cmdk-foot kbd {
  font-family: var(--mono); font-size: 10px;
  background: var(--bg-2); border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 3px;
}

/* ── Barra de herramientas de gráfico ─────────────────────────
   Cada gráfico decide qué muestra. Los ajustes se recuerdan por
   sección, así que no hay que reconfigurarlo cada vez. */
.chart-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 8px 2px 10px;
}
.ct-group {
  display: flex; align-items: center;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  overflow: hidden;
}
.ct-btn {
  padding: 5px 10px; font-size: 11px; font-family: var(--mono);
  color: var(--muted); background: var(--bg-0);
  border-right: 1px solid var(--border);
  transition: color .12s, background .12s;
}
.ct-btn:last-child { border-right: none; }
.ct-btn:hover { color: var(--text); background: var(--bg-2); }
.ct-btn[aria-pressed="true"] { color: var(--bg-0); background: var(--cyan); font-weight: 600; }
:root[data-theme="light"] .ct-btn[aria-pressed="true"] { color: #fff; }
.ct-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin-right: 3px; align-self: center;
}
.ct-spacer { flex: 1; }

@media (max-width: 720px) {
  .chart-toolbar { gap: 5px; }
  .ct-btn { padding: 6px 9px; font-size: 10.5px; }
  .ct-label { display: none; }
}

/* ── Cinta de mercado ─────────────────────────────────────────
   Contexto permanente: en qué régimen estás operando. Estática, sin
   desplazamiento automático: el movimiento constante distrae y
   perjudica la lectura de cifras. */
.ribbon {
  display: flex; align-items: center; gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-0);
  overflow-x: auto; scrollbar-width: none;
  min-height: 34px;
}
.ribbon::-webkit-scrollbar { display: none; }
.ribbon-item {
  display: flex; align-items: baseline; gap: 7px;
  padding: 7px 14px; white-space: nowrap; flex: none;
  border-right: 1px solid var(--border);
}
.ribbon-item .k {
  font-size: 10px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted);
}
.ribbon-item .v { font-family: var(--mono); font-size: 12px; font-weight: 500; }
.ribbon-item .c { font-family: var(--mono); font-size: 11px; }
.ribbon-skel { padding: 7px 14px; font-size: 11px; color: var(--muted); }

/* ── Transición entre secciones ───────────────────────────────
   Desplazamiento corto hacia arriba: comunica "contenido nuevo" sin
   hacer esperar. Se anula con prefers-reduced-motion. */
@keyframes panel-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.panel.active { animation: panel-in .18s cubic-bezier(.32, .72, 0, 1); }

/* ── Fila pulsable ────────────────────────────────────────────
   Cualquier fila de valor abre su ficha en el cajón. */
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--bg-2); }
.tk-btn {
  font-family: var(--mono); font-weight: 600; font-size: inherit;
  color: var(--text); border-bottom: 1px dotted var(--border-strong);
  padding: 0; text-align: left;
}
.tk-btn:hover { border-bottom-color: var(--cyan); color: var(--cyan); }

/* ── Probabilidades ───────────────────────────────────────────
   Barra apilada: probabilidad de subir / lateral / bajar. El número
   siempre visible; el color solo refuerza. */
.prob-bar {
  display: flex; height: 26px; border-radius: var(--r-sm);
  overflow: hidden; border: 1px solid var(--border);
  background: var(--bg-3);
}
.prob-seg {
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  color: var(--bg-0); min-width: 0; overflow: hidden;
}
:root[data-theme="light"] .prob-seg { color: #fff; }
.prob-seg.up { background: var(--green); }
.prob-seg.flat { background: var(--border-strong); color: var(--text); }
.prob-seg.down { background: var(--red); }
.prob-legend {
  display: flex; gap: 16px; margin-top: 7px;
  font-size: 11px; color: var(--muted); flex-wrap: wrap;
}
.prob-legend i {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 2px; margin-right: 5px; vertical-align: middle;
}

/* Calibración: cómo de fiable es la probabilidad que se muestra. Sin
   esto una probabilidad es solo un número con aspecto de autoridad. */
.calib {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--border-strong); color: var(--text-soft);
}
.calib b { font-family: var(--mono); font-weight: 600; }
.calib.good { border-color: var(--green); color: var(--green); }
.calib.weak { border-color: var(--yellow); color: var(--yellow); }
.calib.poor { border-color: var(--red); color: var(--red); }

/* Tarjeta de escenario probabilístico */
.pcards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: var(--r); overflow: hidden;
}
.pcard { background: var(--bg-0); padding: 13px 15px; }
.pcard .k { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.pcard .v { font-family: var(--mono); font-size: 22px; font-weight: 600; margin: 4px 0 2px; }
.pcard .n { font-size: 11px; color: var(--muted); line-height: 1.45; }
.pcard .base { font-size: 10.5px; color: var(--muted); margin-top: 6px; font-family: var(--mono); }

/* ═══════════════════════════════════════════════════════════════
   Generador de estrategia
   Panel de dos columnas: controles a la izquierda, resultado a la
   derecha. En móvil se apilan.
   ═══════════════════════════════════════════════════════════════ */
.strategy-layout {
  display: grid; grid-template-columns: 300px 1fr; gap: 22px;
  align-items: start;
}
.strategy-controls {
  position: sticky; top: 76px;
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--r); padding: 14px 16px;
  max-height: calc(100vh - 96px); overflow-y: auto;
}
.strategy-controls h3 {
  font-size: 11px; margin: 14px 0 8px; padding-top: 10px;
  border-top: 1px solid var(--border);
}
.strategy-controls h3:first-child { margin-top: 0; padding-top: 0; border-top: none; }

.strat-bool {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 2px; font-size: 12.5px; cursor: pointer;
}
.strat-bool input[type="checkbox"] { flex: none; width: 15px; height: 15px; accent-color: var(--cyan); }

.strat-slider { padding: 6px 2px 10px 24px; }
.strat-slider-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11.5px; color: var(--text-soft); margin-bottom: 4px;
}
.strat-slider input[type="range"] {
  width: 100%; accent-color: var(--cyan); height: 4px;
}
.strat-slider input[type="range"]:disabled { opacity: .35; }

.strategy-results { min-width: 0; }

@media (max-width: 880px) {
  .strategy-layout { grid-template-columns: 1fr; }
  .strategy-controls { position: static; max-height: none; }
}

/* Resumen: dos columnas (fundamentales | técnico & riesgo) para leer denso
   sin scroll interminable -- colapsa a 1 columna en pantallas estrechas. */
.summary-cols {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
  align-items: start; margin-top: 20px;
}
.summary-col { min-width: 0; }

@media (max-width: 900px) {
  .summary-cols { grid-template-columns: 1fr; gap: 0; }
}

/* Técnico: carrusel de gráficos (Precio, Volumen, RSI, MACD, Medias). */
.carousel-head { display: flex; align-items: center; gap: 8px; }
.carousel-nav { flex: none; font-size: 18px; line-height: 1; padding: 6px 12px; }
.carousel-tabs { flex: 1; min-width: 0; }
.carousel-body { margin-top: 14px; }
.carousel:focus-visible { outline: 2px solid var(--cyan); outline-offset: 4px; border-radius: var(--r); }

/* Técnico: conclusiones desglosadas por dimensión. */
.conclusion-rows {
  border: 1px solid var(--border); border-radius: var(--r); overflow: hidden;
}
.conclusion-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 16px;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.conclusion-row:last-child { border-bottom: none; }
.conclusion-label { flex: 0 0 190px; font-size: 12.5px; font-weight: 500; color: var(--text-soft); }
.conclusion-text { flex: 1 1 260px; font-size: 12.5px; color: var(--muted); min-width: 0; }

@media (max-width: 640px) {
  .conclusion-label { flex-basis: 100%; }
}
