:root {
  color-scheme: light;
  --ink: #152a38;
  --muted: #647782;
  --line: #dce5e7;
  --panel: #f8fbfb;
  --white: #ffffff;
  --teal: #0f6c6d;
  --teal-dark: #0a4c50;
  --aqua: #55b9b4;
  --orange: #e87842;
  --shadow: 0 14px 40px rgba(12, 48, 55, .14);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: #dfe9e9; }
button, input { font: inherit; }
button, label { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.app-shell { height: 100%; display: grid; grid-template-rows: 68px 1fr; overflow: hidden; }
.topbar { z-index: 1002; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; background: rgba(255,255,255,.97); border-bottom: 1px solid var(--line); box-shadow: 0 2px 14px rgba(24,55,61,.07); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 39px; height: 39px; display: grid; place-items: center; flex: 0 0 auto; color: var(--white); background: var(--teal); border-radius: 12px 12px 12px 4px; }
.brand-mark svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.brand h1 { font-family: Georgia, "Times New Roman", serif; font-size: 1.25rem; line-height: 1.1; margin: 0; letter-spacing: -.025em; }
.brand p { font-size: .75rem; color: var(--muted); margin: 3px 0 0; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.ghost-button { min-height: 38px; display: inline-flex; align-items: center; gap: 7px; padding: 0 11px; border: 1px solid transparent; border-radius: 9px; color: #405864; background: transparent; cursor: pointer; }
.ghost-button:hover { background: #f0f6f6; border-color: #e0e9e9; }
.ghost-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.workspace { position: relative; min-height: 0; display: grid; grid-template-columns: 350px minmax(0, 1fr); }
.sidebar { z-index: 1000; min-height: 0; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid rgba(213,225,226,.95); overflow-y: auto; transition: transform .25s ease, margin .25s ease; }
.panel-section { padding: 20px 22px; border-bottom: 1px solid var(--line); }
.intro-section { background: linear-gradient(150deg, #f9fcfc 0%, #eef7f6 100%); }
.section-kicker, .eyebrow { color: var(--teal); font-size: .68rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.section-kicker { display: flex; align-items: center; gap: 7px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #37a273; box-shadow: 0 0 0 4px rgba(55,162,115,.12); }
.intro-section h2 { font-family: Georgia, "Times New Roman", serif; font-size: 1.55rem; margin: 11px 0 7px; letter-spacing: -.03em; }
.intro-section p { margin: 0; color: var(--muted); font-size: .84rem; line-height: 1.55; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.section-heading h3 { margin: 0; font-size: .9rem; }
.eyebrow + h3 { margin-top: 4px; }
.text-button { padding: 4px; border: 0; color: var(--teal); background: transparent; font-size: .75rem; font-weight: 700; cursor: pointer; }
.text-button:hover { text-decoration: underline; }
.count-badge { min-width: 25px; height: 25px; display: grid; place-items: center; padding: 0 7px; border-radius: 999px; background: #e5eeee; color: #4f666e; font-size: .72rem; font-weight: 800; }

.layer-list { display: grid; gap: 8px; }
.layer-card { border: 1px solid var(--line); border-radius: 11px; background: var(--white); overflow: hidden; transition: border-color .18s, box-shadow .18s; }
.layer-card.active { border-color: rgba(15,108,109,.48); box-shadow: 0 5px 14px rgba(28,86,88,.08); }
.layer-row { min-height: 52px; display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 8px; padding: 8px 11px; cursor: pointer; }
.layer-icon { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 8px; color: var(--layer-color); background: color-mix(in srgb, var(--layer-color) 12%, white); }
.layer-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.layer-copy { min-width: 0; }
.layer-name { display: block; font-size: .78rem; font-weight: 750; line-height: 1.25; }
.layer-meta { display: block; margin-top: 2px; color: #7a8b92; font-size: .65rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.switch { position: relative; width: 34px; height: 19px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #cbd7d9; transition: .2s; }
.switch span::after { content: ""; position: absolute; width: 13px; height: 13px; left: 3px; top: 3px; border-radius: 50%; background: white; box-shadow: 0 1px 4px rgba(0,0,0,.2); transition: .2s; }
.switch input:checked + span { background: var(--teal); }
.switch input:checked + span::after { transform: translateX(15px); }
.layer-controls { display: none; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 0 12px 11px 47px; }
.layer-card.active .layer-controls { display: grid; }
.opacity-control { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .68rem; }
.opacity-control input { width: 100%; accent-color: var(--teal); }
.legend-button { border: 0; background: transparent; color: var(--teal); font-size: .68rem; font-weight: 750; cursor: pointer; }
.legend-box { display: none; padding: 0 12px 12px 47px; }
.legend-box.open { display: block; }
.legend-box img { display: block; max-width: 100%; max-height: 175px; border: 1px solid #e3e9e9; border-radius: 7px; background: white; }
.legend-box img + img { margin-top: 7px; }

.drop-zone { display: flex; align-items: center; justify-content: center; gap: 11px; min-height: 76px; padding: 12px; border: 1.5px dashed #9fb8ba; border-radius: 12px; background: rgba(255,255,255,.72); color: var(--teal-dark); text-align: left; cursor: pointer; transition: .18s; }
.drop-zone:hover, .drop-zone.dragging, .drop-zone:focus-visible { border-color: var(--teal); background: #eef8f7; outline: none; }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-zone svg { width: 25px; height: 25px; flex: 0 0 auto; fill: none; stroke: var(--teal); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.drop-zone strong, .drop-zone small { display: block; }
.drop-zone strong { font-size: .8rem; }
.drop-zone small { margin-top: 3px; color: var(--muted); font-size: .68rem; }
.kml-list { display: grid; gap: 7px; margin-top: 11px; }
.empty-kml { color: #7c8d93; font-size: .68rem; line-height: 1.45; text-align: center; padding: 5px 8px; }
.kml-item { display: grid; grid-template-columns: 9px 1fr auto; align-items: center; gap: 9px; padding: 9px 8px; border-radius: 9px; background: #eef4f4; }
.kml-swatch { width: 9px; height: 28px; border-radius: 4px; background: var(--kml-color); }
.kml-name { display: block; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .72rem; font-weight: 750; }
.kml-meta { display: block; margin-top: 2px; color: #72858c; font-size: .62rem; }
.kml-actions { display: flex; gap: 2px; }
.icon-button { width: 27px; height: 27px; display: grid; place-items: center; border: 0; border-radius: 7px; color: #596d75; background: transparent; cursor: pointer; }
.icon-button:hover { color: var(--teal); background: white; }
.icon-button.delete:hover { color: #b53c35; }
.icon-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-footer { margin-top: auto; padding: 15px 22px 19px; color: #71848b; font-size: .63rem; line-height: 1.45; }
.sidebar-footer p { margin: 0 0 7px; }
.sidebar-footer a { color: var(--teal); font-weight: 700; }

.map-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
#map { position: absolute; inset: 0; background: #dfe8e6; }
.leaflet-control-zoom { border: 0 !important; box-shadow: var(--shadow) !important; }
.leaflet-control-zoom a { color: var(--ink) !important; border-color: #edf1f1 !important; }
.leaflet-control-attribution { font-size: 10px !important; }
.map-button { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid rgba(216,226,227,.9); border-radius: 11px; color: #29434d; background: rgba(255,255,255,.96); box-shadow: var(--shadow); cursor: pointer; }
.map-button:hover { color: var(--teal); background: white; }
.map-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-toggle { display: none; position: absolute; z-index: 600; top: 14px; left: 14px; }
.map-tools { position: absolute; z-index: 600; top: 14px; right: 14px; display: grid; gap: 8px; }
.base-menu { position: absolute; z-index: 650; top: 65px; right: 64px; width: 145px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.98); box-shadow: var(--shadow); }
.base-menu strong { display: block; margin-bottom: 8px; font-size: .75rem; }
.base-menu label { display: flex; align-items: center; gap: 7px; padding: 6px 0; color: #536971; font-size: .72rem; cursor: pointer; }
.base-menu input { accent-color: var(--teal); }
.coordinate-readout { position: absolute; z-index: 500; right: 68px; bottom: 20px; padding: 7px 10px; border-radius: 7px; background: rgba(255,255,255,.92); color: #52676e; font: 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; box-shadow: 0 4px 16px rgba(18,44,51,.11); }

.toast { position: fixed; z-index: 2000; top: 82px; left: 50%; transform: translate(-50%, -16px); padding: 10px 15px; border-radius: 9px; background: #163d46; color: white; box-shadow: var(--shadow); font-size: .76rem; opacity: 0; pointer-events: none; transition: .22s; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.about-panel { position: fixed; z-index: 3000; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(9,31,37,.55); backdrop-filter: blur(5px); }
.about-panel[hidden] { display: none; }
.about-card { position: relative; width: min(530px, 100%); padding: 31px; border-radius: 18px 18px 18px 5px; background: white; box-shadow: 0 28px 80px rgba(0,0,0,.25); }
.about-card h2 { margin: 9px 0 12px; font: 700 1.7rem/1.12 Georgia, serif; letter-spacing: -.03em; }
.about-card p { color: var(--muted); font-size: .86rem; line-height: 1.6; }
.close-button { position: absolute; top: 13px; right: 15px; width: 34px; height: 34px; border: 0; border-radius: 50%; color: #60737a; background: #f0f5f5; font-size: 1.25rem; cursor: pointer; }
.about-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin: 20px 0; }
.about-grid div { padding: 14px 10px; border-radius: 10px; background: #eef6f5; text-align: center; }
.about-grid strong, .about-grid span { display: block; }
.about-grid strong { color: var(--teal); font: 700 1.15rem Georgia, serif; }
.about-grid span { margin-top: 4px; color: #6d8086; font-size: .63rem; }
.about-note { padding: 10px 12px; border-left: 3px solid var(--orange); background: #fff5ef; }
.primary-link { display: inline-block; margin-top: 4px; color: var(--teal); font-size: .82rem; font-weight: 800; text-decoration: none; }

.kml-popup h4 { margin: 0 0 5px; color: var(--ink); font-size: .85rem; }
.kml-popup dl { margin: 0; font-size: .7rem; }
.kml-popup dt { margin-top: 4px; font-weight: 750; }
.kml-popup dd { margin: 0; color: #5f737b; }

@keyframes pulse { 50% { opacity: .35; } }
@media (max-width: 800px) {
  .app-shell { grid-template-rows: 60px 1fr; }
  .topbar { padding: 0 14px; }
  .brand p { display: none; }
  .brand h1 { font-size: 1.05rem; }
  .ghost-button span { display: none; }
  .ghost-button { width: 38px; padding: 0; justify-content: center; }
  .workspace { display: block; }
  .sidebar { position: absolute; inset: 0 auto 0 0; width: min(350px, calc(100vw - 42px)); box-shadow: 12px 0 30px rgba(13,45,52,.2); transform: translateX(-105%); }
  .sidebar.open { transform: translateX(0); }
  .map-stage { width: 100%; height: 100%; }
  .sidebar-toggle { display: grid; }
  .sidebar.open + .map-stage .sidebar-toggle { left: min(364px, calc(100vw - 28px)); }
  .coordinate-readout { display: none; }
  .about-card { padding: 27px 22px 22px; }
  .about-grid { grid-template-columns: 1fr; }
}

@media (min-width: 801px) {
  .workspace.panel-hidden { grid-template-columns: 0 minmax(0, 1fr); }
  .workspace.panel-hidden .sidebar { transform: translateX(-100%); }
  .workspace.panel-hidden .sidebar-toggle { display: grid; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; } }
.abasto-toggle{display:flex;gap:10px;align-items:center;font-weight:600;font-size:15px}.source-note,#abastoStatus{font-size:14px;line-height:1.5;color:#526674}.search-label{display:block;font-size:14px;margin:14px 0 6px}#abastoSearch{width:100%;font:inherit;padding:10px;border:1px solid #c8d6dd;border-radius:7px}.csv-label{display:block;font-size:14px;margin-top:14px}.csv-label input{display:block;max-width:100%;margin-top:8px;font-size:14px}.layer-meta{overflow-wrap:anywhere}.layer-name{font-size:14px}.sidebar-footer p{font-size:13px}.layer-controls label{font-size:14px}
.health-toggle{display:flex;gap:8px;align-items:center;font-weight:600;font-size:15px;margin-top:17px}.health-swatch{width:9px;height:9px;border-radius:50%;flex-shrink:0}.health-swatch.hospital{background:#c02d37}.health-swatch.clinic{background:#246792}.health-swatch.pharmacy{background:#7460a6}#healthSearch{width:100%;font:inherit;padding:10px;border:1px solid #c8d6dd;border-radius:7px}#healthStatus{font-size:14px;line-height:1.5;color:#526674}#healthMissing{padding:10px;border-left:3px solid #8795a2;background:#f2f5f7;margin-top:14px}.health-section .source-note{margin-top:7px;line-height:1.5}

#schoolSearch{width:100%;font:inherit;padding:10px;border:1px solid #c8d6dd;border-radius:7px}#schoolStatus{font-size:14px;line-height:1.5;color:#526674}#schoolNote{padding:10px;border-left:3px solid #8795a2;background:#f2f5f7;margin-top:14px}.school-section .source-note{margin-top:7px;line-height:1.5}

/* Cruce de riesgos: misma identidad del panel existente. */
.analysis-section select {width:100%;padding:.65rem;border:1px solid #cadce0;border-radius:8px;background:white;color:#173746;font:inherit;margin:.5rem 0;}
.analysis-actions {display:flex;gap:.5rem;flex-wrap:wrap;}
.analysis-actions button {padding:.65rem .85rem;border:1px solid #0b7278;border-radius:8px;background:white;color:#0b6068;font:inherit;cursor:pointer;}
.analysis-actions .analysis-button {background:#0c6f73;color:white;}
.analysis-actions button:disabled {opacity:.45;cursor:not-allowed;}
#analysisStatus {font-size:.875rem;line-height:1.5;margin:1rem 0;}
.analysis-card {border:1px solid #d1e2e5;border-radius:10px;background:white;padding:.9rem;margin:1rem 0;font-size:.875rem;line-height:1.5;overflow-wrap:anywhere;}
.analysis-card h4 {font-size:1rem;margin:0;}
.analysis-card table {width:100%;border-collapse:collapse;font-variant-numeric:tabular-nums;}
.analysis-card caption {text-align:left;font-weight:600;margin:.65rem 0;}
.analysis-card th,.analysis-card td {text-align:left;padding:.5rem .2rem;border-bottom:1px solid #e1ecee;vertical-align:top;}
.analysis-card th:not(:first-child),.analysis-card td:not(:first-child){text-align:right;}
.analysis-card details {margin-top:.7rem;}
.analysis-card summary {cursor:pointer;color:#096f77;}
.analysis-error {color:#a82d2d;}

/* Ruteo y radios: controles compactos del visor existente. */
.mobility-section select,.mobility-section input:not([type=checkbox]){width:100%;border:1px solid #d1dedd;border-radius:7px;padding:9px;background:white;font:inherit;min-width:0}
.mobility-section select{margin:8px 0}.mobility-section details summary{cursor:pointer;font-weight:600}.radius-options{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:12px 0}.radius-options label{color:var(--radius-color);font-weight:600;white-space:nowrap}.route-button{display:inline-block;border:1px solid #c8d8d5;border-radius:7px;background:#fff;color:#174c4b;padding:8px 10px;font:inherit;font-size:12px;cursor:pointer;text-decoration:none;margin:3px 0}.route-button:hover,.route-button.active{background:#e3f1ed}.route-button:disabled{opacity:.45;cursor:default}.route-actions,.equipment-route-actions{display:flex;gap:6px;flex-wrap:wrap}.coordinate-entry{display:flex;gap:6px;margin:6px 0}.coordinate-entry input{flex:1}.coordinate-entry button{flex-shrink:0}.endpoint-title{display:block;font-weight:650;margin-top:14px}.mobility-section hr{border:0;border-top:1px solid #e2eae8;margin:15px 0}.mobility-section .analysis-button{margin-top:10px;width:100%}.route-marker span{display:grid;place-items:center;width:28px;height:28px;border:2px solid white;border-radius:50%;color:white;font-weight:700;box-shadow:0 2px 8px #0004}.radius-label{color:#173f43;font-size:11px;font-weight:700;background:#ffffffe0;border-radius:3px;text-align:center;padding:2px}.picking-point,.picking-point .leaflet-interactive{cursor:crosshair!important}#pickStatus:empty,#routeStatus:empty{display:none}[hidden]{display:none!important}
