/* RIP Herconbyte — estilos base */
:root {
  --fondo: #eef1f4; --panel: #ffffff; --tinta: #1e293b; --gris: #64748b; --borde: #d6dde4;
  --lapida: #1f2a36; --piedra: #9aa7b4;
  --ok: #2f7d32; --ok-bg: #e7f4e8; --alerta: #b45309; --alerta-bg: #fdf3e2; --falla: #c62828; --falla-bg: #fdecea;
  --azul: #2563eb; --radio: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--fondo); color: var(--tinta); font-size: 15px; }
body.no-scroll { overflow: hidden; }
a { color: var(--azul); }

/* ---------- encabezado ---------- */
.top { background: var(--lapida); color: #fff; position: sticky; top: 0; z-index: 50; padding-top: env(safe-area-inset-top); }
.top-in { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 14px; padding: 10px 16px; }
.top-logo { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; letter-spacing: .5px; }
.top-logo img { width: 34px; height: 34px; border-radius: 9px; }
.top nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.top nav a { color: #c7d0d9; text-decoration: none; padding: 8px 12px; border-radius: 9px; white-space: nowrap; font-size: .92rem; }
.top nav a.activo, .top nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.top-acc { display: flex; gap: 4px; }
.top-acc a { color: #c7d0d9; text-decoration: none; padding: 8px 9px; border-radius: 9px; font-size: 1.05rem; }
.top-acc a:hover { background: rgba(255,255,255,.1); }

/* el menú va SIEMPRE en una barra inferior fija, también en la PC (pedido del dueño 29/09/26) */
.top nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; background: var(--lapida); gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); justify-content: center; overflow: visible;
  box-shadow: 0 -4px 18px rgba(0,0,0,.18); }
.top nav a { flex: 0 1 150px; text-align: center; padding: 8px 4px; font-size: .86rem; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.top-in { justify-content: space-between; }
@media (max-width: 700px) {
  .top nav { gap: 0; justify-content: space-around; }
  .top nav a { flex: 1; font-size: .72rem; padding: 8px 2px; }
  .top-logo span { display: none; }
}

/* Ajustes: tarjetas una al lado de la otra */
.grid-ajustes { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); align-items: start; }
.grid-ajustes .card { margin-bottom: 0; }
.fila2 { display: grid; gap: 0 10px; grid-template-columns: 1fr 1fr; }

.contenido { max-width: 1100px; margin: 0 auto; padding: 18px 16px 90px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 14px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.35rem; margin: 0; }

/* ---------- tarjetas ---------- */
.card { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: 16px; margin-bottom: 14px; }
.card h2 { font-size: 1.05rem; margin: 0 0 10px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.muted { color: var(--gris); font-size: .86rem; }
.big { font-size: 2rem; font-weight: 700; line-height: 1.1; }

/* estado de vida */
.vida { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.vida-dias { font-size: 3rem; font-weight: 800; line-height: 1; min-width: 90px; text-align: center; }
.vida-dias small { display: block; font-size: .8rem; font-weight: 500; color: var(--gris); }
.fase { display: inline-block; padding: 4px 10px; border-radius: 999px; font-weight: 600; font-size: .82rem; }
.fase.activo { background: var(--ok-bg); color: var(--ok); }
.fase.pregunta, .fase.pausa, .fase.frenado { background: var(--alerta-bg); color: var(--alerta); }
.fase.confianza, .fase.liberado { background: var(--falla-bg); color: var(--falla); }
.linea { display: flex; gap: 4px; margin: 12px 0 4px; }
.linea div { flex: 1; height: 8px; border-radius: 4px; background: #e2e8f0; position: relative; }
.linea div.on { background: var(--piedra); }
.linea div.hoy { background: var(--lapida); }
.linea-leyenda { display: flex; justify-content: space-between; font-size: .75rem; color: var(--gris); }

/* semáforo de sistemas */
.sis { display: flex; align-items: flex-start; gap: 10px; padding: 11px 0; border-top: 1px solid #eef1f4; }
.sis:first-child { border-top: 0; }
.dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 5px; flex: 0 0 12px; background: #cbd5e1; }
.dot.ok { background: var(--ok); } .dot.alerta { background: #f59e0b; } .dot.falla { background: var(--falla); }
.sis-main { flex: 1; min-width: 0; }
.sis-main strong { display: block; }
.sis-acc { display: flex; gap: 6px; }
.chq { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: .76rem; background: #eef1f4; color: var(--tinta); }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.alerta { background: var(--alerta-bg); color: var(--alerta); } .chip.falla { background: var(--falla-bg); color: var(--falla); }

/* tablas → tarjetas en celular */
table.tabla { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.tabla th { text-align: left; color: var(--gris); font-weight: 600; font-size: .78rem; padding: 8px; border-bottom: 1px solid var(--borde); }
table.tabla td { padding: 9px 8px; border-bottom: 1px solid #eef1f4; vertical-align: top; }
@media (max-width: 700px) {
  table.tabla thead { display: none; }
  table.tabla, table.tabla tbody, table.tabla tr, table.tabla td { display: block; width: 100%; }
  table.tabla tr { border: 1px solid var(--borde); border-radius: 12px; margin-bottom: 10px; padding: 6px 4px; background: #fff; }
  table.tabla td { border: 0; padding: 4px 8px; }
  table.tabla td[data-l]::before { content: attr(data-l) ': '; color: var(--gris); font-size: .78rem; }
}

/* ---------- formularios y botones ---------- */
label { display: block; font-size: .82rem; color: var(--gris); margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--borde); border-radius: 10px; font: inherit; background: #fff; color: var(--tinta); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(37,99,235,.25); border-color: var(--azul); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border: 0; border-radius: 10px; font: inherit; font-weight: 600;
  cursor: pointer; background: var(--lapida); color: #fff; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn.sec { background: #e2e8f0; color: var(--tinta); }
.btn.verde { background: var(--ok); } .btn.rojo { background: var(--falla); } .btn.naranja { background: var(--alerta); }
.btn.chico { padding: 6px 10px; font-size: .82rem; }
.btn.grande { padding: 16px 22px; font-size: 1.1rem; width: 100%; }
.fila { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* ---------- modales (reglas de la casa: ✕ + ESC + click afuera, base 1000) ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: 16px; width: min(560px, 100%); max-height: 92dvh; overflow: auto; padding: 20px; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.modal.angosto { width: min(420px, 100%); }
.modal.ancho { width: min(820px, 100%); }
.modal h2 { margin: 0 34px 10px 0; font-size: 1.15rem; }
.modal-close { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: #eef1f4; cursor: pointer; font-size: 1rem; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; position: sticky; bottom: -20px; background: #fff; padding: 10px 0 0; }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 9998; display: flex; flex-direction: column; gap: 8px; width: min(420px, 92vw); }
.toast { background: var(--lapida); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.25); font-size: .92rem; }
.toast.error { background: var(--falla); }

/* ---------- login ---------- */
.login-body { min-height: 100dvh; display: flex; align-items: center; justify-content: center; background: radial-gradient(900px 600px at 50% -10%, #3b4a5a, #1f2a36 55%, #111820); padding: 16px; }
.login-card { width: min(400px, 100%); background: #fff; border-radius: 20px; padding: 30px 26px; text-align: center; box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.login-card img { width: 88px; height: 88px; border-radius: 20px; }
.login-card h1 { font-size: 1.2rem; margin: 12px 0 2px; }
.pin-row { display: flex; gap: 8px; justify-content: center; margin: 8px 0; }
.pin-row input { width: 44px; height: 54px; text-align: center; font-size: 1.4rem; font-weight: 700; padding: 0; }
.msg { margin-top: 14px; padding: 10px 12px; border-radius: 10px; font-size: .88rem; display: none; }
.msg.ok { display: block; background: var(--ok-bg); color: var(--ok); }
.msg.error { display: block; background: var(--falla-bg); color: var(--falla); }
