:root{
  --bg:#fff; --ink:#1b1f24; --muted:#667085; --line:#e6e8ec; --soft:#f5f6f8;
  --brand:#1fa56b; --brand-d:#168554; --brand-bg:#e8f6ef;
  --accent:#b62682; --accent-d:#951c6a; --accent-bg:#fbe9f4;
  --ok:#1fa56b; --justo:#a8d94a; --lejos:#f4a62a; --caro:#ef9a9a; --pend:#8fb8ee; --nodata:#c9ced6;
  --shadow:0 2px 14px rgba(16,24,40,.14); --r:14px;
}
*{box-sizing:border-box}
[hidden]{display:none!important}
html,body{height:100%}
html,body{overflow-x:clip}   /* nada puede provocar desplazamiento horizontal de la página */
body{margin:0;background:var(--bg);color:var(--ink);font:16px/1.45 system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;-webkit-text-size-adjust:100%}
button,input,select{font:inherit;color:inherit}
h1,h2,h3,p{margin:0}
:focus-visible{outline:3px solid #9bd7bc;outline-offset:2px}

/* cabecera */
.top{height:60px;display:flex;align-items:center;justify-content:space-between;padding:0 16px;border-bottom:1px solid var(--line);background:#fff;position:relative;z-index:5}
.brand{display:flex;align-items:center;gap:10px;text-decoration:none;color:var(--ink);font-size:19px;font-weight:500;letter-spacing:-.01em;min-width:0}
.brand span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.brand b{font-weight:800}
.logo{width:30px;height:30px;flex:none}
.top nav{display:flex;align-items:center;gap:8px;flex:none}
.link{background:none;border:0;padding:8px 10px;cursor:pointer;color:var(--ink);font-weight:600;border-radius:8px}
.link:hover{background:var(--soft)}
.btn-outline{border:1px solid var(--line);background:#fff;padding:8px 14px;border-radius:999px;cursor:pointer;font-weight:600}
.btn-outline:hover{border-color:#c5cad3;background:var(--soft)}

/* estructura */
.app{display:grid;grid-template-columns:410px 1fr;height:calc(100dvh - 60px)}
#panel{overflow:auto;border-right:1px solid var(--line);background:#fff;padding:16px;display:flex;flex-direction:column;gap:16px}
#mapwrap{position:relative;min-width:0;overflow:hidden}
#map{position:absolute;inset:0;background:#eef0f2}

/* formulario */
.card{border:1px solid var(--line);border-radius:var(--r);padding:14px 16px;display:flex;flex-direction:column;gap:14px;background:#fff}
.field{display:flex;flex-direction:column;gap:6px}
label,.lbl{font-weight:700;font-size:15px}
.help{color:var(--muted);font-size:13.5px}
.row-between{display:flex;align-items:baseline;justify-content:space-between;gap:10px}
output{font-weight:800;color:var(--brand-d);white-space:nowrap}
.salary{display:flex;align-items:center;border:1.5px solid #cfd4dc;border-radius:12px;padding:0 14px;background:#fff}
.salary:focus-within{border-color:var(--brand);box-shadow:0 0 0 3px #bfe8d5}
.salary input{border:0;outline:0;font-size:27px;font-weight:800;width:100%;padding:5px 0;background:transparent;min-width:0}
.salary .unit{color:var(--muted);font-weight:600;white-space:nowrap}
input[type=range]{-webkit-appearance:none;appearance:none;width:100%;height:28px;margin:0;background:transparent;--p:50%}
input[type=range]::-webkit-slider-runnable-track{height:6px;border-radius:99px;background:linear-gradient(to right,var(--brand) var(--p),#dfe3e8 var(--p))}
input[type=range]::-moz-range-track{height:6px;border-radius:99px;background:linear-gradient(to right,var(--brand) var(--p),#dfe3e8 var(--p))}
input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:24px;height:24px;border-radius:50%;background:#fff;border:2px solid var(--brand);margin-top:-9px;box-shadow:0 1px 4px rgba(16,24,40,.3)}
input[type=range]::-moz-range-thumb{width:20px;height:20px;border-radius:50%;background:#fff;border:2px solid var(--brand);box-shadow:0 1px 4px rgba(16,24,40,.3)}
.soft{font-weight:500;color:var(--muted)}
.seg{display:flex;gap:6px;flex-wrap:wrap}
.seg button{flex:1;min-width:64px;border:1.5px solid #d6dae1;background:#fff;border-radius:999px;padding:7px 10px;cursor:pointer;font-weight:600;white-space:nowrap}
.seg button:hover{border-color:#aeb5c0}
.seg button.on{background:var(--accent);border-color:var(--accent);color:#fff}
.seg button.on:hover{background:var(--accent-d);border-color:var(--accent-d)}
.combo{position:relative}
.combo input{width:100%;border:1.5px solid #cfd4dc;border-radius:12px;padding:10px 14px;font-size:17px;background:#fff}
.combo input:focus{outline:0;border-color:var(--brand);box-shadow:0 0 0 3px #bfe8d5}
#workList{position:absolute;left:0;right:0;top:calc(100% + 6px);z-index:20;list-style:none;margin:0;padding:6px;background:#fff;border:1px solid var(--line);border-radius:12px;box-shadow:var(--shadow);max-height:300px;overflow:auto}
#workList li{padding:9px 10px;border-radius:8px;cursor:pointer;display:flex;justify-content:space-between;gap:8px}
#workList li small{color:var(--muted)}
#workList li.sel,#workList li:hover{background:var(--brand-bg)}
#workList .grp{font-size:12.5px;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);padding:8px 10px 4px;cursor:default}
#workList .grp:hover{background:none}
.btn-ghost{align-self:center;border:0;background:none;color:var(--brand-d);font-weight:700;cursor:pointer;padding:4px 0}
.btn-ghost:hover{text-decoration:underline}
.btn-ghost.on{color:#b42318}

.btn-primary{display:none;margin:12px 0 0 10px;border:0;background:var(--accent);color:#fff;border-radius:999px;padding:9px 16px;font-weight:700;cursor:pointer}
.btn-primary:hover{background:var(--accent-d)}
#segYear button{white-space:normal;line-height:1.2;padding:7px 8px}
/* resumen */
.summary{border-radius:var(--r);background:var(--brand-bg);padding:16px}
.summary .big{font-size:31px;font-weight:800;letter-spacing:-.02em;line-height:1.1}
.summary .big small{font-size:16px;font-weight:600;color:#25523f;letter-spacing:0}
.summary p{margin-top:8px;color:#25523f}
.summary.empty{background:#fff4e5}
.summary.empty p{color:#7a4a0c}
.summary .budget{display:inline-block;margin-top:10px;padding:5px 11px;border-radius:999px;background:#fff;font-weight:700;font-size:14.5px}

/* lista */
.lista h2{font-size:17px}
.lista select{border:1px solid var(--line);border-radius:8px;padding:5px 8px;background:#fff;font-size:14px}
#items{list-style:none;margin:10px 0 0;padding:0;display:flex;flex-direction:column;gap:8px}
#items li{border:1px solid var(--line);border-radius:12px;padding:11px 12px;cursor:pointer;display:grid;grid-template-columns:1fr auto;gap:2px 10px;background:#fff}
#items li:hover{border-color:var(--brand);box-shadow:0 1px 8px rgba(31,165,107,.18)}
#items .n{font-weight:700}
#items .p{font-weight:800;text-align:right}
#items .s{color:var(--muted);font-size:13.5px}
#items .t{color:var(--muted);font-size:13.5px;text-align:right}
.vacio{color:var(--muted);padding:6px 2px}
.foot{color:var(--muted);font-size:13px;padding:4px 2px 16px}
.foot p{margin:0 0 6px}.foot a{color:var(--brand-d)}

/* mapa: leyenda, ficha, etc. */
.legend{position:absolute;left:12px;bottom:28px;background:#fff;border-radius:12px;box-shadow:var(--shadow);padding:10px 12px;display:grid;gap:5px;font-size:13.5px;z-index:8}
.legend div{display:flex;align-items:center;gap:8px}
.legend i{width:14px;height:14px;border-radius:4px;flex:none;border:1px solid rgba(0,0,0,.08)}
.legend .collapse{display:none}
.ficha{position:absolute;right:12px;top:12px;width:340px;max-width:calc(100% - 24px);max-height:calc(100% - 60px);overflow:auto;background:#fff;border-radius:16px;box-shadow:var(--shadow);padding:16px;z-index:8}
.ficha h3{font-size:19px;line-height:1.2;padding-right:28px}
.ficha .sub{color:var(--muted);font-size:13.5px;margin-top:2px}
.ficha .x{position:absolute;right:8px;top:8px;width:32px;height:32px;border:0;background:var(--soft);border-radius:50%;cursor:pointer;font-size:21px;line-height:1}
.chip{display:inline-block;margin-top:10px;padding:5px 11px;border-radius:999px;font-weight:700;font-size:14px}
.chip.ok{background:#d9f2e6;color:#0e6b42}.chip.justo{background:#ecf7cf;color:#4a6a0a}.chip.lejos{background:#fdebc8;color:#8a5200}
.chip.caro{background:#fde2e2;color:#a12121}.chip.pend{background:#dce9fb;color:#1f4e8c}.chip.nodata{background:#eceef1;color:#555d69}
.kv{display:grid;grid-template-columns:1fr auto;gap:7px 12px;margin-top:14px;font-size:15px}
.kv dt{color:var(--muted)} .kv dd{margin:0;text-align:right;font-weight:700}
.kv .bigv{font-size:23px;font-weight:800}
.nota{margin-top:12px;padding:0 2px;background:none;font-size:14px;line-height:1.45;color:#145bc7}
.nota + .nota{margin-top:8px}
.tip{position:absolute;z-index:6;pointer-events:none;background:#1b1f24;color:#fff;border-radius:8px;padding:6px 9px;font-size:13.5px;line-height:1.35;white-space:normal;overflow-wrap:anywhere;max-width:min(320px,calc(100% - 16px));box-sizing:border-box}
.hint{position:absolute;top:12px;left:50%;transform:translateX(-50%);z-index:6;background:#1b1f24;color:#fff;border-radius:999px;padding:9px 16px;font-weight:600;box-shadow:var(--shadow)}
.loading{position:absolute;inset:0;background:rgba(255,255,255,.88);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;z-index:10;font-weight:600}
.spin{width:34px;height:34px;border-radius:50%;border:4px solid #d8efe4;border-top-color:var(--brand);animation:g 1s linear infinite}
@keyframes g{to{transform:rotate(360deg)}}
.loading.err{color:#a12121;text-align:center;padding:24px}
.maplibregl-canvas-container.pick canvas{cursor:crosshair}

/* marcadores */
.pill{transform:translate(0,0);background:#fff;color:#2c3340;border:1.5px solid #cfd4dc;border-radius:999px;padding:3px 9px;font-size:13.5px;font-weight:800;box-shadow:0 1px 5px rgba(16,24,40,.22);cursor:pointer;white-space:nowrap;user-select:none}
.pill:hover{z-index:5;transform:scale(1.08)}
.pill{background:var(--ok);border-color:#fff;color:#fff}
.pill.ok{background:var(--ok);border-color:#fff;color:#fff}
.pill.lejos{background:#fff;border-color:var(--lejos);color:#8a5200}
.pill.caro{background:#fff;color:#8b919c;font-weight:700}
.pill.sel{background:#1b1f24;border-color:#fff;color:#fff}
.work{display:flex;flex-direction:column;align-items:center;cursor:default;pointer-events:auto;filter:drop-shadow(0 2px 3px rgba(0,0,0,.35))}
.work-badge{display:flex;align-items:center;gap:6px;background:#1f2937;color:#fff;border:2px solid #fff;border-radius:999px;
  padding:5px 12px 5px 9px;font-size:15px;font-weight:700;letter-spacing:.01em;white-space:nowrap;line-height:1.1}
.work-badge svg{flex:none}
.work-tip{width:12px;height:12px;background:#1f2937;border-right:2px solid #fff;border-bottom:2px solid #fff;transform:rotate(45deg);margin-top:-8px}

/* diálogo */
dialog{border:0;border-radius:18px;padding:0;width:min(720px,calc(100% - 24px));max-height:calc(100dvh - 40px);box-shadow:0 20px 60px rgba(16,24,40,.35)}
dialog::backdrop{background:rgba(16,24,40,.45)}
.dlg-head{display:flex;justify-content:space-between;align-items:center;padding:16px 20px;border-bottom:1px solid var(--line);position:sticky;top:0;background:#fff}
.dlg-head h2{font-size:21px}
.dlg-head .x{width:36px;height:36px;border:0;border-radius:50%;background:var(--soft);font-size:23px;cursor:pointer}
.dlg-body{padding:6px 20px 22px;overflow:auto;max-height:calc(100dvh - 120px)}
.dlg-body h3{margin:20px 0 6px;font-size:17px}
.dlg-body p,.dlg-body li{color:#3d4653}
.dlg-body ul{padding-left:20px;margin:6px 0}
.dlg-body table{border-collapse:collapse;width:100%;font-size:14.5px;margin-top:8px}
.dlg-body th,.dlg-body td{border-bottom:1px solid var(--line);padding:7px 6px;text-align:left;vertical-align:top}
.dlg-body th{color:var(--muted);font-weight:600}
.dlg-body .aviso{background:#fff4e5;border-radius:10px;padding:10px 12px;color:#6b4208}
.toast{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);background:#1b1f24;color:#fff;padding:10px 16px;border-radius:999px;z-index:50;font-weight:600}

/* móvil: formulario → resumen → mapa → lista */
@media (max-width:860px){
  body{overflow:auto}
  .top nav .link{display:none}
  .top nav{gap:6px}.btn-outline{padding:7px 11px;font-size:14px}
  .brand{font-size:15px}.logo{width:26px;height:26px}
  .help{display:none}
  .help.nota-ref{display:block;font-size:13px}
  .go-map{display:inline-block}
  .app{display:flex;flex-direction:column;height:auto}
  #panel{display:contents}
  #form{order:1;margin:12px 12px 0}
  #summary{order:2;margin:12px 12px 0}
  #mapwrap{order:3;height:62dvh;min-height:380px;margin-top:12px}
  #lista{order:4;margin:16px 12px 0}
  .foot{order:5;margin:0 12px}
  .ficha{left:8px;right:8px;top:auto;bottom:8px;width:auto;max-width:none;max-height:52%}
  .legend{bottom:auto;top:8px;left:8px;padding:8px 10px;font-size:12.5px}
  .legend.min div:not(.collapse){display:none}
  .legend .collapse{display:block;font-weight:700;cursor:pointer}
}

.btn-fit{position:absolute;top:12px;left:12px;z-index:8;border:0;background:var(--accent);color:#fff;font-weight:700;padding:10px 16px;border-radius:999px;box-shadow:var(--shadow);cursor:pointer}
.btn-fit:hover{background:var(--accent-d)}
@media (max-width:860px){.btn-fit{display:none}.btn-primary{display:inline-block}}

.pend-note{font-size:14px}
.link-btn{border:0;background:none;padding:0;margin-left:4px;color:#1f4e8c;font-weight:700;text-decoration:underline;cursor:pointer;font-size:14px}

.nota.nota-nuevos{background:#fff4e5;color:#6b4208;padding:10px 12px;border-radius:10px}


.chip.pocas{background:#fdf3c4;color:#7a5b00}
.prob{margin:12px 0 0;font-size:16px;font-weight:700;color:var(--ink);line-height:1.35}
.dot{display:inline-block;width:10px;height:10px;border-radius:50%;margin-right:7px;vertical-align:middle;border:1px solid rgba(0,0,0,.12)}
.legend .lg-t{font-weight:700;margin-bottom:2px}
.summary .stock{font-size:14.5px;color:#3d4a5c;margin-top:6px}
.dlg-body .resumen-calc{margin-top:14px;padding:14px 16px;border-radius:12px;background:#fdf0f7;color:#3d2a36;line-height:1.5}
.dlg-body .ej-intro{margin-top:12px}
.dlg-body h3 .num{display:inline-grid;place-items:center;width:24px;height:24px;border-radius:50%;background:var(--accent);color:#fff;font-size:14px;margin-right:8px;vertical-align:1px}
.dlg-body .ej{margin:10px 0;padding:10px 14px;border-left:4px solid var(--accent);background:#f7f8fa;border-radius:0 10px 10px 0;line-height:1.55;color:#2b3440}
.dlg-body .ej-t{display:block;font-size:13px;font-weight:700;text-transform:uppercase;letter-spacing:.04em;color:var(--accent-d);margin-bottom:3px}
.dlg-body .ej-fin{border-left-color:#1a9850;background:#eef8f1}
.dlg-body .ej-fin .ej-t{color:#11703a}
.dlg-body ol{padding-left:22px;margin:6px 0}
.dlg-body ol li{margin:4px 0}
.dlg-body .sw{display:inline-block;width:12px;height:12px;border-radius:3px;margin:0 6px 0 2px;vertical-align:-1px;border:1px solid rgba(0,0,0,.12)}
.dlg-body table.colores td{padding:6px}
.dlg-body details.tecnico{margin-top:18px;border:1px solid var(--line);border-radius:10px;padding:8px 14px}
.dlg-body details.tecnico summary{cursor:pointer;font-weight:700}
.dlg-body details.tecnico li{font-size:14.5px;margin:6px 0}
.dlg-body p{margin:8px 0}

.help.nota-ref{color:#145bc7;margin-top:4px}
.summary .titular{font-size:17.5px;line-height:1.4;margin-top:0}
.info-btn{display:inline-flex;align-items:center;justify-content:center;width:19px;height:19px;margin-left:4px;padding:0;border:1.5px solid #145bc7;border-radius:50%;
  background:#fff;color:#145bc7;font:italic 700 12px/1 Georgia,'Times New Roman',serif;cursor:pointer;vertical-align:1px}
.info-btn:hover,.info-btn[aria-expanded="true"]{background:#145bc7;color:#fff}
.info-btn:focus-visible{outline:2px solid #145bc7;outline-offset:2px}
.info-pop{color:#145bc7;font-size:14px;line-height:1.45;margin:8px 0 10px;padding:10px 14px;background:#f2f7fe;border:1px solid #bcd3f5;border-radius:14px;box-shadow:0 1px 3px rgba(20,91,199,.08)}
.info-pop p:first-child{margin-top:0}.info-pop p:last-child{margin-bottom:0}
.info-pop p{margin:4px 0}.info-pop ul{margin:2px 0 4px;padding-left:18px}.info-pop li{margin:1px 0}
/* créditos del mapa: mismo icono «i» y mismo recuadro azul que la información del tiempo de trayecto */
.maplibregl-ctrl-attrib.maplibregl-compact{background:transparent;margin:10px;padding:0;min-height:24px;min-width:24px;color:#145bc7}
.maplibregl-ctrl-attrib.maplibregl-compact:after{display:none}
.maplibregl-ctrl-attrib.maplibregl-compact-show{background:#f2f7fe;border:1px solid #bcd3f5;border-radius:14px;box-shadow:0 1px 3px rgba(20,91,199,.12);
  padding:9px 38px 9px 13px;max-width:min(560px,calc(100vw - 40px))}
.maplibregl-ctrl-attrib-inner{font-size:13.5px;line-height:1.5;white-space:normal;color:#145bc7}
.maplibregl-ctrl-attrib a{color:#145bc7;text-decoration:underline}
.maplibregl-ctrl-attrib a:hover{color:#0e468f}
.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button{
  display:flex;align-items:center;justify-content:center;box-sizing:border-box;width:19px;height:19px;padding:0;margin:0;
  border:1.5px solid #145bc7;border-radius:50%;background:#fff;background-image:none;box-shadow:none;
  position:absolute;left:auto;right:2.5px;top:2.5px;font:italic 700 12px/1 Georgia,'Times New Roman',serif;color:#145bc7}
.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button::before{content:'i';color:inherit;font:inherit}
.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button:hover,
.maplibregl-ctrl-attrib.maplibregl-compact.maplibregl-compact-show .maplibregl-ctrl-attrib-button{background:#145bc7;color:#fff}
.maplibregl-ctrl-attrib.maplibregl-compact.maplibregl-compact-show .maplibregl-ctrl-attrib-button{right:9px;top:9px}
.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button:focus-visible{outline:2px solid #145bc7;outline-offset:2px;box-shadow:none}

/* móvil: aviso de que debajo del mapa hay una lista de barrios */
.btn-lista{display:none}
@media (max-width:860px){
  .btn-lista{position:absolute;left:50%;bottom:14px;transform:translateX(-50%);z-index:8;display:inline-flex;align-items:center;gap:6px;border:0;background:var(--accent);color:#fff;font:inherit;font-weight:700;font-size:15px;padding:10px 16px;border-radius:999px;box-shadow:var(--shadow);cursor:pointer;white-space:nowrap}
  .btn-lista[hidden]{display:none}
  .btn-lista:active{background:var(--accent-d)}
}
