:root {
  --bg: #0e1014; --panel: #14171c; --linea: #23272e; --linea2: #2f343d;
  --txt: #e6e8eb; --txt2: #8b929c; --txt3: #5c636e;
  --azul: #2962ff; --verde: #26a69a; --rojo: #ef5350; --ambar: #e0a526;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--txt); font-family: var(--sans); font-size: 14px; }
body { min-height: 100vh; overflow-x: hidden; }
.mono, .val, td, .reloj, .cuenta b { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.pos { color: var(--verde); } .neg { color: var(--rojo); } .tenue { color: var(--txt2); }

header { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 0 24px; height: 52px; background: var(--panel); border-bottom: 1px solid var(--linea); }
.marca { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; }
.marca svg { width: 20px; height: 20px; }
.marca small { display: none; }
.marca br { display: none; }
.estado-bot { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 500; color: var(--txt2); padding-left: 16px; border-left: 1px solid var(--linea); }
.luz { width: 8px; height: 8px; border-radius: 50%; background: var(--txt3); }
.estado-bot.vivo { color: var(--verde); } .estado-bot.vivo .luz { background: var(--verde); }
.estado-bot.parado { color: var(--ambar); } .estado-bot.parado .luz { background: var(--ambar); }
.estado-bot.caido { color: var(--rojo); } .estado-bot.caido .luz { background: var(--rojo); }
.chips { display: flex; gap: 18px; flex-wrap: wrap; }
.chip { font-size: 12.5px; color: var(--txt3); } .chip b { color: var(--txt2); font-weight: 500; }
.hueco { flex: 1; }
.reloj { font-size: 12px; color: var(--txt3); white-space: nowrap; }
header form button { background: none; border: 0; color: var(--txt2); font: inherit; font-size: 12.5px; cursor: pointer; padding: 6px 0; }
header form button:hover { color: var(--txt); }

main { max-width: 1320px; margin: 0 auto; padding: 20px 24px 60px; display: grid; gap: 16px; }
.tarjeta { background: var(--panel); border: 1px solid var(--linea); border-radius: 4px; padding: 16px 18px; min-width: 0; }
h2 { margin: 0 0 14px; font-size: 13px; font-weight: 600; color: var(--txt); display: flex; align-items: baseline; gap: 10px; }
h2 span { margin-left: auto; font-weight: 400; font-size: 12px; color: var(--txt3); }
.aviso { display: none; border-left: 3px solid var(--ambar); color: var(--txt); font-size: 13px; padding: 12px 16px; }
.aviso.ver { display: block; }

.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); background: var(--panel); border: 1px solid var(--linea); border-radius: 4px; }
.kpis .tarjeta { border: 0; border-right: 1px solid var(--linea); border-radius: 0; background: none; padding: 14px 18px; }
.kpis .tarjeta:last-child { border-right: 0; }
.kpi .eti { font-size: 12px; color: var(--txt2); }
.kpi .val { font-size: 21px; font-weight: 500; margin-top: 6px; white-space: nowrap; }
.kpi .sub { font-size: 12px; color: var(--txt3); margin-top: 3px; font-family: var(--mono); }
.kpi .sub.pos { color: var(--verde); } .kpi .sub.neg { color: var(--rojo); }

.flujo { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.fase { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: baseline; padding: 12px 14px; border: 1px solid var(--linea); border-radius: 4px; background: var(--bg); position: relative; }
.fase:not(:last-child)::after { content: "›"; position: absolute; right: -8px; top: 50%; transform: translate(50%, -55%); color: var(--txt3); font-size: 15px; z-index: 1; }
.nodo { font-family: var(--mono); font-size: 11.5px; color: var(--txt3); }
.fase .nom { font-weight: 500; font-size: 13px; }
.fase .det { grid-column: 1 / -1; font-size: 11.5px; color: var(--txt3); line-height: 1.4; min-height: 32px; margin-top: 2px; }
.fase .cuenta { grid-column: 1 / -1; font-size: 12px; color: var(--txt3); margin-top: 6px; }
.fase .cuenta b { font-size: 17px; font-weight: 500; color: var(--txt2); margin-right: 4px; }
.fase .cuenta.hay b { color: var(--ambar); }
.fase:last-child { border-color: var(--linea2); } .fase:last-child .cuenta.hay b { color: var(--verde); }

.dos { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }
canvas { width: 100%; height: 260px; display: block; }
.vacio { font-size: 13px; color: var(--txt3); padding: 22px 0; text-align: center; }

.barra { margin-bottom: 16px; }
.barra .cab { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--txt2); margin-bottom: 6px; }
.barra .cab b { color: var(--txt); font-weight: 500; font-family: var(--mono); font-size: 12px; }
.barra .pista { height: 6px; border-radius: 3px; background: var(--linea); overflow: hidden; }
.barra .relleno { height: 100%; width: 0; background: var(--verde); transition: width .5s; }
.barra .relleno.medio { background: var(--ambar); } .barra .relleno.alto { background: var(--rojo); }
.pares { display: grid; gap: 0; font-size: 12.5px; }
.pares div { display: flex; justify-content: space-between; border-top: 1px solid var(--linea); padding: 7px 0; color: var(--txt2); }
.pares b { color: var(--txt); font-weight: 500; font-family: var(--mono); font-size: 12px; }
.servicios { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--linea); }
.serv { font-size: 12px; color: var(--txt3); display: flex; gap: 6px; align-items: center; }
.serv i { width: 7px; height: 7px; border-radius: 50%; background: var(--txt3); }
.serv.ok { color: var(--txt2); } .serv.ok i { background: var(--verde); }

.tabla-caja { overflow-x: auto; }
.tabla-larga { max-height: 480px; overflow: auto; }
.tabla-larga thead th { position: sticky; top: 0; background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; font-family: var(--sans); font-weight: 500; font-size: 12px; color: var(--txt3); padding: 7px 10px; border-bottom: 1px solid var(--linea); white-space: nowrap; }
td { padding: 7px 10px; border-bottom: 1px solid var(--linea); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255, 255, 255, .025); }
td.d, th.d { text-align: right; }
.lado { font-family: var(--sans); font-size: 12px; font-weight: 500; } .lado.buy { color: var(--verde); } .lado.sell { color: var(--rojo); }
.resumen { display: none; }

.registro { font-family: var(--mono); font-size: 12px; line-height: 1.7; max-height: 300px; overflow-y: auto; }
.registro div { display: flex; gap: 14px; }
.registro time { color: var(--txt3); flex: none; }
.registro .tipo { flex: none; width: 92px; color: var(--txt2); overflow: hidden; text-overflow: ellipsis; }
.registro .msj { color: var(--txt); white-space: normal; }
.registro .warning .msj { color: var(--ambar); } .registro .error .msj { color: var(--rojo); }
::-webkit-scrollbar { width: 8px; height: 8px; } ::-webkit-scrollbar-thumb { background: var(--linea2); border-radius: 4px; }

.acceso { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.acceso form { width: min(340px, 100%); padding: 26px; }
.acceso h1 { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.acceso p { color: var(--txt2); font-size: 13px; margin: 0 0 18px; }
.acceso input { width: 100%; background: var(--bg); border: 1px solid var(--linea2); color: var(--txt); padding: 11px 12px; border-radius: 4px; font: inherit; font-size: 15px; outline: none; }
.acceso input:focus { border-color: var(--azul); }
.acceso button { width: 100%; margin-top: 10px; padding: 11px; border: 0; border-radius: 4px; background: var(--azul); color: #fff; font: inherit; font-weight: 500; cursor: pointer; }
.acceso .err { color: var(--rojo); font-size: 12.5px; margin-top: 10px; min-height: 16px; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .kpis .tarjeta:nth-child(3) { border-right: 0; } .kpis .tarjeta:nth-child(-n+3) { border-bottom: 1px solid var(--linea); }
  .flujo { grid-template-columns: repeat(3, minmax(0, 1fr)); } .dos { grid-template-columns: 1fr; } .chips .chip:nth-child(n+4) { display: none; }
}
@media (max-width: 720px) {
  header { padding: 0 16px; gap: 12px; } main { padding: 14px 14px 50px; } .chips, .reloj { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis .tarjeta { border-right: 1px solid var(--linea) !important; border-bottom: 1px solid var(--linea); } .kpis .tarjeta:nth-child(2n) { border-right: 0 !important; } .kpis .tarjeta:nth-last-child(-n+2) { border-bottom: 0; }
  .kpi .val { font-size: 18px; }
  .flujo { grid-template-columns: 1fr; } .fase { grid-template-columns: auto 1fr auto; } .fase .det { grid-column: 1 / 3; min-height: 0; } .fase .cuenta { grid-column: 3; grid-row: 1 / 3; margin: 0; text-align: right; } .fase::after { display: none; }
  canvas { height: 200px; } .registro div { flex-wrap: wrap; gap: 0 10px; margin-bottom: 8px; } .registro .msj { flex-basis: 100%; }
}
