/* ===== Red Sismográfica MX — tema ===== */
:root {
  --bg: #0a0e14;
  --bg-elevated: #121822;
  --bg-elevated-2: #1a212c;
  --border: #232b38;
  --text: #e8edf3;
  --text-muted: #8892a0;
  --text-faint: #5a6472;
  --accent: #f2a541;
  --accent-soft: rgba(242, 165, 65, .12);
  --teal: #2dd4bf;
  --ok: #34d399;
  --off: #64748b;
  --danger: #f87171;
  --radius: 14px;
  --radius-sm: 8px;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
}

body {
  background-image:
    radial-gradient(circle at 15% 0%, rgba(242,165,65,.05), transparent 40%),
    radial-gradient(circle at 85% 100%, rgba(45,212,191,.05), transparent 40%);
  background-attachment: fixed;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; margin: 0 0 .4rem; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.1rem; color: var(--text); }
h3 { font-size: .8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }

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

.muted { color: var(--text-muted); font-size: .9rem; }

.container { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

/* Topbar */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-elevated), var(--bg));
  position: relative;
}
.topbar::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: .5;
}
.brand { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: .5rem; }
.topbar nav { display: flex; align-items: center; gap: 1rem; font-family: var(--font-mono); font-size: .85rem; }
.topbar nav a { color: var(--text-muted); border: 1px solid var(--border); padding: .35rem .8rem; border-radius: 999px; }
.topbar nav a:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }

/* Cards */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 0 rgba(255,255,255,.02) inset, 0 8px 24px -12px rgba(0,0,0,.5);
}

/* Stats strip */
.stats-strip { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.stat-pill {
  flex: 1; min-width: 140px;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .9rem 1.1rem;
}
.stat-pill .num { font-family: var(--font-mono); font-size: 1.6rem; color: var(--accent); display: block; line-height: 1; }
.stat-pill .lbl { font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }

/* Mapa */
#mapa { border: 1px solid var(--border); filter: saturate(.9); }
.leaflet-container { background: var(--bg-elevated-2) !important; }

/* Acordeon de estaciones */
.estacion { padding: 0; overflow: hidden; }
.estacion-header {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  background: none; border: none; color: var(--text); cursor: pointer;
  padding: 1.1rem 1.5rem; font-family: var(--font-display); font-size: 1rem; font-weight: 600;
}
.estacion-header:hover { background: var(--bg-elevated-2); }
.estacion-header .chev { display: inline-block; transition: transform .2s ease; color: var(--text-faint); margin-right: .6rem; }
.estacion-header[aria-expanded="true"] .chev { transform: rotate(90deg); }

.badge {
  font-family: var(--font-mono); font-size: .72rem; padding: .25rem .65rem; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .05em; border: 1px solid transparent;
}
.badge.ok { color: var(--ok); background: rgba(52,211,153,.1); border-color: rgba(52,211,153,.3); }
.badge.off { color: var(--off); background: rgba(100,116,139,.1); border-color: rgba(100,116,139,.3); }

.estacion-body { padding: 0 1.5rem 1.5rem; border-top: 1px solid var(--border); }

/* Grupos de graficas */
.chart-group-label { margin: 1.2rem 0 .6rem; }
.grid-6 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.chart-card {
  background: var(--bg-elevated-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .75rem; border-top: 2px solid var(--ch-color, var(--accent));
}
.chart-card canvas { max-height: 160px; }

/* Formularios */
label { display: block; font-size: .8rem; color: var(--text-muted); margin-bottom: .3rem; }
input, select {
  background: var(--bg-elevated-2); border: 1px solid var(--border); color: var(--text);
  padding: .55rem .7rem; border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: .85rem;
  width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
button {
  background: var(--accent); color: #12100a; border: none; font-weight: 700;
  padding: .6rem 1.2rem; border-radius: var(--radius-sm); cursor: pointer; font-family: var(--font-body);
}
button:hover { filter: brightness(1.08); }

.row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; }
.row > div { flex: 1; min-width: 140px; }

.alert.error { background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.3); color: var(--danger); padding: .7rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .9rem; }

/* Login */
body.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-wrap { position: relative; width: 100%; max-width: 420px; padding: 1.5rem; }
.auth-card { position: relative; text-align: left; overflow: hidden; }
.auth-eyebrow { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; color: var(--accent); margin-bottom: .5rem; display: block; }
.seismic-wave { position: absolute; top: 0; left: 0; width: 100%; height: 60px; opacity: .5; pointer-events: none; }
.seismic-wave path { stroke-dasharray: 1000; stroke-dashoffset: 1000; animation: draw 2.2s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.auth-card form { margin-top: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.auth-footer { text-align: center; margin-top: 1.5rem; font-size: .78rem; color: var(--text-faint); font-family: var(--font-mono); letter-spacing: .05em; }

@media (max-width: 720px) {
  .grid-6 { grid-template-columns: 1fr; }
  .stats-strip { flex-direction: column; }
}

/* ===== Fondo de triangulos flotantes (login) ===== */
body.auth-page { position: relative; overflow: hidden; }

.tri-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.tri {
  position: absolute;
  top: var(--y);
  left: var(--x);
  width: 0;
  height: 0;
  border-left: calc(var(--size) / 2) solid transparent;
  border-right: calc(var(--size) / 2) solid transparent;
  border-bottom: var(--size) solid rgba(56, 189, 248, var(--op, .12));
  transform: rotate(var(--rot, 0deg));
  animation: tri-drift var(--dur, 18s) ease-in-out infinite alternate;
  animation-delay: var(--delay, 0s);
  filter: blur(.3px);
}

@keyframes tri-drift {
  0%   { transform: translate(0, 0) rotate(var(--rot, 0deg)); }
  50%  { transform: translate(24px, -32px) rotate(calc(var(--rot, 0deg) + 12deg)); }
  100% { transform: translate(-18px, 22px) rotate(calc(var(--rot, 0deg) - 10deg)); }
}

.auth-wrap, .auth-card { position: relative; z-index: 1; }

@media (prefers-reduced-motion: reduce) {
  .tri { animation: none; }
}
