:root {
  --bg: #0f1419;
  --panel: #171e27;
  --line: #2a3544;
  --text: #e7eef6;
  --muted: #93a4b8;
  --accent: #3ddc97;
  --alarm: #ff5d73;
  --gps: #59b6ff;
  --warn: #ffc14d;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login form, header, .col {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.login form { width: min(420px, 100%); padding: 28px; }
.mark { margin: 0; color: var(--accent); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; }
h1 { margin: 6px 0 8px; font-size: 28px; }
.hint, .phase, .meta { color: var(--muted); }
label { display: block; margin: 18px 0 6px; font-size: 13px; }
input, button { font: inherit; }
input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0d1218;
  color: var(--text);
}
button {
  margin-top: 14px;
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #062216;
  font-weight: 700;
  cursor: pointer;
}
.error { color: var(--alarm); }
#app { height: 100vh; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 12px; padding: 12px; overflow: hidden; }
#app[hidden], #detalle[hidden], [hidden] { display: none !important; }
header { display: grid; grid-template-columns: 220px 1fr; gap: 8px 16px; padding: 14px 16px; align-items: center; }
.phase { grid-column: 1 / -1; margin: 0; font-size: 13px; }
.stats { display: flex; flex-wrap: wrap; gap: 8px; }
.stat {
  background: #101720;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  min-width: 120px;
}
.stat b { display: block; font-size: 20px; }
.stat span { color: var(--muted); font-size: 12px; }
main { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 12px; min-height: 0; height: 100%; }
.col { min-height: 0; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.tabs { display: flex; gap: 6px; padding: 10px; }
.tab { width: auto; margin: 0; background: transparent; color: var(--text); border: 1px solid var(--line); }
.tab.on { background: var(--accent); color: #062216; }
#buscar { width: auto; margin: 0 10px 10px; }
#feed { overflow: auto; padding: 0 10px 10px; }
.row {
  width: 100%;
  text-align: left;
  margin: 0 0 8px;
  padding: 10px 12px;
  background: #101720;
  color: var(--text);
  border: 1px solid var(--line);
}
.row.on { border-color: var(--accent); background: #13261c; }
.row strong { display: block; }
.row em { font-style: normal; color: var(--gps); font-size: 12px; }
.row em.mov { color: var(--accent); font-weight: 700; }
.row em.quieto { color: var(--muted); }
.flecha { background: transparent !important; border: 0 !important; }
.flecha span {
  display: block;
  width: 0;
  height: 0;
  margin: 1px auto 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 16px solid var(--c, #3ddc97);
  filter: drop-shadow(0 0 1px #102033);
  transform: rotate(var(--r, 0deg));
  transform-origin: 50% 65%;
}
.flecha.viva span { animation: pulso 1.1s ease-in-out infinite; }
@keyframes pulso { 50% { opacity: 0.35; } }
.row.alarm em { color: var(--alarm); }
.badge { float: right; color: var(--muted); font-size: 12px; }
.map-wrap { position: relative; }
#map { flex: 1 1 auto; min-height: 0; height: 100%; border-radius: 16px; }
#detalle {
  position: absolute;
  top: 12px;
  right: 12px;
  width: min(360px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  overflow: auto;
  background: rgba(23, 30, 39, 0.96);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}
#detalle h2 { margin: 0 0 6px; font-size: 18px; }
#detalle h3 { margin: 14px 0 6px; font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
#detalle > button { width: auto; margin: 0 0 8px; padding: 6px 10px; background: transparent; color: var(--text); border: 1px solid var(--line); }
.rango { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.rango label { margin: 0; font-size: 12px; }
.rango input { padding: 8px; }
#ver-recorrido { grid-column: 1 / -1; margin: 0; }
.resumen-ruta { margin: 8px 0; font-size: 13px; }
.puntos { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow: auto; }
button.mini {
  width: 100%;
  margin: 0 0 4px;
  padding: 6px 8px;
  text-align: left;
  font-weight: 500;
  background: #101720;
  color: var(--text);
  border: 1px solid var(--line);
}
.leaflet-container { background: #d5e3f2; font-family: inherit; height: 100%; width: 100%; }
.leaflet-popup-content { margin: 10px 12px; line-height: 1.35; }
.leaflet-popup-content b { display: block; }
@media (max-width: 900px) {
  body { overflow: auto; }
  #app { height: auto; min-height: 100vh; overflow: visible; }
  header, main { grid-template-columns: 1fr; }
  #map { height: 420px; flex: none; }
}
