/* =========================================================
   Plataforma NanoFreeze · Demo — estilos mobile-first
   Paleta y tipografías tomadas del sitio de NanoFreeze.
   ========================================================= */
:root {
  --bg: #010b1b;
  --surface: #06152b;
  --surface-2: #0a1f3d;
  --cyan: #00f0ff;
  --blue: #0088ff;
  --ice: #8ee9ff;
  --text: #ffffff;
  --text-2: #e6f0fa;
  --muted: #b0c5e0;
  --border: rgba(0, 240, 255, 0.16);
  --border-strong: rgba(0, 240, 255, 0.4);
  --ok: #3ddc97;
  --warn: #ffb547;
  --crit: #ff5d6c;
  --font-h: 'Outfit', system-ui, sans-serif;
  --font-b: 'Inter', system-ui, sans-serif;
  --r-sm: 8px; --r-md: 14px; --r-lg: 20px;
  --nav-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text-2);
  font: 15px/1.5 var(--font-b); -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
h1, h2, h3 { font-family: var(--font-h); color: var(--text); margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; font-weight: 700; }
p { margin: 0; }
a { color: var(--cyan); }
button, input, select { font: inherit; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.muted { color: var(--muted); }
small { font-size: .65em; color: var(--muted); font-weight: 500; }

/* ---------- Aviso de demo y barra superior ---------- */
.demo-banner {
  background: linear-gradient(90deg, rgba(0,136,255,.25), rgba(0,240,255,.25));
  color: var(--text); text-align: center; font-size: .8rem; padding: 6px 12px;
  border-bottom: 1px solid var(--border);
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: rgba(1, 11, 27, .92);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.brand img { display: block; height: 34px; width: auto; }
.topbar__client { display: none; flex-direction: column; margin-left: 8px; padding-left: 14px; border-left: 1px solid var(--border); }
.topbar__label { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.topbar__client strong { color: var(--text); font-weight: 600; font-size: .9rem; }
.lang { margin-left: auto; display: flex; border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.lang__btn { border: 0; background: none; color: var(--muted); padding: 6px 12px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: .8rem; min-height: 32px; }
.lang__btn.is-active { background: var(--cyan); color: var(--bg); }

/* ---------- Navegación: barra inferior en celular ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: rgba(6, 21, 43, .97); border-top: 1px solid var(--border);
}
.nav__link {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: .7rem; font-weight: 500;
}
.nav__icon { font-size: 1.15rem; line-height: 1; }
.nav__link.is-active { color: var(--cyan); }
.nav__badge {
  position: absolute; top: 8px; left: 56%; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--crit); color: #fff; font-size: .68rem; font-weight: 700;
  display: grid; place-items: center;
}
.nav__badge[hidden] { display: none; }

/* ---------- Contenido ---------- */
.main { width: 100%; padding: 20px 16px 32px; max-width: 1120px; margin: 0 auto; outline: none; }
.view { display: grid; gap: 18px; }
.view__head { display: grid; gap: 10px; }
.lead { color: var(--muted); margin-top: 6px; max-width: 60ch; }
.stamp { display: inline-flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.section-title { font-size: 1.15rem; margin-top: 6px; }
.source { font-size: .75rem; color: var(--muted); margin-top: 12px; }
.empty { color: var(--muted); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip {
  flex: none; border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  padding: 8px 14px; border-radius: 999px; cursor: pointer; font-size: .85rem; min-height: 38px;
}
.chip.is-active { border-color: var(--cyan); color: var(--cyan); background: rgba(0,240,255,.08); }

/* ---------- Tarjetas e indicadores ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px; }
.card__title { font-size: 1.05rem; margin-bottom: 8px; }
.card--cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px; }
.kpi__label { font-size: .75rem; color: var(--muted); }
.kpi__value { font-family: var(--font-h); font-size: 1.4rem; font-weight: 700; color: var(--text); margin-top: 4px; word-break: break-word; }

/* ---------- Gráfica ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .78rem; color: var(--text-2); margin-bottom: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sw--base { background: #3a5378; }
.sw--real { background: var(--cyan); }
.sw--goal { background: var(--warn); width: 3px; height: 14px; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: rgba(176,197,224,.14); }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font-b); }
.bar--base { fill: #3a5378; }
.bar--real { fill: var(--cyan); }

/* ---------- Neveras ---------- */
.fridges { display: grid; gap: 10px; }
.fridge { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px; }
.fridge--alert { border-color: rgba(255,181,71,.5); }
.fridge--nodata { border-style: dashed; }
.fridge__head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.fridge__id { font-size: 1rem; }
.fridge__site { color: var(--muted); font-size: .82rem; }
.fridge__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 8px; margin: 12px 0 8px; }
.fridge__stats dt { font-size: .7rem; color: var(--muted); }
.fridge__stats dd { margin: 0; color: var(--text); font-weight: 600; font-size: .9rem; }
.fridge__stats em, .lease-row__val em { color: var(--warn); font-style: normal; font-weight: 500; }
.fridge__time { font-size: .72rem; color: var(--muted); }

.status { font-size: .72rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.status--ok { color: var(--ok); background: rgba(61,220,151,.12); }
.status--alert { color: var(--warn); background: rgba(255,181,71,.14); }
.status--nodata { color: var(--muted); background: rgba(176,197,224,.12); }

/* ---------- Alertas ---------- */
.alerts { display: grid; gap: 10px; }
.alert {
  display: grid; gap: 12px; background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--warn); border-radius: var(--r-md); padding: 14px;
}
.alert--critical { border-left-color: var(--crit); }
.alert.is-closed { opacity: .65; border-left-color: var(--ok); }
.alert h3 { font-size: 1rem; margin: 6px 0 2px; }
.alert p { font-size: .82rem; }
.alert__notify { color: var(--ice); margin-top: 6px; }
.level { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.level--critical { color: var(--crit); }
.level--preventive { color: var(--warn); }
.done { color: var(--ok); font-size: .85rem; font-weight: 600; }

/* ---------- Arriendo ---------- */
.kpis--3 { grid-template-columns: repeat(3, 1fr); }
.lease { display: grid; gap: 14px; margin-top: 8px; }
.lease-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; }
.lease-row__name { display: flex; flex-direction: column; font-size: .85rem; }
.lease-row__name strong { color: var(--text); }
.lease-row__name .muted { font-size: .75rem; }
.lease-row__val { font-weight: 700; color: var(--text); text-align: right; }
.lease-row--below .lease-row__val { color: var(--crit); }
.lease-bar { grid-column: 1 / -1; position: relative; height: 10px; border-radius: 999px; background: rgba(176,197,224,.12); }
.lease-bar__fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--cyan); }
.lease-row--below .lease-bar__fill { background: var(--crit); }
.lease-bar__goal { position: absolute; top: -4px; bottom: -4px; width: 3px; background: var(--warn); border-radius: 2px; }

/* ---------- Formularios y resultados ---------- */
.form { display: grid; gap: 14px; margin: 14px 0; }
.field { display: grid; gap: 6px; font-size: .82rem; color: var(--muted); }
.field output { color: var(--cyan); font-weight: 700; }
.field input[type=number], .field select {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
}
.field input[type=range] { width: 100%; accent-color: var(--cyan); min-height: 32px; }
.results { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.result { background: var(--surface-2); border-radius: var(--r-md); padding: 12px; }
.result__label { font-size: .72rem; color: var(--muted); }
.result__value { font-family: var(--font-h); font-size: 1.15rem; font-weight: 700; color: var(--cyan); margin-top: 2px; word-break: break-word; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 18px;
  border: 0; border-radius: 999px; cursor: pointer; font-weight: 600; text-decoration: none;
  background: linear-gradient(90deg, var(--blue), var(--cyan)); color: var(--bg);
}
.btn--ghost { background: none; color: var(--cyan); border: 1px solid var(--border-strong); }
.btn--wa { margin-top: 14px; background: #25d366; color: #04210f; }

/* ---------- Página pública ---------- */
.hero { text-align: left; padding: 12px 0 4px; }
.hero h1 { font-size: 1.9rem; background: linear-gradient(90deg, var(--text), var(--ice)); -webkit-background-clip: text; background-clip: text; color: transparent; }
body[data-route="impacto"] .topbar__client { visibility: hidden; }

/* ---------- Reporte (ventana) ---------- */
.dialog {
  width: min(920px, calc(100% - 24px)); max-height: calc(100% - 24px); padding: 0;
  border: 1px solid var(--border-strong); border-radius: var(--r-lg); background: var(--bg); color: var(--text-2);
}
.dialog::backdrop { background: rgba(0, 0, 0, .7); }
.report { padding: 20px; display: grid; gap: 16px; }
.report__head { display: flex; gap: 14px; align-items: center; }
.report__head img { height: 40px; width: auto; }
.report__head h2 { font-size: 1.2rem; }
.report__actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .82rem; min-width: 520px; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 500; }

/* ---------- Escritorio: navegación lateral ---------- */
@media (min-width: 720px) {
  .topbar__client { display: flex; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .kpis--3 { grid-template-columns: repeat(3, 1fr); }
  .fridges { grid-template-columns: repeat(2, 1fr); }
  .results { grid-template-columns: repeat(4, 1fr); }
  .form--grid { grid-template-columns: repeat(4, 1fr); align-items: end; }
  .view__head { grid-template-columns: 1fr auto; align-items: end; }
  .lease-row { grid-template-columns: 200px 1fr 70px; }
  .lease-bar { grid-column: auto; }
  .alert { grid-template-columns: 1fr auto; align-items: center; }
  h1 { font-size: 2rem; }
  .hero h1 { font-size: 2.6rem; }
}
@media (min-width: 1024px) {
  body { padding-bottom: 0; }
  .layout { display: grid; grid-template-columns: 220px 1fr; }
  .nav {
    position: sticky; top: 61px; height: calc(100vh - 61px); padding: 20px 12px;
    display: flex; flex-direction: column; gap: 4px; border-top: 0; border-right: 1px solid var(--border); background: var(--bg);
  }
  .nav__link { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 12px 14px; border-radius: var(--r-sm); font-size: .92rem; }
  .nav__link.is-active { background: rgba(0,240,255,.08); }
  .nav__badge { position: static; margin-left: auto; }
  .main { padding: 32px 32px 48px; }
  .fridges { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Impresión del reporte ---------- */
@media print {
  body { background: #fff; color: #000; padding: 0; }
  body > *:not(dialog) { display: none !important; }
  .dialog { position: static; border: 0; width: 100%; max-height: none; background: #fff; color: #000; }
  .report__actions { display: none; }
  .kpi, .table th, .table td { color: #000; border-color: #ccc; background: #fff; }
  .kpi__value, h2 { color: #000; }
  .report__head img { filter: invert(1); }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
