@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');

:root{
  --bg:#f6f7fb;
  --card:#ffffff;
  --muted:#6b7280;
  --text:#0f172a;
  --primary:#6b9dfc;
  --accent:#e9f0ff;
  --shadow:0 10px 30px rgba(2, 6, 23, 0.08);
  --green:#e8f5e9;
  --green-text:#145a32;
  --yellow:#f5f6e8;
  --yellow-text:#6b6b2e;
  --red:#fdecea;
  --red-text:#7a1c1c;
  --sticky-offset: 340px; /* alto aprox. de topbar + footer + respiración */

}

/* ===== Tema oscuro por variables ===== */
:root.dark{
  --bg:#0b1020;
  --card:#11162a;
  --muted:#98a2b3;
  --text:#e5e7eb;
  --primary:#8b5cf6;
  --accent:#1b2342;
  --shadow:0 10px 30px rgba(0,0,0,.45);
  --green:#16342a;
  --green-text:#4ade80;
  --yellow:#3a3518;
  --yellow-text:#facc15;
  --red:#3a1a1a;
  --red-text:#fca5a5;
}

*{ box-sizing:border-box; }
html,body{
  margin:0; padding:0;
  font-family:Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color:var(--text);
  background:var(--bg);
  line-height: 1.5; /* Mejora la legibilidad general */
  -webkit-font-smoothing: antialiased; /* Suavizado de fuentes para mejor renderizado */
  -moz-osx-font-smoothing: grayscale;
}

/* Loader */
.hidden-loader {
  display: none !important;
}

#loader {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 18px;
  font-weight: 600;
  color: #333;
  z-index: 9999;
}
.spinner {
  border: 4px solid #ddd;
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Topbar (logo | centro | acciones) ===== */
.topbar{
  background:var(--card);
  box-shadow:var(--shadow);
  padding:16px 24px;
  border-bottom:1px solid #eceff5;
  display:grid;
  grid-template-columns: 1fr auto 1fr; /* izquierda | CENTRO | derecha */
  align-items:center;
  column-gap:16px;
}

.brand-left   { justify-self: start; }
.brand-center { grid-column: 2; text-align: center; justify-self: center; }
.top-actions  { justify-self: end; }


/* Izquierda: logo */
.brand-left{ display:flex; align-items:center; }
.logo-img{ width:200px; height:auto; display:block; }

/* Centro: título siempre centrado */
.brand-center{
  text-align:center;
  justify-self:center;
}
.brand-center h1{
  margin:0 0 6px; /* Un poco más de espacio */
  font-size:28px; /* Ligeramente más grande */
  letter-spacing:-.02em; /* Ajuste para un look más moderno */
  font-weight: 700; /* Asegurar negrita */
}
.brand-center p{
  margin:0;
  color:var(--muted);
  font-size:15px; /* Ligeramente más grande */
  line-height: 1.4;
}

/* Derecha: idioma + toggle */
.top-actions{
  justify-self:end;
  display:flex;
  align-items:center;
  gap:12px; /* separa idioma y toggle */
}

/* ===== Dropdown idioma (custom) ===== */
.lang-dd{ position:relative; }
.lang-dd__btn{
  position:relative;
  display:flex; align-items:center; gap:8px;
  padding:10px 36px 10px 12px;
  border-radius:999px;
  background:#f9fafb; border:1px solid #e5e7eb;
  box-shadow:0 6px 18px rgba(16,24,40,.06);
  font-weight:700; color:#111827; cursor:pointer;
}
:root.dark .lang-dd__btn{
  background:#1a2140; border-color:#253056; color:#e5e7eb;
}
.lang-dd__btn:focus{ outline:none; border-color:#7f56d9; box-shadow:0 0 0 4px rgba(127,86,217,.15); }
.lang-dd .chev{
  position:absolute; right:12px; top:50%;
  width:8px; height:8px;
  border-right:2px solid #6b7280; border-bottom:2px solid #6b7280;
  transform:translateY(-50%) rotate(45deg);
  opacity:.7; pointer-events:none;
}
.lang-dd__menu{
  position:absolute; 
  right:0; 
  top:calc(100% + 8px);
  min-width:180px; 
  padding:6px 0; 
  margin:0; 
  list-style:none;
  background:var(--card); 
  border:1px solid #e5e7eb; 
  border-radius:10px;
  box-shadow:0 12px 30px rgba(16,24,40,.12);
  display:none; 
  z-index:2000; /* <<< CAMBIADO de 50 a 2000 */
}

.lang-dd__menu.open{ display:block; }
.lang-dd__menu li{
  display:flex; align-items:center; gap:8px;
  padding:8px 12px; cursor:pointer; user-select:none;
  white-space:nowrap; color:var(--text);
}
.lang-dd__menu li:hover{ background:#eef2ff; }
:root.dark .lang-dd__menu{ border-color:#253056; box-shadow:0 12px 30px rgba(0,0,0,.35); }
:root.dark .lang-dd__menu li:hover{ background:#212a52; }

/* Banderas (SVG embebido) */
.flag{
  width:18px; height:12px; border-radius:2px; display:inline-block;
  background-size:cover; background-position:center;
  box-shadow:0 0 0 1px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.06);
}
.flag-es{
  background-image:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="16"><rect width="24" height="16" fill="%23AA151B"/><rect y="4" width="24" height="8" fill="%23F1BF00"/></svg>');
}
.flag-cat{
  background-image:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="16"><rect width="24" height="16" fill="%23FCDD09"/><g fill="%23DA121A"><rect y="1" width="24" height="2"/><rect y="5" width="24" height="2"/><rect y="9" width="24" height="2"/><rect y="13" width="24" height="2"/></g></svg>');
}
.flag-gb{
  background-image:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="16"><rect width="24" height="16" fill="%23012169"/><path d="M0,0 24,16 M24,0 0,16" stroke="%23ffffff" stroke-width="3"/><path d="M0,0 24,16 M24,0 0,16" stroke="%23C8102E" stroke-width="1.5"/><path d="M12,0 v16 M0,8 h24" stroke="%23ffffff" stroke-width="5"/><path d="M12,0 v16 M0,8 h24" stroke="%23C8102E" stroke-width="3"/></svg>');
}
.flag-fr{
  background-image:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="16"><rect width="8" height="16" fill="%230055A4"/><rect x="8" width="8" height="16" fill="%23FFFFFF"/><rect x="16" width="8" height="16" fill="%23EF4135"/></svg>');
}
.flag-de{
  background-image:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="16"><rect width="24" height="16" fill="%23000000"/><rect y="5.33" width="24" height="5.33" fill="%23DD0000"/><rect y="10.66" width="24" height="5.34" fill="%23FFCE00"/></svg>');
}
.flag-it{
  background-image:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="16"><rect width="8" height="16" fill="%23009246"/><rect x="8" width="8" height="16" fill="%23FFFFFF"/><rect x="16" width="8" height="16" fill="%23CE2B37"/></svg>');
}

/* ===== Layout principal ===== */
.container{
  max-width:1320px;
  margin:24px auto 40px;
  padding:0 24px;
  display:grid;
  gap:20px;
}
/* Empuja el footer hacia abajo en pantallas altas, sin cambiar el ancho */
main.container{
  min-height: calc(100vh - 420px); /* topbar + intro + footer aprox. */
}

/* Ajuste para 2K+ (más alto → más empuje) */
@media (min-width:1600px){
  main.container{ min-height: calc(100vh - 290px); }
}

/* ===== Tarjetas base ===== */
.info-card,.form-card,.chart-card,.report-card,.card{
  background:var(--card);
  border:1px solid #eef1f6;
  border-radius:12px;
  box-shadow:0 8px 24px rgba(16,24,40,.06);
  padding:24px;
}

/* Cabecera reutilizable (título + botones) */
.card-head{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  margin:0 0 10px;
}
.card-head h2, .card-head h3 {
  margin: 0;
}
.icon-btn{
  border:none; background:#f3f4f6; color:#374151; border-radius:10px;
  cursor:pointer; padding:8px; line-height:0; box-shadow:var(--shadow);
}
.icon-btn:hover{ filter:brightness(.98); }

/* ===== Info top ===== */
.info-row{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:16px;
}
.info-col .label{
  display:block; font-size:12px; color:var(--muted); letter-spacing:.4px;
}
.info-col .value{
  font-weight:600; margin-top:6px; display:block;
}

/* ===== Formulario ===== */
.form-card {
  background: var(--card-bg, #fff);
  padding: 2rem;
  border-radius: 16px; /* Bordes más redondeados */
  padding: 32px; /* Más padding para un look más espacioso */
  box-shadow: 0 12px 36px rgba(16,24,40,.08); /* Sombra más pronunciada */
  max-width: 800px;
  margin: 2rem auto;
  transition: all 0.3s ease;
}

.form-card:hover {
  box-shadow: 0 6px 28px rgba(0,0,0,0.12);
}
.form-card .grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}

.field label {
  font-size: 0.95rem; /* Ligeramente más grande */
  font-weight: 600;
  color: var(--muted); /* Usar variable --muted para consistencia */
  margin-bottom: 8px; /* Más espacio entre label y input */
  display: block; /* Asegurar que el label ocupe su propia línea */
}
.field input, .field select{
  width: 100%;
  height: 48px; /* Altura consistente y más cómoda al tacto */
  padding: 12px 14px; /* Más padding */
  border: 1px solid var(--border, #e5e7eb); /* Usar variable --border */
  border-radius: 12px; /* Bordes más redondeados */
  outline: none;
  background: var(--card); /* Usar variable --card para consistencia */
  transition: box-shadow .15s ease, border-color .15s ease, background .15s ease;
  font-size: 16px; /* Evita zoom en iOS */
}

/* Estilos específicos para selectores */
.field select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
  cursor: pointer;
  position: relative;
  z-index: 1;
}
.field input:focus, .field select:focus{
  border-color: #7f56d9;
  box-shadow: 0 0 0 3px rgba(127,86,217,.15);
  background: #fff;
}


.primary{
  align-self: start;
  margin-top: 20px; /* Más espacio arriba */
  padding: 14px 24px; /* Más padding */
  border: none;
  border-radius: 12px; /* Bordes más redondeados */
  background: linear-gradient(180deg, #31c7b2, #1ba895); /* Mantener colores de la empresa */
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(49,199,178,.3); /* Sombra ajustada al color del botón */
  transition: transform .12s ease, box-shadow .2s ease;
  font-size: 16px;
}
.primary:hover{ transform: translateY(-2px); box-shadow:0 12px 28px rgba(49,199,178,.4); }
.primary:active{ transform:none; box-shadow:0 4px 12px rgba(49,199,178,.2); }


/* ===== KPIs ===== */
.kpis{
  display:grid; gap:16px;
  grid-template-columns: repeat(3, 1fr);
}
.kpi-card{
  border-radius:16px; /* Bordes más redondeados */
  box-shadow:0 10px 30px rgba(16,24,40,.06); /* Sombra ligeramente más grande */
  padding:20px; /* Más padding */
  display:flex; align-items:center; gap:16px; /* Más espacio entre elementos */
}
.kpi-card:nth-child(1){ background:var(--green);  color:var(--green-text); }
.kpi-card:nth-child(2){ background:var(--yellow); color:var(--yellow-text); }
.kpi-card:nth-child(3){ background:var(--red);    color:var(--red-text); }

.kpi-icon{
  width:40px; height:40px; /* Icono más grande */
  border-radius:10px; /* Bordes ligeramente más redondeados */
  background:#fff;
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 2px 6px rgba(16,24,40,.1); /* Sombra más definida */
  font-size:20px; /* Icono más grande */
}
.kpi-label{ display:block; font-size:13px; opacity:.85; letter-spacing:.02em; } /* Ligeramente más grande y con espaciado */
.kpi-value{ font-size:26px; font-weight:700; line-height:1.2; } /* Más grande y mejor interlineado */

/* ===== Gráfica ===== */
.chart-card h2, .chart-card h3, 
.report-card h2, .report-card h3{ margin:0 0 12px; }
.legend{
  display:flex; gap:18px; font-size:14px; color:var(--muted); margin-bottom:10px;
}
.legend .box{
  display:inline-block; width:14px; height:10px; border-radius:3px; margin-right:6px;
}
.legend .bar{ background:#cde2ff; }
.legend .line{ background:#9b7cf5; }

.chart-card canvas{
  width:100% !important;
  max-height:360px;
}

/* ===== Bloque: Datos clave de la zona ===== */
#zona-datos h2, #zona-datos h3{ margin:0 0 8px; }
#zona-datos p{ color:var(--muted); margin:6px 0 12px; }
.zona-metricas{
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap:12px;
}
.metric{
  background:var(--accent);
  border:1px solid var(--border); /* Usar variable --border */
  border-radius:14px; /* Bordes más redondeados */
  padding:16px; /* Más padding */
}
.metric .label{ font-size:13px; color:var(--muted); display:block; letter-spacing:.02em; } /* Ligeramente más grande y con espaciado */
.metric .value{ font-weight:700; font-size:18px; margin-top:6px; display:block; line-height:1.2; } /* Más grande y mejor interlineado */

/* ===== Informe detallado MODERNO ===== */
.report-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 12px 36px rgba(16, 24, 40, 0.08);
}

.report-card h2 {
  font-size: 26px;
  font-weight: 800;
  margin: 0 0 24px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 12px;
}

.report-card h2::before {
  content: "📊";
  font-size: 30px;
}

.report-card h3 {
  font-size: 20px;
  font-weight: 700;
  margin: 24px 0 16px;
  color: var(--text);
}

.report-card h4 {
  font-size: 16px;
  font-weight: 600;
  margin: 16px 0 12px;
  color: var(--muted);
}

/* Sección de diagnóstico */
#informe-diagnostico {
  background: linear-gradient(135deg, rgba(124, 145, 255, 0.06), rgba(124, 145, 255, 0.02));
  border-left: 4px solid #7c91ff;
  padding: 20px 24px;
  border-radius: 14px;
  margin-bottom: 28px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  position: relative;
  overflow: hidden;
}

#informe-diagnostico::before {
  content: "💡";
  position: absolute;
  right: 20px;
  top: 20px;
  font-size: 32px;
  opacity: 0.15;
}

/* Títulos de secciones (Palancas y Recomendaciones) */
.report-card h4 {
  font-size: 19px;
  font-weight: 700;
  margin: 28px 0 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.02em;
}

/* Icono para "Palancas" */
.report-card h4:nth-of-type(1)::before {
  content: "⚙️";
  font-size: 22px;
  background: linear-gradient(135deg, rgba(49, 199, 178, 0.1), rgba(49, 199, 178, 0.05));
  padding: 8px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

/* Icono para "Recomendaciones" */
.report-card h4:nth-of-type(2)::before {
  content: "✨";
  font-size: 22px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(139, 92, 246, 0.05));
  padding: 8px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

/* Listas modernizadas */
.report-card ul {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.report-card li {
  background: var(--accent);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px 16px 54px;
  margin-bottom: 12px;
  position: relative;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text);
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.04);
}

.report-card li:hover {
  transform: translateX(4px);
  box-shadow: 0 4px 16px rgba(16, 24, 40, 0.08);
  border-color: rgba(124, 145, 255, 0.3);
}

/* Iconos para items de lista de Palancas */
#informe-palancas li::before {
  content: "🎯";
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  background: linear-gradient(135deg, rgba(49, 199, 178, 0.15), rgba(49, 199, 178, 0.05));
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

/* Iconos para items de lista de Recomendaciones */
#informe-recomendaciones li::before {
  content: "💼";
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(139, 92, 246, 0.05));
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

/* Dark mode enhancements */
:root.dark .report-card li {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.08);
}

:root.dark .report-card li:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(139, 92, 246, 0.3);
}

:root.dark #informe-diagnostico {
  background: linear-gradient(135deg, rgba(124, 145, 255, 0.08), rgba(124, 145, 255, 0.03));
  border-left-color: #8b5cf6;
}

/* Responsive */
@media (max-width: 640px) {
  .report-card {
    padding: 24px 20px;
  }
  
  .report-card h3 {
    font-size: 22px;
  }
  
  .report-card h4 {
    font-size: 17px;
  }
  
  .report-card li {
    padding: 14px 16px 14px 50px;
    font-size: 14px;
  }
  
  #informe-palancas li::before,
  #informe-recomendaciones li::before {
    left: 14px;
    width: 28px;
    height: 28px;
    font-size: 18px;
  }
}

/* ===== Botón PDF ===== */
.actions{
  display:flex; justify-content:flex-end; gap:10px; margin-top:-6px;
}
/* Botón PDF: hereda el estilo azul de .btn-primary-lg */



/* ===== Footer profesional ===== */
.site-footer{
  background: var(--card);
  border-top: 1px solid var(--border, #e5e7eb);
  padding: 32px 24px; /* Más padding */
  margin-top: 32px; /* Más margen superior */
}

.site-footer .footer-inner{
  max-width: 1200px;
  margin: 0 auto;
}

/* fila de contacto */
.footer-contact{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 14px;
}
.footer-item{
  display: flex;
  align-items: center;
  gap: 16px; /* Más espacio */
  padding: 16px 18px; /* Más padding */
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 16px; /* Bordes más redondeados */
  background: var(--card);
  box-shadow: var(--shadow);
}
.footer-item svg{
  width: 24px; /* Icono más grande */
  height: 24px; /* Icono más grande */
  color: #31c7b2; /* Mantener color de la empresa */
  flex-shrink: 0;
}
.footer-kicker{
  display: block;
  font-size: 13px; /* Ligeramente más grande */
  letter-spacing: .04em; /* Más espaciado para un look más premium */
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px; /* Más espacio */
}
.footer-link{
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
  font-size: 16px; /* Ligeramente más grande */
}
.footer-link:hover{ text-decoration: underline; }

/* firma + nota */
.footer-bottom{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px dashed var(--border, #e5e7eb);
}
.made-by{
  margin: 0;
  font-size: 15px; /* Ligeramente más grande */
  color: var(--muted);
}
.footnote{
  margin: 0;
  text-align: right;
  color: var(--muted);
  font-size: 13px; /* Ligeramente más grande */
  line-height: 1.4;
}

/* responsive */
@media (max-width:900px){
  .footer-contact{ grid-template-columns: 1fr; }
  .footer-bottom{ flex-direction: column; align-items: flex-start; }
}


/* ===== Responsive ===== */
@media (max-width:900px){
  .info-row{ grid-template-columns:1fr; }
  .form-card .grid{ grid-template-columns:1fr 1fr; }
  .kpis{ grid-template-columns:1fr; }
  .zona-metricas{ grid-template-columns:1fr 1fr; }
}
@media (max-width:560px){
  .form-card .grid{ grid-template-columns:1fr; }
  .zona-metricas{ grid-template-columns:1fr; }
}


/* ===== Grid mejorado en desktop ===== */
@media (min-width: 1200px){
  .form-card .grid{
    grid-template-columns: repeat(12, 1fr);
    gap: 18px;
  }
  /* Fila 1 */
  .form-card .grid .field:nth-child(1){ grid-column: span 3; } /* Ciudad */
  .form-card .grid .field:nth-child(2){ grid-column: span 3; } /* Zona */
  .form-card .grid .field:nth-child(3){ grid-column: span 3; } /* Huéspedes */
  .form-card .grid .field:nth-child(4){ grid-column: span 3; } /* Habitaciones */
  /* Fila 2 */
  .form-card .grid .field:nth-child(5){ grid-column: span 2; } /* Calidad */
  .form-card .grid .field:nth-child(6){ grid-column: span 4; } /* Propietario */
  .form-card .grid .field:nth-child(7){ grid-column: span 3; } /* Teléfono */
  .form-card .grid .field:nth-child(8){ grid-column: span 3; } /* Email */
}

@media (min-width:1440px){
  .container{ max-width:1440px; }
}

/* Errores de validación */
.field .error-text{
  color:#b42318;
  font-size:12px;
  margin-top:6px;
}
.field input.is-invalid,
.field select.is-invalid{
  border-color:#fda29b;
  box-shadow:0 0 0 3px rgba(240,68,56,.15);
}

/* ===== Modal de gráfica ===== */
.modal{
  position:fixed; inset:0; z-index:9998; display:none;
}
.modal.open{ display:block; }
.modal-backdrop{
  position:absolute; inset:0; background:rgba(15,23,42,.5); backdrop-filter: blur(2px);
}
.modal-dialog{
  position:relative; z-index:9999;
  width:min(96vw, 1100px);
  margin:4vh auto; padding:20px;
  background:var(--card); border-radius:14px; box-shadow:var(--shadow);
}
.modal-head{
  display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:10px;
}
.modal-actions{ display:flex; gap:8px; }
#chartLarge{
  width:100% !important;
  max-height:68vh;
}
.modal-note{
  margin:.5rem 0 0; color:var(--muted); font-size:12px;
}

/* Evita scroll del body con modal abierto */
body.modal-open{ overflow:hidden; }

/* ===== MODO PDF A3 HORIZONTAL ===== */
body.for-pdf-a3-land{ background:#fff; }

/* Cabecera añadida en el clon del PDF */
body.for-pdf-a3-land .pdf-header{ text-align:center; margin:6px 0 12px; }
body.for-pdf-a3-land .pdf-header h1{ margin:0; font-size:22px; line-height:1.25; }
body.for-pdf-a3-land .pdf-header p{ margin:6px 0 0; font-size:12px; color:var(--muted); }

/* A3 landscape ≈ 1587×1121 px @96dpi → evita “miniatura” */
body.for-pdf-a3-land #pdf-root{
  width:1587px !important;
  max-width:1587px !important;
  margin:0 auto !important;
  background:#fff;
}

/* Compacto pero con algo más de aire (A3 tiene más ancho) */
body.for-pdf-a3-land .container{ gap:14px; padding:18px; }
body.for-pdf-a3-land .card,
body.for-pdf-a3-land .chart-card,
body.for-pdf-a3-land .report-card{ padding:18px; margin-bottom:12px; box-shadow:none; }

/* Gráfica un poco más alta para lucirla */
body.for-pdf-a3-land .chart-card canvas{
  max-height:340px !important;
  height:340px !important;
}

/* Oculta elementos de la web que no deben ir al informe */
body.for-pdf-a3-land .actions,
body.for-pdf-a3-land .topbar,
body.for-pdf-a3-land footer{ display:none !important; }

/* ===========================
   Botón de modo oscuro
   =========================== */
.theme-toggle{
  width:36px; height:36px;
  padding:0;
  border-radius:8px;
  border:1px solid #e5e7eb;
  background:#f9fafb;
  color:#111827;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer;
  box-shadow:0 6px 18px rgba(16,24,40,.06);
  transition:transform .12s ease, background .2s ease, border-color .2s ease;
}
.theme-toggle:hover{ transform:translateY(-1px); }
.theme-toggle svg{ width:18px; height:18px; display:block; }
:root.dark .theme-toggle{
  background:#1a2140; color:#e5e7eb; border-color:#253056;
}

/* =========================================
   DARK THEME PRO – mejoras de contraste y estilo
   ========================================= */

/* Paleta pulida */
:root.dark{
  --bg:#0b1020;        /* fondo principal */
  --card:#121832;      /* tarjetas */
  --card-2:#0f152c;    /* superficies oscuras */
  --muted:#aab3c5;     /* texto secundario */
  --text:#eef2ff;      /* texto principal */
  --primary:#8b5cf6;   /* acento morado */
  --accent:#1b2342;    /* chips/metric */
  --border:#223055;    /* borde sutil */
  --shadow:0 14px 38px rgba(0,0,0,.48);

  --green:#0f2b22;     /* KPI OK */
  --green-text:#50e29a;
  --yellow:#2c2a12;    /* KPI ADR */
  --yellow-text:#f7d76d;
  --red:#311717;       /* KPI OCC */
  --red-text:#ff9b9b;
}

/* Topbar con leve blur */
:root.dark .topbar{
  backdrop-filter:saturate(110%) blur(4px);
  border-bottom:1px solid var(--border);
}

/* Tarjetas/bordes más integrados */
:root.dark .info-card,
:root.dark .form-card,
:root.dark .chart-card,
:root.dark .report-card,
:root.dark .card{
  background:var(--card);
  border-color:var(--border);
  box-shadow:var(--shadow);
}

/* Inputs y selects */
:root.dark .field input,
:root.dark .field select{
  background: #0f152c;
  border-color: #243152;
  color: var(--text);
}

/* Flecha del selector en modo oscuro */
:root.dark .field select {
  background: #0f152c url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e") no-repeat right 12px center;
  background-size: 16px;
}
:root.dark .field input::placeholder,
:root.dark .field textarea::placeholder{
  color:#7f8aa6;
}
:root.dark .field input:focus,
:root.dark .field select:focus{
  border-color:#8b5cf6;
  box-shadow:0 0 0 4px rgba(139,92,246,.18);
}

/* Botón primario – brillo sutil */
:root.dark .primary{
  box-shadow:0 8px 22px rgba(139,92,246,.28);
}

/* KPI cards mejor integradas */
:root.dark .kpi-card{
  border-color:transparent;
  box-shadow:0 10px 26px rgba(0,0,0,.4);
}
:root.dark .kpi-card:nth-child(1){ background:linear-gradient(180deg, rgba(15,43,34,.9), var(--green)); color:var(--green-text); }
:root.dark .kpi-card:nth-child(2){ background:linear-gradient(180deg, #27240f, var(--yellow)); color:var(--yellow-text); }
:root.dark .kpi-card:nth-child(3){ background:linear-gradient(180deg, #2a1313, var(--red)); color:var(--red-text); }
:root.dark .kpi-icon{ background:rgba(255,255,255,.06); box-shadow:none; }

/* Chips de métricas de zona */
:root.dark .metric{ background:#131a35; border-color:#223055; }

/* Botón PDF */
:root.dark #btn-pdf{
  background:#0f152c;
  color:#eef2ff;
  border:1px solid #223055;
  box-shadow:0 10px 28px rgba(0,0,0,.5);
}

/* Dropdown idioma */
:root.dark .lang-dd__menu{ background:var(--card); }
:root.dark .lang-dd__menu li:hover{ background:#1d2650; }

/* Modal */
:root.dark .modal-dialog{
  background:var(--card);
  border:1px solid var(--border);
  box-shadow:0 18px 40px rgba(0,0,0,.55);
}
:root.dark .modal-backdrop{ background:rgba(2,6,23,.65); }

/* Scrollbar sutil en dark (Chrome/Edge) */
:root.dark ::-webkit-scrollbar{ height:10px; width:10px; }
:root.dark ::-webkit-scrollbar-track{ background:#0f152c; }
:root.dark ::-webkit-scrollbar-thumb{ background:#2a3864; border-radius:8px; }
:root.dark ::-webkit-scrollbar-thumb:hover{ background:#354777; }

/* Separadores finos en secciones */
:root.dark .info-card .value,
:root.dark .kpi-text .kpi-label,
:root.dark .legend{ color:var(--muted); }

/* Leyenda gráfica */
:root.dark .legend .bar{ background:rgba(109,155,252,.45); }
:root.dark .legend .line{ background:var(--primary); }

/* Iconos del toggle */
.theme-toggle svg{
  width:18px;
  height:18px;
  display:block;
}

/* Rayos del sol un poco más gruesos para mejor visibilidad */
.theme-toggle .sun-icon{
  stroke-width:2.2;
}

/* En dark subimos un pelín el contraste del icono */
:root.dark .theme-toggle{
  color:#f1f5f9; /* <-- sin caracteres extra delante del # */
}

/* En el "skin" de PDF no queremos controles ni modales */
body.for-pdf-a3-land .card-head .icon-btn,
body.for-pdf-a3-land .modal,
body.for-pdf-a3-land .actions{
  display:none !important;
}
/* ==== Botón secundario (comparar) ==== */
.secondary{
  padding:12px 16px; border-radius:12px; border:1px solid #e5e7eb;
  background:#f9fafb; color:#111827; font-weight:600; cursor:pointer;
}
.secondary:hover{ filter:brightness(.98); }
:root.dark .secondary{ background:#1a2140; color:#e5e7eb; border-color:#253056; }

/* ==== Drawer lateral derecho ==== */
.drawer{
  position:fixed; top:0; right:-480px; width:min(92vw, 460px); height:100vh;
  background:var(--card); border-left:1px solid #e5e7eb; box-shadow:var(--shadow);
  padding:18px; z-index:10000; transition:right .22s ease; overflow:auto;
}
.drawer.open{ right:0; }
.drawer-backdrop{
  position:fixed; inset:0; background:rgba(15,23,42,.4); display:none; z-index:9999;
}
.drawer-backdrop.show{ display:block; }
.drawer-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; }
.drawer-actions{ display:flex; gap:8px; }
.ghost{
  padding:10px 12px; border:1px dashed #cbd5e1; background:transparent; border-radius:10px; cursor:pointer;
}
:root.dark .ghost{ border-color:#33406b; }

/* ==== Resumen comparativo Δ ==== */
.compare-summary{
  display:grid; grid-template-columns:repeat(3,1fr); gap:12px; margin:14px 0;
}
.delta-pill{
  background:var(--accent); border:1px solid #e5e7eb; border-radius:12px; padding:12px;
  display:flex; align-items:center; justify-content:space-between; gap:8px;
}
.delta-pill .label{ font-size:12px; color:var(--muted); margin-bottom:4px; }
.delta-pill .diff.up{ color:#16a34a; font-weight:700; }
.delta-pill .diff.down{ color:#dc2626; font-weight:700; }

@media (max-width:900px){
  .compare-summary{ grid-template-columns:1fr; }
}

/* ==== KPIs comparador ==== */
.kpi-compare{
  display:flex;
  align-items:center;
  gap:8px;
  font-weight:700;
  font-size:18px;
}
.kpi-compare .sep{ opacity:.6; }
.kpi-diff{
  margin-left:auto;
  padding:2px 8px;
  border-radius:999px;
  font-size:12px;
  font-weight:800;
  letter-spacing:.2px;
  background:rgba(2,6,23,.06);
}
.kpi-diff.up{ color:#16a34a; background:rgba(22,163,74,.12); }
.kpi-diff.down{ color:#dc2626; background:rgba(220,38,38,.12); }

/* tema oscuro */
:root.dark .kpi-diff{ background:rgba(255,255,255,.06); }

.secondary:disabled{
  opacity:.5;
  cursor:not-allowed;
  filter:none;
}

/* =======================
   Ajustes header en móvil
   ======================= */
@media (max-width: 480px) {
  .topbar {
    padding: 10px 12px;
    grid-template-columns: 1fr auto;
    row-gap: 8px;
  }

  

  .brand-center {
    grid-column: 1 / -1;
    text-align: left;       /* o 'center' si lo prefieres centrado */
    justify-self: start;
  }

  .brand-center h1 {
    font-size: 20px;
    line-height: 1.2;
    margin-bottom: 2px;
  }

  .brand-center p {
    font-size: 12px;
  }

  .logo-img {
    width: 120px;
  }

  .top-actions {
    gap: 8px;
    /* Cambiar el orden en móviles: tema a la izquierda, idioma a la derecha */
    display: flex;
    flex-direction: row;
  }

  /* Intercambiar orden solo en móviles */
  .lang-dd {
    order: 2; /* Selector de idioma al final (derecha) */
  }

  .theme-toggle {
    order: 1; /* Toggle de tema al principio (izquierda) */
    width: 32px;
    height: 32px;
  }

  /* Los demás botones mantienen su orden normal */
  .pill-btn {
    order: 0; /* Botones normales van primero */
  }

  .lang-dd__btn {
    padding: 8px 28px 8px 10px;
    font-size: 13px;
  }

  /* Arreglar menú de idiomas en móviles - ahora que está a la derecha */
  .lang-dd__menu {
    right: 0;
    left: auto;
    min-width: 160px;
    /* Asegurar que no se salga de la pantalla */
    transform: translateX(0);
    /* Máximo ancho para pantallas pequeñas */
    max-width: calc(100vw - 24px);
    margin-right: 0; /* Quitar margen ya que está bien posicionado */
  }
}

/* Pantallas muy pequeñas - ajustes adicionales para el selector de idioma */
@media (max-width: 360px) {
  .lang-dd__menu {
    right: 0;
    min-width: 140px;
    /* En pantallas muy pequeñas, alinear al borde derecho del viewport */
    transform: translateX(0);
    margin-right: 0;
  }

  .lang-dd__btn {
    padding: 6px 24px 6px 8px;
    font-size: 12px;
  }

  .top-actions {
    gap: 6px;
  }

  /* Mantener el orden intercambiado */
  .lang-dd {
    order: 2;
  }

  .theme-toggle {
    order: 1;
  }

  /* Los demás botones mantienen su orden normal */
  .pill-btn {
    order: 0;
  }
}
/* ===== Toolbar de resultados (botones debajo de los datos del inmueble) ===== */
.results-toolbar {
  display: flex;
  justify-content: flex-end; /* 👉 a la derecha */
  gap: 10px;
  margin-top: 12px;
}


/* Botón primario grande (Comparar escenarios) */
.btn-primary-lg {
  padding: 14px 24px; /* Más padding */
  border-radius: 12px; /* Bordes más redondeados */
  font-weight: 600;
  border: 1px solid rgba(49, 199, 178, 0.2); /* Ajustar color de borde a la marca */
  background: linear-gradient(180deg, #31c7b2, #1ba895); /* Mantener colores de la empresa */
  color: #fff;
  box-shadow: 0 8px 22px rgba(49, 199, 178, 0.3); /* Sombra ajustada al color de la marca */
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  font-size: 16px;
}
.btn-primary-lg:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(49, 199, 178, 0.4); /* Sombra ajustada al color de la marca */
}
.btn-primary-lg:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(0.2);
}

/* Botón ghost grande (Editar parámetros) */
.btn-ghost-lg {
  padding: 14px 20px; /* Más padding */
  border-radius: 12px; /* Bordes más redondeados */
  font-weight: 600;
  border: 1px solid var(--border); /* Usar variable --border */
  background: var(--card); /* Usar variable --card */
  color: var(--text); /* Usar variable --text */
  box-shadow: 0 8px 22px rgba(16, 24, 40, 0.08); /* Sombra ligeramente más grande */
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  font-size: 16px;
}
.btn-ghost-lg:hover {
  background: var(--accent); /* Usar variable --accent para el hover */
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(16, 24, 40, 0.1);
}
:root.dark .btn-ghost-lg {
  border-color: #253056;
  background: #1a2140;
  color: #e5e7eb;
}

/* Ajuste en modo resultados */
.results-mode #form-container { 
  display: none; 
}

/* Que la gráfica ocupe más espacio cuando está en resultados */
.results-mode .chart-card canvas { 
  max-height: 520px; 
}
@media (max-width: 768px) {
  .results-mode .chart-card canvas { 
    max-height: 420px; 
  }
}

/* Menos hueco entre info-card y los KPIs */
.results-mode .info-card { 
  margin-bottom: 8px; 
}

/* Intro */
.intro-section{
  text-align:center;
  margin:40px auto 30px;
  max-width:720px;
  color:var(--text);
}
.intro-section h2{
  font-size:1.8rem;
  margin-bottom:12px;
}
.intro-section p{
  font-size:1rem;
  line-height:1.5;
  color:var(--muted);
  margin-bottom:20px;
}
.intro-img{
  max-width:380px;
  width:100%;
  height:auto;
  display:block;
  margin:0 auto;
}

/* Ocultar de inicio */
.hidden, .pdf-logo{ display:none !important; }

@media (min-width: 1600px){
  :root{ --sticky-offset: 520px; } /* 2K */
}
@media (min-width: 2000px){
  :root{ --sticky-offset: 580px; } /* 4K o muy alto */
}

/* Contenedor: dos columnas (imagen | formulario) y texto debajo */
.intro-wrapper {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 32px 48px; /* Más espacio entre columnas y filas */
  align-items: center;
  justify-content: center;
  max-width: 1280px;
  margin: 80px auto 60px; /* Ajustar margen inferior */
  padding: 0 24px;
}


/* Imagen más pequeña */
.intro-wrapper .intro-img {
  max-width: 220px; /* Ligeramente más grande */
  height: auto;
  display: block;
}

/* Que el formulario no quede tan abajo */
.intro-wrapper .form-card {
  margin: 0;
  max-width: 960px; /* más ancho */
  width: 100%;
}

/* Texto: ocupa toda la fila debajo (centrado) */
.intro-text {
  grid-column: 1 / -1;
  justify-self: center;
  text-align: center;
  max-width: 720px; /* Ligeramente más ancho */
  font-size: 1.05rem; /* Ligeramente más grande */
  line-height: 1.6; /* Mejor interlineado */
  color: var(--muted);
  margin-top: 12px; /* Más margen superior */
}

/* Responsive: en móvil todo apilado */
@media (max-width: 900px) {
  .intro-wrapper {
    grid-template-columns: 1fr;
    gap: 16px;
    margin: 1px auto 24px;  /* ↓ reduce el hueco solo en pantallas ≤900px */
  }
  .intro-text {
    grid-column: 1;
  }
  .intro-wrapper .intro-img {
    margin: 0 auto;
  }
}

/* ==== Mejora formulario SOLO móvil ==== */
@media (max-width: 600px){
  .form-card{
    padding: 16px;                /* + compacto en móvil */
  }
  .form-card .grid{
    grid-template-columns: 1fr 1fr; /* 2 columnas para el grid del formulario */
    gap: 10px;                    /* menos separación entre campos */
  }
  .field input,
  .field select{
    height: 52px;                 /* touch-target más cómodo */
    font-size: 16px;              /* evita zoom en iOS */
  }
  .primary{
    position: sticky;             /* botón siempre a mano */
    bottom: 12px;
    width: 100%;
    margin-top: 8px;
  }

  /* Quitar flechas en <input type="number"> (cross-browser) */
  input[type="number"]{
    appearance: textfield;        /* estándar */
    -moz-appearance: textfield;   /* Firefox */
  }
  input[type="number"]::-webkit-outer-spin-button,
  input[type="number"]::-webkit-inner-spin-button{
    -webkit-appearance: none;     /* Chrome, Safari */
    margin: 0;
  }

  /* Por defecto, cada .field ocupa las 2 columnas (una fila completa) */
  .form-card .grid .field{
    grid-column: 1 / -1;
  }

  /* EXCEPCIÓN: 3er y 4º campo (Huéspedes, Habitaciones) ocupan media fila cada uno */
  .form-card .grid .field:nth-child(3),
  .form-card .grid .field:nth-child(4){
    grid-column: auto; /* cada uno una columna */
  }

  /* Pequeños ajustes para ahorrar vertical */
  .field label{ margin-bottom: 4px; }
}

/* Botón "Volver" – versión pro */
.pill-btn{
  display:inline-flex;
  align-items:center;
  gap:8px;
  height:40px; /* Ligeramente más alto */
  padding:0 18px 0 14px; /* Más padding */
  border-radius:999px;
  font-weight:700;
  text-decoration:none;
  color:#111827;
  background:linear-gradient(180deg, #ffffff 0%, #f7f8fb 100%);
  border:1px solid #e5e7eb;
  box-shadow:0 6px 18px rgba(16,24,40,.06), inset 0 1px 0 rgba(255,255,255,.7);
  transition:transform .08s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
}
.pill-btn .btn-ic{ width:18px; height:18px; display:block; } /* Iconos ligeramente más grandes */

.pill-btn:hover{
  transform:translateY(-1px);
  box-shadow:0 10px 22px rgba(16,24,40,.10), inset 0 1px 0 rgba(255,255,255,.7);
  background:linear-gradient(180deg, #ffffff 0%, #f3f5f9 100%);
}
.pill-btn:active{
  transform:translateY(0);
  box-shadow:0 4px 12px rgba(16,24,40,.08);
  background:#f0f2f6;
}
.pill-btn:focus-visible{
  outline:none;
  border-color:#7f56d9;
  box-shadow:
    0 0 0 3px rgba(127,86,217,.18),
    0 8px 22px rgba(16,24,40,.12);
}

/* Dark theme */
:root.dark .pill-btn{
  color:#e5e7eb;
  background:linear-gradient(180deg, #1a2140 0%, #151c36 100%);
  border-color:#253056;
  box-shadow:0 10px 26px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.04);
}
:root.dark .pill-btn:hover{
  background:linear-gradient(180deg, #1f2748 0%, #182042 100%);
}
:root.dark .pill-btn:active{
  background:#1a2140;
}
:root.dark .pill-btn:focus-visible{
  border-color:#8b5cf6;
  box-shadow:
    0 0 0 3px rgba(139,92,246,.22),
    0 12px 30px rgba(0,0,0,.55);
}
/* === Normaliza Volver/Mapa para que midan como el selector de idioma === */
.top-actions .pill-btn{
  height:40px; /* Misma altura que el idioma */
  padding:0 14px; /* Padding compacto como el idioma */
  gap:8px; /* Separa icono y texto */
  font-size:15px; /* Igual que el idioma */
  font-weight:600;
  line-height:1;
}
.top-actions .pill-btn .btn-ic{ width:16px; height:16px; } /* Iconos ligeramente más grandes */
/* =======================
   Ajustes header en móvil
   ======================= */
@media (max-width: 640px) {
  .topbar {
    padding: 10px 12px;
    grid-template-columns: 1fr; /* apilar en 1 columna */
    row-gap: 12px;
    text-align: center;
  }

  .brand-left,
  .top-actions { justify-self: center; }

  /* forzamos el título al centro en móvil */
  .brand-center {
    grid-column: 1;      /* ya no 1 / -1 */
    text-align: center;
    justify-self: center;
  }

  .brand-center h1 { font-size: 20px; line-height: 1.2; margin-bottom: 2px; }
  .brand-center p  { font-size: 12px; }
  .logo-img        { width: 120px; }
  .top-actions     { gap: 8px; }
  .lang-dd__btn    { padding: 8px 28px 8px 10px; font-size: 13px; }
  .theme-toggle    { width: 32px; height: 32px; }
}

/* Ocultar el texto del idioma en la topbar, dejar solo la bandera */
.lang-dd__btn .lang-dd__label {
  display: none;
}

/* Asegura que el footer en /mapa se quede abajo */
main.map-shell {
  min-height: calc(100vh - 280px); /* ajusta el 340 según la altura de tu topbar+footer */
  display: flex;
  flex-direction: column;
}

main.map-shell #map {
  flex: 1; /* el mapa se expande para rellenar el espacio */
}

/* ==== Solo móvil: que el mapa NO dependa del flex (evita “tira” fina) ==== */
@media (max-width: 680px){
  main.map-shell{
    display: block;      /* deja de ser flex en móvil */
    min-height: auto;    /* sin altura mínima forzada */
  }
  main.map-shell #map{
    flex: none;          /* ignora el flex heredado */
    height: 70svh;       /* alto estable en móvil */
    min-height: 420px;   /* nunca más pequeño de esto */
  }
}

/* ==== Mejora visual de círculos del mapa (halo y hover) ==== */
.leaflet-interactive.city-dot {
  transition: r .15s ease, stroke-opacity .15s ease, fill-opacity .15s ease;
  stroke: #0b1f66; stroke-opacity: .45;
}
.leaflet-interactive.city-dot:hover {
  r: 16 !important;
  stroke-opacity: .65;
  cursor: pointer;
}

/* Botones Leaflet a juego */
.leaflet-control-zoom a{
  border-radius:10px !important;
}
/* ==== Botones de la toolbar (Reset, Mi ubicación, Descargar…) - versión pro ==== */
.map-toolbar .map-search,
.map-toolbar .map-select,
.map-toolbar .pill-ghost{
  height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid color-mix(in oklab, var(--border, #e5e7eb) 75%, transparent);
  background: linear-gradient(180deg, color-mix(in oklab, var(--card,#fff) 92%, transparent), var(--card,#fff));
  box-shadow: 0 6px 18px rgba(16,24,40,.06);
  transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease, background .2s ease;
}

/* Inputs */
.map-toolbar .map-search,
.map-toolbar .map-select{
  font-weight: 500;
}

/* “Ghost” buttons convertidos a pills sólidas sutiles */
.map-toolbar .pill-ghost{
  border: 1px solid color-mix(in oklab, #7c91ff 40%, transparent);
  background: linear-gradient(180deg, rgba(124,145,255,.08), rgba(124,145,255,.02));
  font-weight: 600;
}

/* Hover / focus */
.map-toolbar .map-search:hover,
.map-toolbar .map-select:hover,
.map-toolbar .pill-ghost:hover{
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(16,24,40,.10);
  border-color: color-mix(in oklab, #7c91ff 50%, transparent);
}

.map-toolbar .map-search:focus,
.map-toolbar .map-select:focus,
.map-toolbar .pill-ghost:focus{
  outline: 0;
  box-shadow: 0 0 0 3px color-mix(in oklab, #7c91ff 28%, transparent);
}

/* Active (tap/click) */
.map-toolbar .map-search:active,
.map-toolbar .map-select:active,
.map-toolbar .pill-ghost:active{
  transform: translateY(0);
  box-shadow: 0 6px 14px rgba(16,24,40,.08);
}

/* Iconitos con emoji (sin tocar el HTML) */
#btnReset::before{ content: "↺"; margin-right: .5rem; }
#btnLocate::before{ content: "📍"; margin-right: .5rem; }
#btnDownload::before{ content: "⬇️"; margin-right: .5rem; }

/* En móviles, que la toolbar respire y no “salte” de línea feo */
.map-toolbar{ gap: 12px; }
@media (max-width: 680px){
  .map-toolbar{ row-gap: 10px; }
  .map-toolbar .map-select{ min-width: 200px; }
}

/* ==== Controles Leaflet “glass” ==== */
.leaflet-control-zoom{
  border: 0 !important;
  box-shadow: none !important;
}
.leaflet-control-zoom a{
  width: 36px; height: 36px;
  border: 1px solid color-mix(in oklab, var(--border,#e5e7eb) 70%, transparent) !important;
  background: linear-gradient(180deg, rgba(255,255,255,.85), rgba(255,255,255,.65)) !important;
  backdrop-filter: blur(6px);
  color: #111827 !important;
  display: grid; place-items: center;
  border-radius: 12px !important;
  margin: 6px 10px !important;
  box-shadow: 0 8px 24px rgba(16,24,40,.10);
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease;
}
:root.dark .leaflet-control-zoom a{
  background: linear-gradient(180deg, rgba(30,41,59,.75), rgba(15,23,42,.65)) !important;
  color: #e5e7eb !important;
  border-color: color-mix(in oklab, #334155 70%, transparent) !important;
}
.leaflet-control-zoom a:hover{
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(16,24,40,.18);
}
.leaflet-control-zoom a:active{
  transform: translateY(0);
  box-shadow: 0 8px 22px rgba(16,24,40,.14);
}

/* Une los dos botones visualmente (pero redondeados) */
.leaflet-control-zoom-in{ border-bottom-left-radius: 12px !important; border-bottom-right-radius: 12px !important; }
.leaflet-control-zoom-out{ border-top-left-radius: 12px !important; border-top-right-radius: 12px !important; }

/* Mueve un poquito los controles para que no “toquen” los bordes */
.leaflet-top.leaflet-left{ top: 14px; left: 10px; }

/* ==== Leyenda con estilo pill (ya lo tienes parecido, le damos un “lift”) ==== */
.legend{
  border: 1px solid color-mix(in oklab, var(--border,#e5e7eb) 70%, transparent);
  box-shadow: 0 10px 24px rgba(16,24,40,.10);
  backdrop-filter: blur(4px);
}
/* Overlay temporal que solo se usa al exportar el mapa */
.map-export-header{
  position:absolute; left:14px; top:14px;
  background:rgba(255,255,255,.9);
  color:#0f172a;
  border:1px solid #e5e7eb;
  border-radius:10px;
  padding:10px 12px;
  box-shadow:0 6px 18px rgba(16,24,40,.10);
  max-width:min(90%, 520px);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
}
:root.dark .map-export-header{
  background:rgba(15,23,42,.85);
  color:#e5e7eb;
  border-color:#334155;
}
.map-export-title{ font-weight:800; font-size:14px; line-height:1.3; }
.map-export-note{ font-size:12px; opacity:.85; margin-top:4px; }
.map-export-footer{
  position:absolute; right:14px; bottom:14px;
  font-size:11px; opacity:.75;
  background:rgba(255,255,255,.9);
  color:#0f172a;
  border:1px solid #e5e7eb; border-radius:8px; padding:6px 8px;
}
:root.dark .map-export-footer{
  background:rgba(15,23,42,.85);
  color:#e5e7eb; border-color:#334155;
}

/* Microajuste desktop: subir y agrandar la calculadora */
@media (min-width: 901px){
  .intro-left { 
    align-self: start;         
  }
  .intro-left .intro-img{
    margin-top: -12px;          /* súbela un poco */
    max-width: 240px;           /* antes estaba en 190px → ahora más grande */
  }
}

/* === Microinteracciones modernas === */

/* Topbar fija con blur + sombra al hacer scroll */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  backdrop-filter: saturate(115%) blur(6px);
  -webkit-backdrop-filter: saturate(115%) blur(6px);
  background: rgba(255,255,255,.75);
  transition: box-shadow .25s ease, background-color .25s ease;
}
:root.dark .topbar { background: rgba(17,24,39,.65); }
.topbar.is-sticky { box-shadow: 0 10px 28px rgba(2,6,23,.12); } /* Sombra más pronunciada */

/* Scroll reveal (respeta reduced-motion) */
@media (prefers-reduced-motion: no-preference) {
  [data-reveal] { 
    opacity: 0; transform: translateY(12px) scale(.985);
    transition: opacity .45s ease, transform .45s ease;
  }
  .reveal-in { opacity: 1; transform: none; }
}

/* Hover sutil en tarjetas */
@media (hover:hover) {
  .kpi-card,
  #zona-datos .metric,
  .chart-card,
  .report-card {
    transition: transform .18s ease, box-shadow .18s ease;
    will-change: transform;
  }
.kpi-card:hover,
#zona-datos .metric:hover,
.chart-card:hover,
.report-card:hover {
    transform: translateY(-4px); /* Efecto hover más pronunciado */
    box-shadow: 0 14px 32px rgba(2,6,23,.1); /* Sombra más pronunciada */
  }
}

.privacy-block { margin-top: 12px; }
.contact-checkbox { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; line-height: 1.4; }
.contact-checkbox input { margin-top: 2px; }
.privacy-note { margin-top: 8px; font-size: 12px; line-height: 1.5; color: #6b7280; }

/* ===========================
   Estilos específicos de Analytics Dashboard
   =========================== */
.admin-container {
  max-width: 1200px;
  margin: 20px auto;
  padding: 0 20px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px; /* Bordes más redondeados */
  padding: 25px; /* Más padding */
  box-shadow: var(--shadow);
  text-align: center;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.stat-card:hover::before {
  transform: scaleX(1);
}

.stat-number {
  font-size: 2.5rem; /* Más grande */
  font-weight: 800; /* Más negrita */
  color: var(--primary);
  margin: 15px 0; /* Más margen */
  text-shadow: 0 2px 4px rgba(59, 130, 246, 0.1); /* Sombra de texto sutil */
}

.stat-label {
  color: var(--muted);
  font-size: 1rem; /* Más grande */
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 30px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background-color: var(--accent);
  font-weight: 600;
}

tr:hover {
  background-color: var(--accent);
}

.refresh-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 20px;
}

.refresh-btn:hover {
  background: var(--primary-dark); /* Necesitaríamos definir --primary-dark o usar color-mix */
}

.loading {
  text-align: center;
  padding: 20px;
}

.error {
  color: #e53e3e;
  background-color: rgba(229, 62, 62, 0.1);
  padding: 15px;
  border-radius: 8px;
  margin: 20px 0;
}

/* Estilos para el formulario de inicio de sesión */
.login-container {
  max-width: 450px;
  margin: 120px auto 60px;
  padding: 40px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  text-align: center;
  position: relative;
  overflow: hidden;
}

/* Estilos para centrar el login en la pantalla */
.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4edf9 100%);
  background-attachment: fixed;
}

.login-centered {
  width: 100%;
  margin: 0 !important;
}

.login-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), #4ade80, var(--primary));
  background-size: 200% 100%;
  animation: gradient 3s ease-in-out infinite;
}

@keyframes gradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

.login-header {
  margin-bottom: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-header h2 {
  color: var(--primary);
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 8px 0;
}

.login-header p {
  color: var(--muted);
  font-size: 16px;
  margin: 0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

.login-form input {
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 16px;
  transition: all 0.3s ease;
  background: var(--background);
  color: var(--text);
}

.login-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  transform: translateY(-2px);
}

.login-form input::placeholder {
  color: var(--muted);
}

.login-form button {
  padding: 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.login-form button:hover {
  background: var(--primary-dark); /* Necesitaríamos definir --primary-dark o usar color-mix */
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(59, 130, 246, 0.2);
}

.login-form button:active {
  transform: translateY(0);
}

.login-form button::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.login-form button:active::after {
  width: 300px;
  height: 300px;
}

.hidden {
  display: none;
}

/* Estilos para las gráficas */
.chart-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 25px;
  box-shadow: var(--shadow);
  margin-bottom: 30px;
  height: 450px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chart-container:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

/* Estilos para el logo */
.logo-img {
  max-width: 200px;
  margin-bottom: 20px;
  transition: transform 0.3s ease;
}

.logo-img:hover {
  transform: scale(1.05);
}
