:root {
  --bg: #f6f7f9; --panel: #ffffff; --texto: #1b2230; --suave: #5b6578; --borde: #dde1e8;
  --acento: #1f5fd6; --acento-t: #ffffff; --ok: #1a7f46; --aviso: #a86a00; --mal: #c0392b; --info: #5b6578;
  --ok-bg: #e5f5ec; --aviso-bg: #fff3dc; --mal-bg: #fdeaea; --info-bg: #eceff4;
  --radio: 10px; --sombra: 0 1px 2px rgba(20,30,50,.06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f131a; --panel: #171d27; --texto: #e6eaf2; --suave: #98a2b5; --borde: #2a3342;
    --acento: #5b95ff; --acento-t: #0b1220; --ok: #4cc983; --aviso: #f0b24a; --mal: #ff7a6b; --info: #98a2b5;
    --ok-bg: #12301f; --aviso-bg: #33270f; --mal-bg: #3a1a18; --info-bg: #212a38;
  }
}
:root[data-theme="dark"] {
  --bg: #0f131a; --panel: #171d27; --texto: #e6eaf2; --suave: #98a2b5; --borde: #2a3342;
  --acento: #5b95ff; --acento-t: #0b1220; --ok: #4cc983; --aviso: #f0b24a; --mal: #ff7a6b; --info: #98a2b5;
  --ok-bg: #12301f; --aviso-bg: #33270f; --mal-bg: #3a1a18; --info-bg: #212a38;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--texto); }
body { font-size: 15px; line-height: 1.45; }
h1 { font-size: 1.4rem; margin: 0 0 .5rem; } h2 { font-size: 1.1rem; margin: 1.4rem 0 .6rem; } h3 { font-size: 1rem; margin: 0 0 .4rem; }
.muted { color: var(--suave); } .grow { flex: 1; } .error { color: var(--mal); min-height: 1.2em; }
button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--borde); background: var(--panel); color: var(--texto); padding: .45rem .8rem; }
button:hover { border-color: var(--acento); }
button.primary { background: var(--acento); color: var(--acento-t); border-color: var(--acento); font-weight: 600; }
button.ghost { background: transparent; }
button.peligro { color: var(--mal); border-color: var(--mal); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }
input, select, textarea { font: inherit; width: 100%; padding: .5rem .6rem; border-radius: 8px; border: 1px solid var(--borde); background: var(--panel); color: var(--texto); }
textarea { min-height: 90px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
label { display: block; margin: .6rem 0; font-size: .9rem; color: var(--suave); } label > input, label > select, label > textarea { margin-top: .25rem; color: var(--texto); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; }
.card { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: 16px; box-shadow: var(--sombra); }

#app { display: grid; grid-template-columns: 230px 1fr; grid-template-rows: auto 1fr; min-height: 100vh; }
.top { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--borde); position: sticky; top: 0; z-index: 5; }
.menu-btn { display: none; }
.nav { padding: 12px 8px; border-right: 1px solid var(--borde); background: var(--panel); overflow-y: auto; }
.nav button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: .55rem .75rem; border-radius: 8px; }
.nav button[aria-current="page"] { background: var(--info-bg); font-weight: 600; color: var(--acento); }
.main { padding: 18px 20px 60px; min-width: 0; max-width: 1280px; }

.grid { display: grid; gap: 12px; } .g2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); } .g4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.kpi .v { font-size: 1.7rem; font-weight: 700; } .kpi .t { color: var(--suave); font-size: .85rem; }
.pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--info-bg); color: var(--info); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.aviso { background: var(--aviso-bg); color: var(--aviso); } .pill.mal { background: var(--mal-bg); color: var(--mal); }
.tabla-wrap { overflow-x: auto; border: 1px solid var(--borde); border-radius: var(--radio); background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { text-align: left; padding: .5rem .65rem; border-bottom: 1px solid var(--borde); vertical-align: top; max-width: 340px; overflow-wrap: anywhere; }
th { color: var(--suave); font-weight: 600; background: var(--bg); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
.barra { height: 10px; background: var(--info-bg); border-radius: 6px; overflow: hidden; } .barra > i { display: block; height: 100%; background: var(--acento); }
.fila { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: .5rem 0; }
.cap { cursor: pointer; text-align: left; display: block; width: 100%; }
.cap .n { color: var(--suave); font-size: .8rem; }
pre.json { background: var(--bg); border: 1px solid var(--borde); border-radius: 8px; padding: 10px; overflow: auto; max-height: 360px; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
dialog { border: 1px solid var(--borde); border-radius: 12px; background: var(--panel); color: var(--texto); padding: 0; width: min(680px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.modal-box { padding: 18px; max-height: 85vh; overflow: auto; }
svg.spark { width: 100%; height: 60px; } svg.spark polyline { fill: none; stroke: var(--acento); stroke-width: 2; }

@media (max-width: 800px) {
  #app { grid-template-columns: minmax(0, 1fr); }
  .top { gap: 8px; padding: 10px 12px; }
  #reloj { display: none; }
  .grid.g2, .grid.g4 { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-block; }
  .nav { display: none; position: fixed; top: 52px; left: 0; right: 0; bottom: 0; z-index: 6; border-right: 0; }
  .nav.abierto { display: block; }
  .main { padding: 14px 16px 60px; }
}

/* ojito de la contraseña */
.campo-clave { position: relative; }
.campo-clave input { padding-right: 52px; }
.ojo { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--suave); }
.ojo:hover { color: var(--acento); border: 0; }
.ojo[aria-pressed="true"] { color: var(--acento); }
.login-card label { margin-bottom: .1rem; }
.login-card .campo-clave { margin-bottom: .6rem; }
.login-card input[type=text], .login-card input[type=password] { margin-bottom: .2rem; }
