@font-face{font-family:"Instrument Sans";font-style:normal;font-weight:400 700;font-display:swap;src:url(/fonts/instrument-sans-normal-latin.woff2) format("woff2")}
@font-face{font-family:"Newsreader";font-style:italic;font-weight:400 600;font-display:swap;src:url(/fonts/newsreader-italic-latin.woff2) format("woff2")}

/* Tokens: claro = herbe.es; oscuro = «Lights out» */
:root{--bg:#fbfbfa;--panel:#fff;--raise:#f4f6f6;--field:#f4f6f6;--ink:#192325;--muted:#626c70;--line:#dfe4e4;--line-2:#cfd6d6;--accent:#315f94;--accent-soft:#e6edf5;--btn:#192325;--btn-ink:#fbfbfa;--start:#1f7a4d;--end:#b4232b;--up:#1f7a4d;--down:#b4232b;--warn:#9a5b0b;--route:#315f94;--casing:#ffffff;--pin:#192325;--pin-ink:#fff;--shadow:0 1px 2px rgba(25,35,37,.06),0 12px 32px -12px rgba(25,35,37,.22);color-scheme:light}
:root[data-theme=dark]{--bg:#000;--panel:#000;--raise:#16181c;--field:#16181c;--ink:#e7e9ea;--muted:#71767b;--line:#2f3336;--line-2:#3e4346;--accent:#1d9bf0;--accent-soft:#0d2436;--btn:#eff3f4;--btn-ink:#0f1419;--start:#00ba7c;--end:#f4212e;--up:#00ba7c;--down:#f4212e;--warn:#ffd400;--route:#1d9bf0;--casing:#000;--pin:#eff3f4;--pin-ink:#0f1419;--shadow:0 0 0 1px #2f3336,0 16px 40px -12px rgba(0,0,0,.8);color-scheme:dark}

*{box-sizing:border-box}
html,body{margin:0;height:100%}
body{font:14px/1.4 "Instrument Sans",system-ui,-apple-system,"Segoe UI",sans-serif;color:var(--ink);background:var(--bg);font-variant-numeric:tabular-nums;-webkit-font-smoothing:antialiased;letter-spacing:-.005em}
button,input,textarea{font:inherit;color:inherit;letter-spacing:inherit}
button{cursor:pointer;-webkit-tap-highlight-color:transparent}
svg{display:block}
[hidden]{display:none!important}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}

/* Escritorio: mapa a sangre y panel flotante */
.ro{position:relative;height:100vh;height:100dvh}
.ro-map-wrap{position:absolute;inset:0;isolation:isolate;background:var(--raise)}
#ro-map{position:absolute;inset:0;background:var(--raise)}
.ro-panel{position:absolute;z-index:10;top:12px;left:12px;bottom:12px;width:384px;display:flex;flex-direction:column;min-height:0;background:var(--panel);border:1px solid var(--line);border-radius:14px;box-shadow:var(--shadow);overflow:hidden}

.ro-head{display:flex;align-items:center;gap:10px;padding:14px 14px 0 18px}
.ro-brand{display:inline-flex;color:var(--ink);padding:4px 0}
.ro-brand svg{width:62px;height:auto}
.ro-crumb{color:var(--muted);font-size:13px;padding-left:10px;border-left:1px solid var(--line);line-height:16px}
.ro-back{margin-left:auto;display:inline-flex;align-items:center;gap:2px;color:var(--muted);text-decoration:none;font-size:13px;padding:6px 6px 6px 2px;border-radius:8px}
.ro-back:hover{color:var(--ink)}
.ro-back svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
.ro-theme{width:32px;height:32px;display:grid;place-items:center;border:0;border-radius:8px;background:none;color:var(--ink)}
.ro-theme:hover{background:var(--raise)}
.ro-theme svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round}
.ro-theme .sun,:root[data-theme=dark] .ro-theme .moon{display:none}
:root[data-theme=dark] .ro-theme .sun{display:block}

.ro-top{padding:14px 18px 12px;border-bottom:1px solid var(--line)}
.ro-top h1{margin:0 0 12px;font-size:22px;font-weight:600;letter-spacing:-.035em;line-height:1.1}
.ro-modes{display:grid;grid-template-columns:1fr 1fr;padding:3px;gap:3px;background:var(--raise);border-radius:10px}
.ro-modes button{display:flex;align-items:center;justify-content:center;gap:7px;height:32px;border:0;border-radius:8px;background:none;color:var(--muted);font-weight:500;font-size:13px}
.ro-modes button:hover{color:var(--ink)}
.ro-modes button.active{background:var(--panel);color:var(--ink);box-shadow:0 1px 2px rgba(0,0,0,.08),0 0 0 1px var(--line)}
.ro-modes svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round}

.ro-body{flex:1;min-height:0;overflow-y:auto;padding:12px 18px 16px;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:var(--line) transparent}
.ro-sec{display:flex;align-items:center;gap:6px;margin:0 0 8px;font-size:12px;color:var(--muted)}
.ro-sec>span:first-child{color:var(--ink);font-weight:600;font-size:13px}
.ro-count{color:var(--muted)}
.ro-legend{margin-left:auto;display:flex;align-items:center;gap:5px;cursor:help}
.ro-legend .ro-dot+.ro-dot,.ro-legend .ro-dot.f{margin-left:6px}
.ro-dot{display:inline-grid;place-items:center;width:16px;height:16px;border-radius:5px;font-style:normal;font-size:9px;font-weight:700;color:#fff}
.ro-dot.s{background:var(--start)}.ro-dot.f{background:var(--end)}
:root[data-theme=dark] .ro-dot{color:#000}

/* Paradas: línea de recorrido con marcador */
.ro-stops{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;position:relative}
.ro-stop{display:grid;grid-template-columns:22px 1fr auto;column-gap:8px;align-items:center;position:relative;padding:3px 0}
.ro-stop::before{content:"";position:absolute;left:10.5px;top:0;bottom:0;width:1px;background:var(--line)}
.ro-stop:first-child::before{top:50%}.ro-stop:last-child::before{bottom:50%}
.ro-stop:only-child::before{display:none}
.ro-mark{position:relative;z-index:1;display:grid;place-items:center;width:22px;height:22px;border-radius:50%;background:var(--panel);border:1.5px solid var(--line-2);color:var(--muted);font-size:10px;font-weight:700}
.ro-stop.is-s .ro-mark{background:var(--start);border-color:var(--start);color:#fff}
.ro-stop.is-f .ro-mark{background:var(--end);border-color:var(--end);color:#fff}
.ro-stop.is-s.is-f .ro-mark{background:linear-gradient(90deg,var(--start) 50%,var(--end) 50%);border-color:transparent}
:root[data-theme=dark] .ro-stop.is-s .ro-mark,:root[data-theme=dark] .ro-stop.is-f .ro-mark{color:#000}
.ro-field{position:relative;min-width:0}
.ro-field input{width:100%;height:36px;padding:0 30px 0 10px;border:1px solid transparent;border-radius:9px;background:var(--field);transition:border-color .15s,background .15s}
.ro-field input::placeholder{color:var(--muted)}
.ro-field input:hover{border-color:var(--line)}
.ro-field input:focus{outline:0;border-color:var(--accent);background:var(--panel)}
.ro-field .ok{position:absolute;right:9px;top:50%;transform:translateY(-50%);width:14px;height:14px;display:grid;place-items:center;color:var(--up)}
.ro-field .ok svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.ro-field .ok.approx{color:var(--warn)}
.ro-stop.bad input{border-color:var(--down)}
.ro-stop.bad .ok{color:var(--down);font-weight:700;font-size:13px}
.ro-stop .hint{grid-column:2/4;font-size:11.5px;color:var(--muted);margin:2px 0 1px 2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ro-stop.bad .hint{color:var(--down)}
.ro-stop .hint.approx{color:var(--warn)}
.ro-acts{display:flex;gap:2px;align-items:center}
.ro-role,.ro-del{width:26px;height:26px;display:grid;place-items:center;border:0;border-radius:7px;background:none;color:var(--muted);font-size:11px;font-weight:700;padding:0}
.ro-role:hover,.ro-del:hover{background:var(--raise);color:var(--ink)}
.ro-role[aria-pressed=true].s{background:var(--start);color:#fff}
.ro-role[aria-pressed=true].f{background:var(--end);color:#fff}
:root[data-theme=dark] .ro-role[aria-pressed=true]{color:#000}
.ro-del svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round}
.ro-del:hover{color:var(--down)}
@media (hover:hover){.ro-stop .ro-role[aria-pressed=false],.ro-stop .ro-del{opacity:.55}.ro-stop:hover .ro-role,.ro-stop:hover .ro-del,.ro-stop:focus-within .ro-role,.ro-stop:focus-within .ro-del{opacity:1}}

.ro-sug{position:absolute;z-index:1000;left:0;right:0;top:40px;margin:0;padding:4px;list-style:none;background:var(--panel);border:1px solid var(--line);border-radius:11px;box-shadow:var(--shadow);max-height:260px;overflow-y:auto}
.ro-sug li{padding:7px 9px;border-radius:8px;cursor:pointer}
.ro-sug li[aria-selected=true],.ro-sug li:hover{background:var(--raise)}
.ro-sug b{display:block;font-weight:600}
.ro-sug small{color:var(--muted);display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:12px}

.ro-adds{display:flex;align-items:flex-start;gap:8px;margin:8px 0 0 30px;flex-wrap:wrap}
.ro-ghost{display:inline-flex;align-items:center;gap:6px;height:32px;padding:0 12px 0 9px;border:1px solid var(--line);border-radius:9px;background:none;color:var(--ink);font-weight:500;font-size:13px}
.ro-ghost:hover{background:var(--raise)}
.ro-ghost svg{width:15px;height:15px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round}
.ro-bulk{flex:1;min-width:0}
.ro-bulk summary{list-style:none;display:inline-flex;align-items:center;height:32px;padding:0 8px;cursor:pointer;color:var(--muted);font-size:13px;border-radius:9px}
.ro-bulk summary::-webkit-details-marker{display:none}
.ro-bulk summary:hover{color:var(--ink)}
.ro-bulk[open] summary{color:var(--ink)}
.ro-bulk[open]{flex-basis:100%}
.ro-bulk-box{display:flex;flex-direction:column;align-items:flex-start;gap:6px;margin-top:4px}
.ro-bulk textarea{width:100%;padding:8px 10px;border:1px solid var(--line);border-radius:9px;background:var(--field);resize:vertical}
.ro-bulk textarea:focus{outline:0;border-color:var(--accent)}
.ro-bulk-box .ro-ghost{padding:0 12px}

/* Resultado */
.ro-results{margin-top:16px;padding-top:14px;border-top:1px solid var(--line)}
.ro-kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(0,1fr));border:1px solid var(--line);border-radius:12px;margin-bottom:14px}
.ro-kpis div{padding:9px 12px;min-width:0}
.ro-kpis div+div{border-left:1px solid var(--line)}
.ro-kpis span{display:block;font-size:11.5px;color:var(--muted)}
.ro-kpis strong{display:block;font-size:21px;font-weight:600;letter-spacing:-.03em;white-space:nowrap;line-height:1.25}
#ro-saving{color:var(--up)}
.ro-order{margin:0;padding:0;list-style:none;display:flex;flex-direction:column}
.ro-order li{display:grid;grid-template-columns:22px 1fr;gap:8px;align-items:center;font-size:13px;padding:3px 0;position:relative;min-width:0}
.ro-order li span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ro-order li::before{content:"";position:absolute;left:10.5px;top:0;bottom:0;width:1px;background:var(--line)}
.ro-order li:first-child::before{top:50%}.ro-order li:last-child::before{bottom:50%}
.ro-order li i{position:relative;z-index:1;display:grid;place-items:center;width:22px;height:22px;border-radius:50%;background:var(--pin);color:var(--pin-ink);font-style:normal;font-size:10px;font-weight:700}
.ro-order li.s i{background:var(--start);color:#fff}.ro-order li.f i{background:var(--end);color:#fff}
:root[data-theme=dark] .ro-order li.s i,:root[data-theme=dark] .ro-order li.f i{color:#000}
.ro-note{font-size:12px;color:var(--warn);margin:8px 0 0}
.ro-gmaps{display:flex;flex-direction:column;gap:6px;margin-top:12px}
.ro-gmaps a{display:flex;justify-content:space-between;align-items:center;gap:10px;height:38px;padding:0 12px;border-radius:10px;border:1px solid var(--line);color:var(--ink);text-decoration:none;font-weight:500}
.ro-gmaps a:hover{background:var(--raise)}
.ro-gmaps a small{color:var(--muted);font-weight:400;font-size:12px}
.ro-gmaps a svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;flex:none}
.ro-gmaps a span{display:flex;align-items:center;gap:6px}

.ro-foot{padding:10px 18px 14px;border-top:1px solid var(--line);background:var(--panel)}
.ro-status{margin:0 0 8px;min-height:17px;font-size:12px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ro-status.error{color:var(--down);white-space:normal}.ro-status.ok{color:var(--up)}.ro-status.warn{color:var(--warn);white-space:normal}
.ro-primary{width:100%;height:44px;border:0;border-radius:10px;background:var(--btn);color:var(--btn-ink);font-weight:600;font-size:14.5px;transition:transform .15s,opacity .15s}
.ro-primary:hover{opacity:.9}
.ro-primary:active{transform:scale(.99)}
.ro-primary:disabled{opacity:.6;cursor:wait}

/* Mapa */
.ro-pin{display:grid;place-items:center;width:26px;height:26px;border-radius:50%;background:var(--pin);color:var(--pin-ink);font:700 11px "Instrument Sans",system-ui,sans-serif;border:2px solid var(--casing);box-shadow:0 1px 4px rgba(0,0,0,.35)}
.ro-pin.s{background:var(--start);color:#fff}.ro-pin.f{background:var(--end);color:#fff}
:root[data-theme=dark] .ro-pin.s,:root[data-theme=dark] .ro-pin.f{color:#000}
.leaflet-container{font:12px/1.4 "Instrument Sans",system-ui,sans-serif;background:var(--raise)}
.leaflet-bar{border:1px solid var(--line)!important;border-radius:10px!important;box-shadow:var(--shadow)!important;overflow:hidden}
.leaflet-bar a,.leaflet-bar a:hover{background:var(--panel);color:var(--ink);border-bottom-color:var(--line);width:32px;height:32px;line-height:30px;font-weight:400}
.leaflet-bar a:hover{background:var(--raise)}
.leaflet-control-attribution{background:color-mix(in srgb,var(--panel) 82%,transparent)!important;color:var(--muted);border-radius:8px 0 0 0;padding:1px 7px!important}
.leaflet-control-attribution a{color:var(--muted)}
.leaflet-popup-content-wrapper,.leaflet-popup-tip{background:var(--panel);color:var(--ink);box-shadow:var(--shadow)}
.leaflet-popup-content-wrapper{border-radius:10px;border:1px solid var(--line)}
.leaflet-popup-content{margin:9px 12px;font-size:13px}
.leaflet-container a.leaflet-popup-close-button{color:var(--muted)}
.leaflet-tile-pane{filter:saturate(.45) contrast(.96) brightness(1.03)}
:root[data-theme=dark] .leaflet-tile-pane{filter:invert(1) hue-rotate(180deg) saturate(.35) brightness(.82) contrast(1.05)}

/* Móvil: mapa arriba, panel debajo y botón fijo */
@media (max-width:760px){
 .ro{height:auto;min-height:100dvh;display:flex;flex-direction:column}
 .ro-map-wrap{order:-1;position:relative;inset:auto;height:40vh;height:40svh;flex:none}
 .ro-panel{position:relative;top:auto;left:auto;bottom:auto;width:auto;margin-top:-14px;border:0;border-top:1px solid var(--line);border-radius:16px 16px 0 0;box-shadow:0 -8px 24px -16px rgba(0,0,0,.35);flex:1;overflow:visible}
 .ro-head{padding:14px 12px 0 16px}
 .ro-top{padding:12px 16px 12px}
 .ro-top h1{font-size:20px;margin-bottom:10px}
 .ro-body{overflow:visible;padding:12px 16px calc(112px + env(safe-area-inset-bottom))}
 .ro-foot{position:fixed;left:0;right:0;bottom:0;z-index:1100;padding:8px 16px calc(12px + env(safe-area-inset-bottom));box-shadow:0 -8px 20px -14px rgba(0,0,0,.35)}
 .ro-field input{height:40px;font-size:16px}
 .ro-sug{top:44px}
 .ro-role,.ro-del{width:32px;height:36px}
 .ro-modes button{height:36px}
 .leaflet-top.leaflet-right{top:0}
}
@media (max-width:360px){
 .ro-crumb{display:none}
 .ro-legend{display:none}
 .ro-stop{column-gap:6px}
 .ro-role,.ro-del{width:28px}
 .ro-kpis strong{font-size:18px}
}
@media (prefers-reduced-motion:reduce){*{transition:none!important}}
