:root {
  --verde: #0b7a4b;
  --verde-osc: #075a37;
  --verde-claro: #e6f4ec;
  --azul: #0f4c81;
  --texto: #1f2933;
  --texto-2: #52606d;
  --borde: #d9e2ec;
  --fondo: #f5f7fa;
  --rojo: #b42318;
  --rojo-claro: #fdecea;
  --ambar-claro: #fff7e0;
  --radio: 8px;
  --sombra: 0 2px 10px rgba(15, 23, 42, .12);
  font-family: "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  color: var(--texto);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--fondo); font-size: 14px; }
[hidden] { display: none !important; }
code { background: #eef2f6; padding: 1px 5px; border-radius: 4px; font-size: 13px; }

/* botones y campos */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: var(--radio);
  border: 1px solid var(--borde); background: #fff; color: var(--texto); font: inherit; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: #9aa5b1; }
.btn.primario { background: var(--verde); border-color: var(--verde); color: #fff; font-weight: 600; }
.btn.primario:hover { background: var(--verde-osc); }
.btn.peligro { color: var(--rojo); border-color: #f3b8b2; }
.btn.ancho { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-link { background: none; border: 0; color: var(--verde); cursor: pointer; font: inherit; font-weight: 600; padding: 0; }
.btn-icono { background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--texto-2); padding: 4px 8px; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--borde); border-radius: var(--radio); background: #fff; color: var(--texto); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(11, 122, 75, .35); border-color: var(--verde); }
label { display: block; font-weight: 600; font-size: 13px; color: var(--texto-2); margin-bottom: 12px; }
label input, label select, label textarea { margin-top: 4px; font-weight: 400; }
.aviso { padding: 10px 12px; border-radius: var(--radio); background: var(--ambar-claro); border: 1px solid #f5d88a; margin: 0 0 12px; font-size: 13px; }
.aviso.error { background: var(--rojo-claro); border-color: #f3b8b2; color: var(--rojo); }
.aviso.ok { background: var(--verde-claro); border-color: #a6d8bd; color: var(--verde-osc); }

/* marca */
.marca-icono { width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--verde) 0 50%, var(--azul) 50% 100%); position: relative; }
.marca-icono::after { content: ""; position: absolute; inset: 9px; border: 3px solid #fff; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); }

/* login */
.pagina-login { display: grid; place-items: center; min-height: 100%; padding: 20px;
  background: linear-gradient(160deg, #e8f3ee 0%, #eef3f9 100%); }
.login-caja { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; box-shadow: var(--sombra); padding: 28px; }
.login-caja.ancha { max-width: 520px; }
.login-marca { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.login-marca h1 { font-size: 18px; margin: 0; }
.login-marca p { margin: 2px 0 0; color: var(--texto-2); font-size: 13px; }
.pie-login { font-size: 12px; color: var(--texto-2); margin: 16px 0 0; text-align: center; }
.detalle-error { font-family: monospace; font-size: 12px; color: var(--texto-2); word-break: break-word; }

/* barra superior */
.pagina-mapa { display: flex; flex-direction: column; overflow: hidden; }
.barra { height: 58px; flex: none; display: flex; align-items: center; gap: 16px; padding: 0 16px; background: #fff; border-bottom: 1px solid var(--borde); z-index: 5; }
.marca { display: flex; align-items: center; gap: 10px; min-width: 0; }
.marca-texto { display: flex; flex-direction: column; line-height: 1.2; white-space: nowrap; }
.marca-texto strong { font-size: 15px; }
.marca-texto span { font-size: 12px; color: var(--texto-2); }
.buscador { display: flex; gap: 8px; flex: 1; max-width: 440px; margin-left: auto; }
.buscador input { min-width: 0; }
.usuario { position: relative; }
.btn-usuario { background: none; border: 1px solid var(--borde); border-radius: var(--radio); padding: 8px 12px; font: inherit; cursor: pointer; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra); min-width: 200px; padding: 6px; z-index: 20; }
.menu a, .menu button { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 6px; color: var(--texto); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--fondo); }
.menu form { margin: 0; }

/* estructura */
.contenido { flex: 1; display: flex; min-height: 0; position: relative; }
.panel { width: 310px; flex: none; background: #fff; border-right: 1px solid var(--borde); display: flex; flex-direction: column; overflow-y: auto; z-index: 4; }
.panel-cabecera { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.panel-cabecera h2 { font-size: 16px; margin: 0; }
.conteo { margin: 4px 16px 10px; padding: 10px 12px; background: var(--verde-claro); border-radius: var(--radio); font-size: 13px; }
.conteo b { font-size: 16px; }
.conteo-det { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; color: var(--texto-2); font-size: 12px; }
.conteo-det .alerta { color: var(--rojo); }
.filtros { padding: 0 8px; }
.grupo { border-bottom: 1px solid #edf1f5; padding: 2px 8px; }
.grupo summary { cursor: pointer; padding: 9px 0; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
.grupo summary::-webkit-details-marker { display: none; }
.grupo summary::before { content: "▸"; color: var(--texto-2); font-size: 11px; transition: transform .15s; }
.grupo[open] summary::before { transform: rotate(90deg); }
.marca-sel { background: var(--verde); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; margin-left: auto; }
.items { padding: 0 0 10px; }
.items-lista { max-height: 220px; overflow-y: auto; border: 1px solid #edf1f5; border-radius: var(--radio); padding: 4px; margin-bottom: 10px; }
.buscar-lista { margin-bottom: 6px; padding: 6px 9px; }
.chk { display: flex; align-items: center; gap: 8px; margin: 0; padding: 4px 4px; font-weight: 400; color: var(--texto); font-size: 13px; cursor: pointer; border-radius: 5px; }
.chk:hover { background: var(--fondo); }
.chk input { width: auto; margin: 0; accent-color: var(--verde); }
.chk span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chk em { font-style: normal; color: var(--texto-2); font-size: 12px; }
.rango { display: grid; grid-template-columns: 80px 1fr 1fr; gap: 6px; align-items: center; margin-bottom: 8px; font-size: 13px; }
.rango input { padding: 6px 8px; }
.ayuda, .nota-panel { font-size: 12px; color: var(--texto-2); margin: 4px 0 10px; }
.nota-panel { padding: 0 16px 14px; }
.campo-linea { margin: 0 0 8px; }
.panel-acciones { padding: 12px 16px; display: grid; gap: 8px; position: sticky; bottom: 0; background: #fff; border-top: 1px solid #edf1f5; }
.leyenda-caja { padding: 12px 16px 0; }
.leyenda-item { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 13px; }
.leyenda-item .punto { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.2); flex: none; }
.leyenda-item .txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leyenda-item .n { color: var(--texto-2); font-size: 12px; }
.vacio { color: var(--texto-2); font-size: 12px; padding: 4px; }

/* mapa */
.mapa-caja { flex: 1; position: relative; min-width: 0; }
#mapa { position: absolute; inset: 0; }
.selector-base { position: absolute; left: 12px; bottom: 28px; display: flex; background: #fff; border-radius: var(--radio); box-shadow: var(--sombra); overflow: hidden; z-index: 2; }
.selector-base button { border: 0; background: #fff; padding: 9px 14px; font: inherit; cursor: pointer; border-right: 1px solid var(--borde); }
.selector-base button:last-child { border-right: 0; }
.selector-base button.activo { background: var(--verde); color: #fff; font-weight: 600; }
.toggle-capa { position: absolute; left: 12px; top: 12px; background: #fff; border-radius: var(--radio); box-shadow: var(--sombra); padding: 8px 12px; margin: 0; display: flex; gap: 8px; align-items: center; color: var(--texto); z-index: 2; cursor: pointer; }
.toggle-capa input { width: auto; margin: 0; accent-color: var(--verde); }
.cargando { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: var(--texto); color: #fff; padding: 8px 14px; border-radius: 20px; font-size: 13px; z-index: 3; }
.toast { position: absolute; bottom: 80px; left: 50%; transform: translateX(-50%); background: #1f2933; color: #fff; padding: 10px 16px; border-radius: var(--radio); z-index: 6; max-width: 90%; box-shadow: var(--sombra); }
.popup-mini .maplibregl-popup-content { padding: 6px 10px; font-size: 12px; }

/* detalle */
.detalle { width: 360px; flex: none; background: #fff; border-left: 1px solid var(--borde); display: flex; flex-direction: column; z-index: 4; }
.detalle-cabecera { display: flex; justify-content: space-between; align-items: flex-start; padding: 14px 16px; border-bottom: 1px solid var(--borde); background: var(--verde-claro); }
.detalle-cabecera h2 { margin: 0; font-size: 22px; color: var(--verde-osc); }
.detalle-sub { font-size: 12px; color: var(--texto-2); text-transform: uppercase; letter-spacing: .04em; }
.detalle-cuerpo { overflow-y: auto; padding: 12px 16px 24px; }
.detalle-cuerpo section { margin-bottom: 14px; }
.detalle-cuerpo h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--verde-osc); margin: 6px 0 6px; }
.detalle-cuerpo dl { margin: 0; }
.dato { display: grid; grid-template-columns: 130px 1fr; gap: 8px; padding: 5px 0; border-bottom: 1px dashed #edf1f5; font-size: 13px; }
.dato dt { color: var(--texto-2); }
.dato dd { margin: 0; word-break: break-word; }
.acciones-det { display: flex; gap: 8px; margin-bottom: 12px; }
.acciones-det .btn { flex: 1; font-size: 13px; padding: 7px 10px; }
.resto summary { cursor: pointer; font-weight: 600; color: var(--verde); padding: 6px 0; }

/* administración */
.pagina-admin { overflow: auto; }
.admin { max-width: 1150px; margin: 0 auto; padding: 20px 16px 60px; }
.admin-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--borde); margin-bottom: 18px; flex-wrap: wrap; }
.admin-tabs button { border: 0; background: none; padding: 10px 14px; font: inherit; cursor: pointer; border-bottom: 3px solid transparent; color: var(--texto-2); font-weight: 600; }
.admin-tabs button.activo { color: var(--verde-osc); border-bottom-color: var(--verde); }
.tarjeta { background: #fff; border: 1px solid var(--borde); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.tarjeta h2 { font-size: 16px; margin: 0 0 12px; }
.tabla-caja { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #edf1f5; vertical-align: top; }
th { background: var(--fondo); font-weight: 600; color: var(--texto-2); white-space: nowrap; }
.rejilla { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 14px; }
.chk-linea { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--texto); }
.chk-linea input { width: auto; margin: 0; accent-color: var(--verde); }
.barra-progreso { height: 12px; background: #edf1f5; border-radius: 6px; overflow: hidden; margin: 10px 0; }
.barra-progreso div { height: 100%; background: var(--verde); width: 0; transition: width .4s; }
.etiqueta-rol { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; background: #eef2f6; }
.etiqueta-rol.admin { background: #e7eefb; color: var(--azul); }
.inactivo td { color: #9aa5b1; }
.fila-botones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* móvil */
.solo-movil { display: none; }
@media (max-width: 900px) {
  .solo-movil { display: inline-block; }
  .marca-texto span { display: none; }
  .marca-texto strong { font-size: 13px; white-space: normal; max-width: 120px; }
  .barra { gap: 8px; padding: 0 8px; }
  .btn-usuario { max-width: 90px; }
  .panel { position: absolute; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--sombra); width: 88%; max-width: 330px; }
  .panel.abierto { transform: none; z-index: 8; }
  .detalle { position: absolute; left: 0; right: 0; bottom: 0; width: auto; height: 58%; border-left: 0; border-top: 1px solid var(--borde); box-shadow: 0 -4px 16px rgba(0,0,0,.15); border-radius: 14px 14px 0 0; }
  .selector-base { bottom: 32px; }
}
@media (max-width: 560px) {
  .marca-texto { display: none; }
  .buscador .btn { padding: 8px 10px; }
}

/* v1.1 */
.sec-filtro { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--verde-osc); font-weight: 700; padding: 14px 8px 2px; }
.rango { grid-template-columns: 1fr 1fr; }
.grupo input[type=search] { margin-bottom: 10px; }
.detalle-nombre { font-size: 13px; color: var(--texto-2); margin-top: 2px; }
.grafico { width: 100%; height: auto; display: block; }
.grafico .gbar { fill: var(--verde); opacity: .85; }
.grafico g:hover .gbar { opacity: 1; fill: var(--verde-osc); }
.grafico .eje { font-size: 9px; fill: var(--texto-2); }
.tabla-campos input[type=text], .tabla-campos select { padding: 5px 7px; font-size: 13px; }
.tabla-campos td { vertical-align: middle; }
.tabla-campos .col-nombre code { font-size: 12px; }
.tabla-campos .stat { font-size: 11px; color: var(--texto-2); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabla-campos tr.modificado td { background: #fffbea; }
.tabla-campos tr.ausente td { color: #9aa5b1; }
.tabla-campos th.c, .tabla-campos td.c { text-align: center; }
.tabla-campos input[type=checkbox] { width: auto; accent-color: var(--verde); }
.barra-campos { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.barra-campos input, .barra-campos select { width: auto; }
.pegajoso { position: sticky; bottom: 0; background: #fff; padding: 12px 0 4px; border-top: 1px solid var(--borde); }

/* capas */
.panel-capas { position: absolute; left: 12px; top: 12px; width: 270px; max-width: calc(100% - 70px); background: #fff; border-radius: var(--radio); box-shadow: var(--sombra); z-index: 2; font-size: 13px; }
.capas-titulo { width: 100%; text-align: left; background: none; border: 0; padding: 9px 12px; font: inherit; font-weight: 700; cursor: pointer; display: flex; justify-content: space-between; }
.capas-cuerpo { padding: 0 12px 10px; max-height: calc(100vh - 220px); overflow-y: auto; }
.chk-capa { display: flex; gap: 8px; align-items: center; margin: 0 0 6px; color: var(--texto); font-weight: 400; font-size: 13px; cursor: pointer; }
.chk-capa input { width: auto; margin: 0; accent-color: var(--verde); }
.opciones-rutas { border-left: 3px solid var(--verde-claro); padding: 4px 0 6px 10px; margin: 0 0 8px; display: grid; gap: 6px; }
.opciones-rutas select { padding: 5px 7px; font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 3px; }
.chips button { border: 1px solid var(--borde); background: #fff; border-radius: 14px; padding: 3px 8px; font: inherit; font-size: 12px; cursor: pointer; }
.chips button.activo { background: var(--verde); border-color: var(--verde); color: #fff; font-weight: 600; }
.rango-hora { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--texto-2); }
.rango-hora select { width: auto; }
.leyenda-hora { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--texto-2); }
.leyenda-hora .grad { flex: 1; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #1d4ed8, #0891b2 23%, #16a34a 38%, #eab308 54%, #ea580c 69%, #dc2626 85%, #7c3aed); }
.leyenda-macro { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 8px; margin: 4px 0 6px; font-size: 12px; }
.leyenda-macro span { display: flex; align-items: center; gap: 5px; }
.leyenda-macro i { width: 14px; height: 4px; border-radius: 2px; display: inline-block; }
.popup-ruta .maplibregl-popup-content { font-size: 12px; padding: 8px 10px; max-width: 260px; }
.popup-ruta b { color: var(--verde-osc); }
.popup-ruta table { border-collapse: collapse; margin-top: 4px; }
.popup-ruta td { padding: 1px 6px 1px 0; border: 0; }
@media (max-width: 900px) { .panel-capas { width: 230px; } .capas-cuerpo { max-height: 45vh; } }

/* v1.3 · módulos (comercial y proyectos técnicos) */
.modulos { display: flex; gap: 4px; padding: 3px; background: var(--fondo); border: 1px solid var(--borde); border-radius: 10px;
  overflow-x: auto; scrollbar-width: none; flex: 0 1 auto; min-width: 0; }
.modulos::-webkit-scrollbar { display: none; }
.modulos button { border: 0; background: none; font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 7px; cursor: pointer;
  white-space: nowrap; color: var(--texto-2); display: inline-flex; align-items: center; gap: 6px; }
.modulos button::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--verde); flex: none; }
.modulos button.mod-tecnico::before { background: var(--azul); }
.modulos button:hover { color: var(--texto); background: #fff; }
.modulos button.activo { background: #fff; color: var(--texto); font-weight: 600; box-shadow: 0 1px 3px rgba(15, 23, 42, .15); }
.modo-proyecto .usuario { margin-left: auto; }
.vista-proyecto { flex: 1; min-height: 0; position: relative; background: #fff; }
.marco-proyecto { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.cargando-proyecto { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); background: #fff; border: 1px solid var(--borde);
  box-shadow: var(--sombra); border-radius: 20px; padding: 8px 16px; font-size: 13px; z-index: 2; }
.sin-modulos { margin: 60px auto; max-width: 460px; text-align: center; color: var(--texto-2); }
.chk-modulos { display: flex; gap: 14px; flex-wrap: wrap; }
@media (max-width: 900px) {
  .modulos button { padding: 6px 9px; font-size: 12px; }
  .modulos button::before { display: none; }
}
.caja-modulos { border: 1px solid var(--borde); border-radius: var(--radio); padding: 8px 12px 10px; margin: 0 0 12px; }
.caja-modulos legend { font-size: 13px; font-weight: 600; padding: 0 4px; }
.modo-proyecto .buscador { display: none; }
.modo-proyecto #btnPanel { display: none !important; }
