:root {
  --bg: #05131b;
  --bg2: #082230;
  --card: rgba(14, 42, 56, .62);
  --line: rgba(140, 220, 235, .12);
  --text: #e6f6f8;
  --muted: #8bb0ba;
  --c1: #3ee6d2;
  --c2: #2b8cff;
  --ok: #3ddc97;
  --warn: #ffb547;
  --danger: #ff5d6c;
  --radius: 20px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 700px at 80% -10%, #0e4a5e 0%, transparent 60%),
              radial-gradient(900px 600px at -10% 110%, #0a3550 0%, transparent 60%),
              linear-gradient(180deg, var(--bg2), var(--bg));
  background-attachment: fixed;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
h1, h2 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }
.err { color: var(--danger); min-height: 1.2em; }

/* burbujas de fondo */
.bubbles { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.bubbles i { position: absolute; bottom: -20px; border-radius: 50%; border: 1px solid rgba(160, 240, 255, .25);
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.25), transparent 60%);
  animation: rise linear infinite; }
@keyframes rise { to { transform: translate3d(var(--dx), -110vh, 0); opacity: 0; } }

.top, .view, .foot, .banner { position: relative; z-index: 1; max-width: 1100px; margin-inline: auto; padding-inline: 16px; }
.view { display: grid; gap: 14px; padding-bottom: 20px; }
.top-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-title h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 12px; font-size: 26px; line-height: 1;
  color: var(--text); text-decoration: none; background: var(--card); border: 1px solid var(--line); }
.back[hidden] { display: none; }
code { background: rgba(0,0,0,.3); padding: 1px 5px; border-radius: 5px; font-size: .92em; }
.empty-state { text-align: center; color: var(--muted); padding: 28px 18px; }
.empty-state a { color: var(--c1); }

/* portada: acuarios y dispositivos */
.aq + .aq { margin-top: 18px; }
.aq-head { display: flex; align-items: baseline; gap: 10px; margin: 4px 2px 10px; }
.aq-head h2 { font-size: 18px; }
.dev-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.dev { display: flex; flex-direction: column; gap: 6px; color: inherit; text-decoration: none; transition: transform .15s, border-color .2s; }
.dev:hover { border-color: rgba(62,230,210,.4); }
.dev:active { transform: scale(.985); }
.dev.off { opacity: .7; }
.dev.danger { border-color: rgba(255,93,108,.55); }
.dev.warn { border-color: rgba(255,181,71,.5); }
.dev-top { display: flex; align-items: center; gap: 10px; }
.dev-id { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.dev-id b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ico { width: 34px; height: 34px; flex: none; padding: 6px; border-radius: 10px; color: var(--c1);
  background: linear-gradient(135deg, rgba(62,230,210,.15), rgba(43,140,255,.15)); }
.ico.xl { width: 88px; height: 88px; padding: 18px; border-radius: 26px; }
.dot-s { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--danger); }
.dot-s.on { background: var(--ok); }
.dev-val { display: flex; align-items: baseline; gap: 4px; margin-top: 4px; }
.dev-val .v { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.dev-val .u { font-size: 16px; color: var(--muted); }
.dev-val .l { margin-left: auto; }
.dev-state { font-size: 13.5px; }
.dev.danger .dev-state { color: #ffc0c6; }
.dev.warn .dev-state { color: #ffd9a0; }
.two-col { margin-top: 4px; }
@media (min-width: 900px) { .grid.two-col { grid-template-columns: 1fr 1fr; } .grid.two-col > * { grid-column: auto !important; } }
.hub { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.hub-r { display: flex; align-items: center; gap: 8px; }
.pill { font-size: 12px; padding: 3px 9px; border-radius: 99px; border: 1px solid var(--line); }
.pill.ok { color: var(--ok); border-color: rgba(61,220,151,.4); }
.pill.warn { color: var(--warn); border-color: rgba(255,181,71,.45); }

/* detalle genérico */
.gen-hero { justify-content: flex-start; }
.gen-hero.alert { border-color: rgba(255,93,108,.55); }
.gen-icon { flex: none; }
.ctl { padding: 4px 0 14px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.ctl:last-child { border-bottom: 0; margin-bottom: 0; }
.ctl-btn { width: 100%; margin-bottom: 10px; }
.ctl input[type=number] { background: rgba(0,0,0,.3); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; font: inherit; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 20px; padding-bottom: 14px; }
.conn { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 7px 12px; border-radius: 99px;
  background: var(--card); border: 1px solid var(--line); white-space: nowrap; }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.conn.on .dot { background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: ping 2s infinite; }
.conn.off .dot { background: var(--danger); }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(61,220,151,.6); } 100% { box-shadow: 0 0 0 8px rgba(61,220,151,0); } }

.banner { margin-bottom: 12px; }
.banner > div { padding: 12px 14px; border-radius: 14px; font-size: 13.5px; margin-bottom: 8px;
  background: rgba(255,181,71,.12); border: 1px solid rgba(255,181,71,.35); color: #ffd9a0; }
.banner > div.danger { background: rgba(255,93,108,.14); border-color: rgba(255,93,108,.45); color: #ffc0c6; }

.grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 900px) {
  .grid { grid-template-columns: 1.1fr 1fr; }
  .hero { grid-column: 1; }
  .kpis { grid-column: 2; }
  .control { grid-column: 1; grid-row: span 2; }
  .history { grid-column: 2; }
  .events { grid-column: 2; }
  .info { grid-column: 1; }
}
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }

/* hero */
.hero { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; justify-content: center; }
.gauge { position: relative; width: 200px; height: 200px; flex: none; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge circle { fill: none; stroke-width: 14; }
.gauge .track { stroke: rgba(255,255,255,.07); }
.gauge .bar { stroke: url(#g1); stroke-linecap: round; stroke-dasharray: 0 100; transition: stroke-dasharray .9s cubic-bezier(.2,.8,.2,1); }
.gauge-in { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.big { font-size: 52px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.big small { font-size: 20px; color: var(--muted); margin-left: 2px; }
.rotor { position: absolute; inset: 34px; animation: spin var(--spin, 0s) linear infinite; opacity: .14; }
.rotor span { position: absolute; left: 50%; top: 50%; width: 44%; height: 10px; border-radius: 10px; background: var(--c1);
  transform-origin: 0 50%; }
.rotor span:nth-child(1) { transform: rotate(0deg); }
.rotor span:nth-child(2) { transform: rotate(120deg); }
.rotor span:nth-child(3) { transform: rotate(240deg); }
.hero.paused .rotor { animation-play-state: paused; }
@keyframes spin { to { transform: rotate(360deg); } }
.hero-side { flex: 1 1 220px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.chip { align-self: flex-start; padding: 5px 12px; border-radius: 99px; font-size: 13px; font-weight: 600;
  background: linear-gradient(90deg, rgba(62,230,210,.18), rgba(43,140,255,.18)); border: 1px solid rgba(62,230,210,.35); }
.state { font-size: 15px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* kpis */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.kpi { padding: 16px; }
.kpi-label { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; }
.kpi-val { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.kpi.ok .kpi-val { color: var(--ok); }
.kpi.warn .kpi-val { color: var(--warn); }
.kpi.danger .kpi-val { color: var(--danger); }
.meter { height: 6px; border-radius: 6px; background: rgba(255,255,255,.08); margin-top: 8px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--c1), var(--c2)); transition: width .8s; border-radius: 6px; }
.kpi.warn .meter i { background: var(--warn); }
.kpi.danger .meter i { background: var(--danger); }

/* botones */
.btn { appearance: none; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: var(--text);
  padding: 11px 16px; border-radius: 14px; font: inherit; font-weight: 600; cursor: pointer;
  transition: transform .12s, background .2s, opacity .2s; touch-action: manipulation; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: progress; }
.btn.primary { background: linear-gradient(90deg, var(--c1), var(--c2)); color: #03202a; border: 0; width: 100%; margin-top: 6px; }
.btn.warn { background: rgba(255,181,71,.15); border-color: rgba(255,181,71,.4); color: #ffd9a0; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn.ghost { background: transparent; }

/* tabs */
.tabs, .seg { display: flex; gap: 4px; padding: 4px; background: rgba(0,0,0,.25); border-radius: 14px; }
.tabs { margin-bottom: 14px; }
.tabs button, .seg button { flex: 1; appearance: none; border: 0; background: none; color: var(--muted); font: inherit;
  font-weight: 600; padding: 9px 8px; border-radius: 10px; cursor: pointer; position: relative; }
.seg button { padding: 5px 12px; font-size: 13px; }
.tabs button.on, .seg button.on { background: rgba(255,255,255,.1); color: var(--text); }
.tabs button.current::after { content: ""; position: absolute; top: 6px; right: 8px; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.pane { display: none; }
.pane.on { display: block; animation: fade .25s; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
.pane > p { margin: 0 0 12px; font-size: 13.5px; }
.two { display: grid; grid-template-columns: 1fr; gap: 6px 18px; }
@media (min-width: 520px) { .two { grid-template-columns: 1fr 1fr; } }

label.slider, label.time { display: block; margin: 10px 0; font-size: 13.5px; color: var(--muted); }
label.slider output { float: right; color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
label.time { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
input[type=time] { background: rgba(0,0,0,.3); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; font: inherit; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 30px; background: transparent; margin: 4px 0 0; }
input[type=range]::-webkit-slider-runnable-track { height: 8px; border-radius: 8px;
  background: linear-gradient(90deg, var(--c1) var(--p, 50%), rgba(255,255,255,.1) var(--p, 50%)); }
input[type=range]::-moz-range-track { height: 8px; border-radius: 8px; background: rgba(255,255,255,.1); }
input[type=range]::-moz-range-progress { height: 8px; border-radius: 8px; background: var(--c1); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%; margin-top: -8px;
  background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.4); border: 0; }
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 0; }
.presets { display: flex; gap: 6px; margin: 4px 0 10px; }
.presets button { flex: 1; appearance: none; border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--text);
  border-radius: 10px; padding: 7px 0; font: inherit; font-size: 13px; cursor: pointer; }

.daybar { position: relative; height: 26px; border-radius: 10px; background: linear-gradient(90deg, #0c1d3a, #142a52); overflow: hidden; border: 1px solid var(--line); }
.daybar-day { position: absolute; top: 0; bottom: 0; background: linear-gradient(90deg, #ffcf6b, #ffb547); opacity: .8; }
.daybar-now { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #fff; box-shadow: 0 0 6px #fff; }
.daybar-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin: 3px 2px 6px; }
.pulse-wave { width: 100%; height: 60px; display: block; margin-bottom: 4px; }
.pulse-wave path { fill: rgba(62,230,210,.15); stroke: var(--c1); stroke-width: 2; vector-effect: non-scaling-stroke; }

/* chart */
.chart { height: 200px; position: relative; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .grid-l { stroke: rgba(255,255,255,.06); }
.chart text { fill: var(--muted); font-size: 10px; }
.chart .area { fill: url(#ga); }
.chart .line { fill: none; stroke: var(--c1); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart .off { fill: rgba(255,93,108,.18); }
.chart .tip { position: absolute; pointer-events: none; background: rgba(3,20,28,.92); border: 1px solid var(--line);
  padding: 6px 9px; border-radius: 8px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -110%); }
.chart .empty { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 13.5px; text-align: center; }

/* events */
.ev { list-style: none; margin: 0; padding: 0; max-height: 330px; overflow: auto; }
.ev li { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.ev li:last-child { border-bottom: 0; }
.ev .b { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); transform: translateY(-1px); }
.ev .ok .b, .ev li.ok .b { background: var(--ok); }
.ev li.warn .b { background: var(--warn); }
.ev li.danger .b { background: var(--danger); }
.ev time { color: var(--muted); font-size: 12px; white-space: nowrap; }

.authform { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.authform p { margin: 0 0 10px; }
label.field { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 8px 0; font-size: 13.5px; color: var(--muted); }
label.field input { width: min(220px, 60%); background: rgba(0,0,0,.3); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px; font: inherit; }
label.field input:invalid:not(:placeholder-shown):not(:focus) { border-color: rgba(255,93,108,.6); }
label.check { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); margin: 6px 0; }
.banner button { margin-left: 6px; background: none; border: 1px solid currentColor; color: inherit; border-radius: 8px; padding: 2px 8px; font: inherit; cursor: pointer; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 10px 0 0; font-size: 13.5px; }
dt { color: var(--muted); }
dd { margin: 0; text-align: right; overflow-wrap: anywhere; }

.foot { text-align: center; padding-bottom: 24px; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 30px); opacity: 0;
  background: #0f3a4a; border: 1px solid var(--line); padding: 11px 16px; border-radius: 14px; z-index: 10;
  transition: .3s; max-width: calc(100% - 32px); font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: #4a1820; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(360px, 100%); text-align: center; display: grid; gap: 12px; }
.login input { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0,0,0,.3); color: var(--text); font: inherit; }
.logo-dot { width: 56px; height: 56px; margin: 0 auto; border-radius: 50%; background: linear-gradient(135deg, var(--c1), var(--c2)); }

@media (prefers-reduced-motion: reduce) {
  .rotor, .bubbles i, .conn.on .dot { animation: none !important; }
}
