/* Maps by Vexco · página del mapa. Colores en variables: el acento, el tema y las esquinas
   vienen de la configuración del portal (appearance) y se aplican desde map.js. */
:root {
  --accent: #2d46e8;
  --accent-ink: #ffffff;
  --accent-soft: rgba(45, 70, 232, 0.12);
  --signal: #c8f03c;
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #f3f4f1;
  --text: #0d1321;
  --muted: #5a6472;
  --line: #dfe2dc;
  --hover: rgba(13, 19, 33, 0.05);
  --shadow: 0 0 0 1px rgba(13, 19, 33, 0.08), 0 8px 24px rgba(13, 19, 33, 0.12);
  --shadow-sm: 0 0 0 1px rgba(13, 19, 33, 0.08);
  --r: 6px;
  --r-sm: 4px;
  --mono: "Plex Mono", ui-monospace, Menlo, monospace;
  --panel-w: 320px;
  font-family: "Plex Sans", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
:root.dark {
  --bg: #0b1019;
  --panel: #0f1520;
  --panel-2: #161e2b;
  --text: #e9edf2;
  --muted: #8d97a6;
  --line: #232d3c;
  --hover: rgba(255, 255, 255, 0.06);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}
:root.square { --r: 2px; --r-sm: 2px; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#app { display: flex; height: 100vh; height: 100dvh; width: 100vw; overflow: hidden; }
#app.right { flex-direction: row-reverse; }

/* ───────── Panel ───────── */
#panel { width: var(--panel-w); flex: none; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); z-index: 3; min-height: 0; }
#app.right #panel { border-right: 0; border-left: 1px solid var(--line); }
#app.panel-hidden #panel { display: none; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px; }
.brand-mark { width: 26px; height: 26px; flex: none; display: block; }
.brand-mark img { display: block; width: 26px; height: 26px; }
.panel-title { flex: 1; font-size: 15px; font-weight: 600; letter-spacing: -0.005em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: var(--r-sm); background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--hover); color: var(--text); }

.search-wrap { position: relative; margin: 0 14px 10px; }
.search-ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); display: flex; pointer-events: none; }
#search { width: 100%; padding: 9px 34px 9px 34px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel-2); outline: none; transition: border-color .15s, box-shadow .15s, background .15s; }
#search::placeholder { color: var(--muted); }
#search:focus { background: var(--panel); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#search::-webkit-search-cancel-button { display: none; }
.kbd { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font: 11px/1 var(--mono); color: var(--muted); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 2px 5px; background: var(--panel); }
#search:focus ~ .kbd { display: none; }
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); z-index: 10; max-height: 320px; overflow-y: auto; }
.suggest li { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r-sm); cursor: pointer; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--hover); }
.suggest .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest .s { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest .txt { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.suggest mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 0 1px; }

.tabs { display: flex; gap: 0; margin: 0 14px; padding: 0; border-bottom: 1px solid var(--line); }
.tab { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 8px 9px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; color: var(--muted); font-weight: 500; cursor: pointer; }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab .badge { font: 400 11px var(--mono); color: var(--muted); }

.panel-body { flex: 1; overflow-y: auto; padding: 4px 14px 14px; min-height: 0; scrollbar-width: thin; }
section { margin-top: 14px; }
h3 { font: 500 10.5px/1.4 var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
h3::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); border-radius: var(--r-sm); padding: 5px 11px; font-size: 12.5px; cursor: pointer; transition: background .15s, border-color .15s; }
.chip:hover { background: var(--hover); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip svg.i { width: 14px; height: 14px; }

/* Capas */
.layer { border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 8px; background: var(--panel); overflow: hidden; }
.layer.off { opacity: 0.55; }
.layer-head { display: flex; align-items: center; gap: 10px; padding: 9px 10px; }
.layer-head .name { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.n { color: var(--muted); font: 400 11.5px var(--mono); font-variant-numeric: tabular-nums; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px rgba(0,0,0,0.12); }
.dot.sq { border-radius: 3px; }
.dot.di { border-radius: 2px; transform: rotate(45deg) scale(.85); }
.dot.multi { background: conic-gradient(#ff7a59 0 25%, #00a4bd 0 50%, #7c4dff 0 75%, #f5a623 0); }
.expand { border: 0; background: none; color: var(--muted); cursor: pointer; display: inline-flex; padding: 2px; border-radius: 5px; transition: transform .2s; }
.expand:hover { background: var(--hover); }
.layer.open .expand { transform: rotate(180deg); }
.layer-body { border-top: 1px solid var(--line); padding: 8px 10px 10px; display: none; }
.layer.open .layer-body { display: block; }
.prop-title { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 12px; padding: 0; }
.values { display: grid; gap: 2px; }
.value { display: flex; align-items: center; gap: 9px; font-size: 13px; cursor: pointer; padding: 4px 4px; border-radius: 6px; }
.value:hover { background: var(--hover); }
.value .lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.value input { margin: 0; accent-color: var(--accent); }
.value.off .lbl, .value.off .dot { opacity: .4; }
.size-legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.size-legend .bub { border-radius: 50%; background: var(--muted); opacity: .45; flex: none; }

/* Interruptor */
.switch { position: relative; width: 32px; height: 18px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }

/* Herramientas */
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px; }
.tool { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 10px 6px 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); cursor: pointer; font-size: 12px; color: var(--text); text-align: center; line-height: 1.2; transition: background .15s, border-color .15s; }
.tool svg.i { width: 18px; height: 18px; color: var(--muted); }
.tool:hover { background: var(--hover); }
.tool[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.tool[aria-pressed="true"] svg.i { color: var(--accent); }
#tool-panel:not(:empty) { margin-top: 10px; padding: 10px; background: var(--panel-2); border-radius: var(--r); font-size: 13px; }
#tool-panel .help { display: flex; gap: 8px; color: var(--muted); }
#tool-panel input[type="number"] { width: 76px; padding: 5px 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); }
.result-title { font-weight: 600; margin: 8px 0 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: var(--r-sm); padding: 6px 11px; font-size: 13px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, filter .15s; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 500; }
.btn.primary:hover { filter: brightness(0.95); background: var(--accent); }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.btn svg.i { width: 14px; height: 14px; }
.row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

/* Listas de registros */
.rec-list { list-style: none; margin: 0; padding: 0; }
.rec-list li { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: var(--r-sm); cursor: pointer; }
.rec-list li:hover, .rec-list li.hl { background: var(--hover); }
.rec-list .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rec-list .t { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-list .s { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-list .d { font: 400 11.5px var(--mono); color: var(--muted); flex: none; }
.rec-list .more { justify-content: center; color: var(--muted); font-size: 12px; cursor: default; }
.rec-list.compact li { padding: 5px 4px; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 12px 0 6px; }
.select-sm { border: 1px solid var(--line); background: var(--panel); border-radius: var(--r-sm); padding: 4px 6px; font-size: 12px; }
.empty-note { text-align: center; color: var(--muted); padding: 24px 8px; font-size: 13px; }

#route-list { margin: 0; padding: 0; list-style: none; counter-reset: stop; }
#route-list li { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; border-bottom: 1px dashed var(--line); }
#route-list li::before { counter-increment: stop; content: counter(stop); width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 600; display: grid; place-items: center; flex: none; }
#route-list li .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#route-list li .acts { display: flex; }
#route-list li .acts button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 2px; border-radius: 4px; display: inline-flex; }
#route-list li .acts button:hover { background: var(--hover); color: var(--text); }
#route-list li .acts svg.i { width: 14px; height: 14px; }

.panel-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding: 9px 14px; color: var(--muted); font: 400 11px var(--mono); }
.credit { color: var(--muted); text-decoration: none; font-size: 11px; opacity: .8; letter-spacing: .02em; }
.credit:hover { color: var(--accent); }

/* ───────── Mapa ───────── */
#map-wrap { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; }
.floating { position: absolute; top: 12px; left: 12px; z-index: 4; display: inline-flex; align-items: center; gap: 8px; border: 0; background: var(--panel); color: var(--text); box-shadow: var(--shadow); border-radius: var(--r); padding: 9px 13px; font-weight: 600; cursor: pointer; }
#app.right .floating { left: auto; right: 12px; }
#app:not(.panel-hidden) .floating { display: none; }

.maplibregl-ctrl-group { border-radius: var(--r) !important; box-shadow: var(--shadow) !important; overflow: hidden; background: var(--panel) !important; }
.maplibregl-ctrl-group button { width: 34px !important; height: 34px !important; }
:root.dark .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1) hue-rotate(180deg); }
:root.dark .maplibregl-ctrl-group button + button { border-top-color: var(--line) !important; }
.vx-ctrl button { display: grid !important; place-items: center; color: var(--text); }
.vx-ctrl button svg.i { width: 17px; height: 17px; }
.vx-ctrl button[aria-pressed="true"] { color: var(--accent); }
.style-menu { position: absolute; z-index: 5; background: var(--panel); border-radius: var(--r); box-shadow: var(--shadow); padding: 6px; min-width: 150px; border: 1px solid var(--line); }
.style-menu button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 7px 8px; border-radius: var(--r-sm); cursor: pointer; text-align: left; }
.style-menu button:hover { background: var(--hover); }
.style-menu button[aria-checked="true"] { color: var(--accent); font-weight: 600; }
.style-menu .sw { width: 22px; height: 22px; border-radius: 3px; flex: none; border: 1px solid var(--line); }

#status { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(2px); z-index: 6; padding: 24px; }
.status-card { max-width: 380px; background: var(--panel); border-radius: calc(var(--r) + 4px); box-shadow: var(--shadow); padding: 22px 24px; text-align: center; color: var(--muted); }
.status-card p { margin: 10px 0 0; line-height: 1.5; }
.spinner { display: inline-block; width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
#status.msg .spinner { display: none; }
#status.msg p { margin: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

#toast { position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); background: #0d1321; border-left: 3px solid var(--signal); color: #fff; padding: 9px 14px; border-radius: var(--r); box-shadow: var(--shadow); z-index: 7; font-size: 13px; max-width: calc(100% - 32px); }

/* Ventana del pin */
.maplibregl-popup-content { border-radius: calc(var(--r) + 2px); padding: 0; box-shadow: var(--shadow); font-family: inherit; background: var(--panel); color: var(--text); overflow: hidden; }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip, .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip, .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip { border-top-color: var(--panel); }
.maplibregl-popup-anchor-top .maplibregl-popup-tip, .maplibregl-popup-anchor-top-left .maplibregl-popup-tip, .maplibregl-popup-anchor-top-right .maplibregl-popup-tip { border-bottom-color: var(--panel); }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--panel); }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--panel); }
.maplibregl-popup-close-button { font-size: 18px; width: 28px; height: 28px; color: var(--muted); right: 4px; top: 4px; border-radius: 6px; }
.maplibregl-popup-close-button:hover { background: var(--hover); }
.pop { min-width: 240px; max-width: 330px; }
.pop-band { height: 3px; }
.pop-in { padding: 12px 14px 14px; }
.pop-layer { display: flex; align-items: center; gap: 6px; font: 500 10.5px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding-right: 22px; }
.pop-title { font-size: 15.5px; font-weight: 600; margin: 4px 0 1px; color: var(--text); text-decoration: none; display: block; line-height: 1.3; }
.pop-title:hover { color: var(--accent); }
.pop-sub { color: var(--muted); font-size: 13px; }
.pop-props { margin: 10px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; padding-top: 10px; border-top: 1px solid var(--line); }
.pop-props dt { color: var(--muted); }
.pop-props dd { margin: 0; overflow-wrap: anywhere; }
.pop-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.pop-actions .btn { padding: 5px 9px; font-size: 12px; }
.pop-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 260px; overflow-y: auto; }
.pop-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); padding: 8px 2px; cursor: pointer; }
.pop-item:hover, .pop-item:focus-visible { background: var(--hover); }
.pop-item .txt { display: flex; flex-direction: column; min-width: 0; }
.pop-item-title { font-weight: 600; color: var(--text); }
.pop-item-sub { font-size: 12px; color: var(--muted); }

.maplibregl-ctrl-attrib { font-size: 10.5px; }
:root.dark .maplibregl-ctrl-attrib { background: rgba(20, 29, 42, .8); color: var(--muted); }
:root.dark .maplibregl-ctrl-attrib a { color: var(--muted); }
:root.dark .maplibregl-ctrl-scale { background: rgba(20, 29, 42, .8); color: var(--text); border-color: var(--muted); }

/* ───────── Móvil: el panel es una hoja inferior ───────── */
@media (max-width: 640px) {
  #panel, #app.right #panel { position: absolute; left: 0; right: 0; bottom: 0; top: auto; width: auto; height: 58vh; border: 0; border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.18); }
  .panel-head::before { content: ""; position: absolute; left: 50%; top: 6px; width: 36px; height: 4px; border-radius: 2px; background: var(--line); transform: translateX(-50%); }
  .panel-head { position: relative; padding-top: 18px; }
  .floating, #app.right .floating { top: auto; bottom: 64px; left: 50%; right: auto; transform: translateX(-50%); }
  .kbd { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
