/* binabotpro-real · página. Sin estilos en línea (CSP estricta): todo vive acá; JS solo cambia clases y propiedades por CSSOM. */
:root {
  --bg: #0d1117; --panel: #151b26; --panel2: #1a2232; --line: #232c3d; --line2: #34415a;
  --text: #d7deea; --muted: #8b96a8; --green: #3fb68b; --red: #ef5b5b; --amber: #f0b429; --blue: #2f6fde; --link: #7fb0ff; --cyan: #4dd0e1;
  --radio: 10px; --nav-alto: 64px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--link); }
h1, h2, h3 { margin: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.cargando { text-align: center; color: var(--muted); padding: 40vh 0 0; margin: 0; }

/* ---- botones, etiquetas ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 16px; border-radius: 8px;
  border: 1px solid var(--line2); background: #1d2636; color: var(--text); font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover:not(:disabled) { border-color: #4a5a7a; background: #222d40; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primario { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primario:hover:not(:disabled) { background: #3b7cf0; border-color: #3b7cf0; }
.btn-peligro { background: transparent; border-color: #7a3434; color: #ff9a9a; }
.btn-peligro:hover:not(:disabled) { background: #2a1717; border-color: var(--red); }
.btn-ancho { width: 100%; }
.btn-grande { min-height: 52px; padding: 12px 28px; font-size: 16.5px; }
.btn-chico { min-height: 44px; padding: 6px 12px; font-size: 14px; }
.con-razon { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.razon { color: var(--muted); font-size: 13px; }
.razon::before { content: "· "; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 800; letter-spacing: .06em; vertical-align: middle; line-height: 1.6; }
.badge-sim { background: var(--blue); color: #fff; border: 2px solid var(--blue); }
.badge-real { background: var(--amber); color: #1a1300; border: 2px solid var(--red); }
.chip-estado { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 6px; background: #1f2738; color: var(--muted); }
.chip-estado.e-activo { background: #173d2f; color: #8fe3b8; }
.chip-estado.e-pausado { background: #4a3a12; color: #ffd27a; }
.chip-estado.e-detenido { background: #3a1f24; color: #ff9a9a; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: #1b2333; border: 1px solid var(--line); font-size: 13px; color: var(--muted); white-space: nowrap; }
.punto { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.pill-ok .punto { background: var(--green); } .pill-mal .punto { background: var(--red); } .pill-aviso .punto { background: var(--amber); }
.pill-apagado .punto { background: #4b5566; }

.pos { color: var(--green); } .neg { color: var(--red); } .cero { color: var(--text); }
.nota { color: var(--muted); font-size: 13.5px; margin: 4px 0 0; }
.vacio { color: var(--muted); margin: 6px 0; }
.vacio b { color: var(--text); }

/* ---- ingreso ---- */
.ingreso { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.ingreso-caja { width: 100%; max-width: 380px; text-align: center; }
.logo { font-weight: 800; font-size: 19px; letter-spacing: -.01em; color: var(--text); text-decoration: none; }
.logo-grande { font-size: 34px; margin-bottom: 12px; }
.ingreso-texto { color: var(--muted); margin: 0 0 22px; }
.ingreso-msg { min-height: 48px; margin: 16px 0 0; color: var(--text); }
.ingreso-msg.mal { color: #ff9a9a; }

/* ---- cabecera y navegación ---- */
.cabecera { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px 18px; padding: 8px 24px; background: rgba(13, 17, 23, .96); border-bottom: 1px solid var(--line); }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 6px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; }
.nav a:hover { color: var(--text); background: var(--panel); }
.nav a[aria-current="page"] { color: var(--text); background: #1d2a42; }
.nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.contenido { max-width: 1200px; margin: 0 auto; padding: 20px 24px 48px; }
.vista { display: grid; gap: 16px; }
.titulo { font-size: 24px; font-weight: 750; }
.titulo-fila { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.subtitulo { font-size: 15px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-top: 4px; }

/* ---- paneles y cifras ---- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radio); padding: 16px; min-width: 0; }
.panel h2 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.panel-cab { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; margin-bottom: 8px; }
.panel-cab h2 { margin: 0; }
.panel-real { border-color: #5b4a1c; }
.cifras { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 20px; margin-top: 10px; }
.cifras.panel { margin-top: 0; }
.cifra-caja .etq { color: var(--muted); font-size: 13px; }
.cifra-caja .val { font-size: 24px; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.25; }
.cifra-caja .sub { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.cifra-caja.principal .val { font-size: 30px; }
.cifra-linea { margin: 0 0 10px; }
.cifra { font-size: 22px; font-weight: 750; }
.estado-linea { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0; color: var(--muted); }

/* ---- tarjetas de bots ---- */
.tarjetas { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.tarjeta { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radio); padding: 14px 16px; display: grid; gap: 8px; cursor: pointer; min-width: 0; }
.tarjeta:hover { border-color: var(--line2); }
.tarjeta.sel { border-color: var(--link); box-shadow: 0 0 0 1px var(--link) inset; }
.tarjeta.detenida { opacity: .72; cursor: default; }
.t-cab { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.t-moneda { font-size: 19px; font-weight: 800; }
.t-estr { color: var(--muted); font-weight: 600; }
.t-precio { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; }
.t-res { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.t-res .grande { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.15; }
.t-res .pct { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.t-estado { color: #c3cbd8; font-size: 14px; margin: 0; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; margin: 0; }
.kv dt { margin: 0; } .kv dd { margin: 0; color: var(--text); font-weight: 600; text-align: right; }
.barra { height: 6px; background: #222b3b; border-radius: 3px; overflow: hidden; }
.barra i { display: block; height: 100%; width: 0; background: var(--amber); }
.t-modo { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.interruptor { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 4px; background: none; border: 0; color: var(--muted); cursor: not-allowed; }
.interruptor .riel { width: 40px; height: 22px; border-radius: 11px; background: #2a3346; position: relative; flex: none; }
.interruptor .riel::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #6b778b; }
.interruptor:disabled { opacity: .7; }
.t-acciones { display: flex; gap: 8px; flex-wrap: wrap; }
.t-acciones .btn { flex: 1 1 auto; }

/* ---- gráfico ---- */
.grafico { height: 420px; margin-top: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 8px; overflow: hidden; flex-wrap: wrap; }
.seg button { min-height: 44px; min-width: 52px; padding: 6px 12px; background: transparent; border: 0; color: var(--muted); font-weight: 600; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line2); }
.seg button[aria-pressed="true"] { background: #22304a; color: var(--text); }
.leyenda { display: flex; flex-wrap: wrap; gap: 6px 18px; list-style: none; margin: 10px 0 0; padding: 0; font-size: 13px; color: var(--muted); }
.leyenda li { display: inline-flex; align-items: center; gap: 6px; }
.sw { font-size: 13px; } .sw-compra { color: var(--green); } .sw-venta { color: #5aa9ff; }
.ln { display: inline-block; width: 18px; height: 0; border-top: 2px solid; }
.ln-prom { border-color: var(--amber); } .ln-obj { border-color: var(--green); border-top-style: dashed; } .ln-piso { border-color: var(--cyan); border-top-style: dashed; }
.ln-prox { border-color: #9aa6ba; border-top-style: dotted; } .ln-corte { border-color: var(--red); border-top-style: dashed; }

/* ---- actividad ---- */
.actividad summary { cursor: pointer; font-weight: 700; min-height: 32px; }
.eventos { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13.5px; max-height: 360px; overflow: auto; }
.eventos li { display: grid; grid-template-columns: 120px 1fr; gap: 8px; padding: 5px 0; border-bottom: 1px solid #1b2230; }
.eventos .t { color: var(--muted); font-variant-numeric: tabular-nums; }
.k-error { color: #ff9a9a; } .k-aviso { color: #e6d08a; } .k-compra { color: #8fe3b8; } .k-venta { color: #7fc0ff; }

/* ---- formularios ---- */
.campo { display: grid; gap: 4px; min-width: 0; }
.etiqueta { font-size: 13.5px; color: var(--muted); }
input[type="text"], input[type="search"], input[type="date"], select {
  min-height: 44px; width: 100%; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line2); background: #0f141d; color: var(--text); }
input[aria-invalid="true"] { border-color: var(--red); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--blue); flex: none; }
.grupo { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 12px; margin: 0; display: grid; gap: 10px; min-width: 0; }
.grupo legend { padding: 0 6px; font-weight: 700; }
.filtros { display: grid; grid-template-columns: auto minmax(150px, 1fr) minmax(140px, 180px) minmax(140px, 180px) auto; gap: 12px; align-items: end; }
.campo-fin { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.acciones { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.errores { margin: 0; padding: 0 0 0 18px; color: #ff9a9a; font-size: 14px; }
.errores:empty { display: none; }

/* ---- pestañas ---- */
.pestanas { display: flex; gap: 6px; border-bottom: 1px solid var(--line); }
.pestanas button { min-height: 44px; padding: 8px 16px; background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted); font-weight: 700; cursor: pointer; }
.pestanas button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--link); }

/* ---- tablas (en pantallas angostas, cada fila es una tarjeta) ---- */
.panel-tabla { padding: 4px 8px; overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.tabla th, .tabla td { text-align: right; padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tabla th { color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; }
.tabla .izq { text-align: left; }
.tabla tbody tr:last-child td { border-bottom: 0; }
.tabla tfoot td { font-weight: 700; border-top: 1px solid var(--line2); border-bottom: 0; }
.tabla .chico { color: var(--muted); font-size: 12.5px; }

/* ---- nuevo bot ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { min-height: 44px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line2); background: #1b2333; color: var(--text); font-weight: 700; cursor: pointer; }
.chip[aria-selected="true"] { background: #1d2a42; border-color: var(--link); color: #fff; }
.chip .chico { color: var(--muted); font-weight: 500; margin-left: 4px; }
.opciones { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.opcion { text-align: left; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--line2); background: #171f2d; cursor: pointer; display: grid; gap: 4px; min-height: 44px; }
.opcion[aria-checked="true"] { border-color: var(--link); box-shadow: 0 0 0 1px var(--link) inset; background: #1a2539; }
.opcion .nom { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.opcion .det { color: var(--muted); font-size: 13px; }
.candado { width: 14px; height: 14px; fill: none; stroke: var(--muted); stroke-width: 2.2; flex: none; }
.resumen { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 20px; margin: 4px 0 12px; }
.crear { display: grid; gap: 6px; justify-items: start; }

/* ---- estrategias ---- */
.tarjetas-estr { grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
.estr { cursor: default; }
.estr .t-acciones .btn { flex: 0 1 auto; }
.etq-estr { font-size: 12px; padding: 1px 8px; border-radius: 6px; background: #1f2738; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.etq-uso { background: #16324f; color: #8cc4ff; }
.params { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 13.5px; margin: 0; padding: 0; list-style: none; }
.params b { color: var(--text); font-weight: 600; }
.cuadro { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.cuadro th, .cuadro td { padding: 4px 6px; text-align: right; border-bottom: 1px solid #1d2533; white-space: nowrap; }
.cuadro .bajo { display: block; color: var(--muted); font-size: 12px; }
.tabla.compacta td, .tabla.compacta th { white-space: nowrap; }
.tabla.compacta th.envolver { white-space: normal; }
.cuadro th:first-child, .cuadro td:first-child { text-align: left; }
.cuadro th { color: var(--muted); font-weight: 600; font-size: 12.5px; }
.cuadro tfoot td { font-weight: 700; border-bottom: 0; }
.editor-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; align-items: start; }
#edForm { display: grid; gap: 14px; }
.editor-vista { position: sticky; top: 76px; }
.escalon { display: grid; grid-template-columns: 92px minmax(0, 1fr) minmax(0, 1fr) 44px; gap: 8px; align-items: end; margin-bottom: 8px; }
.escalon .n { font-weight: 700; padding-bottom: 10px; }
.btn-quitar { min-width: 44px; padding: 0; }

/* ---- ajustes ---- */
.sesiones { list-style: none; margin: 0 0 12px; padding: 0; }
.sesiones li { display: grid; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.sesiones .disp { font-weight: 600; }
.sesiones .esta { color: var(--green); font-size: 13px; font-weight: 700; margin-left: 6px; }

/* ---- modal y aviso ---- */
.modal { max-width: min(460px, calc(100vw - 32px)); width: 100%; background: var(--panel); color: var(--text); border: 1px solid var(--line2); border-radius: 12px; padding: 20px; }
.modal::backdrop { background: rgba(0, 0, 0, .6); }
.modal h2 { font-size: 19px; margin-bottom: 8px; }
.modal p { color: #c3cbd8; margin: 0 0 18px; }
.acciones-modal { justify-content: flex-end; }
.aviso { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; max-width: min(520px, calc(100vw - 32px)); padding: 12px 18px; border-radius: 10px;
  background: #1d2a42; border: 1px solid var(--line2); color: var(--text); box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }
.aviso.mal { background: #3a1f24; border-color: #7a3434; }

/* ---- pantallas medianas ---- */
@media (max-width: 1000px) {
  .filtros { grid-template-columns: 1fr 1fr; }
  .campo-fin { grid-column: 1 / -1; }
  .editor-grid { grid-template-columns: 1fr; }
  .editor-vista { position: static; }
}

/* ---- celular: navegación abajo, tablas como tarjetas ---- */
@media (max-width: 760px) {
  body { font-size: 15px; }
  .cabecera { padding: 8px 14px; }
  .cabecera #conn { margin-left: auto; }
  .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0; gap: 0; justify-content: space-around; background: #111722; border-top: 1px solid var(--line);
    padding: 4px 2px calc(4px + env(safe-area-inset-bottom)); }
  .nav a { flex: 1 1 0; flex-direction: column; gap: 2px; min-height: 54px; padding: 4px 2px; font-size: 11.5px; justify-content: center; text-align: center; border-radius: 8px; }
  .nav svg { width: 22px; height: 22px; }
  .contenido { padding: 14px 12px calc(var(--nav-alto) + 32px); }
  .aviso { bottom: calc(var(--nav-alto) + 16px); }
  .titulo { font-size: 22px; }
  .tarjetas, .tarjetas-estr { grid-template-columns: 1fr; }
  .grafico { height: 340px; }
  .filtros { grid-template-columns: 1fr 1fr; }
  .filtros > .campo:first-child, .filtros > label:nth-child(2) { grid-column: 1 / -1; }
  .campo-fin .btn { flex: 1 1 auto; }
  .eventos li { grid-template-columns: 1fr; gap: 0; }
  .escalon { grid-template-columns: 1fr 1fr 44px; }
  .escalon .n { grid-column: 1 / -1; padding: 0; }
  .panel { padding: 14px 12px; }
  .panel-tabla:has(.apilada) { padding: 0; background: none; border: 0; overflow: visible; }
  .tabla.apilada thead { display: none; }
  .tabla.apilada, .tabla.apilada tbody, .tabla.apilada tfoot, .tabla.apilada tr, .tabla.apilada td { display: block; width: 100%; }
  .tabla.apilada tr { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radio); padding: 8px 12px; margin-bottom: 10px; }
  .tabla.apilada td { display: flex; justify-content: space-between; gap: 12px; text-align: right; padding: 5px 0; border-bottom: 1px solid #1d2533; }
  .tabla.apilada td:last-child { border-bottom: 0; }
  .tabla.apilada td::before { content: attr(data-label); color: var(--muted); text-align: left; font-weight: 500; flex: none; max-width: 45%; }
  .tabla.apilada td.izq { text-align: right; }
  .tabla.apilada td.primera { font-weight: 700; font-size: 15px; }
  .tabla.apilada td.primera::before { content: none; }
  .tabla.apilada td.primera { justify-content: flex-start; text-align: left; }
  .tabla.apilada tfoot tr { border-color: var(--line2); }
  .solo-ancho { display: none; }
  .tabla.compacta th, .tabla.compacta td { padding: 7px 5px; font-size: 13.5px; }
  .cifras { grid-template-columns: 1fr 1fr; gap: 12px 14px; }
  .cifras .principal { grid-column: 1 / -1; }
  .cifra-caja .val { font-size: 20px; }
  .tabla.apilada td > span { text-align: right; }
}
@media (max-width: 380px) {
  .t-res .grande { font-size: 25px; }
  .cifra-caja .val { font-size: 21px; }
  .cifra-caja.principal .val { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
input:disabled { opacity: .55; cursor: not-allowed; }
details > summary { cursor: pointer; padding: 10px 0; min-height: 44px; box-sizing: border-box; }
