/* Radar Visionarios · diseño propio (tema oscuro de terminal de trading, sin frameworks). */
@font-face { font-family: 'Inter'; src: url('vendor/fuentes/inter.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('vendor/fuentes/jetbrains-mono.woff2') format('woff2'); font-weight: 100 800; font-display: swap; }

:root {
  --bg: #0a0e15;
  --panel: #111723;
  --panel-2: #172031;
  --panel-3: #1d283c;
  --line: #243149;
  --line-2: #2f3f5c;
  --text: #e8eef7;
  --muted: #8f9fba;
  --dim: #64748b;
  --accent: #4f8cff;
  --accent-2: #7aa7ff;
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, .14);
  --red: #f05252;
  --red-bg: rgba(240, 82, 82, .14);
  --amber: #f5a524;
  --amber-bg: rgba(245, 165, 36, .14);
  --blue-bg: rgba(79, 140, 255, .15);
  --violet: #a78bfa;
  --radius: 12px;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 1rem/1.5 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: .93em; white-space: nowrap; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.green { color: var(--green); }
.red { color: var(--red); }
.amber { color: var(--amber); }
.small { font-size: .87rem; }
.hidden { display: none !important; }

/* Barra superior */
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(10, 14, 21, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; gap: 16px; height: 60px; }
.marca { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.08rem; color: var(--text); }
.marca:hover { text-decoration: none; }
.marca-icono {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 1.05rem; color: #fff;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6); box-shadow: 0 4px 16px rgba(79, 140, 255, .35);
}
.topbar .espacio { flex: 1; }
.wrap { width: 100%; margin: 0; padding: 0 24px; }
main.wrap { padding-top: 20px; padding-bottom: 40px; }

/* Controles */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); font: 500 .93rem 'Inter', sans-serif;
  white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--panel-3); border-color: var(--dim); text-decoration: none; }
.btn-primario { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primario:hover { background: #3d7af0; border-color: #3d7af0; }
.btn-verde { background: var(--green-bg); border-color: rgba(34, 197, 94, .45); color: var(--green); }
.btn-verde:hover { background: rgba(34, 197, 94, .24); border-color: var(--green); }
.btn-rojo { background: var(--red-bg); border-color: rgba(240, 82, 82, .45); color: var(--red); }
.btn-rojo:hover { background: rgba(240, 82, 82, .24); border-color: var(--red); }
.btn-icono { width: 34px; height: 34px; padding: 0; justify-content: center; }
.btn-mini { height: 28px; padding: 0 9px; font-size: .85rem; border-radius: 7px; }
select, input {
  height: 38px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--panel-2);
  color: var(--text); font: 400 .95rem 'Inter', sans-serif; width: 100%;
}
select:focus, input:focus { outline: 2px solid rgba(79, 140, 255, .5); outline-offset: 0; border-color: var(--accent); }
.topbar select { width: auto; height: 36px; }
label.campo { display: grid; gap: 6px; font-size: .87rem; color: var(--muted); }

/* Tarjetas y mercado */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.mercado { display: grid; grid-template-columns: minmax(280px, 1.1fr) 2fr; gap: 20px; padding: 18px 20px; margin-bottom: 18px; position: relative; overflow: hidden; }
.mercado::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--reg); }
.regimen { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.05rem; padding: 6px 14px; border-radius: 999px;
  color: var(--reg); background: color-mix(in srgb, var(--reg) 15%, transparent); border: 1px solid color-mix(in srgb, var(--reg) 45%, transparent); }
.mercado p { margin: 10px 0 0; color: var(--text); }
.indices { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.indice { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.indice .t { color: var(--muted); font-size: .85rem; }
.indice .v { font-size: 1.2rem; font-weight: 650; font-family: var(--mono); }
.indice .c { font-size: .85rem; color: var(--muted); display: flex; gap: 12px; }
.ok::before { content: '●'; color: var(--green); margin-right: 4px; }
.ko::before { content: '●'; color: var(--red); margin-right: 4px; }
@media (max-width: 900px) { .mercado { grid-template-columns: 1fr; } }

/* Pestañas */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 18px; scrollbar-width: thin; }
.tab {
  display: flex; align-items: center; gap: 8px; padding: 12px 16px; border: 0; background: none; cursor: pointer; white-space: nowrap;
  color: var(--muted); font: 600 .97rem 'Inter', sans-serif; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.activa { color: var(--text); border-bottom-color: var(--accent); }
.tab .cuenta { min-width: 24px; height: 22px; padding: 0 7px; border-radius: 999px; display: inline-grid; place-items: center;
  font-size: .8rem; background: var(--panel-3); color: var(--muted); font-family: var(--mono); }
.tab .cuenta.on { background: var(--green-bg); color: var(--green); }
.tab .cuenta.alerta { background: var(--red-bg); color: var(--red); }
.panel { display: none; }
.panel.activo { display: block; }
.cabecera { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 6px 0 12px; }
.cabecera p { margin: 4px 0 0; color: var(--muted); }
.seccion { margin-top: 30px; }

/* Tablas */
.tabla { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); max-height: 74vh; }
table { width: 100%; border-collapse: collapse; min-width: 1100px; }
th {
  position: sticky; top: 0; z-index: 2; background: var(--panel-2); text-align: left; white-space: nowrap;
  font-size: .78rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
  padding: 11px 12px; border-bottom: 1px solid var(--line);
}
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.nw { white-space: nowrap; }
tbody tr:hover td { background: rgba(79, 140, 255, .05); }
tbody tr:last-child td { border-bottom: 0; }
tr.seleccionada td { background: rgba(79, 140, 255, .12) !important; }
.der { text-align: right; }
.valor { display: flex; align-items: center; gap: 10px; min-width: 170px; }
.valor .nombre { min-width: 0; }
.valor a.ticker { font-weight: 700; font-size: 1.02rem; color: var(--text); letter-spacing: .01em; }
.valor a.ticker:hover { color: var(--accent-2); text-decoration: none; }
.valor .empresa { color: var(--muted); font-size: .84rem; max-width: 210px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.valor .btn { margin-left: auto; }
.buy-stop { font-weight: 700; color: #fff; background: var(--blue-bg); border: 1px solid rgba(79, 140, 255, .45); padding: 3px 9px; border-radius: 7px; }
.avisos { list-style: none; margin: 0; padding: 0; font-size: .86rem; min-width: 340px; color: var(--muted); }
.avisos li { display: flex; gap: 6px; line-height: 1.4; }
.avisos li + li { margin-top: 3px; }
.avisos li.grave { color: #ffb4b4; }
.avisos li.venta { color: #ffd38a; }
.avisos li.compra { color: var(--accent-2); }
.cd { display: inline-block; margin-top: 4px; font-size: .75rem; color: var(--dim); border: 1px solid var(--line-2); border-radius: 6px; padding: 0 6px; cursor: help; }
.sub { display: block; font-size: .8rem; color: var(--muted); font-family: 'Inter', sans-serif; }

/* Etiquetas */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: .82rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.b-verde { color: var(--green); background: var(--green-bg); border-color: rgba(34, 197, 94, .35); }
.b-rojo { color: var(--red); background: var(--red-bg); border-color: rgba(240, 82, 82, .35); }
.b-ambar { color: var(--amber); background: var(--amber-bg); border-color: rgba(245, 165, 36, .35); }
.b-azul { color: var(--accent-2); background: var(--blue-bg); border-color: rgba(79, 140, 255, .35); }
.b-gris { color: var(--muted); background: var(--panel-3); border-color: var(--line-2); }

.vacio { border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted); }
.vacio .bi { display: block; font-size: 1.6rem; margin-bottom: 6px; }
.aviso-caja { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; background: var(--amber-bg); color: #ffd38a; border: 1px solid rgba(245, 165, 36, .35); }
.aviso-caja.ok { background: var(--green-bg); color: #9ff0bd; border-color: rgba(34, 197, 94, .35); }
.aviso-caja.error { background: var(--red-bg); color: #ffb4b4; border-color: rgba(240, 82, 82, .35); }

/* KPIs de la cartera */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; gap: 14px; align-items: center; }
.kpi .bi { font-size: 1.4rem; color: var(--accent-2); width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; background: var(--blue-bg); }
.kpi .t { color: var(--muted); font-size: .85rem; }
.kpi .v { font-size: 1.35rem; font-weight: 700; font-family: var(--mono); }
.kpi .n { color: var(--dim); font-size: .82rem; }

/* Ventanas (dialog nativo) */
dialog { border: 1px solid var(--line-2); border-radius: 16px; background: var(--panel); color: var(--text); padding: 0; width: min(560px, 94vw);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
dialog::backdrop { background: rgba(3, 6, 12, .72); backdrop-filter: blur(3px); }
dialog .cab { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
dialog .cuerpo { padding: 18px 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
dialog .cuerpo .ancho { grid-column: 1 / -1; }
dialog .pie { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }
dialog .ayuda { grid-column: 1 / -1; color: var(--muted); font-size: .87rem; margin: 0; }

/* Ficha a pantalla completa */
dialog.ficha { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; border-radius: 0; border: 0; background: var(--bg); }
.ficha-cab { display: flex; align-items: center; gap: 16px; padding: 14px 22px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.ficha-cab .tk { font-size: 1.6rem; font-weight: 800; letter-spacing: .01em; }
.ficha-cab .px { font-size: 1.35rem; font-weight: 650; font-family: var(--mono); }
.ficha-cab .emp { color: var(--muted); }
.ficha-cuerpo { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 18px; padding: 18px 22px; height: calc(100vh - 74px); overflow: auto; }
.ficha-graficos { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.marcos { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.marcos button { border: 0; background: none; color: var(--muted); font: 600 .9rem 'Inter', sans-serif; padding: 7px 14px; border-radius: 8px; cursor: pointer; }
.marcos button.activo { background: var(--accent); color: #fff; }
.marcos button .met { font-size: .7rem; opacity: .8; margin-left: 4px; }
.leyenda { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .86rem; color: var(--muted); }
.leyenda i { display: inline-block; width: 16px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.ohlc { font-family: var(--mono); font-size: .85rem; color: var(--muted); min-height: 1.3em; }
.ohlc b { color: var(--text); font-weight: 500; margin-right: 10px; }
.g-precio { height: 58vh; min-height: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.g-rs { height: 130px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.ficha-lateral { display: flex; flex-direction: column; gap: 14px; }
.bloque { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.bloque h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
.datos { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .92rem; }
.datos dt { color: var(--muted); }
.datos dd { margin: 0; text-align: right; font-family: var(--mono); font-size: .88rem; }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: .9rem; }
.checks li { display: grid; grid-template-columns: 20px 1fr auto; gap: 8px; align-items: baseline; }
.checks .si { color: var(--green); }
.checks .no { color: var(--red); }
.checks .nd { color: var(--dim); }
.checks .val { font-family: var(--mono); font-size: .84rem; color: var(--muted); }
.mini td, .mini th { padding: 6px 8px; font-size: .86rem; }
.mini table { min-width: 0; }
.mini th { position: static; }

/* Acceso */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(79, 140, 255, .18), transparent), radial-gradient(900px 500px at 110% 110%, rgba(139, 92, 246, .14), transparent), var(--bg); }
.login .card { width: min(420px, 100%); padding: 34px 32px; box-shadow: 0 30px 80px rgba(0, 0, 0, .45); }
.login .marca-icono { width: 54px; height: 54px; font-size: 1.6rem; border-radius: 15px; margin: 0 auto 14px; }
.login h1 { text-align: center; font-size: 1.45rem; }
.login p.muted { text-align: center; margin: 6px 0 24px; }
.login form { display: grid; gap: 16px; }
.login .btn { height: 44px; justify-content: center; font-size: 1rem; }

footer { color: var(--dim); font-size: .85rem; margin-top: 30px; line-height: 1.6; }

.resumen-h { font-size: .92rem; margin-bottom: 10px; }
.ficha-lateral .mini { max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.ficha-lateral .mini th { position: sticky; top: 0; }
/* La ficha ocupa la pantalla: el gráfico queda fijo y el panel lateral se desplaza por su cuenta. */
.ficha-cuerpo { grid-template-columns: minmax(0, 1fr) 620px; overflow: hidden; }
.ficha-graficos, .ficha-lateral { overflow-y: auto; min-height: 0; padding-right: 4px; }
.ficha-lateral .mini td, .ficha-lateral .mini th { padding: 5px 7px; font-size: .82rem; white-space: nowrap; }
.ficha-lateral .mini .badge { font-size: .74rem; padding: 2px 7px; }
@media (max-width: 1250px) { .ficha-cuerpo { grid-template-columns: 1fr; height: auto; overflow: visible; } .ficha-graficos, .ficha-lateral { overflow: visible; } dialog.ficha { overflow-y: auto; } }
