:root {
  /* Acero de cocina + semáforo: la identidad del sistema */
  --ink: #1c2024;
  --muta: #5b6168;
  --linea: #d9dde1;
  --fondo: #f5f6f7;
  --panel: #ffffff;
  --acero: #2f6f8f;        /* azul acero, acento de marca */
  --verde: #1d9e56;
  --ambar: #e0911a;
  --rojo: #d23b3b;
  --radio: 14px;
  font-size: 18px;          /* base grande: se lee de pie, con guantes */
}

* { box-sizing: border-box; }
/* El atributo hidden debe ocultar SIEMPRE, aunque la regla del elemento ponga display:grid/flex. */
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--fondo);
  -webkit-tap-highlight-color: transparent;
}
.pantalla { min-height: 100vh; }

/* Transición de "entrar": la app aparece deslizándose desde arriba. */
#app:not([hidden]) { animation: entrar .3s ease-out both; }
@keyframes entrar {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) { #app:not([hidden]) { animation: none; } }

/* --- Login --- */
#login { display: grid; place-items: center; }
.login-caja {
  background: var(--panel); padding: 2rem; border-radius: var(--radio);
  width: min(90vw, 380px); box-shadow: 0 1px 0 var(--linea);
}
.marca { letter-spacing: .3em; color: var(--acero); font-weight: 600; margin: 0; }
.login-caja h1 { margin: .2rem 0 0; font-size: 1.8rem; }
.sub { color: var(--muta); margin: .2rem 0 1.4rem; }

.campo {
  width: 100%; padding: .9rem 1rem; margin-bottom: .8rem;
  border: 1.5px solid var(--linea); border-radius: 10px;
  font-size: 1.1rem; background: var(--panel); color: var(--ink);
}
.campo-mini { width: auto; padding: .5rem .7rem; margin: 0; font-size: 1rem; }

/* --- Botones --- */
.btn {
  border: 0; border-radius: 10px; cursor: pointer; font-size: 1.05rem;
  padding: .9rem 1.2rem; background: var(--acero); color: #fff; font-weight: 600;
}
.btn:active { transform: translateY(1px); }
.btn-grande { width: 100%; padding: 1.1rem; font-size: 1.2rem; }
.btn-texto { background: none; color: var(--muta); font-weight: 500; }
.btn-fantasma { background: var(--panel); color: var(--ink); border: 1.5px solid var(--linea); }

.error { color: var(--rojo); margin: .6rem 0 0; }

/* --- Barra superior --- */
.barra {
  display: flex; justify-content: space-between; align-items: center;
  padding: .8rem 1.2rem; background: var(--panel); border-bottom: 1px solid var(--linea);
}
.barra-sede { font-weight: 600; }
.barra-usuario { color: var(--muta); margin-left: .6rem; }
.barra-acciones { display: flex; align-items: center; gap: .6rem; }

/* --- Menú de módulos --- */
.menu {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem; padding: 1.2rem;
}
.tarjeta {
  background: var(--panel); border: 1px solid var(--linea); border-radius: var(--radio);
  padding: 1.4rem 1rem; text-align: center; cursor: pointer; font-size: 1.1rem; font-weight: 600;
}
.tarjeta:active { transform: translateY(1px); }
.tarjeta small { display: block; color: var(--muta); font-weight: 400; margin-top: .3rem; }

/* --- Módulo activo --- */
.modulo { padding: 1.2rem; max-width: 640px; margin: 0 auto; }
.modulo h2 { margin: 0 0 1rem; }
.fila { display: flex; gap: .8rem; flex-wrap: wrap; align-items: end; }
.fila > label { flex: 1; display: block; }
.fila label span { display: block; color: var(--muta); margin-bottom: .3rem; font-size: .95rem; }

/* --- Semáforo: el elemento firma --- */
.semaforo {
  display: flex; align-items: center; gap: 1rem; padding: 1.2rem; border-radius: var(--radio);
  background: var(--panel); border: 1px solid var(--linea); margin: 1rem 0;
}
.luz { width: 64px; height: 64px; border-radius: 50%; background: var(--linea); flex: none; }
.semaforo.verde .luz { background: var(--verde); }
.semaforo.ambar .luz { background: var(--ambar); }
.semaforo.rojo  .luz { background: var(--rojo); }
.semaforo .estado { font-size: 1.3rem; font-weight: 600; }
.semaforo .accion { color: var(--muta); }

/* --- Tabla de registros --- */
table { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: .95rem; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--linea); }
th { color: var(--muta); font-weight: 600; }
.pill { padding: .15rem .55rem; border-radius: 999px; color: #fff; font-size: .8rem; }
.pill.verde { background: var(--verde); } .pill.ambar { background: var(--ambar); } .pill.rojo { background: var(--rojo); }

/* --- Temperaturas: vista "Cocina" en directo --- */
.temp-meta { color: var(--muta); margin: .2rem 0 1rem; }
.temp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.temp-card {
  background: var(--panel); border: 1px solid var(--linea); border-left: 8px solid var(--linea);
  border-radius: var(--radio); padding: 1rem 1.1rem;
}
.temp-card.verde { border-left-color: var(--verde); }
.temp-card.ambar { border-left-color: var(--ambar); }
.temp-card.rojo  { border-left-color: var(--rojo); background: #fdecec; }
.temp-card.sin-dato { border-left-color: var(--muta); opacity: .65; }
.temp-camara { font-weight: 600; }
.temp-valor { font-size: 2.4rem; font-weight: 700; line-height: 1.1; margin: .3rem 0; }
.temp-card.verde .temp-valor { color: var(--verde); }
.temp-card.ambar .temp-valor { color: var(--ambar); }
.temp-card.rojo  .temp-valor { color: var(--rojo); }
.temp-ud { font-size: 1rem; font-weight: 600; color: var(--muta); margin-left: .15rem; }
.temp-tipo { color: var(--muta); font-size: .9rem; }
.temp-aviso { color: var(--ambar); font-size: .85rem; font-weight: 600; margin-top: .4rem; }
.temp-leyenda { color: var(--muta); font-size: .85rem; margin-top: 1.2rem; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* --- Administración de sondas --- */
.adm-campo { display: block; max-width: 320px; margin-bottom: 1rem; }
.adm-campo span { display: block; color: var(--muta); margin-bottom: .3rem; }
.adm-form { background: var(--panel); border: 1px solid var(--linea); border-radius: var(--radio); padding: 1rem 1.2rem; }
.adm-form h3 { margin: .2rem 0 .8rem; }
.adm-form .fila label span { color: var(--muta); }
.adm-det-item { display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .6rem .9rem; border: 1px solid var(--linea); border-radius: 10px; margin-bottom: .5rem; background: var(--panel); }
.adm-det-nombre { font-weight: 600; }
.adm-det-eid { color: var(--muta); font-size: .8rem; word-break: break-all; }
.adm-det-add { padding: .5rem 1rem; }
.adm-ayuda-btn { background: none; border: 1.5px solid var(--acero); color: var(--acero);
  border-radius: 999px; padding: .5rem 1rem; font-size: .95rem; font-weight: 600; cursor: pointer; margin-bottom: 1rem; }
.adm-ayuda-btn:active { transform: translateY(1px); }
.adm-ayuda { background: #eef4f7; border: 1px solid #cfe0e8; border-radius: var(--radio);
  padding: 1rem 1.3rem; margin-bottom: 1.2rem; }
.adm-ayuda h3 { margin: .2rem 0 .6rem; }
.adm-ayuda ol { margin: 0; padding-left: 1.2rem; }
.adm-ayuda li { margin-bottom: .5rem; line-height: 1.4; }
.adm-ayuda code { background: #fff; border: 1px solid var(--linea); border-radius: 5px; padding: .05rem .3rem; font-size: .85em; }
.adm-ayuda-nota { color: var(--muta); font-size: .9rem; margin: .6rem 0 0; }
