/* ==========================================================================
   Panel de reactores — sistema de diseño
   Colores de estado tomados de panel.md §4.2 (validados para daltonismo).
   El estado nunca se transmite solo por color: siempre lleva icono o etiqueta.
   ========================================================================== */

:root {
  /* superficies */
  --bg:        #f6f7f5;
  --surface:   #ffffff;
  --surface-2: #fafbf9;
  --line:      #e4e6e1;
  --line-soft: #eef0ec;

  /* texto */
  --ink:    #14171c;
  --ink-2:  #4a515c;
  --ink-3:  #78808d;

  /* marca y estados */
  --accent:  #2a78d6;
  --accent-2:#7a5bd6;
  --standby: #b9bab0;
  --good:    #0ca30c;
  --good-ink:#0a7d0a;
  --warn:    #fab219;
  --warn-ink:#8f6505;
  --mid:     #ec835a;
  --bad:     #d03b3b;

  /* espaciado (escala de 4) */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s7: 32px; --s8: 48px;

  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-full: 999px;

  --shadow-sm: 0 1px 2px rgba(16,20,28,.05);
  --shadow-md: 0 2px 8px rgba(16,20,28,.06), 0 1px 2px rgba(16,20,28,.04);
  --shadow-lg: 0 12px 32px rgba(16,20,28,.12);

  --nav-h: 60px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0f1115;
    --surface:   #171a20;
    --surface-2: #1d2027;
    --line:      #282c34;
    --line-soft: #21242b;
    --ink:    #e9ecf1;
    --ink-2:  #a8b0bd;
    --ink-3:  #79828f;
    --standby: #4a4f58;
    --good-ink:#3fce3f;
    --warn-ink:#f0bd4e;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow-md: 0 2px 10px rgba(0,0,0,.35);
    --shadow-lg: 0 16px 40px rgba(0,0,0,.5);
  }
}

*, *::before, *::after { box-sizing: border-box; }

/* Defensa general: cualquier clase de aqui que fije `display` gana al
   [hidden]{display:none} del navegador y el atributo deja de funcionar.
   Con !important nos aseguramos de que `hidden` siempre oculte. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* cifras alineadas en tablas y KPIs */
.num, dd, td, .stat-value, .pump-value { font-variant-numeric: tabular-nums; }

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.35rem, 1.1rem + 1.1vw, 1.75rem); font-weight: 650; }
h2 { font-size: 1rem; font-weight: 620; }
h3 { font-size: .875rem; font-weight: 600; }
p  { margin: 0 0 var(--s3); }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: .86em;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  padding: .1em .4em; border-radius: 5px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- barra de navegación ---------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--nav-h);
  display: flex; align-items: center; gap: var(--s5);
  padding: 0 var(--s5);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex; align-items: center; gap: var(--s2);
  font-weight: 650; color: var(--ink); letter-spacing: -0.015em;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 24px; height: 24px; border-radius: 7px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.nav { display: flex; gap: var(--s1); flex: 1; }
.nav a {
  padding: var(--s2) var(--s3); border-radius: var(--r-sm);
  color: var(--ink-2); font-size: .9rem; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a.is-active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }

.nav-right { display: flex; align-items: center; gap: var(--s3); margin-left: auto; }
.who {
  display: flex; align-items: center; gap: var(--s2);
  font-size: .875rem; color: var(--ink-2);
}
.avatar {
  width: 28px; height: 28px; border-radius: var(--r-full); flex: none;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent); font-size: .75rem; font-weight: 650;
}

.nav-toggle {
  display: none;
  width: 40px; height: 40px; padding: 0;
  align-items: center; justify-content: center;
  background: none; border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--ink); cursor: pointer;
}
.nav-toggle svg { width: 20px; height: 20px; }

@media (max-width: 760px) {
  .topbar { padding: 0 var(--s4); gap: var(--s3); }
  .nav-toggle { display: inline-flex; margin-left: auto; }
  .nav, .nav-right {
    position: fixed; left: 0; right: 0; top: var(--nav-h);
    flex-direction: column; align-items: stretch; gap: var(--s1);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: var(--s3) var(--s4);
    margin: 0;
    box-shadow: var(--shadow-lg);
    display: none;
  }
  .nav-right { top: auto; box-shadow: none; border-bottom: 0; }
  body.nav-open .nav { display: flex; }
  body.nav-open .nav-right {
    display: flex; position: static; box-shadow: none;
    border: 0; border-top: 1px solid var(--line-soft);
    padding: var(--s3) 0 0;
  }
  body.nav-open .nav { padding-bottom: 0; }
  .nav a { padding: var(--s3); font-size: .95rem; }
  .who { justify-content: flex-start; }
}

/* ---------- estructura ---------- */

main {
  max-width: 1200px; margin: 0 auto;
  padding: var(--s6) var(--s5) var(--s8);
}
@media (max-width: 600px) { main { padding: var(--s4) var(--s4) var(--s7); } }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s5);
}
.page-head .subtitle { color: var(--ink-3); font-size: .875rem; margin: var(--s1) 0 0; }
.page-actions { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s5);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: var(--s4); }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3); margin-bottom: var(--s4); flex-wrap: wrap;
}
.card-head h2 { margin: 0; }

.stack   { display: grid; gap: var(--s4); }
.cols    { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid    { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }

.muted { color: var(--ink-3); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.empty  { text-align: center; color: var(--ink-3); padding: var(--s7) var(--s4); }

/* ---------- tarjetas de equipo ---------- */

.device-card {
  display: flex; flex-direction: column; gap: var(--s3);
  color: inherit; position: relative; overflow: hidden;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.device-card:hover {
  text-decoration: none; border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: var(--shadow-md); transform: translateY(-1px);
}
.device-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: transparent;
}
.device-card.has-alarm::before { background: var(--warn); }
.device-card.is-stale::before  { background: var(--bad); }
.device-head { display: flex; align-items: start; justify-content: space-between; gap: var(--s3); }
.device-head h2 { font-size: 1.05rem; }

/* ---------- chips de estado ---------- */

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--r-full);
  font-size: .75rem; font-weight: 600; letter-spacing: .01em;
  border: 1px solid transparent; white-space: nowrap;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: var(--r-full); background: currentColor; }
.chip-ok   { background: color-mix(in srgb, var(--good) 13%, transparent); color: var(--good-ink); border-color: color-mix(in srgb, var(--good) 28%, transparent); }
.chip-warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn-ink); border-color: color-mix(in srgb, var(--warn) 32%, transparent); }
.chip-bad  { background: color-mix(in srgb, var(--bad) 13%, transparent);  color: var(--bad);      border-color: color-mix(in srgb, var(--bad) 28%, transparent); }
.chip-off  { background: color-mix(in srgb, var(--ink) 8%, transparent);   color: var(--ink-3);    border-color: var(--line); }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2); }

/* ---------- bombas ---------- */

.pumps { display: grid; gap: var(--s3); }
.pump-row { display: grid; gap: 6px; }
.pump-top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); }
.pump-name { font-size: .8rem; color: var(--ink-3); }
.pump-pct  { font-size: .875rem; font-weight: 650; }

.bar { height: 7px; border-radius: var(--r-full); background: color-mix(in srgb, var(--ink) 9%, transparent); overflow: hidden; }
.bar-fill { height: 100%; border-radius: var(--r-full); background: var(--accent); transition: width .4s cubic-bezier(.4,0,.2,1); }
.bar-fill.alt { background: var(--accent-2); }

.pump-hero { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s6); }
.pump-hero .bar { height: 10px; }
.pump-label { color: var(--ink-3); font-size: .875rem; margin-bottom: var(--s1); }
.pump-value { font-size: clamp(2rem, 1.4rem + 2.4vw, 2.75rem); font-weight: 640; line-height: 1.05; letter-spacing: -0.02em; }
.pump-value small { font-size: .4em; font-weight: 500; color: var(--ink-3); margin-left: 2px; }
.pump-meta { margin-top: var(--s2); font-size: .8rem; color: var(--ink-3); }

/* ---------- listas de datos ---------- */

.stats { display: grid; gap: var(--s4) var(--s5); grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); margin: 0; }
.stats > div { min-width: 0; }
.stats dt { font-size: .78rem; color: var(--ink-3); margin-bottom: 2px; }
.stats dd { margin: 0; font-size: 1.05rem; font-weight: 620; letter-spacing: -0.01em; }
.stats dd .unit { font-size: .78rem; font-weight: 500; color: var(--ink-3); margin-left: 2px; }
.stats.compact { grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: var(--s3); }
.stats.compact dd { font-size: .95rem; }

.stat-hero { font-size: clamp(2rem, 1.4rem + 2.4vw, 2.75rem); font-weight: 640; letter-spacing: -0.02em; line-height: 1.05; }
.stat-hero small { font-size: .38em; font-weight: 500; color: var(--ink-3); margin-left: 4px; }

/* barra apilada producción / stand-by */
.split { display: flex; height: 10px; border-radius: var(--r-full); overflow: hidden; background: color-mix(in srgb, var(--ink) 9%, transparent); }
.split-prod    { background: var(--accent); }
.split-standby { background: var(--standby); }
.legend { display: flex; gap: var(--s4); flex-wrap: wrap; margin-top: var(--s2); font-size: .8rem; color: var(--ink-3); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

/* LEDs de salidas */
.leds { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--s2); font-size: .85rem; }
.leds li { display: flex; align-items: center; gap: var(--s2); color: var(--ink-2); }
.led { width: 9px; height: 9px; border-radius: var(--r-full); flex: none; }
.led.on  { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 20%, transparent); }
.led.off { background: color-mix(in srgb, var(--ink) 22%, transparent); }

/* ---------- tablas ---------- */

.table-wrap { overflow-x: auto; margin: 0 calc(var(--s5) * -1); padding: 0 var(--s5); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th {
  text-align: left; font-size: .72rem; font-weight: 650; text-transform: uppercase;
  letter-spacing: .05em; color: var(--ink-3);
  padding: 0 var(--s3) var(--s2); border-bottom: 1px solid var(--line);
}
td { padding: var(--s3); border-bottom: 1px solid var(--line-soft); color: var(--ink-2); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td strong { color: var(--ink); font-weight: 600; }

.pct { font-weight: 650; }
.pct.good { color: var(--good-ink); }
.pct.mid  { color: var(--accent); }
.pct.low  { color: var(--mid); }

/* ---------- botones ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 15px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-size: .875rem; font-weight: 550; cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .06s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--ink) 20%, var(--line)); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); border-color: transparent; }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); background: transparent; }
.btn-danger:hover { background: color-mix(in srgb, var(--bad) 10%, transparent); }
.btn-sm { padding: 6px 11px; font-size: .8rem; }
.btn-block { width: 100%; }

.segmented { display: inline-flex; gap: 2px; padding: 3px; background: color-mix(in srgb, var(--ink) 6%, transparent); border-radius: var(--r-sm); }
.segmented a {
  padding: 5px 12px; border-radius: 6px; font-size: .8rem; font-weight: 550; color: var(--ink-2);
}
.segmented a:hover { color: var(--ink); text-decoration: none; }
.segmented a.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---------- formularios ---------- */

.form { display: grid; gap: var(--s4); }
.field-grid { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.field { display: grid; gap: 6px; min-width: 0; }
.field > .label { font-size: .8rem; font-weight: 560; color: var(--ink-2); }
.field .hint { font-size: .75rem; color: var(--ink-3); }
.field-wide { grid-column: 1 / -1; }

select.select,
input[type=text], input[type=password], input[type=number], input:not([type]) {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--bg); color: var(--ink);
  font: inherit; font-size: .9rem;
  transition: border-color .12s ease, box-shadow .12s ease;
}
select.select { appearance: none; background-image:
  linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
  linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input:hover:not(:focus), select.select:hover:not(:focus) { border-color: color-mix(in srgb, var(--ink) 18%, var(--line)); }
select.select:focus,
input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
input::placeholder { color: var(--ink-3); }

.switch { display: flex; align-items: center; gap: var(--s2); font-size: .875rem; cursor: pointer; }
.switch input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* selección de equipos: casillas como fichas */
.picker { display: flex; flex-wrap: wrap; gap: var(--s2); border: 0; padding: 0; margin: 0; }
.picker legend { font-size: .8rem; font-weight: 560; color: var(--ink-2); padding: 0; margin-bottom: 6px; }
.pick {
  display: inline-flex; align-items: center; gap: var(--s2);
  padding: 7px 13px; border: 1px solid var(--line); border-radius: var(--r-full);
  background: var(--surface); font-size: .85rem; cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.pick:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.pick input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.pick:has(input:checked) {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
}

.form-actions { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
.inline-form { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.inline-form input { max-width: 260px; }

.divider { height: 1px; background: var(--line-soft); border: 0; margin: var(--s5) 0; }

/* acordeón para las fichas de edición */
details.panel { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
details.panel > summary {
  list-style: none; cursor: pointer; padding: var(--s3) var(--s4);
  font-size: .875rem; font-weight: 560; color: var(--ink-2);
  display: flex; align-items: center; gap: var(--s2);
}
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after { content: "▾"; margin-left: auto; color: var(--ink-3); transition: transform .15s ease; }
details.panel[open] > summary::after { transform: rotate(180deg); }
details.panel > .panel-body { padding: 0 var(--s4) var(--s4); }

/* ---------- avisos ---------- */

.flash {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3) var(--s4); border-radius: var(--r-md);
  margin-bottom: var(--s4); font-size: .875rem; border: 1px solid transparent;
}
.flash-ok    { background: color-mix(in srgb, var(--good) 11%, transparent); color: var(--good-ink); border-color: color-mix(in srgb, var(--good) 25%, transparent); }
.flash-error { background: color-mix(in srgb, var(--bad) 11%, transparent);  color: var(--bad);      border-color: color-mix(in srgb, var(--bad) 25%, transparent); }

.notice {
  border-left: 3px solid var(--warn);
  background: color-mix(in srgb, var(--warn) 7%, transparent);
  padding: var(--s3) var(--s4); border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: .85rem;
}

/* ---------- login ---------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: var(--s5); }
.login-card { width: 100%; max-width: 380px; padding: var(--s7) var(--s6); }
.login-brand { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s6); }
.login-brand .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
.login-card .field { margin-bottom: var(--s4); }

/* ---------- gráficas ---------- */

.chart { padding: var(--s4) 0; border-top: 1px solid var(--line-soft); }
.chart:first-child { border-top: 0; padding-top: 0; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s2); }
.chart-title { font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.chart-now { font-size: .95rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.chart svg { width: 100%; height: 128px; display: block; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- diálogo de progreso en vivo ---------- */

.overlay {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: var(--s4);
  background: color-mix(in srgb, #05070a 55%, transparent);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fade .15s ease;
}
.overlay[hidden] { display: none; }
body.modal-open { overflow: hidden; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.modal {
  width: 100%; max-width: 460px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  padding: var(--s5); animation: rise .18s cubic-bezier(.2,.8,.3,1);
}
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.98) } to { opacity: 1 } }

.modal-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s4); }
.modal-head h2 { font-size: 1rem; }

.spinner {
  width: 18px; height: 18px; flex: none; border-radius: var(--r-full);
  border: 2px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-top-color: var(--accent); animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }
.spinner.is-done  { border-color: var(--good); animation: none; position: relative; }
.spinner.is-done::after {
  content: ""; position: absolute; inset: 0;
  background: var(--good); border-radius: var(--r-full);
  clip-path: polygon(14% 47%, 0 61%, 39% 100%, 100% 22%, 85% 8%, 39% 71%);
}
.spinner.is-error { border-color: var(--bad); animation: none; }

.progress {
  height: 4px; border-radius: var(--r-full); overflow: hidden;
  background: color-mix(in srgb, var(--ink) 10%, transparent); margin-bottom: var(--s4);
}
.progress-fill {
  height: 100%; width: 0; border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .35s cubic-bezier(.4,0,.2,1);
}

.steps {
  list-style: none; margin: 0 0 var(--s4); padding: 0;
  max-height: 230px; overflow-y: auto; display: grid; gap: 2px;
}
.step {
  display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: var(--s2);
  padding: 6px 4px; font-size: .85rem; color: var(--ink-3);
  animation: stepIn .2s ease;
}
@keyframes stepIn { from { opacity: 0; transform: translateX(-4px) } to { opacity: 1 } }
.step-dot {
  width: 6px; height: 6px; border-radius: var(--r-full); margin: 0 auto;
  background: color-mix(in srgb, var(--ink) 25%, transparent);
}
.step.is-current { color: var(--ink); }
.step.is-current .step-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.step-error { color: var(--bad); }
.step-error .step-dot { background: var(--bad); }
.step-t { font-size: .72rem; font-variant-numeric: tabular-nums; color: var(--ink-3); }
.modal-foot { display: flex; justify-content: flex-end; }

/* indicador de refresco del listado */
.live-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; color: var(--ink-3);
}
.live-status::before {
  content: ""; width: 6px; height: 6px; border-radius: var(--r-full);
  background: var(--good); flex: none;
}
.live-status.is-busy::before { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3 } }

/* estado de la máquina */
.states { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: var(--s5); }
@media (max-width: 640px) { .states { grid-template-columns: 1fr; gap: var(--s4); } }
.state-value { font-size: 1.6rem; font-weight: 640; letter-spacing: -0.02em; line-height: 1.15; }
.state-sub   { font-size: 1.05rem; font-weight: 600; }
.states code { display: inline-block; margin-top: 4px; color: var(--ink-3); }

/* diagnóstico del manual, plegado bajo cada alarma */
.diag { margin-top: 6px; }
.diag > summary {
  cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 4px;
  font-size: .78rem; font-weight: 550; color: var(--accent);
}
.diag > summary::-webkit-details-marker { display: none; }
.diag > summary::after { content: "▾"; font-size: .7em; }
.diag[open] > summary::after { content: "▴"; }
.diag p {
  margin: 6px 0 0; padding: var(--s3); border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--line-soft);
  font-size: .82rem; line-height: 1.6; color: var(--ink-2); max-width: 65ch;
}

/* ---------- vigilancia en vivo ---------- */
.live-controls { display: flex; align-items: center; gap: var(--s3); }
.live-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .72rem; font-weight: 650; text-transform: uppercase;
  letter-spacing: .04em; color: var(--good-ink);
}
/* sin esto el atributo hidden no surte efecto: la regla de arriba, al ser de
   autor, gana al [hidden]{display:none} del navegador */
.live-badge[hidden] { display: none; }
.live-badge::before {
  content: ""; width: 7px; height: 7px; border-radius: var(--r-full);
  background: var(--good); animation: latido 1.4s ease-in-out infinite;
}
@keyframes latido { 0%,100% { opacity: 1 } 50% { opacity: .25 } }

/* el punto debe decir la verdad: verde latiendo solo cuando llegan datos */
.live-badge.conectando { color: var(--accent); }
.live-badge.conectando::before { background: var(--accent); }
.live-badge.fallo { color: var(--bad); }
.live-badge.fallo::before { background: var(--bad); animation: none; }

[data-live-device].is-live { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }
[data-live-device].is-live [data-live-hint] { display: none; }

/* destello al cambiar un valor: se ve qué se ha movido */
.acaba-de-cambiar { animation: destello 1s ease-out; }
@keyframes destello {
  0%   { background: color-mix(in srgb, var(--accent) 28%, transparent); border-radius: 4px; }
  100% { background: transparent; }
}
