:root {
  --bg: #f6f7f9; --panel: #fff; --text: #1d2430; --muted: #5f6b7a; --line: #dfe3e8;
  --accent: #1d5fa8; --accent-soft: #e8f0fa; --danger: #b42318; --danger-soft: #fdecea;
  --warn: #9a5b00; --warn-soft: #fff4e0; --ok: #1b7f3b; --ok-soft: #e6f4ea;
  --radius: 8px; --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  /* estados de las actuaciones (mismos colores en mapa, listados y panel) */
  --e-pendiente: #8a94a3; --e-planeamiento: #7b5cd6; --e-gestion: #e08a1e; --e-urbanizacion: #1f6fbf;
  --e-recibida: #2e9d4f; --e-finalizada: #17643a; --e-paralizada: #c8372d; --e-archivada: #7a5c48;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* cabecera */
.top { display: flex; align-items: center; gap: 1.5rem; padding: 0 16px; height: 52px; background: #14233a; color: #fff; }
.top .marca { font-weight: 650; color: #fff; white-space: nowrap; }
.top nav { display: flex; gap: .25rem; overflow-x: auto; flex: 1; }
.top nav a { color: #cfd8e3; padding: .35rem .7rem; border-radius: 6px; white-space: nowrap; }
.top nav a.activo, .top nav a:hover { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.top .usuario { color: #cfd8e3; font-size: .85rem; white-space: nowrap; }
.top .usuario button { background: none; border: 0; color: #cfd8e3; cursor: pointer; font: inherit; text-decoration: underline; }

@media (max-width: 760px) {
  .top { flex-wrap: wrap; height: auto; padding: 8px 16px 0; gap: .25rem 1rem; }
  .top .usuario { margin-left: auto; }
  .top nav { order: 3; flex: 1 0 100%; padding-bottom: 6px; }
  .visor { height: auto; }
}
main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 48px; }
main.ancho { max-width: none; padding: 0; }

.mensajes { list-style: none; padding: 0; margin: 0 0 1rem; }
.mensajes li { padding: .6rem .9rem; border-radius: var(--radius); margin-bottom: .4rem; background: var(--accent-soft); }
.mensajes li.error { background: var(--danger-soft); color: var(--danger); }
.mensajes li.success { background: var(--ok-soft); color: var(--ok); }

/* tarjetas y rejillas */
.tarjetas { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 1rem 0; }
.tarjeta { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tarjeta .cifra { font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.tarjeta .etq { color: var(--muted); font-size: .85rem; }
.rejilla-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.bloque { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.bloque > h2:first-child, .bloque > h3:first-child { margin-top: 0; }
.tabla-wrap + .rejilla-2, .tabla-wrap + section, .rejilla-2 + .rejilla-2 { margin-top: 24px; }
@media (max-width: 860px) { .rejilla-2 { grid-template-columns: 1fr; } }

/* barras del panel */
.barras { display: grid; gap: 6px; }
.barra { display: grid; grid-template-columns: 210px 1fr 48px; align-items: center; gap: 8px; font-size: .9rem; }
.barra .pista { background: #eef1f4; border-radius: 4px; height: 14px; overflow: hidden; }
.barra .relleno { height: 100%; border-radius: 4px; }
.barra .n { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .barra { grid-template-columns: 1fr 48px; } .barra .pista { display: none; } }

/* tablas */
.tabla-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: var(--panel); }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); font-weight: 600; background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.vencido td { background: var(--danger-soft); }
tr.proximo td { background: var(--warn-soft); }

/* etiquetas de estado */
.estado { display: inline-flex; align-items: center; gap: .35rem; font-size: .82rem; white-space: nowrap; }
.estado::before { content: ""; width: .7rem; height: .7rem; border-radius: 3px; background: var(--c, #999); }
.estado-pendiente { --c: var(--e-pendiente); } .estado-planeamiento { --c: var(--e-planeamiento); }
.estado-gestion { --c: var(--e-gestion); } .estado-urbanizacion { --c: var(--e-urbanizacion); }
.estado-recibida { --c: var(--e-recibida); } .estado-finalizada { --c: var(--e-finalizada); }
.estado-paralizada { --c: var(--e-paralizada); } .estado-archivada { --c: var(--e-archivada); }
.chip { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .78rem; background: #eef1f4; color: var(--muted); white-space: nowrap; }
.chip.rojo { background: var(--danger-soft); color: var(--danger); }
.chip.ambar { background: var(--warn-soft); color: var(--warn); }
.chip.verde { background: var(--ok-soft); color: var(--ok); }

/* formularios */
form.filtros { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 1rem 0; }
form.filtros label { display: grid; font-size: .8rem; color: var(--muted); gap: 2px; }
input, select, button, .boton { font: inherit; }
input[type=text], input[type=search], input[type=number], input[type=password], select, input[type=file] {
  padding: .4rem .55rem; border: 1px solid #c9d0d8; border-radius: 6px; background: #fff; min-width: 0; max-width: 100%; }
button, .boton { display: inline-block; padding: .42rem .9rem; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; }
button.secundario, .boton.secundario { background: #fff; color: var(--accent); }
.boton:hover { text-decoration: none; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ficha */
.cabecera-ficha { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: start; }
dl.datos { display: grid; grid-template-columns: minmax(150px, max-content) 1fr; gap: 4px 16px; margin: 0; }
dl.datos dt { color: var(--muted); font-size: .88rem; }
dl.datos dd { margin: 0; font-variant-numeric: tabular-nums; }
.mapa-ficha { height: 340px; border-radius: var(--radius); border: 1px solid var(--line); }
.proyecto { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 16px; }
.proyecto:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.progreso { background: #eef1f4; border-radius: 4px; height: 10px; overflow: hidden; max-width: 320px; }
.progreso > div { height: 100%; background: var(--e-urbanizacion); }

/* linea de tiempo de tramites */
ol.tramites { list-style: none; padding: 0; margin: .25rem 0; }
ol.tramites li { display: grid; grid-template-columns: 18px 110px 1fr; gap: 8px; padding: 4px 0; align-items: baseline; }
ol.tramites li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--ok); margin-top: 5px; }
ol.tramites li.pendiente::before { background: #fff; border: 2px solid #b0b8c2; }
ol.tramites li.vencido::before { background: var(--danger); }
ol.tramites .fecha { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .88rem; }

/* visor */
.visor { display: grid; grid-template-columns: 300px 1fr; height: calc(100vh - 52px); }
.visor aside { overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); padding: 12px 14px; }
.visor aside h3 { font-size: .8rem; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; margin: 1rem 0 .4rem; }
.visor aside label { display: flex; gap: .45rem; align-items: center; font-size: .9rem; padding: 2px 0; cursor: pointer; }
.visor #mapa { width: 100%; height: 100%; }
.leyenda .muestra { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; flex: none; }
.maplibregl-popup-content { font: 14px/1.4 system-ui, sans-serif; padding: 10px 12px; }
@media (max-width: 760px) {
  .visor { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: auto; }
  .visor aside { max-height: 38vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .visor #mapa { height: 62vh; }
}

/* acceso */
.acceso { max-width: 360px; margin: 10vh auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.acceso p { display: grid; gap: 4px; }
.paginacion { display: flex; gap: 8px; align-items: center; margin-top: 12px; }

@media (max-width: 560px) {
  dl.datos { grid-template-columns: 1fr; gap: 0; }
  dl.datos dd { margin-bottom: 6px; }
}

/* Zonas de calificación y fichas urbanísticas */
.muestra-zona { display: inline-block; width: .85rem; height: .85rem; border-radius: 3px; margin-right: .45rem; vertical-align: -1px; border: 1px solid rgba(0,0,0,.25); }
.muestra-zona.grande { width: 1.1rem; height: 1.1rem; vertical-align: -2px; }
.ficha-zona { margin-top: 16px; scroll-margin-top: 16px; }
.ficha-zona h2 { margin: 0; }
.texto-ficha { white-space: normal; overflow-wrap: anywhere; }
table.parametros th { text-transform: none; letter-spacing: 0; font-size: .9rem; color: var(--text, inherit); background: none; font-weight: 500; width: 40%; }
table.parametros tr.nota td { background: #fafbfc; }
@media (max-width: 560px) { table.parametros th { width: auto; } }
