:root {
  --bg: #0a0f1e;
  --bg2: #0f1629;
  --surface: #131c33;
  --surface2: #192441;
  --border: #22304f;
  --border2: #2c3c62;
  --text: #e8edf7;
  --muted: #8b9bb9;
  --accent: #38bdf8;
  --accent2: #818cf8;
  --ok: #22c55e;
  --bad: #f43f5e;
  --warn: #f59e0b;
  --info: #60a5fa;
  --sombra: 0 10px 30px rgba(0, 0, 0, .35);
  --radio: 14px;
  --fuente: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--fuente);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: radial-gradient(1200px 600px at 10% -10%, #15224a 0%, transparent 60%),
              radial-gradient(900px 500px at 100% 0%, #1b1740 0%, transparent 55%),
              var(--bg);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; font-weight: 800; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 12px; display: flex; align-items: center; gap: 10px; }
h2 .chico { text-transform: none; letter-spacing: 0; font-weight: 500; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.chico { font-size: 12px; }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- cabecera */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 28px;
  padding: 0 24px; height: 60px;
  background: rgba(10, 15, 30, .85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.marca { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; letter-spacing: .12em; font-size: 14px; }
.marca:hover { text-decoration: none; }
.marca .sub { color: var(--muted); font-weight: 600; letter-spacing: .02em; font-size: 13px; }
.logo {
  width: 26px; height: 26px; border-radius: 50%;
  background: conic-gradient(from 200deg, var(--accent), var(--accent2), var(--accent));
  box-shadow: 0 0 18px rgba(56, 189, 248, .45);
  position: relative;
}
.logo::after { content: ''; position: absolute; inset: 7px; border-radius: 50%; background: var(--bg); }
.logo.grande { width: 42px; height: 42px; }
.logo.grande::after { inset: 11px; }
.nav { display: flex; gap: 4px; }
.nav a { color: var(--muted); padding: 8px 14px; border-radius: 10px; font-weight: 600; font-size: 14px; }
.nav a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.nav a.activo { color: var(--text); background: var(--surface2); }
.derecha { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.salir { color: var(--muted); font-weight: 600; font-size: 13px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: 12px; letter-spacing: .06em;
  border: 1px solid var(--border2); background: var(--surface);
}
.pill .punto { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.pill[data-estado="ok"] .punto { background: var(--ok); box-shadow: 0 0 0 0 rgba(34, 197, 94, .7); animation: late 1.6s infinite; }
.pill[data-estado="ok"] { color: #bbf7d0; border-color: rgba(34, 197, 94, .35); }
.pill[data-estado="bad"] .punto { background: var(--bad); }
.pill[data-estado="bad"] { color: #fecdd3; border-color: rgba(244, 63, 94, .4); }
.pill[data-estado="warn"] .punto { background: var(--warn); }
.pill[data-estado="warn"] { color: #fde68a; border-color: rgba(245, 158, 11, .4); }
@keyframes late { 0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .6); } 70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } }

/* ------------------------------------------------------------- layout */
.wrap { max-width: 1480px; margin: 0 auto; padding: 22px 24px 40px; }
.cabecera { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 16px; }
.cabecera h1 { margin-right: auto; }
.pie { display: flex; justify-content: space-between; gap: 12px; padding: 14px 24px 26px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--border); }
.tarjetas { display: grid; grid-template-columns: 1.6fr repeat(5, 1fr); gap: 14px; margin-bottom: 18px; }
.tarjeta {
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg2) 100%);
  border: 1px solid var(--border); border-radius: var(--radio); padding: 16px 18px;
  box-shadow: var(--sombra); min-width: 0;
}
.tarjeta .eti { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.tarjeta .valor { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin: 6px 0 2px; line-height: 1.1; white-space: nowrap; }
.tarjeta.grande .valor { font-size: 44px; }
.tarjeta .nota { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra { height: 8px; border-radius: 999px; background: var(--surface2); margin: 10px 0 8px; overflow: hidden; }
.barra-relleno { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--ok), var(--warn) 70%, var(--bad)); transition: width .6s ease; }
.dos { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; }
.tres { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.caja {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radio);
  padding: 16px 18px; box-shadow: var(--sombra); min-width: 0;
}
.caja + .caja { margin-top: 16px; }
.dos > .caja + .caja, .tres > .caja + .caja { margin-top: 0; }
.ver { margin-left: auto; font-size: 12px; font-weight: 600; text-transform: none; letter-spacing: 0; }

/* ------------------------------------------------------------- tablas */
.tabla { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tabla th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--border2); white-space: nowrap; }
.tabla th.num { text-align: right; }
.tabla td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tabla tbody tr:hover { background: rgba(255, 255, 255, .025); }
.tabla tbody tr:last-child td { border-bottom: 0; }
.tabla tr.nuevo td { animation: aparece 1.4s ease; }
@keyframes aparece { from { background: rgba(56, 189, 248, .22); } to { background: transparent; } }
.tabla .vacio td { color: var(--muted); text-align: center; padding: 22px 10px; }
.tabla.eventos td.detalle { font-family: var(--mono); font-size: 11.5px; color: var(--muted); max-width: 520px; overflow-wrap: anywhere; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 7px; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; background: var(--surface2); color: var(--text); border: 1px solid var(--border2); }
.badge.ok { color: #bbf7d0; background: rgba(34, 197, 94, .14); border-color: rgba(34, 197, 94, .35); }
.badge.bad { color: #fecdd3; background: rgba(244, 63, 94, .14); border-color: rgba(244, 63, 94, .35); }
.badge.warn { color: #fde68a; background: rgba(245, 158, 11, .14); border-color: rgba(245, 158, 11, .35); }
.badge.info { color: #bfdbfe; background: rgba(96, 165, 250, .14); border-color: rgba(96, 165, 250, .35); }
.lado { font-weight: 700; }
.lado.sube { color: var(--ok); }
.lado.baja { color: var(--bad); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border2); background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .03em; }
.chip:hover { color: var(--text); text-decoration: none; }
.chip.activo { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.buscador { display: flex; gap: 8px; }
.buscador input[type=search] { background: var(--bg2); border: 1px solid var(--border2); color: var(--text); border-radius: 10px; padding: 8px 12px; min-width: 280px; font: inherit; }
.boton { display: inline-block; border: 0; border-radius: 11px; padding: 12px 18px; font: inherit; font-weight: 800; color: var(--bg); background: linear-gradient(90deg, var(--accent), #7dd3fc); cursor: pointer; letter-spacing: .02em; }
.boton:hover { filter: brightness(1.08); text-decoration: none; }
.boton.chico { padding: 8px 14px; font-size: 13px; }
.datos { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 13.5px; }
.datos dt { color: var(--muted); }
.datos dd { margin: 0; overflow-wrap: anywhere; }
.alerta { margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: rgba(244, 63, 94, .12); border: 1px solid rgba(244, 63, 94, .4); color: #fecdd3; font-size: 13.5px; }
.alerta ul { margin: 8px 0 0; padding-left: 18px; }

/* ------------------------------------------------------------- feed */
.feed-caja { flex: 1; }
.feed { list-style: none; margin: 0; padding: 0; max-height: 640px; overflow: auto; }
.feed li { display: grid; grid-template-columns: 64px 150px 1fr; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border); font-size: 13px; align-items: start; }
.feed li:last-child { border-bottom: 0; }
.feed li.nuevo { animation: aparece 1.6s ease; }
.feed time { color: var(--muted); font-family: var(--mono); font-size: 12px; padding-top: 2px; }
.feed .texto { overflow-wrap: anywhere; }
.feed .texto small { display: block; color: var(--muted); font-family: var(--mono); font-size: 11px; margin-top: 2px; }
.punto-vivo { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; animation: late 1.6s infinite; }

/* ------------------------------------------------------------- gráfica */
#grafica { width: 100%; height: 170px; display: block; }
.grafica-pie { display: flex; justify-content: space-between; margin-top: 6px; }

/* ------------------------------------------------------------- login */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-fondo { position: fixed; inset: 0; z-index: -1; background: radial-gradient(800px 500px at 20% 20%, rgba(56, 189, 248, .18), transparent 60%), radial-gradient(700px 500px at 80% 80%, rgba(129, 140, 248, .18), transparent 60%); }
.login { width: min(440px, 92vw); }
.login-caja { background: var(--surface); border: 1px solid var(--border2); border-radius: 20px; padding: 32px 30px; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); }
.login-marca { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.login-marca .nombre { font-weight: 800; letter-spacing: .14em; font-size: 15px; }
.login-marca .sub { color: var(--muted); font-size: 13px; }
.login h1 { font-size: 30px; margin-bottom: 4px; }
.login p { margin: 0 0 18px; }
.login label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 14px; }
.login input { display: block; width: 100%; margin-top: 6px; background: var(--bg2); border: 1px solid var(--border2); color: var(--text); border-radius: 11px; padding: 13px 14px; font: inherit; font-size: 16px; }
.login input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.login .boton { width: 100%; margin-top: 6px; font-size: 16px; padding: 14px; }
.login .alerta { margin: 0 0 16px; }
.login-pie { margin-top: 16px !important; font-size: 12px; text-align: center; }

/* ------------------------------------------------------------- responsive */
@media (max-width: 1200px) {
  .tarjetas { grid-template-columns: repeat(3, 1fr); }
  .tarjeta.grande { grid-column: span 3; }
  .dos, .tres { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .top { gap: 12px; padding: 0 14px; height: auto; flex-wrap: wrap; padding-bottom: 8px; }
  .nav { order: 3; width: 100%; overflow: auto; }
  .wrap { padding: 14px; }
  .tarjetas { grid-template-columns: repeat(2, 1fr); }
  .tarjeta.grande { grid-column: span 2; }
  .tarjeta .valor { font-size: 24px; }
  .tarjeta.grande .valor { font-size: 36px; }
  .feed li { grid-template-columns: 56px 1fr; }
  .feed li .badge { grid-column: 2; justify-self: start; }
  .caja { padding: 12px; overflow-x: auto; }
  .buscador input[type=search] { min-width: 0; width: 100%; }
}
