:root{
  --bg: #f2f4f8;
  --card: #ffffff;
  --border: #e2e6ee;
  --ink: #1b2436;
  --ink-soft: #5b6472;
  --blue: #2f5ce0;
  --blue-dark: #1d3fa8;
  --amarillo: #ffd54a;
  --naranja: #ff9d3d;
  --map-low: #cfe0ff;
  --map-high: #14226b;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(20,30,60,0.08), 0 8px 24px rgba(20,30,60,0.05);
}

*{ box-sizing: border-box; }

body{
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, "IBM Plex Sans", Arial, sans-serif;
  padding: 20px;
}

h1,h2{ font-family: Georgia, "Sora", serif; margin: 0; }

.topbar{
  display:flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 22px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.topbar-title h1{ font-size: 22px; }
.topbar-title p{ margin: 4px 0 0; color: var(--ink-soft); font-size: 13px; }

.stats{ display:flex; gap: 10px; flex-wrap: wrap; }
.stat-chip{
  background: #eef1f8;
  border-radius: 999px;
  padding: 8px 16px;
  display:flex;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
}
.stat-label{ color: var(--ink-soft); }
.stat-value{ font-weight: 700; font-size: 16px; }

.buscador-serie-panel{
  margin-bottom: 16px;
  position: relative;
}
.buscador-serie-panel label{
  display:block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--ink);
}
.buscador-serie-wrap{ position: relative; }
#buscar-serie{
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f7f8fb;
  font-size: 15px;
}
#buscar-serie:focus{ outline: 2px solid var(--blue); background: #fff; }

.sugerencias-serie{
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 280px;
  overflow-y: auto;
  z-index: 500;
}
.sugerencia-item{
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.sugerencia-item:last-child{ border-bottom: none; }
.sugerencia-item:hover, .sugerencia-item.resaltada{ background: #eef1f8; }
.sugerencia-item b{ color: var(--blue-dark); }
.sugerencia-item .sug-dom{ color: var(--ink-soft); font-size: 12px; margin-top: 2px; }

.buscar-serie-msg{
  margin-top: 8px;
  font-size: 13px;
}
.buscar-serie-msg.error{ color: #a02020; }
.buscar-serie-msg.ok{ color: #1c6b34; }

.layout{
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  align-items: stretch;
}
@media (max-width: 900px){
  .layout{ grid-template-columns: 1fr; }
}

.panel{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-header{
  display:flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 10px;
  flex-wrap: wrap;
}
.panel-header h2{ font-size: 17px; }

.btn-reset{
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--blue-dark);
}
.btn-reset:hover{ background: #eef1f8; }
a.btn-reset{ text-decoration: none; display: inline-flex; align-items: center; white-space: nowrap; }

#map{
  height: 560px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.legend{
  display:flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 12px;
  color: var(--ink-soft);
}
.legend-item{ display:flex; align-items:center; gap:6px; }
.legend-swatch{ width: 26px; height: 10px; border-radius: 3px; display:inline-block; }
.grad-low{ background: var(--map-low); }
.grad-high{ background: var(--map-high); }
.legend-dot{ width: 10px; height: 10px; border-radius: 50%; display:inline-block; }
.dot-calle{ background: #1c9b4a; }
.dot-manual{ background: #2f5ce0; }
.dot-municipio{ background: #e14a3b; }
.dot-estado{ background: #ff9d3d; }

#buscar-estado, #buscar-equipo{
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f7f8fb;
  font-size: 13px;
  margin-bottom: 10px;
}

.lista-estados{
  max-height: 500px;
  overflow-y: auto;
}
.estado-row{
  display:flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.estado-row:hover{ background: #eef1f8; }
.estado-row.activo{ background: var(--blue); color: #fff; }
.estado-row .cnt{ font-weight: 700; }

.table-panel{ margin-top: 16px; }
.table-wrap{ overflow-x: auto; max-height: 420px; overflow-y: auto; }
table{ width: 100%; border-collapse: collapse; font-size: 13px; }
thead th{
  text-align:left;
  position: sticky;
  top: 0;
  background: var(--card);
  border-bottom: 2px solid var(--border);
  padding: 8px 10px;
  color: var(--ink-soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
tbody td{ padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:hover{ background: #f7f9ff; }
tbody tr.fila-resaltada{ background: #fff4cf; transition: background 0.3s; }
tbody tr.fila-clickeable{ cursor: pointer; }
tbody tr.fila-clickeable:hover{ background: #eaf0ff; }

.badge{
  display:inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.badge-amarillo{ background: var(--amarillo); color: #6b5300; }
.badge-naranja{ background: var(--naranja); color: #6b3300; }

/* --- overrides Leaflet --- */
.leaflet-popup-content{ font-size: 13px; line-height: 1.5; }
.leaflet-popup-content b{ display:block; margin-bottom: 2px; }

/* --- boton "ubicar" en la tabla --- */
.btn-ubicar{
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-ubicar:hover{ background: #eef1f8; }
.btn-ubicar.tiene-punto{ border-color: var(--blue); color: var(--blue-dark); }

/* --- modal para ubicar un equipo a mano --- */
.modal-overlay{
  position: fixed;
  inset: 0;
  background: rgba(20, 26, 40, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}
.modal-overlay[hidden]{ display: none; }
.modal-box{
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header{
  display:flex;
  align-items:center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.modal-header h3{ margin: 0; }
.modal-cerrar{
  border: none;
  background: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-soft);
  padding: 2px 6px;
}
.modal-cerrar:hover{ color: var(--ink); }
.modal-hint{ font-size: 13px; color: var(--ink-soft); margin: 0 0 8px; }
.modal-domicilio{
  font-size: 13px;
  background: #f7f8fb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
}
.modal-coords-pegar{ margin-bottom: 10px; }
.modal-coords-pegar label{ font-size: 12px; font-weight: 600; color: var(--ink); display:block; margin-bottom: 4px; }
.modal-coords-pegar-fila{ display:flex; gap: 8px; }
.modal-coords-pegar-fila input{
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f7f8fb;
  font-size: 13px;
  font-family: inherit;
}
.modal-coords-pegar-fila button{ flex-shrink: 0; padding: 8px 16px; font-size: 13px; }

#modal-mini-map{
  height: 320px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.modal-coords{
  margin-top: 8px;
  font-size: 13px;
  color: var(--ink-soft);
}
.modal-botones{
  display:flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}
.btn-primario{
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primario:hover{ background: var(--blue-dark); }
.btn-primario:disabled{ opacity: 0.6; cursor: default; }
.btn-secundario{
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
}
.btn-secundario:hover{ background: #eef1f8; }
.mensaje{
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
}
.mensaje.ok{ background: #e6f6ea; color: #1c6b34; border: 1px solid #b7e4c4; }
.mensaje.error{ background: #fdeaea; color: #a02020; border: 1px solid #f3c2c2; }