:root {
  --vino: #3F1840;
  --verde-sugle: #1F8A4C;
  --rojo-sugle: #D3342B;
  --azul-sugle: #3B3FA0;
  --turquesa: #0E8C8C;
  --barney: #A02671;
  --lila: #E5DBEB;
  --humo: #E8E6E6;
  --texto: #1C1C1C;
  --suave: #5f5f5f;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: Calibri, Carlito, system-ui, sans-serif; color: var(--texto); background: var(--humo); }
[hidden] { display: none !important; }
button, input { font: inherit; }
button { cursor: pointer; padding: 6px 12px; border: 1px solid var(--vino); border-radius: 6px; background: #fff; color: var(--vino); }
button.primario { background: var(--barney); border-color: var(--barney); color: #fff; }
button.enlace { border: 0; background: none; padding: 0; color: var(--barney); text-decoration: underline; }
input[type=search], .tarjeta-acceso input { width: 100%; padding: 8px; border: 1px solid #bbb; border-radius: 6px; }
.error { color: #b00020; margin: 4px 0; }
.error:empty { display: none; }

.acceso { min-height: 100%; display: grid; place-items: center; padding: 16px; background: var(--vino); }
.tarjeta-acceso { width: min(360px, 100%); padding: 24px; display: grid; gap: 12px; background: #fff; border-radius: 12px; }
.tarjeta-acceso h1 { margin: 0; color: var(--vino); }
.tarjeta-acceso p { margin: 0; }
.tarjeta-acceso label { display: grid; gap: 4px; }

.aplicacion { height: 100%; display: flex; flex-direction: column; }
.visor { flex: 1; min-height: 0; display: grid; grid-template-columns: 360px 1fr; }
.panel { display: flex; flex-direction: column; min-height: 0; background: #fff; box-shadow: 2px 0 6px rgb(0 0 0 / 15%); z-index: 1000; }
.cabecera { display: flex; gap: 16px; align-items: center; padding: 8px 16px; background: var(--vino); color: #fff; }
.cabecera .pestanas { flex: 1; display: flex; gap: 4px; }
.pestanas button { border: 0; background: none; color: #fff; }
.pestanas button[aria-current] { background: #fff; color: var(--vino); font-weight: 700; }
.cabecera button.enlace { color: #fff; }
.cabecera .usuario { min-width: 0; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .9; font-size: .9rem; }
.resumen { margin: 0; padding: 8px 16px; background: var(--lila); }
.vista { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px; }
.vista h2 { margin: 18px 0 6px; font-size: 1.05rem; color: var(--vino); overflow-wrap: anywhere; }
.nota { margin: 4px 0 8px; font-size: .9rem; color: var(--suave); }
.fila { display: flex; flex-wrap: wrap; gap: 8px; }
.mapa { min-height: 0; }

.lista { list-style: none; margin: 8px 0 0; padding: 0; max-height: 40vh; overflow-y: auto; }
.lista li button { width: 100%; display: flex; gap: 8px; align-items: center; text-align: left; border: 0; border-bottom: 1px solid var(--humo); border-radius: 0; padding: 8px 4px; color: var(--texto); background: none; }
.lista li button:hover { background: var(--lila); }
.lista small { display: block; color: var(--suave); }
.lista button.carpeta-taxa { font-weight: 700; color: var(--vino); background: var(--humo); }
.lista button.carpeta-taxa small { font-weight: 400; }
.lista .titulo-carpeta { padding: 8px 10px; font-weight: 700; color: #fff; background: var(--vino); border-radius: 6px; }
.lista button.volver-carpetas { background: none; border: 0; color: var(--vino); padding: 4px 6px; }
.lista li.en-carpeta button { padding-left: 20px; }
.punto { flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--barney); }
.punto.registrada { background: #2e7d32; }
.punto.sin-ubicacion { background: #9e9e9e; }
.punto.con-borde { box-shadow: 0 0 0 2px #000; }
.lista button.carpeta-taxa { gap: 10px; }

.boton-archivo { display: inline-block; padding: 6px 12px; border-radius: 6px; background: var(--barney); color: #fff; cursor: pointer; }
.boton-archivo:focus-within { outline: 2px solid var(--vino); outline-offset: 2px; }
.boton-archivo input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.lista-capas { list-style: none; margin: 8px 0 0; padding: 0; }
.lista-capas li { display: flex; gap: 8px; align-items: center; padding: 4px 0; }
.lista-capas label { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.fotos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin: 8px 0; }
.fotos button { padding: 0; border: 0; aspect-ratio: 4 / 3; overflow: hidden; background: var(--humo); }
.fotos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto-falla { aspect-ratio: 4 / 3; display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center; padding: 8px; text-align: center; font-size: .85rem; background: var(--humo); color: var(--suave); overflow-wrap: anywhere; }
.sin-conexion { margin: 0; padding: 6px 16px; background: #fff3cd; color: #5c4400; font-size: .9rem; }
.enlaces-ficha { display: grid; gap: 6px; }
.enlaces-ficha a { display: block; padding: 8px 12px; border: 1px solid var(--lila); border-radius: 6px; color: var(--vino); font-weight: 700; text-decoration: none; overflow-wrap: anywhere; }
.enlaces-ficha a:hover, .enlaces-ficha a:focus-visible { background: var(--lila); }
.enlaces-ficha small { display: block; font-weight: 400; color: var(--suave); }
.ficha dt { font-weight: 700; margin-top: 8px; overflow-wrap: anywhere; }
.ficha dd { margin: 0; overflow-wrap: anywhere; }

.foto-grande { max-width: min(96vw, 1100px); padding: 8px; border: 0; border-radius: 8px; }
.foto-grande::backdrop { background: rgb(0 0 0 / 70%); }
.foto-grande form { text-align: right; }
.foto-grande img { max-width: 100%; max-height: 80vh; display: block; margin: auto; }
.foto-grande p { margin: 6px 0 0; }

.fichas { flex: 1; min-height: 0; overflow-y: auto; background: var(--humo); }
.generador-cuerpo { max-width: 900px; margin: auto; padding: 20px 16px; }
.generador-titulo { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.generador-titulo h1 { margin: 0; color: var(--vino); font-size: 1.5rem; }
.generador-titulo p { margin: 0; }
.fichas-lista { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.ficha-tarjeta { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; padding: 12px 16px; background: #fff; border-radius: 8px; }
.ficha-tarjeta strong { overflow-wrap: anywhere; }
.ficha-tarjeta small { display: block; color: var(--suave); }

.generador-barra { position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 16px; background: #fff; border-bottom: 1px solid #ccc; }
.generador-errores { flex-basis: 100%; padding: 8px 12px; border-radius: 6px; background: #fdecea; color: #7a1c14; }
.generador-errores ul { margin: 4px 0 0; padding-left: 20px; }
.generador-editor { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; max-width: 1200px; margin: auto; padding: 16px; }
.generador-formulario { display: grid; gap: 12px; min-width: 0; }
.tarjeta-seccion { display: grid; gap: 10px; padding: 14px; background: #fff; border-radius: 8px; }
.tarjeta-campo { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--lila); border-radius: 8px; }
.cabecera-seccion { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.crece { flex: 1 1 220px; min-width: 0; }
.campo-edicion { display: grid; gap: 4px; font-size: .9rem; color: var(--suave); }
.generador-editor input:not([type=checkbox]), .generador-editor select, .generador-editor textarea { width: 100%; min-width: 0; padding: 7px; border: 1px solid #bbb; border-radius: 6px; font: inherit; color: var(--texto); background: #fff; }
.generador-formulario .fila > .campo-edicion { flex: 1 1 130px; min-width: 0; }
.generador-formulario .fila > input, .generador-formulario .fila > select { flex: 1 1 130px; width: auto; }
.casilla { display: flex; gap: 6px; align-items: center; align-self: flex-end; padding-bottom: 8px; }
.orden { display: flex; gap: 4px; }
.orden button { padding: 6px 10px; }
button:disabled { opacity: .45; cursor: default; }
.columnas { display: grid; gap: 8px; }
.condicion { padding-top: 4px; }

.generador-vista { position: sticky; top: 72px; min-width: 0; }
.generador-vista h2 { margin: 0; font-size: 1.05rem; color: var(--vino); }
.generador-vista .nota { margin: 2px 0 8px; }
.vista-celular { max-height: 70vh; overflow-y: auto; padding: 14px; border: 8px solid #222; border-radius: 22px; background: #fff; }
.vista-completa { max-width: 720px; max-height: none; border-width: 2px; border-radius: 12px; }
.vista-celular h3 { margin: 0 0 8px; color: var(--vino); overflow-wrap: anywhere; }
.vista-celular h4 { margin: 14px 0 6px; padding: 4px 8px; background: var(--vino); color: #fff; border-radius: 4px; overflow-wrap: anywhere; }
.vista-campo { display: grid; gap: 4px; margin-bottom: 10px; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border-radius: 16px; }
.chip.activo { background: var(--barney); border-color: var(--barney); color: #fff; }
.vista-tabla { display: grid; gap: 6px; }
.vista-fila { display: grid; gap: 4px; padding: 6px; border: 1px solid var(--lila); border-radius: 6px; }

button.peligro { border-color: #b00020; color: #b00020; }
button.peligro:hover:not(:disabled) { background: #b00020; color: #fff; }
.zona-admin { margin-top: 20px; padding-top: 4px; border-top: 1px solid var(--humo); }

.boton-enlace { padding: 6px 12px; border: 1px solid var(--vino); border-radius: 6px; background: #fff; color: var(--vino); text-decoration: none; }
.boton-enlace:hover { background: var(--lila); }

.cabecera a { color: #fff; }
.cabecera .crece { flex: 1; }
.consulta { max-width: 1000px; margin: auto; padding: 20px 16px; }
.consulta-ancha { max-width: none; }
.consulta h1 { margin: 0 0 4px; color: var(--vino); font-size: 1.5rem; overflow-wrap: anywhere; }
.consulta a { color: var(--barney); }
.controles-tabla { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.controles-tabla input[type=search] { flex: 1 1 220px; width: auto; min-width: 0; background: #fff; }
.controles-tabla select { padding: 8px; border: 1px solid #bbb; border-radius: 6px; background: #fff; font: inherit; }
.controles-tabla .nota { margin: 0; }
.tabla-contenedor { overflow: auto; margin: 12px 0; border: 1px solid #c8c8c8; border-radius: 6px; background: #fff; }
.tabla-general { max-height: calc(100vh - 190px); }
.tabla-datos { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .95rem; }
.tabla-datos th, .tabla-datos td { padding: 6px 10px; border-right: 1px solid var(--humo); border-bottom: 1px solid var(--humo); text-align: left; vertical-align: top; }
.tabla-datos th { position: sticky; top: 0; z-index: 1; background: var(--lila); color: var(--vino); font-weight: 700; white-space: nowrap; }
.tabla-datos th button { padding: 0; border: 0; background: none; color: inherit; font-weight: inherit; }
.tabla-datos tbody tr:hover td { background: #f7f3f9; }
.tabla-datos td { min-width: 90px; max-width: 360px; overflow-wrap: break-word; }
.tabla-datos td.multilinea { white-space: pre-line; }
.tabla-ficha th { position: static; min-width: 120px; white-space: normal; overflow-wrap: break-word; }
.tabla-ficha .fila-secciones th { background: var(--vino); color: #fff; border-right-color: #fff; }
.fotos-ficha { display: flex; flex-wrap: wrap; gap: 8px; }
.fotos-ficha figure { margin: 0; width: 140px; }
.fotos-ficha img, .foto-pendiente { display: block; width: 140px; height: 105px; object-fit: cover; border-radius: 6px; background: var(--humo); }
.foto-pendiente { display: grid; place-items: center; padding: 8px; text-align: center; font-size: .8rem; color: var(--suave); box-sizing: border-box; }
.fotos-ficha figcaption { font-size: .8rem; color: var(--suave); margin-top: 2px; overflow-wrap: anywhere; }
.tabla-ficha td:has(.fotos-ficha) { max-width: none; }
.tabla-datos td.numero { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .generador-editor { grid-template-columns: minmax(0, 1fr); }
  .generador-vista { position: static; }
  .vista-celular { max-height: none; }
}

@media (max-width: 760px) {
  .visor { grid-template-columns: 1fr; grid-template-rows: 45vh 1fr; }
  .mapa { grid-row: 1; }
  .panel { grid-row: 2; box-shadow: none; }
  .lista { max-height: none; }
}

.equipos { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: grid; gap: 16px; align-content: start; }
.equipos-seccion { background: #fff; border-radius: 8px; padding: 16px; display: grid; gap: 10px; max-width: 960px; }
.equipos-seccion h2 { margin: 0; font-size: 1.1rem; color: var(--vino); }
.equipos-seccion h3 { margin: 8px 0 4px; font-size: 1rem; }
.equipos-seccion label { display: flex; gap: 6px; align-items: center; }
.equipos-seccion input[type=number] { width: 5em; padding: 4px; }
.resumen-plan { background: var(--lila); border-radius: 6px; padding: 8px 12px; }
.resumen-plan p { margin: 4px 0; }
.taxas-plan { columns: 2 220px; margin: 0; padding-left: 1.2em; }
.bloque ul { margin: 0; padding-left: 1.2em; max-height: 30vh; overflow-y: auto; }
.bloque.errores { color: #b00020; }
.tabla-personas { overflow-x: auto; }
.tabla-personas table { border-collapse: collapse; width: 100%; }
.tabla-personas th, .tabla-personas td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--humo); vertical-align: top; }
.tabla-personas tr.inactivo { color: var(--suave); }

/* Nombres fijos de las estaciones al acercar el mapa. */
.leaflet-tooltip.etiqueta { padding: 1px 5px; font-size: 12px; font-weight: 700; border: 0; border-radius: 4px; background: rgb(255 255 255 / 85%); box-shadow: none; }
.leaflet-tooltip.etiqueta::before { display: none; }
.control-fotos button { display: block; padding: 6px 10px; border: 0; border-radius: 4px; background: #fff; color: #222; font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.control-fotos button:hover { background: #f4f4f4; }
.control-fotos button[aria-pressed="true"] { background: #1565c0; color: #fff; }

.tabla-personas td.celda-taxa, .tabla-personas th.celda-taxa { text-align: center; }
.formulario-estacion { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px 12px; }
.formulario-estacion label { display: grid; gap: 2px; font-size: .9rem; }
.formulario-estacion input, .formulario-estacion select, .formulario-estacion input[type=number] { width: 100%; padding: 4px 6px; }

button.peligro-texto { color: #b00020; }
.lista li.accion-carpeta { padding: 8px 4px 8px 20px; }
.ficha-con-accion { display: flex; gap: 8px; align-items: center; }
.ficha-con-accion a { flex: 1; min-width: 0; }

/* Recorrido de demostración: solo mirar. */
body.demo .solo-real { display: none !important; }
.franja-demo { position: sticky; top: 0; z-index: 2000; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: center; padding: 8px 16px; background: #fff4d6; color: #5a3d00; border-bottom: 1px solid #e8c56a; font-size: 0.9rem; }
.franja-demo a { color: var(--vino); font-weight: 600; }
.franja-demo .boton-demo { padding: 4px 12px; border-radius: 999px; background: var(--vino); color: #fff; text-decoration: none; }

/* Portada pública (sin sesión). */
.portada { min-height: 100%; background: #fff; color: var(--texto); }
.portada-cabecera { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 24px; border-bottom: 1px solid var(--humo); }
.portada-logo { height: 56px; width: auto; }
.portada-acciones { display: flex; flex-wrap: wrap; gap: 8px; }
.boton-portada { display: inline-block; padding: 9px 18px; border-radius: 999px; border: 2px solid var(--vino); background: var(--vino); color: #fff; font-weight: 600; text-decoration: none; cursor: pointer; }
.boton-portada.secundario { background: #fff; color: var(--vino); }
.boton-portada.grande { padding: 13px 26px; font-size: 1.05rem; }
.boton-portada.claro { background: #fff; color: var(--vino); border-color: #fff; }
.portada-heroe { padding: 80px 24px 88px; text-align: center; color: #fff; background: linear-gradient(135deg, rgba(63, 24, 64, 0.88) 0%, rgba(160, 38, 113, 0.78) 100%), url(img/heroe.jpg) center / cover no-repeat; }
.portada-marca { margin: 0 0 8px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.85; }
.portada-heroe h1 { max-width: 820px; margin: 0 auto 16px; font-size: clamp(1.7rem, 4.5vw, 2.8rem); line-height: 1.15; }
.portada-bajada { max-width: 640px; margin: 0 auto 28px; font-size: 1.1rem; opacity: 0.92; }
.portada-botones { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.portada-heroe .boton-portada.grande:not(.claro) { background: transparent; border-color: #fff; }
.portada-seccion { max-width: 1040px; margin: 0 auto; padding: 56px 24px 8px; }
.portada-fondo { max-width: none; padding-bottom: 56px; background: #f7f1f8; }
.portada-fondo > * { max-width: 1040px; margin-left: auto; margin-right: auto; }
.portada-seccion h2, .portada-cierre h2 { margin: 0 0 24px; color: var(--vino); font-size: 1.6rem; text-align: center; }
.portada-bloques { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin: 0; padding: 0; list-style: none; }
.portada-bloques li { --color: var(--barney); padding: 22px; border-radius: 12px; background: #fff; border-top: 5px solid var(--color); box-shadow: 0 2px 10px rgba(63, 24, 64, 0.08); }
.portada-bloques li:nth-child(1) { --color: var(--verde-sugle); }
.portada-bloques li:nth-child(2) { --color: var(--azul-sugle); }
.portada-bloques li:nth-child(3) { --color: var(--rojo-sugle); }
.portada-bloques li:nth-child(4) { --color: var(--turquesa); }
.portada-bloques li:nth-child(5) { --color: var(--barney); }
.portada-bloques li:nth-child(6) { --color: var(--vino); }
.portada-icono { display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--color); color: #fff; }
.portada-icono svg { width: 28px; height: 28px; }
.portada-bloques h3 { margin: 12px 0 6px; color: var(--vino); font-size: 1.1rem; }
.portada-bloques p { margin: 0; color: var(--suave); }
.portada-pasos { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin: 0; padding: 0; list-style: none; counter-reset: paso; }
.portada-pasos li { --color: var(--verde-sugle); counter-increment: paso; padding: 20px; border: 2px solid var(--color); border-radius: 12px; background: #fff; }
.portada-pasos li:nth-child(2) { --color: var(--azul-sugle); }
.portada-pasos li:nth-child(3) { --color: var(--rojo-sugle); }
.portada-pasos li::before { content: counter(paso); display: inline-grid; place-items: center; width: 32px; height: 32px; margin-bottom: 8px; border-radius: 50%; background: var(--color); color: #fff; font-weight: 700; }
.portada-pasos strong { display: block; color: var(--vino); font-size: 1.1rem; }
.portada-pasos span { color: var(--suave); }
.portada-cierre { margin: 56px 0 0; padding: 48px 24px; text-align: center; color: #fff; background: var(--vino); }
.portada-cierre h2 { color: #fff; margin-bottom: 8px; }
.portada-cierre p { margin: 0 0 20px; opacity: 0.9; }
.portada-pie { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: center; padding: 20px 24px; font-size: 0.9rem; color: var(--suave); }
.portada-pie a { color: var(--vino); }
@media (max-width: 560px) {
  .portada-cabecera { justify-content: center; }
  .portada-logo { height: 44px; }
  .portada-heroe { padding: 40px 16px 48px; }
  .portada-seccion { padding: 40px 16px 8px; }
}
.portada-fondo .portada-bloques { margin: 0 auto; }
