:root {
  --bg: #0b0f14;
  --bg-elev: #121821;
  --bg-elev-2: #18202b;
  --line: #24303f;
  --txt: #e6edf5;
  --txt-dim: #9aa9bd;
  --accent: #4da3ff;
  --warn: #ffb020;
  --danger: #ff5c5c;
  --ok: #3ddc97;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font: 400 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-font-smoothing: antialiased;
}

.wrap { width: min(720px, 100% - 2rem); margin-inline: auto; }

/* ── encabezado ───────────────────────────────────────────────────────────── */
.hero {
  padding: calc(2.5rem + env(safe-area-inset-top)) 0 2rem;
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(77,163,255,.16), transparent 60%),
    var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .7rem; }
.brand h1 { font-size: 1.6rem; margin: 0; letter-spacing: -.02em; }
.tagline { color: var(--txt-dim); margin: .6rem 0 0; max-width: 46ch; }

.pulse {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); flex: none;
  box-shadow: 0 0 0 0 rgba(77,163,255,.7);
  animation: pulse 2.4s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(77,163,255,.6); }
  70%  { box-shadow: 0 0 0 14px rgba(77,163,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(77,163,255,0); }
}
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

/* ── bloques ──────────────────────────────────────────────────────────────── */
main { padding: 1.5rem 0 2rem; display: grid; gap: 1rem; }

.card, .notice {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  box-shadow: var(--shadow);
}
.card h2, .notice h2 { font-size: 1.02rem; margin: 0 0 .7rem; letter-spacing: -.01em; }
.cardHead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .7rem; }
.cardHead h2 { margin: 0; }

.notice { background: linear-gradient(180deg, rgba(255,176,32,.07), transparent), var(--bg-elev); border-color: #3a3320; }
.notice p { margin: 0 0 .6rem; color: var(--txt-dim); font-size: .93rem; }
.notice p:last-child { margin-bottom: 0; }
.notice strong { color: var(--txt); }
.warn { border-left: 3px solid var(--warn); padding-left: .8rem; }

.ios-gate { border-color: #2a3b52; background: linear-gradient(180deg, rgba(77,163,255,.08), transparent), var(--bg-elev); }
.steps { margin: .6rem 0 .6rem; padding-left: 1.2rem; color: var(--txt-dim); font-size: .93rem; }
.steps li { margin: .35rem 0; }
.steps strong { color: var(--txt); }
.glyph { font-family: -apple-system, sans-serif; }

.fine { font-size: .8rem; color: var(--txt-dim); margin: .4rem 0 0; }

/* ── estado ───────────────────────────────────────────────────────────────── */
.status {
  display: flex; align-items: center; gap: .55rem;
  padding: .6rem .8rem; border-radius: 10px;
  background: var(--bg-elev-2); border: 1px solid var(--line);
  font-size: .9rem; margin-bottom: 1rem;
}
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--txt-dim); flex: none; }
.status--on .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.status--on { border-color: #23503f; }
.status--err .dot { background: var(--danger); }
.status--err { border-color: #52262a; }

/* ── formulario ───────────────────────────────────────────────────────────── */
.field { margin-bottom: 1.1rem; }
.field > label { display: block; font-size: .88rem; color: var(--txt-dim); margin-bottom: .45rem; }

.rangeRow { display: flex; align-items: center; gap: .9rem; }
.rangeRow output {
  min-width: 4.6rem; text-align: right;
  font-variant-numeric: tabular-nums; font-weight: 600; font-size: 1.05rem;
}

input[type=range] {
  flex: 1; appearance: none; height: 4px; border-radius: 2px;
  background: var(--line); outline: none;
}
input[type=range]::-webkit-slider-thumb {
  appearance: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 3px solid var(--bg-elev);
}
input[type=range]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 3px solid var(--bg-elev);
}

input[type=text] {
  width: 100%; padding: .65rem .75rem; font-size: 16px;
  background: var(--bg-elev-2); border: 1px solid var(--line);
  border-radius: 10px; color: var(--txt);
}
input[type=text]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.check { display: flex; align-items: center; gap: .6rem; cursor: pointer; color: var(--txt); font-size: .95rem; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ── botones ──────────────────────────────────────────────────────────────── */
.actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.btn {
  appearance: none; border: 1px solid transparent; cursor: pointer;
  font: inherit; font-weight: 600; padding: .8rem 1.3rem;
  border-radius: 11px; transition: filter .15s, opacity .15s;
  min-height: 48px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:active:not(:disabled) { filter: brightness(.9); }
.btn--primary { background: var(--accent); color: #041426; flex: 1; }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--txt-dim); }
.btn--tiny { padding: .35rem .7rem; min-height: 0; font-size: .8rem; background: var(--bg-elev-2); border-color: var(--line); color: var(--txt-dim); border-radius: 8px; }

.error {
  color: #ffd7d7; background: rgba(255,92,92,.1);
  border: 1px solid #52262a; border-radius: 10px;
  padding: .6rem .8rem; font-size: .88rem; margin: .9rem 0 0;
}

/* ── lista de eventos ─────────────────────────────────────────────────────── */
.events { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.events .empty { color: var(--txt-dim); font-size: .9rem; padding: .5rem 0; }

.evt {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .85rem;
  padding: .7rem .8rem; border-radius: 11px;
  background: var(--bg-elev-2); border: 1px solid var(--line);
}
.mag {
  font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums;
  min-width: 3.1rem; text-align: center;
  padding: .3rem .1rem; border-radius: 8px;
  background: #223047; color: var(--txt);
}
.mag--moderado { background: #4a3a12; color: #ffd98a; }
.mag--fuerte   { background: #5a2f14; color: #ffc09a; }
.mag--extremo  { background: #5c1d22; color: #ffb3b3; }

.evt .place { font-size: .92rem; line-height: 1.35; }
.evt .meta  { font-size: .78rem; color: var(--txt-dim); margin-top: .15rem; }
.evt .when  { font-size: .78rem; color: var(--txt-dim); white-space: nowrap; text-align: right; }
.badge {
  display: inline-block; font-size: .68rem; letter-spacing: .04em; text-transform: uppercase;
  padding: .1rem .38rem; border-radius: 5px; background: #24303f; color: var(--txt-dim); margin-left: .35rem;
}

/* ── red de sensores ──────────────────────────────────────────────────────── */
.netBadge {
  font-size: .74rem; letter-spacing: .04em; text-transform: uppercase;
  padding: .22rem .5rem; border-radius: 6px;
  background: #24303f; color: var(--txt-dim); white-space: nowrap;
}
.netBadge--ready { background: rgba(61,220,151,.14); color: var(--ok); }
.netBadge--thin  { background: rgba(255,176,32,.14); color: var(--warn); }
.netBadge--down  { background: rgba(255,92,92,.14); color: var(--danger); }

#netIntro { margin-bottom: .9rem; }

.stationGrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .5rem; margin-bottom: 1.2rem;
}
.city {
  background: var(--bg-elev-2); border: 1px solid var(--line);
  border-radius: 10px; padding: .55rem .65rem;
  transition: border-color .2s, background .2s;
}
.city--off { opacity: .5; }
.city--fired { border-color: var(--warn); background: rgba(255,176,32,.1); }

.cityDots { display: flex; gap: .22rem; flex-wrap: wrap; margin-bottom: .38rem; min-height: 8px; }
.stDot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: #3a4757; transition: transform .15s;
}
.stDot--on { background: var(--ok); box-shadow: 0 0 5px rgba(61,220,151,.7); }
.stDot--fired { background: var(--warn); box-shadow: 0 0 10px var(--warn); transform: scale(1.9); }

.city .cityName { font-size: .9rem; font-weight: 600; line-height: 1.25; }
.city .cityMeta { font-size: .72rem; color: var(--txt-dim); margin-top: .2rem; }

@media (prefers-reduced-motion: reduce) { .stDot--fired { transform: none; } }

.tickerHead { display: flex; align-items: center; gap: .5rem; margin: 0 0 .5rem; }
.tickerHead h3 { font-size: .84rem; margin: 0; color: var(--txt-dim); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.liveDot { width: 7px; height: 7px; border-radius: 50%; background: var(--txt-dim); }
.liveDot--on { background: var(--ok); animation: pulse 2.4s infinite; }

.ticker { list-style: none; margin: 0 0 .6rem; padding: 0; display: grid; gap: .3rem; max-height: 240px; overflow-y: auto; }
.ticker .empty { color: var(--txt-dim); font-size: .85rem; padding: .3rem 0; }
.tk {
  display: grid; grid-template-columns: auto 1fr auto; gap: .6rem; align-items: baseline;
  font-size: .82rem; padding: .35rem .55rem; border-radius: 8px;
  background: var(--bg-elev-2); border: 1px solid var(--line);
}
.tk--new { animation: slideIn .35s ease-out; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.tk--confirmed { border-color: #52262a; background: rgba(255,92,92,.1); }
.tk .tkCode { font-variant-numeric: tabular-nums; color: var(--txt-dim); font-size: .76rem; }
.tk .tkWhen { color: var(--txt-dim); font-size: .74rem; white-space: nowrap; }
.tk .tkRatio { color: var(--warn); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── salud ────────────────────────────────────────────────────────────────── */
.healthGrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .55rem; }
.hcell { background: var(--bg-elev-2); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; }
.hcell .k { font-size: .72rem; color: var(--txt-dim); text-transform: uppercase; letter-spacing: .04em; }
.hcell .v { font-size: .95rem; font-weight: 600; margin-top: .15rem; }
.v--ok { color: var(--ok); } .v--bad { color: var(--danger); } .v--warn { color: var(--warn); }

/* ── pie ──────────────────────────────────────────────────────────────────── */
.footer { padding: 1.5rem 0 2.5rem; color: var(--txt-dim); font-size: .82rem; border-top: 1px solid var(--line); margin-top: .5rem; }
.footer p { margin: .3rem 0; }
.footer a { color: var(--accent); }

@media (max-width: 420px) {
  .brand h1 { font-size: 1.35rem; }
  .evt { grid-template-columns: auto 1fr; }
  .evt .when { grid-column: 2; text-align: left; margin-top: .2rem; }
}
