:root {
  --bg: #0f1115;
  --panel: #171a21;
  --border: #5b6781;
  /* Aclarado desde #262b36 (1.33:1 contra --bg, 1.23:1 contra --panel
     -- ambos por debajo del mínimo WCAG 1.4.11 de 3:1 para límites de
     componentes de interfaz). Este valor cumple 3.33:1 y 3.07:1
     respectivamente. Es un cambio visual perceptible (bordes más
     visibles en toda la plataforma), documentado explícitamente, no
     oculto -- necesario para que inputs/tarjetas/botones con borde
     sean identificables para usuarios con baja visión. */
  --text: #e6e8eb;
  --muted: #8a8f98;
  --green: #3ecf8e;
  --yellow: #e6b93e;
  --red: #e65a5a;
  --accent: #4f8cff;
  /* Mismo matiz que --accent, pero calibrado para que TEXTO BLANCO
     encima cumpla WCAG AA (4.5:1) -- --accent puro (#4f8cff) solo da
     3.22:1 con blanco, insuficiente para texto normal. --accent sigue
     siendo el correcto para enlaces/texto sobre el fondo oscuro
     (ahí sí cumple, 5.87:1); --accent-strong es específicamente para
     fondos de botón con texto blanco encima. */
  --accent-strong: #4072d1;
}
* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  margin: 0;
  padding: 32px 24px 64px;
}
/* Las pantallas con el shell nuevo (sidebar+topbar) manejan su propio
   espaciado vía .app-content -- sin este reset, el padding del body
   se apilaba con el de .app-content, restando ~48px de ancho útil de
   más en cada pantalla migrada, en todos los anchos. */
body:has(> .app-shell) { padding: 0; margin: 0; }
.header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
  max-width: 1100px;
  margin: 0 auto 24px;
}
h1 { font-size: 22px; margin: 0; letter-spacing: 0.3px; }
.subtitle { color: var(--muted); font-size: 13px; margin-top: 4px; }
.meta { color: var(--muted); font-size: 13px; text-align: right; }
.container { max-width: 1100px; margin: 0 auto; }
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
button:hover { opacity: 0.9; }
.error-banner {
  background: rgba(230, 90, 90, 0.12);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}
.empty-state {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 40px;
  text-align: center;
  color: var(--muted);
}
table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 10px; overflow: hidden; }
th, td { padding: 12px 14px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; }
tr:last-child td { border-bottom: none; }
tr.best { background: rgba(62, 207, 142, 0.06); }
.symbol { font-weight: 700; }
.score { font-weight: 700; font-size: 15px; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.risk-LOW { background: rgba(62,207,142,0.15); color: var(--green); }
.risk-MEDIUM { background: rgba(230,185,62,0.15); color: var(--yellow); }
.risk-HIGH { background: rgba(230,90,90,0.15); color: var(--red); }
.conf-LOW { color: var(--red); }
.conf-MEDIUM { color: var(--yellow); }
.conf-HIGH { color: var(--green); }
.explanation { color: var(--muted); font-size: 12px; max-width: 480px; }
.crown { margin-right: 4px; }
.footer-note { max-width: 1100px; margin: 24px auto 0; color: var(--muted); font-size: 12px; text-align: center; }

/* ============================================================
   RESPONSIVE (móvil/tablet) -- sobre el sistema de estilos
   existente, sin framework nuevo ni rediseño. Reglas genéricas
   compartidas por todas las páginas que ya usan este archivo.
   ============================================================ */

/* Utilidad: envuelve una <table> existente para que solo ELLA
   scrollee horizontalmente si no entra, en vez de la página entera. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 100%; }

/* Navegación principal (_nav.html) -- mismo markup, solo ajustes de
   tamaño/espaciado para que quepa mejor al envolver en pantallas chicas. */
.tis-nav { row-gap: 6px; gap: 18px; padding: 10px 16px; font-size: 13px; }

@media (max-width: 720px) {
  body { padding: 16px 12px 48px; }
  .header { gap: 8px; }
  h1 { font-size: 18px; }
  table { font-size: 12px; }
  th, td { padding: 8px 8px; }
  .tis-nav { gap: 10px; padding: 8px 10px; font-size: 12px; }
  button, .submit-btn { font-size: 13px; }
}

@media (max-width: 480px) {
  th, td { padding: 6px 6px; font-size: 11px; }
  .explanation { max-width: 100%; }
}

/* ============================================================
   Sistema de diseño de plataforma (sidebar + topbar + tarjetas)
   Usado por las pantallas migradas a la nueva experiencia.
   Reutiliza las mismas variables de color de arriba -- no crea
   una paleta nueva ni un framework nuevo.
   ============================================================ */

.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
  width: 232px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--border);
  padding: 20px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.app-sidebar .brand { padding: 0 22px 22px; font-weight: 800; font-size: 18px; letter-spacing: 0.02em; }
.sidebar-group { margin-bottom: 20px; }
.sidebar-group-title { padding: 0 22px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 6px; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 22px; color: var(--text);
  text-decoration: none; font-size: 14px; border-left: 3px solid transparent;
}
.sidebar-link:hover { background: rgba(79, 140, 255, 0.08); }
button.sidebar-link { width: 100%; background: none; border: none; border-left: 3px solid transparent; text-align: left; cursor: pointer; font: inherit; }
.sidebar-link.active { border-left-color: var(--accent); background: rgba(79, 140, 255, 0.10); color: var(--accent); font-weight: 600; }
.sidebar-icon { width: 18px; text-align: center; }

.app-main { flex: 1; min-width: 0; }
.app-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 28px; border-bottom: 1px solid var(--border); background: var(--bg);
  position: sticky; top: 0; z-index: 5;
}
.app-topbar .env-badge { font-size: 12px; padding: 4px 10px; border-radius: 20px; font-weight: 600; }
.env-badge.testnet { background: rgba(230, 185, 62, 0.15); color: var(--yellow); }
.env-badge.live { background: rgba(230, 90, 90, 0.15); color: var(--red); }
.app-topbar .user-chip { font-size: 13px; color: var(--muted); text-decoration: none; }

.app-content { padding: 28px; max-width: 1100px; }

/* Tarjetas de estadística (valor de cuenta, PnL, etc.) */
.stat-cards { display: flex; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.stat-card { flex: 1; min-width: 200px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 20px 22px; }
.stat-card .label { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.stat-card .value { font-size: 28px; font-weight: 800; line-height: 1.1; }
.stat-card .delta { font-size: 13px; font-weight: 600; margin-top: 6px; }

/* Tarjeta de sección con encabezado (reemplaza los <h2>+panel sueltos) */
.tis-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; margin-bottom: 22px; }
.tis-card-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); gap: 10px; flex-wrap: wrap; }
.tis-card-header h2 { font-size: 14px; margin: 0; }
.tis-card-header a.card-link { font-size: 12px; color: var(--accent); text-decoration: none; }

.tis-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); gap: 12px; flex-wrap: wrap; }
.tis-row:last-child { border-bottom: none; }
a.tis-row-link { display: block; text-decoration: none; color: inherit; }
a.tis-row-link:hover .tis-row { background: rgba(79, 140, 255, 0.05); }

.asset-icon {
  width: 36px; height: 36px; border-radius: 50%; background: var(--bg); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; color: var(--accent); flex-shrink: 0;
}
.tis-row-main { display: flex; align-items: center; gap: 12px; }

/* Botones de acción rápida (pills) */
.action-pills { display: flex; gap: 10px; margin-bottom: 22px; flex-wrap: wrap; }
.action-pills a { flex: 1; min-width: 130px; text-align: center; padding: 14px; border-radius: 10px; text-decoration: none; font-weight: 700; font-size: 13px; }
.pill-buy { background: var(--green); color: #0f1115; }
.pill-sell { background: var(--red); color: #0f1115; }
.pill-neutral { background: var(--bg); border: 1px solid var(--border); color: var(--text); }

/* Barra de navegación móvil (reemplaza la sidebar en pantallas chicas) */
.mobile-tabbar {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; background: var(--panel);
  border-top: 1px solid var(--border); z-index: 20;
}
.mobile-tabbar a, .mobile-tabbar button {
  flex: 1; text-align: center; padding: 10px 4px 8px; font-size: 10px; color: var(--muted);
  text-decoration: none; background: none; border: none; font-family: inherit; cursor: pointer;
}
.mobile-tabbar a .tab-icon, .mobile-tabbar button .tab-icon { font-size: 18px; display: block; margin-bottom: 2px; }
.mobile-tabbar a.active, .mobile-tabbar button.active { color: var(--accent); }

/* Menú "Más" (bottom sheet) -- reúne las pantallas avanzadas/sistema que no caben
   como pestaña fija en la mobile-tabbar (Terminal, Estrategias, Backtesting,
   Decision Log, Consola, Reconciliación). */
.more-menu-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 21; }
.more-menu-overlay.open { display: block; }
.more-menu {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; background: var(--panel);
  border-top: 1px solid var(--border); border-radius: 14px 14px 0 0; z-index: 22;
  padding: 8px 0 78px;
}
.more-menu.open { display: block; }
.more-menu a { display: flex; align-items: center; gap: 10px; padding: 12px 22px; color: var(--text); text-decoration: none; font-size: 14px; }
.more-menu a .tab-icon { width: 20px; text-align: center; }
.more-menu a.active { color: var(--accent); font-weight: 600; }

@media (max-width: 900px) {
  .app-sidebar { display: none; }
  .mobile-tabbar { display: flex; }
  .app-content { padding-bottom: 78px; padding-left: 16px; padding-right: 16px; }
  .app-topbar { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .app-topbar .env-badge { font-size: 11px; padding: 3px 8px; }
}
@media (min-width: 901px) {
  .more-menu, .more-menu-overlay { display: none !important; }
}

/* Asistente de conexión Binance (/config) */
.connect-hero { text-align: center; padding: 40px 24px; }
.connect-hero .connect-icon { font-size: 40px; margin-bottom: 12px; }
.connect-hero h1 { font-size: 20px; margin: 0 0 8px; }
.connect-hero p { color: var(--muted); font-size: 14px; max-width: 420px; margin: 0 auto 24px; }
.trust-list { list-style: none; padding: 0; margin: 20px 0; text-align: left; max-width: 320px; margin-left: auto; margin-right: auto; }
.trust-list li { padding: 6px 0; font-size: 13px; color: var(--text); }
.trust-list li.no { color: var(--muted); }
.connect-steps { max-width: 440px; margin: 0 auto; }
.connect-step { text-align: left; padding: 18px 0; border-bottom: 1px solid var(--border); }
.connect-step:last-child { border-bottom: none; }
.connect-step .step-num { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; background: var(--accent-strong); color: #fff; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; margin-right: 8px; }
.permission-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 10px; border-radius: 20px; margin: 3px 4px 3px 0; }
.permission-badge.allowed { background: rgba(62, 207, 142, 0.12); color: var(--green); }
.permission-badge.blocked { background: rgba(230, 90, 90, 0.12); color: var(--red); }
.connected-account-card { display: flex; justify-content: space-between; align-items: center; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; margin: 16px 0; }
