/* =====================================================================
   TempLink · estilo Neko Sistemas (mismo sistema que nekosistemas.com
   y el panel de ServiLink). Compartido por la app y el panel admin.
   ===================================================================== */
:root {
  color-scheme: dark;
  --bg-0: #060b14;
  --bg-1: #0c1829;
  --bg-2: #101f36;
  --line: #1c3252;
  --accent: #4fc3f7;
  --accent-dim: #2ea8e8;
  --chrome: #eaf2fa;
  --chrome-dim: #9db3c9;
  --warn: #e8a33d;
  --rojo: #ff6b6b;
  --rojo-fondo: rgba(255, 107, 107, 0.10);
  --azul: #6fb6ff;
  --verde: #4fd18b;
  --radius: 10px;
  --pad: clamp(16px, 5vw, 56px);
  font-family: 'IBM Plex Sans', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg-0); color: var(--chrome); min-height: 100%; }
body {
  background:
    radial-gradient(ellipse at 20% -10%, rgba(79,195,247,0.10), transparent 45%),
    radial-gradient(ellipse at 90% 10%, rgba(79,195,247,0.06), transparent 40%),
    var(--bg-0);
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.oculto { display: none !important; }
.chakra { font-family: 'Chakra Petch', sans-serif; }

/* ───── Cabecera ───── */
header.cab {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 18px var(--pad); padding-top: max(18px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { height: 30px; width: auto; display: block; }
.brand .texto-logo { font-family: 'Chakra Petch', sans-serif; font-weight: 700; font-size: 15px; letter-spacing: .06em; }
.brand .divider { width: 1px; height: 18px; background: var(--line); }
.brand .producto { font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 15px; color: var(--accent); letter-spacing: .03em; }
.cab-der { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--chrome-dim); }
.cab-der .yo span { color: var(--chrome); }
.estado { display: inline-flex; align-items: center; gap: 7px; }
.punto { width: 8px; height: 8px; border-radius: 50%; background: var(--verde); box-shadow: 0 0 8px var(--verde); }
.punto.mal { background: var(--rojo); box-shadow: 0 0 8px var(--rojo); }
.punto.gris { background: var(--chrome-dim); box-shadow: none; }
@media (max-width: 560px) { .cab-der .yo { display: none; } }

/* ───── Botones ───── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 14px; border-radius: var(--radius); border: 1px solid var(--line);
  background: linear-gradient(160deg, var(--bg-1), var(--bg-2)); font-size: 13px; font-weight: 500;
  transition: border-color .18s ease, color .18s ease;
}
.btn:hover, .btn:focus-visible { border-color: var(--accent-dim); color: var(--accent); outline: none; }
.btn.prim { background: var(--accent); border-color: var(--accent); color: #04202e; font-weight: 600; }
.btn.prim:hover { background: #7dd3fa; color: #04202e; }
.btn.peligro:hover { border-color: var(--rojo); color: var(--rojo); }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.btn.icono { padding: 8px 10px; }
.btn[disabled] { opacity: .5; cursor: default; }

/* ───── Hero con trazas ───── */
.hero { position: relative; padding: clamp(26px, 5vw, 56px) var(--pad) clamp(22px, 4vw, 40px); overflow: hidden; border-bottom: 1px solid var(--line); }
.hero svg.traces { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .5; pointer-events: none; }
.hero svg.traces path { fill: none; stroke: var(--accent-dim); stroke-width: 1.5; stroke-dasharray: 400; stroke-dashoffset: 400; animation: draw 1.8s ease-out forwards; }
.hero svg.traces circle { fill: var(--accent); opacity: 0; animation: dot-in .6s ease-out 1.6s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes dot-in { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .hero svg.traces path { animation: none; stroke-dashoffset: 0; }
  .hero svg.traces circle { animation: none; opacity: 1; }
}
.hero-content { position: relative; max-width: 680px; }
.hero h1 { font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: clamp(24px, 4vw, 36px); line-height: 1.15; margin: 0 0 10px; }
.hero p { font-size: 15px; line-height: 1.6; color: var(--chrome-dim); margin: 0; max-width: 52ch; }

/* ───── Contenido ───── */
main { padding: clamp(22px, 4vw, 44px) var(--pad) 48px; }
.section-label { font-size: 13px; color: var(--chrome-dim); margin: 0 0 16px; display: flex; align-items: center; gap: 10px; }
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.pestanas { display: flex; gap: 6px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.pestanas button { background: none; border: none; border-bottom: 2px solid transparent; padding: 10px 14px; color: var(--chrome-dim); font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 15px; letter-spacing: .02em; margin-bottom: -1px; }
.pestanas button.activo { color: var(--chrome); border-color: var(--accent); }
.contador { display: inline-block; background: var(--rojo); color: #fff; border-radius: 100px; padding: 0 7px; font-size: 11px; margin-left: 6px; font-family: 'IBM Plex Sans', sans-serif; vertical-align: 1px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.chip { font-size: 12px; padding: 4px 11px; border-radius: 100px; border: 1px solid var(--line); color: var(--chrome-dim); background: rgba(12,24,41,.6); }
.chip b { color: var(--chrome); font-weight: 600; }
.chip.rojo { border-color: rgba(255,107,107,.45); color: var(--rojo); }
.chip.warn { border-color: rgba(232,163,61,.45); color: var(--warn); }

/* ───── Tarjetas (tiles) ───── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 12px; padding: 20px;
  background: linear-gradient(160deg, var(--bg-1), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius); text-align: left;
  transition: border-color .18s ease, transform .18s ease;
}
button.tile, a.tile { cursor: pointer; }
.tile:hover, .tile:focus-visible { border-color: var(--accent-dim); transform: translateY(-2px); outline: none; }
.tile h3 { font-family: 'Chakra Petch', sans-serif; font-size: 16px; font-weight: 600; margin: 0; }
.tile p { font-size: 13px; line-height: 1.5; color: var(--chrome-dim); margin: 0; }
.tile .tag { position: absolute; top: 16px; right: 16px; font-size: 10px; letter-spacing: .04em; padding: 3px 8px; border-radius: 100px; border: 1px solid var(--line); color: var(--chrome-dim); }
.tile .tag.warn { color: var(--warn); border-color: rgba(232,163,61,.4); }
.tile .tag.frio { color: var(--accent); border-color: rgba(79,195,247,.4); }
.tile .tag.rojo { color: var(--rojo); border-color: rgba(255,107,107,.45); }

.hex {
  flex: none; width: 46px; height: 46px; display: flex; align-items: center; justify-content: center;
  background: var(--bg-0); clip-path: polygon(25% 2%, 75% 2%, 100% 50%, 75% 98%, 25% 98%, 0% 50%);
  border: 1px solid var(--accent-dim); box-shadow: 0 0 12px rgba(79,195,247,0.25) inset;
}
.hex svg { width: 22px; height: 22px; stroke: var(--accent); fill: none; stroke-width: 1.6; }
.hex.peq { width: 38px; height: 38px; }
.hex.peq svg { width: 18px; height: 18px; }
.hex.rojo { border-color: var(--rojo); box-shadow: 0 0 12px rgba(255,107,107,.3) inset; }
.hex.rojo svg { stroke: var(--rojo); }
.hex.gris svg { stroke: var(--chrome-dim); }

/* Tarjeta de nevera */
.nevera { min-height: 168px; gap: 6px; }
.nevera .cab-tarjeta { display: flex; align-items: center; gap: 12px; padding-right: 74px; }
.nevera .nombre { font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nevera .temp { font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 44px; line-height: 1; margin: 10px 0 4px; font-variant-numeric: tabular-nums; }
.nevera .temp small { font-size: 16px; color: var(--chrome-dim); font-weight: 500; margin-left: 4px; }
.nevera .temp.texto { font-size: 19px; margin: 16px 0 8px; color: var(--chrome-dim); }
.nevera .linea { font-size: 12.5px; color: var(--chrome-dim); }
.nevera.alarma { border-color: var(--rojo); background: linear-gradient(160deg, #2a1420, var(--bg-2) 70%); box-shadow: 0 0 0 1px rgba(255,107,107,.25), 0 0 24px rgba(255,107,107,.12); }
.nevera.alarma .temp { color: var(--rojo); }
.nevera.baja .temp { color: var(--azul); }
.nevera.sincom { border-style: dashed; opacity: .75; }
.nevera.apagada { opacity: .5; background: transparent; }

/* Aviso destacado */
.banda { border: 1px solid rgba(255,107,107,.45); background: var(--rojo-fondo); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; font-size: 14px; line-height: 1.6; }
.banda.info { border-color: var(--line); background: rgba(12,24,41,.6); color: var(--chrome-dim); }

/* Listas (eventos, usuarios) */
.lista { display: flex; flex-direction: column; gap: 8px; }
.fila { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: linear-gradient(160deg, var(--bg-1), var(--bg-2)); border: 1px solid var(--line); border-radius: var(--radius); font-size: 14px; }
.fila .crece { flex: 1; min-width: 0; }
.fila time, .fila .sub { display: block; color: var(--chrome-dim); font-size: 12px; margin-bottom: 2px; }
.fila.activa { border-color: rgba(255,107,107,.5); }
.vacio { color: var(--chrome-dim); font-size: 14px; padding: 6px 2px; }

/* Formularios */
label { display: block; font-size: 12.5px; color: var(--chrome-dim); margin: 14px 0 6px; }
input[type=text], input[type=password], input[type=number], select {
  width: 100%; padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--bg-0); color: var(--chrome); font: inherit; font-size: 15px;
}
input:focus, select:focus { outline: none; border-color: var(--accent-dim); box-shadow: 0 0 0 3px rgba(79,195,247,.15); }
.error { color: var(--rojo); font-size: 13px; min-height: 1.2em; margin-top: 10px; }
.ok-msg { color: var(--verde); font-size: 13px; min-height: 1.2em; margin-top: 10px; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; }
.login { width: min(100% - 32px, 380px); margin: auto; padding: 30px 26px; background: linear-gradient(160deg, var(--bg-1), var(--bg-2)); border: 1px solid var(--line); border-radius: 14px; position: relative; }
.login .brand { justify-content: center; margin-bottom: 18px; }
.login h1 { font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 22px; text-align: center; margin: 0 0 4px; }
.login .sub { text-align: center; color: var(--chrome-dim); font-size: 13px; margin: 0 0 10px; }
.login .btn.prim { width: 100%; margin-top: 20px; padding: 12px; font-size: 15px; }

/* Diálogo */
dialog { border: 1px solid var(--line); padding: 0; background: linear-gradient(160deg, var(--bg-1), var(--bg-2)); color: var(--chrome); border-radius: 16px 16px 0 0; width: 100%; max-width: 560px; margin: auto auto 0; max-height: calc(100% - 48px); overflow: auto; overscroll-behavior: contain; }
@media (min-width: 640px) { dialog { border-radius: 16px; margin: auto; } }
dialog[open] { display: block; }
dialog::backdrop { background: rgba(2,6,12,.75); backdrop-filter: blur(2px); }
.dlg-cab { position: sticky; top: 0; z-index: 1; background: var(--bg-1); padding: 16px 18px 12px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.dlg-cab h3 { margin: 0; flex: 1; font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 18px; }
.dlg-cuerpo { padding: 6px 18px 18px; }
.dlg-pie { position: sticky; bottom: 0; background: var(--bg-2); padding: 12px 18px 16px; display: flex; gap: 10px; border-top: 1px solid var(--line); }
.dlg-pie .btn { flex: 1; padding: 12px; font-size: 14px; }
.nota { font-size: 13px; color: var(--chrome-dim); margin: 8px 0 12px; }
canvas.grafica { width: 100%; height: 150px; background: var(--bg-0); border-radius: var(--radius); border: 1px solid var(--line); display: block; }

.interruptor-fila { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--bg-0); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 14px 0 4px; }
.interruptor-fila small { display: block; color: var(--chrome-dim); font-size: 12px; margin-top: 2px; }
.interruptor { position: relative; width: 50px; height: 28px; flex: none; }
.interruptor input { opacity: 0; width: 0; height: 0; }
.interruptor span { position: absolute; inset: 0; background: var(--bg-2); border-radius: 30px; border: 1px solid var(--line); transition: .2s; }
.interruptor span::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: var(--chrome-dim); border-radius: 50%; transition: .2s; }
.interruptor input:checked + span { background: rgba(79,195,247,.18); border-color: var(--accent); }
.interruptor input:checked + span::before { transform: translateX(22px); background: var(--accent); box-shadow: 0 0 8px var(--accent); }

.param { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.param .et { font-size: 14px; }
.param .et small { display: block; color: var(--chrome-dim); font-size: 11.5px; margin-top: 2px; }
.ajuste { display: flex; align-items: center; gap: 6px; }
.ajuste button { width: 38px; height: 38px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-0); font-size: 18px; }
.ajuste button:hover { border-color: var(--accent-dim); color: var(--accent); }
.ajuste input { width: 82px; text-align: center; padding: 8px 4px; font-family: 'Chakra Petch', sans-serif; font-weight: 600; }

footer { padding: 20px var(--pad) 32px; font-size: 12px; color: var(--chrome-dim); border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
