:root{
  --verde-nav: #103028;
  --verde-nav-hover: #1a4438;
  --verde-acento: #2f7a36;
  --verde-acento-d: #1b5a24;
  --verde-suave: #6ba950;
  --azul-info: #3a8ad2;
  --texto: #1a1a1a;
  --texto-sec: #555;
  --texto-terc: #888;
  --borde: #e2e2e2;
  --borde-suave: #ededed;
  --bg: #ffffff;
  --bg-gris: #f7f7f5;
  --bg-panel: #fbfbf8;
  --bg-panel-2: #f5f5f1;
  --cl0: #f4f9ec;
  --cl1: #dcecc2;
  --cl2: #a8ce85;
  --cl3: #6ba950;
  --cl4: #3d7f2d;
  --cl5: #1a5417;
  --cl-nodata: #eeeeee;
  --cl-off: #eef0ed;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 1px 3px rgba(0,0,0,.08);
  --nav-h: 56px;
  --foot-h: 36px;
}
*{box-sizing:border-box}
html,body{
  margin:0;padding:0;height:100%;
  font-family:'Inter',system-ui,-apple-system,Arial,sans-serif;font-size:14px;
  color:var(--texto);background:var(--bg-gris);line-height:1.45;
  overflow:hidden;
}
a{color:inherit;text-decoration:none}
button{font-family:inherit;cursor:pointer}

/* ---------------- NAVBAR ---------------- */
.navbar{
  display:flex;align-items:center;justify-content:space-between;
  background:var(--verde-nav);color:#fff;padding:.5rem 1.5rem;
  height:var(--nav-h);
}
.brand{display:flex;align-items:center;gap:.7rem}
.brand .olive-logo{flex-shrink:0}
.brand-main{font-weight:700;font-size:1.15rem;letter-spacing:.4px;line-height:1.1}
.brand-sub{font-size:.74rem;opacity:.8;font-weight:400;margin-top:1px;line-height:1.2}
.nav-items{display:flex;gap:.3rem}
.nav-items a{padding:.4rem .95rem;border-radius:4px;font-size:.88rem;transition:background .15s}
.nav-items a:hover{background:var(--verde-nav-hover)}
.nav-items a.active{background:var(--verde-nav-hover);font-weight:500}

/* ---------------- LAYOUT ---------------- */
.layout{
  display:grid;
  grid-template-columns: 250px 1fr 400px;
  height: calc(100vh - var(--nav-h) - var(--foot-h));
  overflow:hidden;
}

/* ---------------- SIDEBAR IZQ ---------------- */
.sidebar{
  background:var(--bg);border-right:1px solid var(--borde);
  display:flex;flex-direction:column;height:100%;overflow:hidden;
}
.sidebar-scroll{
  flex:1;overflow-y:auto;padding:1rem .9rem;
  display:flex;flex-direction:column;gap:.85rem;
}
.sidebar-footer{
  border-top:1px solid var(--borde);padding:.7rem .9rem;background:var(--bg-panel);
}
.sidebar h2{font-size:.95rem;margin:0;font-weight:600}

.search{position:relative}
.search input{
  width:100%;padding:.48rem .7rem;border:1px solid var(--borde);border-radius:4px;
  font-family:inherit;font-size:.85rem;background:var(--bg-gris);
}
.search input:focus{outline:none;border-color:var(--verde-acento);background:#fff}
.search-results{
  position:absolute;top:100%;left:0;right:0;background:#fff;border:1px solid var(--borde);
  border-top:none;max-height:200px;overflow-y:auto;margin:0;padding:0;list-style:none;
  z-index:10;border-radius:0 0 4px 4px;box-shadow:var(--shadow);
}
.search-results li{padding:.4rem .7rem;cursor:pointer;font-size:.83rem}
.search-results li:hover{background:var(--bg-gris)}
.search-results .prov{color:var(--texto-terc);font-size:.73rem;margin-left:.4rem}

.selected .selected-header{
  display:flex;justify-content:space-between;align-items:center;
  font-size:.76rem;color:var(--texto-sec);margin-bottom:.3rem;
}
.selected-header a{color:var(--verde-acento);cursor:pointer;font-size:.74rem}
#selected-list .sel-chip{
  display:flex;align-items:center;justify-content:space-between;
  background:var(--bg-gris);border:1px solid var(--borde);
  border-radius:4px;padding:.35rem .55rem;margin-bottom:.25rem;font-size:.82rem;
}
#selected-list .sel-chip .close{color:var(--texto-terc);cursor:pointer;margin-left:.4rem}
#selected-list:empty::before{content:"Sin selección";color:var(--texto-terc);font-size:.76rem;font-style:italic}

/* ---------------- CAPAS (como tarjetas) ---------------- */
.capas-block{border-top:1px solid var(--borde-suave);padding-top:.7rem;display:flex;flex-direction:column;gap:.25rem}
.capas-title{font-size:.95rem;font-weight:600;margin-bottom:.4rem;color:var(--texto)}
.capa-card{
  display:flex;align-items:center;gap:.55rem;
  padding:.45rem .55rem;border:1px solid var(--borde-suave);border-radius:5px;
  background:var(--bg);cursor:pointer;transition:all .15s;font-size:.82rem;
}
.capa-card .capa-dot{
  width:12px;height:12px;border-radius:3px;flex-shrink:0;
  box-shadow:0 0 0 1px rgba(0,0,0,.05);
}
.capa-card .capa-nombre{flex:1;color:var(--texto)}
.capa-card .capa-estado{
  font-size:.66rem;color:var(--texto-terc);font-style:italic;flex-shrink:0;
}
.capa-card .capa-estado.disponible{
  color:var(--verde-acento);font-style:normal;font-weight:500;
}
.capa-card:hover{background:var(--bg-gris);border-color:var(--borde)}
.capa-card.active{
  background:#eaf3e0;border-color:var(--verde-suave);
}
.capa-card.active .capa-nombre{font-weight:500}
.capa-card.pending{opacity:.7;cursor:default}
.capa-card.pending:hover{background:var(--bg);border-color:var(--borde-suave)}

.prototipo-aviso{
  font-size:.7rem;color:var(--texto-sec);margin:0;line-height:1.5;
  padding-left:.55rem;border-left:3px solid var(--verde-acento);
}
.prototipo-aviso strong{color:var(--verde-acento-d)}

/* ---------------- MAPA CENTRO ---------------- */
.map-area{
  display:flex;flex-direction:column;background:var(--bg-panel);
  height:100%;overflow:hidden;
}
.map-header{
  display:flex;justify-content:space-between;align-items:flex-start;
  padding:.8rem 1rem .3rem 1rem;gap:1rem;flex-shrink:0;
}
.legend{
  background:#fff;border:1px solid var(--borde);border-radius:4px;
  padding:.55rem .75rem;box-shadow:var(--shadow-sm);min-width:220px;
}
.legend-title{font-size:.75rem;color:var(--texto-sec);margin-bottom:.35rem;font-weight:500}
.legend-items{display:flex;flex-direction:column;gap:2px}
.legend-row{display:flex;align-items:center;gap:.4rem;font-size:.74rem}
.legend-swatch{width:18px;height:10px;border:1px solid rgba(0,0,0,.08)}

.map-tools button{
  background:#fff;border:1px solid var(--borde);width:34px;height:34px;
  border-radius:4px;font-size:1rem;box-shadow:var(--shadow-sm);
}

.map-wrap{flex:1;min-height:0;position:relative}
#map{width:100%;height:100%;display:block}

.mun{stroke:#fff;stroke-width:.4;cursor:pointer;transition:stroke-width .15s}
.mun:hover{stroke:#222;stroke-width:1.2}
.mun.selected{stroke:#c0392b;stroke-width:2}
.mun.off{stroke:#c8ccc5 !important;stroke-width:.5}

.tooltip{
  position:absolute;pointer-events:none;background:#fff;border:1px solid var(--borde);
  padding:.45rem .65rem;border-radius:4px;font-size:.8rem;box-shadow:0 2px 10px rgba(0,0,0,.15);
  z-index:20;max-width:240px;
}
.tooltip strong{display:block;margin-bottom:.2rem}
.tooltip .val{color:var(--verde-acento-d);font-weight:600}

.coop-bubble{
  fill:#3a8ad2;fill-opacity:.55;stroke:#fff;stroke-width:.8;pointer-events:none;
}

.timeline{
  display:flex;justify-content:center;padding:.5rem 1rem .7rem 1rem;flex-shrink:0;
  border-top:1px solid var(--borde-suave);background:var(--bg-panel);
}
.timeline-inner{display:flex;align-items:center;gap:1rem}
.timeline-label{font-size:.8rem;color:var(--texto-sec);font-weight:500;flex-shrink:0}
.timeline-buttons{display:flex;gap:.35rem}
.timeline-buttons button{
  background:#fff;border:1px solid var(--borde);padding:.42rem 1.1rem;
  border-radius:4px;font-size:.85rem;color:var(--texto-sec);min-width:72px;font-weight:500;
}
.timeline-buttons button:hover{border-color:var(--verde-acento)}
.timeline-buttons button.active{background:var(--verde-acento-d);color:#fff;border-color:var(--verde-acento-d)}

/* ---------------- PANEL DETALLE ---------------- */
.detail{
  background:var(--bg);border-left:1px solid var(--borde);
  padding:1.1rem 1rem;overflow-y:auto;height:100%;
}
.detail-empty{
  color:var(--texto-terc);font-size:.9rem;text-align:center;margin-top:2.5rem;
  display:flex;flex-direction:column;align-items:center;gap:.7rem;
}
.detail-empty-icon{opacity:.5}
.detail-empty p{max-width:230px;margin:0;line-height:1.5}

.detail-header{margin-bottom:.9rem;padding-bottom:.5rem;border-bottom:1px solid var(--borde-suave)}
.detail-header h3{margin:0;font-size:1.3rem;font-weight:700;letter-spacing:.3px;text-transform:uppercase;color:var(--verde-acento-d)}
.detail-header #detail-prov{font-size:.78rem;color:var(--texto-sec);margin-top:.2rem}

.kpi-row{display:grid;grid-template-columns:1fr 1fr 1fr;gap:.4rem;margin-bottom:1.1rem}
.kpi{border:1px solid var(--borde);border-radius:5px;padding:.55rem .55rem;background:var(--bg-panel);text-align:left}
.kpi-label{font-size:.68rem;color:var(--texto-sec);font-weight:500;line-height:1.25}
.kpi-year{font-size:.62rem;color:var(--texto-terc);margin-top:1px}
.kpi-value{font-size:1.15rem;font-weight:700;margin-top:.25rem;color:var(--verde-acento-d);line-height:1}
.kpi-unit{font-size:.62rem;color:var(--texto-terc);margin-top:2px}

.mini-chart{position:relative;margin-bottom:1.2rem}
.mini-title{
  font-size:.82rem;color:var(--texto);font-weight:600;margin-bottom:.3rem;
  display:flex;align-items:center;gap:.5rem;
}
.tag-pending{
  font-size:.64rem;color:var(--texto-terc);font-weight:400;
  background:var(--bg-panel-2);padding:.1rem .45rem;border-radius:3px;font-style:italic;
}
.mini-svg{width:100%;height:120px;display:block}
.mini-caption{font-size:.7rem;color:var(--texto-terc);margin-top:.25rem;line-height:1.4}
.mini-placeholder{
  position:absolute;top:28px;left:0;right:0;bottom:24px;
  display:flex;align-items:center;justify-content:center;padding:.5rem;
  color:var(--texto-terc);font-size:.72rem;font-style:italic;text-align:center;
  background:repeating-linear-gradient(45deg,transparent,transparent 7px,rgba(0,0,0,.025) 7px,rgba(0,0,0,.025) 14px);
  border-radius:3px;border:1px dashed rgba(0,0,0,.08);
}
.mini-svg .axis text{font-size:9.5px;fill:var(--texto-terc)}
.mini-svg .axis path,.mini-svg .axis line{stroke:var(--borde)}

.coop-section{margin-bottom:1rem}
.coop-list{list-style:none;padding:0;margin:0;max-height:180px;overflow-y:auto;
  border:1px solid var(--borde-suave);border-radius:4px;padding:.3rem .55rem;background:var(--bg-panel)}
.coop-list li{padding:.32rem 0;border-bottom:1px dotted var(--borde-suave);font-size:.78rem}
.coop-list li:last-child{border-bottom:none}
.coop-list .coop-nombre{font-weight:500}
.coop-list .coop-meta{color:var(--texto-terc);font-size:.7rem;margin-top:1px}

.placeholder-grid{
  display:grid;grid-template-columns:1fr 1fr;gap:.5rem;margin-top:.5rem;
}
.placeholder-card{
  border:1px dashed var(--borde);border-radius:5px;padding:.55rem .6rem;
  background:var(--bg-panel-2);
}
.placeholder-head{
  font-size:.78rem;font-weight:600;color:var(--texto-sec);margin-bottom:.25rem;
}
.placeholder-head::before{
  content:"◷ ";color:var(--verde-acento);font-size:.85rem;
}
.placeholder-body{font-size:.7rem;color:var(--texto-terc);line-height:1.4}

/* ---------------- FOOTER ---------------- */
.footer{
  background:var(--verde-nav);color:#fff;padding:.55rem 1.5rem;
  display:flex;justify-content:space-between;align-items:center;
  font-size:.76rem;opacity:.92;height:var(--foot-h);
}

/* ---------------- MODAL ---------------- */
.modal[hidden]{display:none !important}
.modal{
  position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:200;
  display:flex;align-items:center;justify-content:center;padding:2rem;
}
.modal-content{
  background:#fff;border-radius:6px;max-width:720px;max-height:85vh;overflow-y:auto;
  padding:2rem 2.2rem;position:relative;width:100%;
}
.modal-close{
  position:absolute;top:.8rem;right:.8rem;background:none;border:none;font-size:1.1rem;
  color:var(--texto-sec);cursor:pointer;width:30px;height:30px;border-radius:50%;
}
.modal-close:hover{background:var(--bg-gris)}
.modal-content h2{margin-top:0;color:var(--verde-acento-d)}
.modal-content h3{font-size:1rem;color:var(--verde-acento-d);margin-top:1.4rem;margin-bottom:.4rem}
.modal-content p, .modal-content li{font-size:.86rem;line-height:1.6}
.modal-content ul{padding-left:1.2rem}
.disclaimer{font-size:.74rem;color:var(--texto-sec);background:var(--bg-panel);
  padding:.55rem;border-radius:4px;border-left:3px solid var(--verde-acento);margin-top:.7rem}

/* ---------------- RESPONSIVE ---------------- */
@media (max-width: 1200px){
  .layout{grid-template-columns: 230px 1fr 340px}
  .placeholder-grid{grid-template-columns:1fr}
}
