* { box-sizing: border-box; }
.hidden { display: none !important; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #ffffff;
  color: #1c2b22;
  display: flex;
  flex-direction: column;
  overscroll-behavior: none;
  overflow-x: hidden;
}
button, select, input { font: inherit; }
button:focus-visible, select:focus-visible, input:focus-visible,
.assistant-history-item:focus-visible {
  outline: 3px solid rgba(47, 143, 82, 0.38);
  outline-offset: 2px;
}
header {
  flex-shrink: 0;
  padding: 14px 24px;
  background: #ffffff;
  border-bottom: 1px solid #dfe7e2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
header h1 { margin: 0; font-size: 1.15rem; color: #1f7a43; }
header p { margin: 2px 0 0; font-size: 0.82rem; color: #5b6d64; }

/* Botón hamburguesa: oculto en escritorio, se muestra en el media query móvil */
.mobile-menu-btn {
  display: none;
  --btn-bg: transparent;
  --btn-fg: #1f7a43;
  --btn-hover-bg: #f0f4f1;
  --btn-hover-fg: #1f7a43;
  background: transparent;
  color: #1f7a43;
  border: 1px solid #cddcd3;
  border-radius: 8px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  font-size: 1.3rem;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
}
.menu-icon {
  width: 24px;
  height: 20px;
  display: inline-flex;
  flex-direction: column;
  justify-content: space-between;
}
.menu-icon span {
  display: block;
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
  transition: transform .2s ease, opacity .2s ease;
}
.mobile-menu-btn[aria-expanded="true"] .menu-icon span:nth-child(1) { transform: translateY(8.5px) rotate(45deg); }
.mobile-menu-btn[aria-expanded="true"] .menu-icon span:nth-child(2) { opacity: 0; }
.mobile-menu-btn[aria-expanded="true"] .menu-icon span:nth-child(3) { transform: translateY(-8.5px) rotate(-45deg); }
body.logged-out .app-menu-trigger,
body.logged-out .sidebar-backdrop { display: none !important; }

/* ---- Usuario / logout en el header ---- */
.header-actions { display: flex; align-items: center; gap: 14px; }
.header-actions > button { padding: 8px 12px; }
body.logged-out #btnMapas { display: none; }
#btnMapas.is-active {
  --btn-bg: #e3f3e8;
  --btn-fg: #1f7a43;
  --btn-hover-bg: #d7eee0;
  --btn-hover-fg: #1f7a43;
  background: #e3f3e8;
  color: #1f7a43;
  border-color: #9ecfb0;
}

.mapas-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.mapas-secciones {
  display: flex;
  flex-wrap: wrap;
  border-bottom: 1px solid #dfe7e2;
  background: #f7fbf8;
}
.mapas-secciones button {
  flex: 1 1 160px;
  min-height: 52px;
  padding: 8px 12px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #3d5c4a;
  font-weight: 700;
  --btn-bg: transparent;
  --btn-fg: #3d5c4a;
  --btn-hover-bg: #eef6f1;
  --btn-hover-fg: #14552f;
}
.mapas-secciones button small {
  display: block;
  margin-top: 2px;
  font-size: .72rem;
  font-weight: 600;
  color: #5b6d64;
}
.mapas-secciones button.is-active {
  background: #fff;
  color: #14552f;
  border-bottom-color: #1f7a43;
  --btn-bg: #fff;
  --btn-fg: #14552f;
}
.mapas-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.mapas-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
}
.mapas-head h2 { margin: 0; color: #1f7a43; font-size: 1.05rem; }
.mapas-head p { margin: 2px 0 0; color: #5b6d64; font-size: .82rem; }
.mapas-head a {
  flex-shrink: 0;
  color: #1f7a43;
  font-weight: 700;
  font-size: .85rem;
}
.mapas-frame-wrap {
  position: relative;
  flex: 1;
  min-height: 320px;
  background: #eef4f0;
}
#mapasCarga {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 12px;
  right: 12px;
  max-width: 420px;
}
#mapasFrame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #eef4f0;
}
.label-short { display: none; }
.user-badge { display: flex; align-items: center; gap: 10px; }
.user-badge img { width: 32px; height: 32px; border-radius: 50%; }
.user-badge .user-name { font-size: 0.85rem; color: #33453a; font-weight: 600; }
.user-badge button { padding: 7px 12px; font-size: 0.82rem; }

.app { flex: 1; display: flex; min-height: 0; position: relative; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }

.sidebar-backdrop { display: none; }

.sidebar {
  width: 250px;
  flex-shrink: 0;
  border-right: 1px solid #dfe7e2;
  background: #fafcfa;
  padding: 16px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: #8a9a91; padding: 0 10px 8px; }
.sidebar-new-chat {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; margin-bottom: 10px;
  border-radius: 10px; border: 1px solid #2f8f52;
  --btn-bg: #2f8f52;
  --btn-fg: #fff;
  --btn-hover-bg: #26773f;
  --btn-hover-fg: #fff;
  background: #2f8f52; color: #fff; font-weight: 600; font-size: 0.88rem;
}
.sidebar-section { margin-bottom: 14px; }
.sidebar-section-title {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: #8a9a91;
  padding: 4px 10px 8px;
}
.assistant-history-list { display: flex; flex-direction: column; gap: 5px; }
.assistant-history-item-wrapper { display: flex; align-items: center; gap: 4px; }
.assistant-history-item {
  flex: 1; min-width: 0; min-height: 42px; padding: 9px 10px; text-align: left;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  --btn-bg: transparent; --btn-fg: #50655a; --btn-hover-bg: #e3f3e8; --btn-hover-fg: #1f7a43;
  background: transparent; color: #50655a; font-size: .82rem; border-radius: 8px;
}
.assistant-history-item.active {
  --btn-bg: #e3f3e8; --btn-fg: #1f7a43; --btn-hover-bg: #e3f3e8; --btn-hover-fg: #1f7a43;
  background: #e3f3e8; color: #1f7a43;
}
.assistant-history-actions { display: flex; gap: 2px; flex-shrink: 0; }
.assistant-history-edit, .assistant-history-delete {
  width: 32px; min-height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;
  --btn-bg: transparent; --btn-fg: #8a9a91; --btn-hover-bg: #e3f3e8; --btn-hover-fg: #1f7a43;
  background: transparent; color: #8a9a91; border: none; border-radius: 6px; font-size: 0.9rem; cursor: pointer;
}
.assistant-history-delete { --btn-hover-bg: #fde8e8; --btn-hover-fg: #c0392b; }

/* Animación de entrada */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeSlideIn 0.32s ease; }

.view { flex: 1; min-height: 0; display: none; flex-direction: column; }
.view.active { display: flex; }

/* Sub-pantallas tipo "card" centrada */
.subscreen { flex: 1; min-height: 0; display: none; overflow-y: auto; }
.subscreen.active { display: block; }
.center-wrap { max-width: 760px; margin: 0 auto; padding: 40px 20px 60px; }
.map-screen .center-wrap { max-width: 1440px; width: 100%; }
.center-wrap h2 { color: #1f7a43; font-size: 1.15rem; margin-bottom: 4px; }
.center-wrap .sub { color: #5b6d64; font-size: 0.88rem; margin-bottom: 24px; }
.ndvi-workspace-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(300px, 520px) minmax(280px, 1fr);
  grid-template-areas: "panel map";
  gap: 12px 16px;
  align-items: start;
}
.ndvi-options-toggle {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 4;
  min-height: 44px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #cddcd3;
  border-radius: 10px;
  --btn-bg: #ffffff;
  --btn-fg: #1f7a43;
  --btn-hover-bg: #e3f3e8;
  --btn-hover-fg: #14552f;
  background: #ffffff;
  color: #1f7a43;
  box-shadow: 0 2px 8px rgba(28,67,42,.12);
}
/* El control de detalles del mapa es el único menú para abrir/cerrar las
   opciones NDVI. Evita duplicar un segundo botón sobre el mapa. */
.ndvi-options-toggle { display: none !important; }
#ndviMapWrapper .map-toolbar {
  position: static;
  top: auto;
  right: auto;
  left: auto;
  z-index: auto;
  width: auto;
  min-width: 0;
  max-width: 100%;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}
#ndviMapWrapper .map-toolbar > button {
  height: 48px;
  min-height: 48px;
  border-radius: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  gap: 6px;
  padding: 0 12px;
  width: auto;
}
.map-btn-icon {
  font-size: 1.05rem;
  line-height: 1;
}
.map-btn-label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .01em;
  line-height: 1.1;
}
.tool-bar-back .map-btn-label { display: none; }
.tool-bar-back .map-btn-label-full { display: inline; }
#ndviMapWrapper #btnMapOnlyNdvi {
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  width: auto;
  min-width: 0;
  padding: 0 12px;
  gap: 6px;
  white-space: nowrap;
}
#ndviMapWrapper #btnNdviOptions {
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  width: auto;
  min-width: 0;
  padding: 0 12px;
  gap: 6px;
  white-space: nowrap;
  --btn-bg: #176b39;
  --btn-fg: #ffffff;
  --btn-hover-bg: #14552f;
  --btn-hover-fg: #ffffff;
  background: #176b39;
  color: #ffffff;
  border-color: #176b39;
}
#ndviMapWrapper #btnNdviOptions.is-map-hidden {
  display: none !important;
}
#ndviMapWrapper #btnNdviOptions:focus-visible {
  background: #14552f;
}
.ndvi-back-map-btn {
  display: none;
  width: 100%;
  min-height: 48px;
  margin: 0 0 8px;
  padding: 0 16px;
  align-items: center;
  justify-content: center;
  border: 1px solid #cddcd3;
  border-radius: 8px;
  --btn-bg: #ffffff;
  --btn-fg: #33453a;
  --btn-hover-bg: #f0f4f1;
  --btn-hover-fg: #1f7a43;
  background: #ffffff;
  color: #33453a;
  box-shadow: 0 1px 4px rgba(0,0,0,.12);
  font-weight: 600;
}
.ndvi-back-map-btn:focus-visible { background: #f0f4f1; color: #1f7a43; }
#ndviMapWrapper #btnMapOnlyNdvi span:first-child {
  font-size: 1.2rem;
  line-height: 1;
}
.ndvi-options-toggle:focus-visible {
  background: #e3f3e8;
  color: #14552f;
}
.ndvi-options-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}
.ndvi-options-collapsed > :not(.map-wrapper):not(.ndvi-options-toggle) {
  display: none !important;
}
.ndvi-workspace-card > .ndvi-panel {
  grid-area: panel;
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  z-index: 2;
  container: ndvi-panel / inline-size;
}
.ndvi-secciones {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border: 0;
  background: transparent;
}
.ndvi-secciones button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 10px 8px;
  border: 1px solid #d7e3dc;
  border-radius: 10px;
  --btn-bg: #fff;
  --btn-fg: #33453a;
  --btn-hover-bg: #e3f3e8;
  --btn-hover-fg: #14552f;
  background: #fff;
  color: #33453a;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .02em;
  line-height: 1.2;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: none;
}
.ndvi-secciones button.is-active,
.ndvi-secciones button.is-active:active {
  --btn-bg: #176b39;
  --btn-fg: #fff;
  --btn-hover-bg: #14552f;
  --btn-hover-fg: #fff;
  background: #176b39;
  color: #fff;
  border-color: #176b39;
}
.ndvi-secciones button:hover:not(.is-active) {
  background: #e3f3e8;
  color: #14552f;
}
.ndvi-secciones button:focus-visible {
  outline: 2px solid #176b39;
  outline-offset: 2px;
}
/* Si la columna no alcanza para la fila completa, cada opción ocupa la mitad. */
@container ndvi-panel (max-width: 720px) {
  .ndvi-secciones button {
    flex: 1 1 calc(50% - 8px);
    min-width: calc(50% - 8px);
    padding: 12px 10px;
  }
  .ndvi-secciones button:last-child {
    flex: 1 1 100%;
    min-width: 100%;
  }
}
.ndvi-seccion {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.ndvi-seccion[hidden] { display: none !important; }
.ndvi-seccion .map-search,
.ndvi-seccion .coordinate-entry,
.ndvi-seccion .actions { margin: 0; }
.ndvi-seccion .ndvi-lot-save { margin: 0; padding: 0; border: 0; }
.ndvi-workspace-card > .map-wrapper {
  grid-area: map;
  min-width: 0;
  position: sticky;
  top: 12px;
  z-index: 1;
  overflow: hidden;
  border-radius: 12px;
  align-self: start;
}
.ndvi-workspace-card #map-ndvi {
  height: min(72vh, 720px);
  min-height: 480px;
}

/* Computadora y tablet: el análisis ocupa el alto de la pantalla.
   El panel izquierdo se desplaza si no entra; el mapa llena el resto. */
@media (min-width: 769px) {
  #view-ndvi.tool-overlay-open {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }
  #view-ndvi.tool-overlay-open > .tool-bar { flex-shrink: 0; }
  #view-ndvi.tool-overlay-open > .map-screen {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  #view-ndvi .center-wrap {
    flex: 1;
    min-height: 0;
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 8px 16px 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  #view-ndvi .center-wrap > h2 {
    margin: 0 0 2px;
    flex-shrink: 0;
  }
  #view-ndvi .center-wrap > .sub {
    margin: 0 0 8px;
    flex-shrink: 0;
  }
  #view-ndvi #ndviCard {
    flex: 1;
    min-height: 0;
    align-items: stretch;
    grid-template-rows: minmax(0, 1fr);
    overflow: hidden;
  }
  #view-ndvi .ndvi-workspace-card > .ndvi-panel {
    min-height: 0;
    overflow: auto;
  }
  #view-ndvi .ndvi-secciones {
    position: sticky;
    top: 0;
    z-index: 6;
    flex-shrink: 0;
    background: #fff;
  }
  #view-ndvi .ndvi-workspace-card > .map-wrapper {
    align-self: stretch;
    position: relative;
    top: auto;
    height: 100%;
    min-height: 0;
  }
  #view-ndvi .ndvi-workspace-card #map-ndvi {
    height: 100%;
    min-height: 0;
    margin: 0;
  }

  #view-gps.tool-overlay-open,
  #view-prospeccion.tool-overlay-open {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }
  #view-gps.tool-overlay-open > .tool-bar,
  #view-prospeccion.tool-overlay-open > .tool-bar { flex-shrink: 0; }
  #view-gps.tool-overlay-open > .map-screen,
  #view-prospeccion.tool-overlay-open > .map-screen {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  #view-gps .center-wrap,
  #view-prospeccion .center-wrap {
    flex: 1;
    min-height: 0;
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 8px 16px 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  #view-gps .center-wrap > h2,
  #view-prospeccion .center-wrap > h2 {
    margin: 0 0 2px;
    flex-shrink: 0;
  }
  #view-gps .center-wrap > .sub,
  #view-prospeccion .center-wrap > .sub {
    margin: 0 0 8px;
    flex-shrink: 0;
  }
  #view-gps .gps-workspace,
  #view-prospeccion .prospect-workspace {
    flex: 1;
    min-height: 0;
    align-items: stretch;
    overflow: hidden;
    grid-template-rows: minmax(0, 1fr);
  }
  #view-gps .gps-workspace {
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  }
  #view-gps .gps-panel,
  #view-prospeccion .prospect-panel {
    min-height: 0;
    max-height: none;
    overflow: hidden;
  }
  #view-gps .gps-panel { overflow: auto; }
  #view-prospeccion .prospect-body,
  #view-prospeccion .prospect-form.is-active,
  #view-prospeccion .prospect-seccion-scroll {
    flex: 1;
    min-height: 0;
  }
  #view-prospeccion .prospect-seccion-scroll { overflow: auto; }
  #view-gps #gpsMapWrapper,
  #view-prospeccion #prospectMapWrapper {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    height: 100%;
    position: relative;
  }
  #view-gps #map-gps,
  #view-prospeccion #map-prospect {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    margin: 0;
  }
  #view-prospeccion .prospect-ha-summary { flex-shrink: 0; margin-top: 8px; }
}

.card {
  background: #ffffff;
  border: 1px solid #dfe7e2;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(28, 67, 42, 0.08);
}

label { display: block; font-size: 0.85rem; color: #5b6d64; margin: 4px 0 6px; }
select, input[type=text] {
  width: 100%;
  background: #ffffff;
  color: #1c2b22;
  border: 1px solid #cddcd3;
  border-radius: 6px;
  padding: 10px 12px;
  min-height: 44px;
  font-size: 0.95rem;
  margin-bottom: 16px;
  -webkit-appearance: none;
}

button {
  --btn-bg: #2f8f52;
  --btn-fg: #fff;
  --btn-hover-bg: #257a43;
  --btn-hover-fg: #fff;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: none;
  padding: 11px 20px;
  min-height: 44px;
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
}
button:disabled {
  --btn-bg: #d7e3da;
  --btn-fg: #5f7066;
  cursor: not-allowed;
}
button:active:not(:disabled) {
  background: var(--btn-hover-bg);
  color: var(--btn-hover-fg);
}
button.secondary {
  --btn-bg: transparent;
  --btn-fg: #5b6d64;
  --btn-hover-bg: #f0f4f1;
  --btn-hover-fg: #5b6d64;
  border: 1px solid #cddcd3;
}
button.icon-btn {
  --btn-bg: #f0f4f1;
  --btn-fg: #33453a;
  --btn-hover-bg: #e3ece6;
  --btn-hover-fg: #33453a;
  padding: 10px 14px;
}
.actions { display: flex; justify-content: space-between; margin-top: 20px; gap: 10px; }
.actions.end { justify-content: flex-end; }

/* ---- Buscador de ubicaciones (Nominatim) sobre los mapas ---- */
.map-search { position: relative; margin-bottom: 12px; }
.map-search input[type=text] { margin-bottom: 0; }
.coordinate-entry {
  margin: 0 0 12px;
  padding: 10px 12px;
  background: #f4f7f5;
  border: 1px solid #dfe7e2;
  border-radius: 8px;
}
.coordinate-entry label { margin: 0 0 6px; font-weight: 600; }
.coordinate-row { display: flex; gap: 8px; align-items: center; }
.coordinate-row input[type=number],
.coordinate-row input.coordinate-input {
  margin: 0;
  min-width: 0;
  flex: 1;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #cddcd3;
  border-radius: 6px;
  background: #fff;
  color: #1c2b22;
}
.coordinate-row button { flex-shrink: 0; white-space: nowrap; }
.coordinate-error { min-height: 0; color: #c0392b; font-size: .8rem; margin-top: 5px; }
.search-results {
  display: none;
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: #ffffff;
  border: 1px solid #cddcd3;
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 240px;
  overflow-y: auto;
  z-index: 1200;
  box-shadow: 0 6px 14px rgba(0,0,0,0.1);
}
.location-result-item {
  padding: 11px 12px;
  font-size: 0.85rem;
  color: #33453a;
  cursor: pointer;
  border-bottom: 1px solid #eef4f0;
}
.location-result-item:last-child { border-bottom: none; }
.location-result-empty { padding: 11px 12px; font-size: 0.85rem; color: #8a9a91; }

#map, #map-ndvi, #map-prospect, #map-gps {
  height: clamp(500px, 64vh, 760px);
  min-height: 420px;
  border-radius: 8px;
  border: 1px solid #dfe7e2;
  margin-bottom: 12px;
  z-index: 1;
}
#btnCrearLoteMapa[hidden] { display: none !important; }
.map-fullscreen-btn {
  position: absolute;
  top: 10px; right: 10px;
  z-index: 1000;
  width: 44px; height: 44px; min-width: 44px; min-height: 44px;
  padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  --btn-bg: #ffffff;
  --btn-fg: #33453a;
  --btn-hover-bg: #f0f4f1;
  --btn-hover-fg: #33453a;
  background: #ffffff;
  color: #33453a;
  border: 1px solid #dfe7e2;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
  font-size: 1.15rem;
}
.map-toolbar {
  position: absolute;
  top: 10px; right: 10px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.map-toolbar .map-fullscreen-btn {
  position: static;
  width: auto;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0 10px;
  gap: 6px;
}

/* Vértices de edición redondos y fáciles de seleccionar con el dedo. */
.leaflet-marker-icon.leaflet-editing-icon {
  width: 12px !important;
  height: 12px !important;
  margin-left: -6px !important;
  margin-top: -6px !important;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #2f8f52;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}

/* El control de detalles no debe convertir el mapa en pantalla completa. */
#ndviCard.ndvi-details-hidden > .ndvi-panel {
  display: none !important;
}
#ndviCard.ndvi-details-hidden > .ndvi-options-toggle {
  display: none !important;
}

/* En el modo compacto del NDVI se conserva únicamente el mapa y la barra
   superior derecha; los controles Leaflet se restauran con el botón de detalles. */
#ndviMapWrapper.ndvi-controls-hidden .leaflet-top.leaflet-left .leaflet-control:not(.leaflet-draw):not(.ndvi-tipo-control):not(.ndvi-overlay-toggle),
#ndviMapWrapper.ndvi-controls-hidden .leaflet-control-zoom {
  display: none;
}
.is-drawing-lote .leaflet-overlay-pane,
#map-ndvi.is-drawing-lote .leaflet-overlay-pane,
#map-ndvi.is-drawing-lote .ndviImagePane,
#map-ndvi.is-drawing-lote .ndviMaskPane,
#map-ndvi.is-drawing-lote .ndviImagePane img {
  pointer-events: none !important;
}
#ndviMapWrapper.ndvi-controls-hidden .leaflet-control-layers,
#ndviMapWrapper.ndvi-controls-hidden #btnFullscreenNdvi {
  display: none;
}
#ndviMapWrapper.ndvi-controls-hidden #btnMapOnlyNdvi {
  display: inline-flex !important;
}
#agricolaMapWrapper.map-controls-hidden .leaflet-top.leaflet-left,
#agricolaMapWrapper.map-controls-hidden .leaflet-control-layers,
#agricolaMapWrapper.map-controls-hidden #btnFullscreenAgricola {
  display: none;
}

/* El botón de detalles vive dentro del mapa y permanece visible para
   recuperar los formularios y resultados ocultos. */
#agricolaMapCard.map-details-hidden > .map-search,
#agricolaMapCard.map-details-hidden > .coordinate-entry,
#agricolaMapCard.map-details-hidden > .coords,
#agricolaMapCard.map-details-hidden > .actions {
  display: none !important;
}

/* El control de capas comparte la esquina superior derecha con las
   herramientas de pantalla completa. Lo desplazamos debajo de ellas para
   mantener ambos controles accesibles en escritorio y móvil. */
#agricolaMapWrapper .leaflet-top.leaflet-right {
  top: 66px;
  right: 10px;
}
#agricolaMapWrapper .leaflet-top.leaflet-right .leaflet-control-layers {
  margin-top: 0;
}
#ndviMapWrapper .leaflet-top.leaflet-right {
  top: 66px;
  right: 10px;
}
#ndviMapWrapper .leaflet-top.leaflet-right .leaflet-control-layers {
  margin-top: 0;
}
#ndviCarga {
  position: absolute;
  z-index: 700;
  left: 50%;
  top: 54%;
  transform: translate(-50%, -50%);
  width: min(380px, calc(100% - 28px));
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  box-sizing: border-box;
}
#ndviCarga .ndvi-carga-caja {
  pointer-events: auto;
  width: 100%;
  max-height: 100%;
  overflow: auto;
}
.ndvi-carga-cancelar,
.ndvi-carga-confirm { margin-top: 12px; }
.ndvi-carga-confirm {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ndvi-carga-confirm p {
  margin: 0;
  font-size: .88rem;
  font-weight: 600;
  color: #173526;
  line-height: 1.35;
}
.ndvi-carga-caja .ndvi-carga-cancelar,
.ndvi-carga-confirm button { width: 100%; }
.ndvi-carga-caja .ndvi-carga-cancelar-si {
  --btn-bg: #a33b32;
  --btn-fg: #fff;
  --btn-hover-bg: #8c3129;
  --btn-hover-fg: #fff;
  background: #a33b32;
  color: #fff;
}
#ndviCarga[hidden] { display: none !important; }
.ndvi-carga-caja {
  background: rgba(255,255,255,.97);
  border: 1px solid #dfe7e2;
  border-radius: 14px;
  padding: 14px 14px 12px;
  box-shadow: 0 10px 28px rgba(28,67,42,.18);
}
.ndvi-carga-caja > p {
  margin: 0 0 10px;
  font-weight: 700;
  color: #176b39;
}
.ndvi-carga-conteo {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f3faf6;
  color: #14552f;
  font-size: .92rem;
  font-weight: 700;
  line-height: 1.35;
}
.ndvi-carga-conteo b { font-variant-numeric: tabular-nums; }
.ndvi-carga-conteo span {
  display: block;
  margin-top: 2px;
  font-size: .78rem;
  font-weight: 600;
  color: #3d5c4a;
}
.ndvi-carga-pasos {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ndvi-carga-pasos li {
  display: grid;
  grid-template-columns: 12px 1fr;
  grid-template-rows: auto 6px;
  column-gap: 8px;
  row-gap: 4px;
  align-items: center;
  color: #8a9a91;
  font-size: .84rem;
}
.ndvi-carga-pasos li i {
  grid-column: 1 / -1;
  height: 6px;
  border-radius: 99px;
  background: #e4eee8;
}
.ndvi-carga-marca {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d5e4db;
}
.ndvi-carga-pasos li.is-done { color: #1f7a43; font-weight: 700; }
.ndvi-carga-pasos li.is-done i { background: #1f7a43; }
.ndvi-carga-pasos li.is-done .ndvi-carga-marca { background: #1f7a43; }
.ndvi-carga-pasos li.is-active { color: #14552f; font-weight: 700; }
.ndvi-carga-pasos li.is-active .ndvi-carga-marca {
  background: #176b39;
  box-shadow: 0 0 0 4px rgba(23,107,57,.18);
}
.ndvi-carga-pasos li.is-active i {
  background: linear-gradient(90deg, #176b39 0 45%, #d7e8de 45% 100%);
  background-size: 220% 100%;
  animation: ndvi-carga-mover 1.1s linear infinite;
}
@keyframes ndvi-carga-mover {
  from { background-position: 80% 0; }
  to { background-position: -80% 0; }
}
#ndviMapWrapper .ndvi-map-badge {
  position: absolute;
  left: max(10px, env(safe-area-inset-left));
  right: auto;
  /* Por encima del botón de ubicación (esquina inferior izquierda),
     sin pisar la atribución del mapa. */
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: max-content;
  max-width: min(520px, calc(100vw - 40px));
  background: rgba(15, 42, 28, .9);
  color: #eaf7ee;
  font-weight: 700;
  font-size: .8rem;
  line-height: 1.25;
  padding: 8px 12px;
  border-radius: 8px;
  pointer-events: none;
  box-shadow: 0 2px 10px rgba(0,0,0,.28);
  letter-spacing: .02em;
}
#ndviMapWrapper .ndvi-map-badge.is-pending {
  background: rgba(110, 72, 12, .92);
}
#ndviMapWrapper .ndvi-map-badge-lote {
  font-size: .86rem;
}
#ndviMapWrapper .ndvi-map-badge-fecha {
  font-size: .75rem;
  font-weight: 600;
  opacity: .92;
}
#ndviMapWrapper:has(.ndvi-map-legend:not([hidden])) .ndvi-map-badge {
  max-width: min(520px, calc(100% - 168px));
}
#ndviMapWrapper .ndvi-map-legend {
  position: absolute;
  right: max(8px, env(safe-area-inset-right));
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: max-content;
  max-width: 168px;
  padding: 6px 8px 7px;
  background: rgba(255, 255, 255, .94);
  color: #1c2b22;
  border-radius: 6px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .28);
  pointer-events: none;
}
#ndviMapWrapper .ndvi-map-legend[hidden] { display: none !important; }
#ndviMapWrapper .ndvi-map-legend-titulo {
  margin: 0;
  font-size: .75rem;
  font-weight: 700;
  line-height: 1.2;
}
#ndviMapWrapper .ndvi-map-legend-cuerpo {
  display: flex;
  align-items: stretch;
  gap: 6px;
  height: 96px;
}
#ndviMapWrapper .ndvi-map-legend-barra {
  flex: 0 0 14px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, .18);
}
#ndviMapWrapper .ndvi-map-legend-marcas {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  font-size: .68rem;
  font-weight: 700;
  line-height: 1.15;
}
#ndviMapWrapper .ndvi-map-legend-alto,
#ndviMapWrapper .ndvi-map-legend-bajo {
  display: block;
}
#ndviMapWrapper .ndvi-map-chrome {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  z-index: 1400;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: start;
  gap: 8px 12px;
  pointer-events: none;
}
#ndviMapWrapper .ndvi-map-chrome-left,
#ndviMapWrapper .ndvi-map-chrome-right,
#ndviMapWrapper .ndvi-fecha-mapa {
  pointer-events: auto;
  min-width: 0;
}
#ndviMapWrapper .ndvi-map-chrome-left {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "zoom tipos"
    "draw tipos";
  align-items: start;
  justify-content: start;
  gap: 8px;
}
#ndviMapWrapper .ndvi-map-chrome-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
#ndviMapWrapper .ndvi-map-chrome-side {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  max-width: 100%;
  pointer-events: auto;
}
#ndviMapWrapper .ndvi-map-chrome .leaflet-control,
#ndviMapWrapper .ndvi-map-chrome-side .ndvi-overlay-toggle {
  float: none;
  clear: none;
  margin: 0;
}
#ndviChromeLeft .leaflet-control-zoom { grid-area: zoom; justify-self: start; }
#ndviChromeLeft .ndvi-tipo-switch {
  grid-area: tipos;
  align-self: center;
  max-width: 100%;
  min-width: 0;
  margin-bottom: 0;
}
#ndviChromeLeft .leaflet-draw {
  grid-area: draw;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 0;
  box-shadow: none;
}
#ndviChromeLeft .leaflet-draw-toolbar { margin: 0; }
#ndviMapWrapper .ndvi-fecha-mapa {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  transform: none;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-self: center;
  width: max-content;
  max-width: 100%;
  pointer-events: none;
}
#ndviMapWrapper .ndvi-fecha-pill,
#ndviMapWrapper .ndvi-fecha-popover { pointer-events: auto; }
#ndviMapWrapper .ndvi-fecha-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: #1c1c1c;
  color: #fff;
  border-radius: 999px;
  padding: 3px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .35);
}
#ndviMapWrapper .ndvi-fecha-pill button {
  --btn-bg: transparent;
  --btn-fg: #fff;
  --btn-hover-bg: rgba(255, 255, 255, .16);
  --btn-hover-fg: #fff;
  background: transparent;
  color: #fff;
  border: 0;
  min-height: 36px;
  padding: 0 8px;
  border-radius: 999px;
  box-shadow: none;
}
#ndviMapWrapper .ndvi-fecha-pill button:hover:not(:disabled),
#ndviMapWrapper .ndvi-fecha-pill button:active:not(:disabled) {
  background: rgba(255, 255, 255, .16);
  color: #fff;
}
#ndviMapWrapper .ndvi-fecha-pill button:disabled {
  --btn-bg: transparent;
  --btn-fg: rgba(255, 255, 255, .35);
  background: transparent;
  color: rgba(255, 255, 255, .35);
}
#ndviMapWrapper .ndvi-fecha-paso {
  width: 34px;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
}
#ndviMapWrapper .ndvi-fecha-dia {
  font-weight: 700;
  white-space: nowrap;
  padding: 0 6px;
}
#ndviMapWrapper .ndvi-fecha-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: min(360px, calc(100vw - 32px));
  max-height: min(68vh, 520px);
  overflow: auto;
  background: #fff;
  color: #173526;
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .28);
}
#ndviMapWrapper .ndvi-fecha-popover[hidden] { display: none !important; }
#ndviMapWrapper { container-type: inline-size; }

/* El mapa angosto no alcanza para fecha, tipos y botones en una sola fila.
   Se apilan para que ninguno tape al otro. En un mapa ancho sigue la fila. */
@container (max-width: 980px) {
  #ndviMapWrapper .ndvi-map-chrome {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "fecha fecha"
      "tools tools"
      "left side";
    align-items: start;
    gap: 8px;
  }
  #ndviMapWrapper .ndvi-fecha-mapa {
    grid-area: fecha;
    order: unset;
    align-self: center;
    justify-self: center;
    width: max-content;
    max-width: 100%;
  }
  #ndviMapWrapper .ndvi-map-chrome-right { display: contents; }
  #ndviMapWrapper .ndvi-map-chrome-left {
    grid-area: left;
    order: unset;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    grid-template-areas:
      "zoom tipos"
      "draw tipos";
    width: 100%;
    justify-content: stretch;
    gap: 8px;
  }
  #ndviMapWrapper .ndvi-map-chrome-side {
    grid-area: side;
    align-self: start;
    width: auto;
    max-width: 46%;
    justify-content: flex-end;
  }
  #ndviChromeLeft .leaflet-control-zoom { grid-area: zoom; justify-self: start; }
  #ndviChromeLeft .ndvi-tipo-switch {
    grid-area: tipos;
    align-self: start;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
  }
  #ndviChromeLeft .ndvi-tipo-item { flex: 0 1 auto; width: auto; max-width: 100%; }
  #ndviChromeLeft .leaflet-draw {
    grid-area: draw;
    flex-direction: column;
    width: 36px;
  }
  #view-ndvi #ndviMapWrapper .ndvi-map-chrome .map-toolbar {
    grid-area: tools;
    position: static;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
    max-width: 100%;
    gap: 6px;
  }
  #view-ndvi #ndviMapWrapper .ndvi-map-chrome .map-toolbar > button {
    width: 100%;
    min-width: 0;
    height: 44px;
    min-height: 44px;
    padding: 0;
  }
  #view-ndvi #ndviMapWrapper .ndvi-map-chrome .map-toolbar > button .map-btn-label { display: none; }
  #ndviMapWrapper .ndvi-fecha-popover {
    position: fixed;
    top: auto;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 12px;
    right: 12px;
    transform: none;
    width: auto;
    max-height: min(78dvh, 560px);
    z-index: 2600;
  }
}

.map-wrapper { position: relative; }
#ndviMapWrapper .ndvi-overlay-toggle {
  clear: both;
  margin-top: 8px;
  float: right;
  display: flex;
  flex-direction: row;
}
#ndviMapWrapper.ndvi-controls-hidden .ndvi-overlay-toggle {
  margin-top: 8px;
}
#ndviMapWrapper .ndvi-overlay-toggle a {
  width: auto;
  min-width: 0;
  height: auto;
  padding: 8px 10px;
  line-height: 1.2;
  font-size: 12px;
  font-weight: 600;
  color: #1f7a43;
  text-align: center;
  white-space: nowrap;
  float: none;
  border-bottom: 0;
}
#ndviMapWrapper .ndvi-overlay-toggle a + a {
  border-left: 1px solid #d5ddd8;
}
#ndviMapWrapper .ndvi-overlay-toggle a.is-off {
  color: #33453a;
}
#ndviMapWrapper .ndvi-overlay-toggle a.is-disabled {
  color: #9aa79f;
  pointer-events: none;
  cursor: not-allowed;
}
#ndviMapWrapper .leaflet-top.leaflet-right .leaflet-control {
  margin-right: 0;
}

/* Pantalla completa "falsa" (position:fixed) — funciona igual en iOS y Android,
   a diferencia de la Fullscreen API nativa que en iOS Safari es poco confiable. */
.map-wrapper--fullscreen {
  position: fixed !important;
  inset: 0;
  z-index: 3000;
  background: #000000;
  margin: 0;
  border-radius: 0;
}
.map-wrapper--fullscreen #map,
.map-wrapper--fullscreen #map-ndvi,
.map-wrapper--fullscreen #map-prospect,
.map-wrapper--fullscreen #map-gps {
  height: 100%;
  width: 100%;
  border-radius: 0;
  margin-bottom: 0;
  border: none;
}
body.body-map-fullscreen { overflow: hidden; }
.map-wrapper--fullscreen .map-fullscreen-btn {
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
}
.map-wrapper--fullscreen .map-toolbar {
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
}

/* Barra flotante del modo "solo mapa" del NDVI (oculta salvo en ese modo) */
.map-only-bar {
  display: none;
  position: absolute;
  bottom: 16px; left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  gap: 10px;
  background: rgba(255,255,255,0.96);
  padding: 10px;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}
body.ndvi-map-only-mode .map-only-bar { display: flex; }

/* Modo "solo mapa" del NDVI: oculta todo lo demás y expande el mapa */
body.ndvi-map-only-mode header,
body.ndvi-map-only-mode .sidebar,
body.ndvi-map-only-mode .sidebar-backdrop {
  display: none !important;
}
body.ndvi-map-only-mode #view-ndvi .center-wrap { padding: 0; max-width: none; }
body.ndvi-map-only-mode #view-ndvi .center-wrap h2,
body.ndvi-map-only-mode #view-ndvi .center-wrap .sub,
body.ndvi-map-only-mode #view-ndvi .ndvi-panel {
  display: none !important;
}
body.ndvi-map-only-mode #ndviCard {
  border: none; border-radius: 0; padding: 0; box-shadow: none;
}
body.ndvi-map-only-mode .main,
body.ndvi-map-only-mode #view-ndvi,
body.ndvi-map-only-mode .subscreen,
body.ndvi-map-only-mode #ndviMapWrapper {
  height: 100vh;
  height: 100dvh;
}
body.ndvi-map-only-mode #ndviMapWrapper #map-ndvi {
  height: 100%;
  border-radius: 0;
  margin-bottom: 0;
  border: none;
}

.coords {
  font-family: monospace;
  background: #f4f7f5;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
  word-break: normal;
}

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
td { padding: 4px 4px; border-bottom: 1px solid #e5ece7; }
td:first-child { color: #5b6d64; }

.ai-text { font-size: 0.94rem; line-height: 1.6; }
.ai-text h1, .ai-text h2, .ai-text h3, .ai-text h4 { margin: 12px 0 6px; color: #1f7a43; line-height: 1.3; }
.ai-text h1 { font-size: 1.08rem; }
.ai-text h2 { font-size: 1.02rem; }
.ai-text h3 { font-size: 0.98rem; }
.ai-text h4 { font-size: 0.95rem; }
.ai-text h1:first-child, .ai-text h2:first-child, .ai-text h3:first-child, .ai-text h4:first-child { margin-top: 0; }
.ai-text ul, .ai-text ol { margin: 4px 0; padding-left: 20px; }
.ai-text li { margin: 2px 0; }
.ai-text p { margin: 6px 0; }
.ai-text hr { border: none; border-top: 1px solid #e5ece7; margin: 12px 0; }
.ai-text blockquote {
  margin: 8px 0; padding: 6px 12px;
  border-left: 3px solid #2f8f52;
  background: #f4f7f5; color: #33453a;
  font-size: 0.9rem;
}
.ai-text blockquote p { margin: 2px 0; }
.ai-text table { margin: 8px 0; display: block; overflow-x: auto; }
.ai-text th { text-align: left; padding: 4px 6px; border-bottom: 2px solid #cddcd3; color: #1f7a43; }
.ai-text td { padding: 4px 6px; }
.ai-text code { background: #f0f4f1; padding: 1px 5px; border-radius: 4px; font-size: 0.88em; }
.ai-text .sub-block { margin-top: 14px; padding-top: 12px; border-top: 1px solid #e5ece7; }
.ai-text .sub-block h5 { margin: 0 0 8px; font-size: 0.85rem; color: #5b6d64; }
.ai-text .windy-embed {
  width: 100%;
  height: 280px;
  border: 0;
  border-radius: 8px;
  display: block;
}
.ai-text .windy-embed-note {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: #5b6d64;
}
.data-sources {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin: 0 0 12px;
  padding: 9px 11px;
  border: 1px solid #cfe4d5;
  border-radius: 8px;
  background: #f1f8f3;
  color: #33453a;
  font-size: 0.82rem;
}
.data-sources strong { color: #1f7a43; }
.data-sources span { color: #50655a; }
.data-sources small { flex-basis: 100%; color: #6c7c73; font-size: 0.78rem; }
.ndvi-date-check {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  min-width: 0;
  max-width: 100%;
}
.ndvi-date-check select { width: 100%; margin: 0 0 10px; }
.ndvi-periodos { display: flex; flex-direction: column; gap: 6px; margin: 0 0 8px; }
.ndvi-periodo-row { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.ndvi-periodo-row span { font-size: .78rem; font-weight: 700; color: #1f7a43; width: auto; min-width: 78px; }
.ndvi-periodo-dates { font-weight: 600 !important; color: #33453a !important; min-width: 0 !important; }
#ndviCampanaYear { max-width: 110px; margin-bottom: 0; }
.ndvi-periodo-row input { flex: 1; min-width: 0; margin: 0; }
.ndvi-image-switch { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.ndvi-image-switch button { flex: 1 1 140px; }
button.secondary.ndvi-periodo-overlay.is-active {
  --btn-bg: #1f7a43;
  --btn-fg: #fff;
  --btn-hover-bg: #176b39;
  --btn-hover-fg: #fff;
  background: #1f7a43;
  color: #fff;
  border-color: #1f7a43;
}
.ndvi-campana, .ndvi-vis-bad, .ndvi-vis-good { display: block; margin-top: 2px; font-size: .75rem; line-height: 1.3; }
.ndvi-campana { color: #1f7a43; font-weight: 700; }
.ndvi-vis-bad { color: #9a6700; }
.ndvi-vis-good { color: #1f7a43; }
.ndvi-precip-note { margin: 4px 0 6px; font-size: .78rem; color: #5b6d64; line-height: 1.4; }
.ndvi-curva { margin-top: 12px; }
.ndvi-curva h4 { margin: 0 0 6px; color: #176b39; font-size: .92rem; }
.ndvi-curva-cabecera {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 6px;
}
.ndvi-curva-cabecera h4 { margin: 0; color: #176b39; font-size: .92rem; }
.analisis-seccion--mensual { margin-top: 18px; padding-top: 14px; border-top: 1px solid #dfe7e2; }
.ndvi-mensual-meta {
  margin: 6px 0 0;
  font-size: .9rem;
  color: #4a6356;
}
.ndvi-mensual-carga { margin-top: 10px; }
.ndvi-mensual-avance-linea { margin: 0; font-size: .95rem; color: #1f3d2c; }
.ndvi-mensual-actual { margin: 4px 0 0; font-size: .88rem; color: #5b6d64; }
.ndvi-mensual-barra {
  height: 10px;
  background: #e3f3e8;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}
.ndvi-mensual-barra i {
  display: block;
  height: 100%;
  background: #2f8f52;
  width: 0;
  transition: width .25s ease;
}
.ndvi-mensual-resumen { margin-top: 12px; }
.ndvi-mensual-resumen .ndvi-curva-nota { margin: 0 0 8px; }
#btnExportarCurvaPdf:disabled { opacity: .55; }
.ndvi-curva-cabecera button { flex: 0 0 auto; white-space: nowrap; }
.ndvi-curva-rango { display: flex; flex-wrap: wrap; gap: 6px; }
.ndvi-curva-rango button:disabled,
#btnExportarAnalisisPdf:disabled { opacity: .55; }
.ndvi-result-titulo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ndvi-result-titulo h3 { margin: 0; }
.ndvi-curva-export-estado { margin: 0 0 8px; color: #9a6700; font-size: .75rem; }
.ndvi-curva-export-estado:empty { display: none; }
.ndvi-curva-scroll { overflow-x: auto; margin-bottom: 8px; }
.ndvi-curva-nota { margin: 0 0 8px; color: #5b6d64; font-size: .75rem; line-height: 1.35; }
.ndvi-curva-detalle { margin: 0 0 8px; color: #14552f; font-size: .82rem; font-weight: 700; line-height: 1.35; }
.ndvi-curva-leyenda { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 8px; font-size: .75rem; color: #33453a; }
.ndvi-curva-leyenda i { display: inline-block; width: 12px; height: 12px; margin-right: 4px; border-radius: 3px; vertical-align: -2px; }
.ndvi-curva-leyenda .sw-ndvi { background: #1f7a43; }
.ndvi-curva-leyenda .sw-lluvia { background: #7eb6d9; }
.ndvi-curva-leyenda .sw-sol { background: #e0a106; }
.ndvi-curva-marco { position: relative; }
.ndvi-curva-base { stroke: #e6eeea; stroke-width: 1; }
.ndvi-curva-area { fill: url(#ndviCurvaArea); stroke: none; }
.ndvi-curva-lluvia { fill: #b9d7ea; opacity: .9; }
.ndvi-curva-ndvi { fill: none; stroke: #1f7a43; stroke-width: 2.5; }
circle.ndvi-curva-ndvi { fill: #1f7a43; stroke: #fff; stroke-width: 2; }
circle.ndvi-curva-ndvi.is-pico { stroke: #0e4d28; }
.ndvi-curva-guia { stroke: #d5e4da; stroke-width: 1; opacity: 0; }
[data-curva-i].is-selected .ndvi-curva-guia { opacity: 1; }
[data-curva-i].is-selected circle.ndvi-curva-ndvi { stroke: #0e4d28; stroke-width: 3; }
.ndvi-curva-hit { fill: transparent; cursor: pointer; }
.ndvi-curva-leyenda-svg { font-size: 12px; fill: #33453a; }
.ndvi-curva-tip {
  position: absolute;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 148px;
  padding: 8px 10px;
  border: 1px solid #d7e6dc;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(20, 40, 30, .12);
  color: #33453a;
  font-size: .75rem;
  line-height: 1.35;
  pointer-events: none;
}
.ndvi-curva-tip[hidden] { display: none; }
.ndvi-curva-tip b { color: #14552f; }
.ndvi-serie-carga p { margin: 0 0 8px; color: #14552f; font-size: .82rem; }
.ndvi-serie-carga ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
}
.ndvi-serie-carga li {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 8px;
  align-items: center;
  color: #5b6d64;
  font-size: .75rem;
}
.ndvi-serie-carga li i {
  display: block;
  height: 8px;
  border-radius: 99px;
  background: #e4eee8;
  position: relative;
  overflow: hidden;
}
.ndvi-serie-carga li.is-done { color: #1f7a43; font-weight: 700; }
.ndvi-serie-carga li.is-done i { background: #1f7a43; }
.ndvi-serie-carga li.is-active i::after {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 42%;
  background: #1f7a43;
  animation: ndvi-carga-mover 1.1s linear infinite;
}
button.ndvi-ver-analisis {
  display: inline-flex;
  margin-top: 4px;
  min-height: 28px;
  padding: 4px 8px;
  font-size: .72rem;
}
.ndvi-curva-sol { fill: none; stroke: #e0a106; stroke-width: 2; }
.ndvi-curva-eje { fill: #5b6d64; font-size: 11px; }
.ndvi-precip {
  display: flex; gap: 6px; align-items: flex-end; overflow-x: auto;
  padding: 8px 2px 6px; border-bottom: 1px solid #eef3ef;
}
.ndvi-precip-bar {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  flex: 0 0 auto; min-width: 92px; text-align: center;
}
.ndvi-precip-value { font-size: .7rem; font-weight: 700; color: #02636a; margin-bottom: 3px; white-space: nowrap; }
.ndvi-precip-fill { display: block; width: 22px; background: #02818a; border-radius: 3px 3px 0 0; }
.ndvi-precip-month {
  margin-top: 4px; padding-top: 3px; border-top: 1px solid #cddcd3; width: 100%;
  font-size: .7rem; font-weight: 600; color: #33453a; white-space: nowrap;
}
.ndvi-precip-peak {
  display: flex; flex-direction: column; justify-content: flex-start; margin-top: 3px; min-height: 2.4em;
  font-size: .64rem; line-height: 1.2; color: #5b6d64; white-space: nowrap;
}
.ndvi-precip-peak b { color: #02636a; font-weight: 700; }
.ndvi-precip-peak.is-empty { color: #b3c0b8; }
.ndvi-precip-bar.is-empty .ndvi-precip-value { color: #8a9a91; font-weight: 400; }
.ndvi-date-row { display: flex; gap: 8px; align-items: center; }
.ndvi-date-row input { flex: 1; min-width: 0; margin: 0; }
.ndvi-date-row button { flex-shrink: 0; }
.ndvi-availability { margin-top: 8px; color: #5b6d64; font-size: .82rem; line-height: 1.45; }
.ndvi-availability.is-good { color: #1f7a43; }
.ndvi-availability.is-warning { color: #9a6700; }
.ndvi-availability.is-ok { color: #176b39; }
.ndvi-historicos {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-top: 12px;
}
.ndvi-historicos-title {
  font-size: .78rem;
  font-weight: 700;
  color: #1f7a43;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.ndvi-historico-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid #dfe7e2;
  border-radius: 8px;
  --btn-bg: #fff; --btn-fg: #33453a; --btn-hover-bg: #eef4f0; --btn-hover-fg: #1f7a43;
  background: #fff;
  color: #33453a;
  text-align: left;
  cursor: pointer;
}
.ndvi-historico-btn span { color: #5b6d64; font-size: .78rem; }
.ndvi-historico-btn b { font-size: .86rem; }
.ndvi-historico-btn.is-active {
  --btn-bg: #e3f3e8; --btn-fg: #1f7a43; --btn-hover-bg: #e3f3e8; --btn-hover-fg: #1f7a43;
  border-color: #2f8f52;
  background: #e3f3e8;
  color: #1f7a43;
}
.ndvi-historico-btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  background: #f3f6f4;
}
.assistant-history-rename, .lote-rename {
  flex: 1;
  min-height: 42px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #2f8f52;
  border-radius: 8px;
  background: #fff;
  color: #33453a;
  font-size: .82rem;
}
.ndvi-legend { list-style: none; padding: 0; margin: 8px 0 0; }
.ndvi-legend li { display: flex; align-items: flex-start; gap: 8px; margin: 8px 0; color: #33453a; }
.ndvi-legend-copy { display: flex; flex-direction: column; gap: 2px; line-height: 1.25; }
.ndvi-legend-stats { font-size: .82rem; color: #5a6f62; }
.ndvi-swatch { width: 16px; height: 16px; border-radius: 4px; flex-shrink: 0; border: 1px solid rgba(0,0,0,.12); }
.ndvi-swatch--dark { background: #0d6b1f; }
.ndvi-swatch--light { background: #8cd159; }
.ndvi-swatch--yellow { background: #ffd600; }
.ndvi-swatch--red { background: #dc261f; }
.leaflet-pane.ndviImagePane,
.leaflet-pane.ndviImagePane img,
.ndvi-image-overlay {
  mix-blend-mode: normal !important;
  filter: none !important;
  opacity: 1 !important;
  image-rendering: auto;
}
.ndvi-vertex, .ndvi-vertex-touch {
  background: #fff;
  border: 2px solid #33453a;
}

.error { color: #c0392b; }

.lotes-list { display: flex; flex-direction: column; gap: 6px; }
.lote-item-wrapper { display: flex; align-items: center; gap: 4px; }
.lote-item {
  flex: 1;
  display: flex; justify-content: flex-start; align-items: center;
  gap: 10px;
  padding: 8px 10px;
  min-height: 56px;
  min-width: 0;
  border: 1px solid #dfe7e2;
  border-radius: 8px;
  font-size: 0.88rem;
  color: #33453a;
  cursor: pointer;
  background: #fafcfa;
  transition: background 0.15s;
}
.lote-thumb {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: block;
  border-radius: 8px;
}
.lote-item-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.lote-item .lote-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lote-item .lote-area { color: #5b6d64; font-size: 0.82rem; }
.lote-actions { display: flex; gap: 2px; flex-shrink: 0; }
.lote-edit, .lote-delete {
  width: 32px; min-height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;
  --btn-bg: transparent; --btn-fg: #8a9a91; --btn-hover-bg: #e3f3e8; --btn-hover-fg: #1f7a43;
  background: transparent; color: #8a9a91; border: none; border-radius: 6px; font-size: 0.9rem; cursor: pointer;
}
.lote-delete { --btn-hover-bg: #fde8e8; --btn-hover-fg: #c0392b; }
.spinner {
  width: 26px; height: 26px;
  border: 3px solid #dfe7e2;
  border-top-color: #2f8f52;
  border-radius: 50%;
  margin: 8px auto;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.proceso {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #d7e8de;
  border-radius: 10px;
  background: #f3faf6;
  color: #14552f;
  font-size: .9rem;
  font-weight: 700;
  line-height: 1.35;
}
.proceso i,
.is-proceso::after {
  display: block;
  height: 6px;
  margin-top: 8px;
  border-radius: 99px;
  background: linear-gradient(90deg, #176b39 0 40%, #d7e8de 40% 100%);
  background-size: 220% 100%;
  animation: proceso-mover 1.1s linear infinite;
}
button.is-procesando {
  position: relative;
  overflow: hidden;
}
button.is-procesando::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 5px;
  height: 3px;
  border-radius: 99px;
  background: linear-gradient(90deg, transparent, #7dcea0, transparent);
  background-size: 45% 100%;
  animation: proceso-mover 1s linear infinite;
}
@keyframes proceso-mover {
  from { background-position: 80% 0; }
  to { background-position: -80% 0; }
}

/* ---- Asistente unificado ---- */
.assistant-view { min-height: 0; background: linear-gradient(180deg, #f8fbf8 0%, #ffffff 42%); position: relative; }
.assistant-shell { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.assistant-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: clamp(24px, 6vh, 72px) 24px 24px;
}
.assistant-welcome { max-width: 900px; margin: 0 auto; text-align: center; }
.assistant-mark {
  width: 64px; height: 64px; display: grid; place-items: center; margin: 0 auto 16px;
  border-radius: 20px; background: #e3f3e8; font-size: 2rem;
  box-shadow: 0 8px 24px rgba(47, 143, 82, .14);
}
.assistant-welcome h2 { margin: 0 0 10px; color: #1f7a43; font-size: clamp(1.35rem, 3vw, 2rem); }
.assistant-welcome p { max-width: 620px; margin: 0 auto 28px; color: #5b6d64; line-height: 1.55; }
.assistant-quick-actions {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; text-align: left;
}
.assistant-action {
  display: flex; flex-direction: column; align-items: flex-start; gap: 5px;
  min-height: 122px; padding: 16px;
  --btn-bg: #fff; --btn-fg: #33453a; --btn-hover-bg: #e3f3e8; --btn-hover-fg: #1c2b22;
  color: #33453a; background: #fff;
  border: 1px solid #dfe7e2; box-shadow: 0 5px 18px rgba(28, 67, 42, .06);
  transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.assistant-action span { font-size: 1.4rem; }
.assistant-action b { color: #1f7a43; }
.assistant-action small { color: #6c7c73; font-weight: 400; }
.assistant-action:focus-visible {
  background: #e3f3e8;
  border-color: #2f8f52;
  color: #1c2b22;
  box-shadow: 0 8px 22px rgba(47, 143, 82, .16);
}
.assistant-action:focus-visible b { color: #176b39; }
.assistant-action:focus-visible small { color: #456254; }
.assistant-action--tool { position: relative; }
.tool-badge {
  position: absolute; top: 10px; right: 10px; font-size: .62rem; font-weight: 700;
  letter-spacing: .02em; color: #1f7a43; background: #e3f3e8; border: 1px solid #cfe4d5;
  border-radius: 999px; padding: 2px 8px;
}
.assistant-messages > .msg { width: min(760px, 100%); margin: 0 auto 12px; }
.assistant-inline-action { margin-top: 10px; padding: 8px 12px; min-height: 38px; font-size: .85rem; }
.assistant-composer { flex-shrink: 0; padding: 12px 24px max(18px, env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); border-top: 1px solid #dfe7e2; box-shadow: 0 -5px 20px rgba(28,67,42,.06); }
.assistant-options-toggle {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  margin: 0 0 8px;
  padding: 6px 12px;
  border: 1px solid #c9ddd0;
  border-radius: 999px;
  --btn-bg: #f4faf6;
  --btn-fg: #176b39;
  --btn-hover-bg: #e7f5ec;
  --btn-hover-fg: #14552f;
  background: #f4faf6;
  color: #176b39;
  font-weight: 700;
}
.assistant-options:not(.is-open) { display: none; }
.assistant-composer-inner { max-width: 900px; margin: 0 auto; }
.assistant-suggestion-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; }
.suggestion-chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 7px 12px; white-space: nowrap; border: 1px solid #cfe4d5; border-radius: 999px;
  --btn-bg: #f1f8f3; --btn-fg: #1f7a43; --btn-hover-bg: #e3f3e8; --btn-hover-fg: #1f7a43;
  background: #f1f8f3; color: #1f7a43; font-size: .82rem;
}
.suggestion-chip-icon { font-size: 1rem; line-height: 1; flex-shrink: 0; }
.assistant-lote-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.assistant-lote-row label {
  flex-shrink: 0; margin: 0; font-size: .82rem; font-weight: 700; color: #1f7a43;
}
.assistant-lote-row select {
  flex: 1; min-width: 0; margin: 0; min-height: 42px; border-radius: 10px;
  border: 1px solid #cfe4d5; background: #fafcfa; color: #33453a; padding: 6px 10px;
}
.lote-item.is-active {
  border-color: #1f7a43; background: #e3f3e8; font-weight: 600;
}
.assistant-input-row { display: flex; gap: 8px; }
.assistant-input-row input { flex: 1; min-width: 0; margin: 0; border-radius: 12px; min-height: 50px; padding: 12px 15px; }
.assistant-input-row button { min-height: 50px; border-radius: 12px; }
.photo-source { position: relative; flex-shrink: 0; }
.photo-source-menu {
  position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 50;
  display: flex; flex-direction: column; gap: 2px; min-width: 168px;
  padding: 6px; background: #fff; border: 1px solid #cfe4d5; border-radius: 12px;
  box-shadow: 0 10px 28px rgba(28,67,42,.14);
}
.photo-source-menu[hidden] { display: none !important; }
.photo-source-menu button {
  min-height: 44px; padding: 8px 12px; border: 0; border-radius: 8px; text-align: left;
  --btn-bg: transparent; --btn-fg: #33453a; --btn-hover-bg: #f1f8f3; --btn-hover-fg: #1f7a43;
  background: transparent; color: #33453a; font-size: .88rem; font-weight: 600;
}
.assistant-attach-btn {
  flex-shrink: 0; width: 50px; min-height: 50px; padding: 0; border-radius: 12px;
  --btn-bg: #f1f8f3; --btn-fg: #1f7a43; --btn-hover-bg: #e3f3e8; --btn-hover-fg: #1f7a43;
  background: #f1f8f3; border: 1px solid #cfe4d5; color: #1f7a43; font-size: 1.2rem;
}
.assistant-attach-btn.has-image {
  --btn-bg: #1f7a43; --btn-fg: #fff; --btn-hover-bg: #176b39; --btn-hover-fg: #fff;
  background: #1f7a43; border-color: #1f7a43; color: #fff;
}
.assistant-mic-btn.is-listening {
  --btn-bg: #b42318; --btn-fg: #fff; --btn-hover-bg: #912018; --btn-hover-fg: #fff;
  background: #b42318; border-color: #b42318; color: #fff;
}
.assistant-voice-status {
  margin: 8px 0 0;
  font-size: .82rem;
  line-height: 1.35;
  color: #176b39;
}
.assistant-voice-status[hidden] { display: none !important; }
.assistant-image-preview {
  display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 8px 10px;
  background: #f1f8f3; border: 1px solid #cfe4d5; border-radius: 12px;
}
.assistant-image-preview img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.assistant-image-preview span { flex: 1; font-size: .82rem; color: #33453a; }
.assistant-image-preview button {
  min-width: 44px; min-height: 44px; border-radius: 999px;
  --btn-bg: #fff; --btn-fg: #33453a; --btn-hover-bg: #f0f4f1; --btn-hover-fg: #33453a;
  background: #fff; border: 1px solid #cddcd3; color: #33453a;
}
.assistant-share { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 8px; }
.assistant-share p { margin: 0; flex: 1 1 200px; font-size: .78rem; line-height: 1.35; color: #33453a; }
.assistant-share button { flex: 0 0 auto; }
.chat-author { display: block; margin-bottom: 2px; font-size: .72rem; font-weight: 700; line-height: 1.2; color: #e8fff0; }
.assistant-disclaimer {
  margin-top: 8px; padding: 6px 10px; text-align: center;
  color: #6b5200; background: #fff8e1; border: 1px solid #f1e0a5; border-radius: 8px;
  font-size: .76rem; line-height: 1.35;
}

/* Escritorio y tablet ancha: el chat usa el ancho del panel y el alto
   que queda entre el encabezado y el compositor. */
@media (min-width: 769px) {
  .assistant-messages {
    display: flex;
    flex-direction: column;
    padding: 16px 28px 12px;
  }
  .assistant-welcome {
    max-width: none;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 0;
  }
  .assistant-welcome p { max-width: 760px; }
  .assistant-quick-actions { width: 100%; }
  .assistant-action { min-height: 168px; padding: 20px 22px; }
  .assistant-action b { font-size: 1.08rem; }
  .assistant-action small { font-size: .92rem; line-height: 1.35; }
  .assistant-composer-inner { max-width: none; }
  .assistant-suggestion-row { flex-wrap: wrap; }
  .suggestion-chip {
    flex: 1 1 180px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }
  .assistant-messages > .msg {
    width: auto;
    max-width: 100%;
    margin: 0 0 12px;
  }
  .assistant-messages > .msg.user { max-width: 78%; margin-left: auto; }
  .assistant-messages > .msg.ai,
  .assistant-messages > .msg.analysis { max-width: 100%; margin-right: auto; }
}
@media (min-width: 1400px) {
  .assistant-quick-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---- Tarjeta embebida en el chat para capturar cultivo + ubicación sin
   salir del chat ni abrir el mapa (análisis de parcela). ---- */
.parcela-capture { display: flex; flex-direction: column; gap: 10px; }
.parcela-capture select {
  width: 100%; margin: 0; min-height: 44px; border-radius: 8px; border: 1px solid #cddcd3; padding: 8px 12px;
}
.parcela-capture .map-search { margin-bottom: 0; }
.parcela-capture .coordinate-entry { margin: 0; }
.parcela-capture-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.parcela-capture-actions button { flex: 1; min-width: 130px; min-height: 44px; }
.parcela-capture-status { font-size: .82rem; color: #33453a; min-height: 0; }
.parcela-capture-status.error { color: #c0392b; }

/* ---- Barra "herramienta del asistente" (NDVI / Plagas) ---- */
.tool-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; background: #f1f8f3; border-bottom: 1px solid #dfe7e2;
}
.tool-bar-back {
  min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 1px solid #cfe4d5;
  --btn-bg: #fff; --btn-fg: #1f7a43; --btn-hover-bg: #e3f3e8; --btn-hover-fg: #1f7a43;
  background: #fff; color: #1f7a43; font-weight: 600; font-size: .85rem;
}
.tool-bar-label { font-size: .78rem; color: #5b6d64; font-weight: 600; }
/* El botón de historial/lotes dentro de las herramientas solo hace falta
   en móvil, donde la herramienta tapa el sidebar de escritorio. */
.tool-bar-menu-btn { display: none; }

/* ---- Herramientas del asistente (NDVI / Plagas) como hoja a pantalla
   completa ENCIMA del chat, para que la app se sienta como una sola
   pantalla continua en vez de navegar a otra página. ---- */
.view.tool-overlay-open {
  display: flex !important;
  position: fixed;
  inset: 0;
  z-index: 2200;
  background: #fff;
}
body.tool-overlay-active { overflow: hidden; }

/* ---- Análisis agrícola y Diagnóstico de plagas: paneles EMBEBIDOS dentro
   de #view-assistant (misma pantalla, mismo encabezado y misma barra
   lateral). Nunca navegan a otra vista: solo se muestra/oculta este panel
   encima del chat, y "Volver al asistente" simplemente lo cierra. ---- */
.assistant-tool-panel {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 40;
  background: #fff;
  flex-direction: column;
  min-height: 0;
}
.assistant-tool-panel.open { display: flex; }

/* ---- Chat estilo ChatGPT/Claude ---- */
.chat-screen { flex-direction: column; }
.subscreen.chat-screen.active { display: flex; }
.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.chat-messages-inner { max-width: 760px; margin: 0 auto; width: 100%; display: flex; flex-direction: column; gap: 16px; }
.msg { padding: 12px 15px; border-radius: 12px; font-size: 0.94rem; line-height: 1.5; }
.msg.user { align-self: flex-end; max-width: 80%; background: #2f8f52; color: #fff; }
.msg.ai { align-self: flex-start; max-width: 80%; background: #f4f7f5; border: 1px solid #dfe7e2; }
.msg.ai .ai-text { font-size: 0.93rem; }
.msg.analysis { align-self: stretch; max-width: 100%; background: #f4f7f5; border: 1px solid #dfe7e2; }
.msg img.thumb { max-width: 220px; border-radius: 8px; display: block; margin-top: 8px; }

.chat-input-bar {
  flex-shrink: 0;
  border-top: 1px solid #dfe7e2;
  padding: 14px 24px 20px;
  background: #ffffff;
  box-shadow: 0 -4px 18px rgba(28, 67, 42, 0.06);
}
.chat-input-inner { max-width: 760px; margin: 0 auto; }
.chat-input-row { display: flex; gap: 8px; align-items: center; }
.chat-input-row input[type=text] { margin-bottom: 0; flex: 1; }
.chat-input-row button { flex-shrink: 0; }
.image-preview {
  display: flex; align-items: center; gap: 10px;
  background: #f4f7f5; border: 1px solid #dfe7e2; border-radius: 8px;
  padding: 6px 10px; margin-bottom: 10px; font-size: 0.85rem; color: #5b6d64;
}
.image-preview img { height: 40px; border-radius: 4px; }
.image-preview button { padding: 4px 8px; min-height: 32px; font-size: 0.8rem; }
.chat-status {
  min-height: 20px;
  margin: 0 0 8px;
  color: #5b6d64;
  font-size: 0.8rem;
}
.chat-status.error { color: #c0392b; }

/* ---- Pantalla de inicio de sesión ---- */
#login-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#login-screen.hidden { display: none; }
.login-card {
  max-width: 360px;
  width: 100%;
  text-align: center;
  padding: 36px 28px;
}
.login-card h2 { color: #1f7a43; margin: 0 0 6px; font-size: 1.2rem; }
.login-card p { color: #5b6d64; font-size: 0.88rem; margin: 0 0 24px; }
.google-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  --btn-bg: #ffffff;
  --btn-fg: #33453a;
  --btn-hover-bg: #f0f4f1;
  --btn-hover-fg: #33453a;
  background: #ffffff;
  color: #33453a;
  border: 1px solid #cddcd3;
  font-weight: 600;
}
.google-btn img { width: 18px; height: 18px; }
.login-error { color: #c0392b; font-size: 0.85rem; margin-top: 14px; }

#app-shell.hidden { display: none; }

.is-hidden { display: none !important; }

.prospect-wrap { max-width: 1600px; }
.prospect-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  padding: 16px;
}
.prospect-panel {
  min-width: 0;
  max-height: min(82vh, 920px);
  overflow: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
}
.prospect-secciones {
  display: flex;
  flex-wrap: wrap;
  flex-shrink: 0;
  border: 1px solid #d7e3dc;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  margin-bottom: 10px;
}
.prospect-secciones button {
  flex: 1 1 22%;
  min-width: 0;
  min-height: 40px;
  margin: 0;
  padding: 8px 6px;
  border: 0;
  border-right: 1px solid #e4eee8;
  border-bottom: 1px solid #e4eee8;
  border-radius: 0;
  --btn-bg: #fff;
  --btn-fg: #33453a;
  --btn-hover-bg: #e3f3e8;
  --btn-hover-fg: #14552f;
  background: #fff;
  color: #33453a;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
  line-height: 1.2;
  text-align: center;
  text-transform: uppercase;
  box-shadow: none;
}
.prospect-secciones button.is-active,
.prospect-secciones button.is-active:active {
  --btn-bg: #176b39;
  --btn-fg: #fff;
  --btn-hover-bg: #176b39;
  --btn-hover-fg: #fff;
  background: #176b39;
  color: #fff;
}
.prospect-secciones button:hover:not(.is-active) {
  background: #e3f3e8;
  color: #14552f;
}
.prospect-secciones button:focus-visible {
  outline: 2px solid #176b39;
  outline-offset: -2px;
}
.prospect-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.prospect-form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.prospect-form:not(.is-active) .prospect-seccion-scroll { display: none; }
.prospect-form-actions,
.prospect-status { flex-shrink: 0; }
.gps-workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.gps-panel { min-width: 0; }
.gps-panel input[type="datetime-local"] {
  width: 100%;
  background: #fff;
  color: #1c2b22;
  border: 1px solid #cddcd3;
  border-radius: 6px;
  padding: 10px 12px;
  min-height: 44px;
  font-size: .95rem;
  margin-bottom: 12px;
}
.gps-panel .actions { margin-top: 4px; flex-wrap: wrap; }
.gps-panel .actions button { flex: 1; }
.prospect-panel-head {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.prospect-panel-head button { flex: 1; }
.prospect-list, .prospect-sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.prospect-list-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  min-height: 44px;
  border: 1px solid #dfe7e2;
  border-radius: 8px;
  --btn-bg: #fafcfa;
  --btn-fg: #33453a;
  --btn-hover-bg: #e3f3e8;
  --btn-hover-fg: #33453a;
  background: #fafcfa;
  color: #33453a;
  font-size: .86rem;
}
.prospect-list-item small { color: #5b6d64; font-size: .75rem; }
.prospect-list-item.is-active {
  --btn-bg: #e3f3e8;
  --btn-hover-bg: #e3f3e8;
  background: #e3f3e8;
  border-color: #b7d4c2;
}
.prospect-form fieldset {
  border: 1px solid #dfe7e2;
  border-radius: 10px;
  margin: 0 0 12px;
  padding: 12px 12px 4px;
}
.prospect-form fieldset[hidden] { display: none !important; }
.prospect-form legend {
  font-size: .75rem;
  font-weight: 700;
  color: #176b39;
  padding: 0 6px;
}
.prospect-form textarea {
  width: 100%;
  min-height: 96px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #cddcd3;
  border-radius: 6px;
  resize: vertical;
  font: inherit;
}
.prospect-help { margin: 0 0 10px; color: #5b6d64; font-size: .8rem; line-height: 1.4; }
.prospect-check { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: .84rem; color: #33453a; }
.prospect-check input { width: auto; margin: 0; }
.prospect-zone-types {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 12px;
  font-size: .86rem;
}
.prospect-zone-types label { display: flex; align-items: center; gap: 8px; margin: 0; }
.prospect-zone-types input { width: auto; margin: 0; }
.prospect-import-row { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.prospect-import-row select { flex: 1; margin: 0; }
.prospect-file-import { margin: 0 0 12px; padding: 10px 12px; border: 1px dashed #b7d4c2; border-radius: 8px; background: #fafcfa; }
.prospect-file-import label { margin-top: 0; }
.prospect-file-help { margin: 2px 0 8px; font-size: .78rem; line-height: 1.4; }
.prospect-file-import .prospect-import-row { margin-bottom: 0; }
.prospect-docs-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.prospect-docs-list:empty { display: none; }
.prospect-doc-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 10px; border: 1px solid #dfe7e2; border-radius: 8px; background: #fff;
  font-size: .82rem; color: #33453a; overflow-wrap: anywhere;
}
.prospect-doc-item small { color: #5b6d64; font-size: .74rem; }
.prospect-doc-item.is-loading small { color: #1f7a43; }
.prospect-doc-item.is-error { border-color: #f1c2bc; background: #fdf3f2; }
.prospect-doc-item.is-error small { color: #c0392b; }
.prospect-doc-item .prospect-doc-warning { color: #8a5a00; }
.prospect-zones-list { display: flex; flex-direction: column; gap: 8px; margin: 0 0 12px; }
.prospect-zone-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #dfe7e2;
  cursor: pointer;
}
.prospect-zone-item div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.prospect-zone-item small { color: #5b6d64; font-size: .75rem; }
.prospect-zone-item.is-bioteq { background: #ecfdf3; border-color: #86efac; }
.prospect-zone-item.is-hibrido { background: #fefce8; border-color: #fde047; }
.prospect-zone-item.is-otro { background: #fef2f2; border-color: #fecaca; }
.prospect-form-actions { display: flex; gap: 8px; margin-top: 4px; }
.prospect-form-actions button { flex: 1; }
.prospect-status { min-height: 1.2em; font-size: .82rem; color: #5b6d64; }
.prospect-status.is-ok { color: #176b39; }
.prospect-status.is-error { color: #c0392b; }
.prospect-status.is-warning { color: #a16207; }
.prospect-ha-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0 8px;
}
.prospect-ha-chip {
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: .78rem;
  color: #33453a;
  background: #f4f7f5;
}
.prospect-ha-chip b { font-size: .95rem; }
.prospect-ha-chip.is-bioteq { background: #ecfdf3; }
.prospect-ha-chip.is-hibrido { background: #fefce8; }
.prospect-ha-chip.is-otro { background: #fef2f2; }
.prospect-ha-chip.is-total { background: #eef4f0; }
#prospectMapWrapper .map-search { margin-top: 48px; }
#map-prospect { height: min(64vh, 680px); min-height: 420px; }
#prospectMapWrapper .leaflet-top.leaflet-right {
  top: 66px;
  right: 10px;
}

/* =========================================
   TABLET Y TELÉFONO (1024px): menú tipo cajón.
   El overlay de herramientas tapa el sidebar de escritorio,
   así que el hamburguesa y "Lotes" viven también en tablet.
========================================= */
@media (max-width: 1024px) {
  header {
    padding: max(8px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
    gap: 8px;
  }
  header > div:first-child { display: flex; align-items: center; gap: 10px; min-width: 0; }
  header h1 { font-size: 1.08rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .header-actions { gap: 8px; flex-shrink: 0; }
  .mobile-menu-btn { display: inline-flex; }

  .center-wrap { max-width: 100%; padding: 24px 16px 40px; }
  #map, #map-ndvi, #map-prospect, #map-gps { height: min(62vh, 620px); min-height: 360px; }

  .ndvi-workspace-card {
    grid-template-columns: minmax(280px, 520px) minmax(340px, 1fr);
  }
  .ndvi-workspace-card > .map-wrapper { position: sticky; top: 12px; }
  .ndvi-workspace-card #map-ndvi {
    height: min(68vh, 620px);
    min-height: 360px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    width: min(86vw, 320px);
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    border-right: 1px solid #dfe7e2;
    box-shadow: 2px 0 20px rgba(0,0,0,0.18);
    transform: translateX(-105%);
    transition: transform 0.28s cubic-bezier(.22, .61, .36, 1);
    z-index: 2400;
    display: flex;
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 30, 20, 0.42);
    z-index: 2380;
    backdrop-filter: blur(2px);
  }
  .sidebar-backdrop.visible { display: block; }

  .tool-bar-menu-btn {
    display: flex;
    flex-direction: column;
    min-width: 52px;
    min-height: 48px;
    width: auto;
    height: auto;
    padding: 6px 8px;
    border-radius: 12px;
    font-size: 1.05rem;
    align-items: center;
    justify-content: center;
    --btn-bg: #fff; --btn-fg: #1f7a43; --btn-hover-bg: #e3f3e8; --btn-hover-fg: #1f7a43;
    background: #fff;
    box-shadow: 0 3px 10px rgba(28,67,42,.22);
    border: 0;
    color: #1f7a43;
    margin-left: 0;
    gap: 2px;
  }
  .tool-bar-menu-btn .map-btn-label {
    display: block;
    font-size: .62rem;
    font-weight: 700;
    color: #176b39;
  }

  .view.tool-overlay-open {
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
  }

  #view-ndvi .tool-bar,
  #view-prospeccion .tool-bar,
  #view-gps .tool-bar,
  #view-admin .tool-bar,
  #view-enfermedades .tool-bar,
  #view-agricola .tool-bar {
    position: relative;
    z-index: 5;
    flex-shrink: 0;
  }

  #view-ndvi.tool-overlay-open > .subscreen,
  #view-prospeccion.tool-overlay-open > .subscreen,
  #view-gps.tool-overlay-open > .subscreen,
  #view-admin.tool-overlay-open > .subscreen {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  #view-ndvi .center-wrap,
  #view-prospeccion .center-wrap,
  #view-gps .center-wrap,
  #view-admin .center-wrap {
    flex: 1;
    min-height: 0;
    width: 100%;
  }
  #view-ndvi #ndviCard {
    min-height: 0;
  }

  .assistant-welcome { padding: 0 4px; }
  .assistant-composer { padding-left: 16px; padding-right: 16px; }
  .tabla-scroll { -webkit-overflow-scrolling: touch; }
}

/* =========================================
   TELÉFONO (768px): mapa a pantalla completa,
   formularios en hoja, chat apilado.
========================================= */
@media (max-width: 768px) {
  header {
    min-height: 56px;
    align-items: center;
    gap: 6px;
    padding-right: max(8px, env(safe-area-inset-right));
    padding-left: max(8px, env(safe-area-inset-left));
  }
  header > div:first-child { flex: 1 1 auto; }
  header h1 { font-size: .95rem; }
  header p { display: none; }
  .header-actions { gap: 4px; min-width: 0; }
  .header-actions > button {
    padding: 8px;
    min-width: 40px;
    min-height: 40px;
  }
  .header-actions .label-full { display: none; }
  .user-badge { gap: 6px; }
  .user-badge .user-name,
  .user-badge .user-role { display: none; }
  .user-badge img { width: 28px; height: 28px; }
  .user-badge button { padding: 6px 8px; }
  .user-badge .label-short { display: inline; }

  .main { width: 100%; }

  #view-ndvi .tool-bar,
  #view-prospeccion .tool-bar,
  #view-gps .tool-bar,
  #view-admin .tool-bar,
  #view-enfermedades .tool-bar,
  #view-agricola .tool-bar {
    position: absolute;
    left: max(10px, env(safe-area-inset-left));
    right: auto;
    top: max(10px, env(safe-area-inset-top));
    z-index: 2300;
    padding: 0;
    background: transparent;
    border: 0;
    width: auto;
    flex-wrap: nowrap;
    gap: 8px;
  }
  #view-ndvi .tool-bar-label,
  #view-prospeccion .tool-bar-label,
  #view-gps .tool-bar-label,
  #view-admin .tool-bar-label,
  #view-enfermedades .tool-bar-label,
  #view-agricola .tool-bar-label { display: none; }

  #view-ndvi .tool-bar-back,
  #view-prospeccion .tool-bar-back,
  #view-gps .tool-bar-back,
  #view-admin .tool-bar-back,
  #view-enfermedades .tool-bar-back,
  #view-agricola .tool-bar-back {
    min-width: 52px;
    min-height: 48px;
    width: auto;
    height: auto;
    padding: 6px 8px;
    border-radius: 12px;
    font-size: 1.05rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: #fff;
    box-shadow: 0 3px 10px rgba(28,67,42,.22);
  }
  #view-ndvi .tool-bar-back .map-btn-label-full,
  #view-prospeccion .tool-bar-back .map-btn-label-full,
  #view-gps .tool-bar-back span,
  #view-admin .tool-bar-back span,
  #view-enfermedades .tool-bar-back span,
  #view-agricola .tool-bar-back span { display: none; }
  #view-ndvi .tool-bar-back .map-btn-label,
  #view-prospeccion .tool-bar-back .map-btn-label {
    display: block;
    font-size: .62rem;
    font-weight: 700;
    color: #176b39;
  }

  #view-ndvi:has(#ndviCard:not(.ndvi-options-collapsed)) .tool-bar {
    display: none;
  }

  /* En vistas de formulario o chat la barra va en su propia franja: flotando
     tapaba el texto al hacer scroll. Solo el mapa NDVI la deja encima. */
  #view-prospeccion .tool-bar,
  #view-gps .tool-bar,
  #view-admin .tool-bar,
  #view-enfermedades .tool-bar {
    position: relative;
    top: auto;
    left: auto;
    width: 100%;
    padding: 8px max(12px, env(safe-area-inset-left));
    background: #fff;
    border-bottom: 1px solid #dfe7e2;
  }
  #view-agricola .tool-bar { position: relative; top: auto; left: auto; padding: 10px 12px; }
  #view-agricola .tool-bar-label { display: none; }
  #view-agricola.assistant-tool-panel.open .tool-bar-back span { display: none; }

  #view-agricola .map-screen.active,
  #view-ndvi .map-screen.active {
    min-height: 0;
    background: #eef3f0;
  }
  #view-ndvi.tool-overlay-open { overflow: hidden; }
  #view-agricola #screen-2 .center-wrap,
  #view-ndvi .center-wrap {
    padding: 0 !important;
    max-width: none;
    overflow: hidden;
    height: 100%;
    margin: 0;
  }
  #view-agricola #screen-2 .center-wrap > h2,
  #view-ndvi .center-wrap > h2 { display: none; }
  #view-agricola #screen-2 .center-wrap > .sub,
  #view-ndvi .center-wrap > .sub { display: none; }

  #view-agricola #screen-2 .card,
  #view-ndvi #ndviCard {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    gap: 0;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: #eef3f0;
    box-shadow: none;
    overflow: hidden;
  }

  #view-agricola #screen-2 .map-wrapper,
  #view-ndvi #ndviCard > .map-wrapper {
    order: -1;
    position: relative;
    top: 0;
    flex: 1;
    width: 100%;
    min-height: 0;
    height: auto;
    margin: 0;
  }
  #view-agricola #map,
  #view-ndvi #map-ndvi {
    height: 100%;
    min-height: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  #view-agricola #screen-2 .map-wrapper .map-toolbar,
  #view-ndvi #ndviCard .map-toolbar {
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    left: auto;
    width: auto;
    max-width: calc(100% - 140px);
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: flex-start;
    gap: 6px;
  }
  #view-agricola #screen-2 .map-fullscreen-btn,
  #view-ndvi #ndviCard .map-fullscreen-btn,
  #view-ndvi #ndviMapWrapper #btnMapOnlyNdvi,
  #view-ndvi #ndviMapWrapper #btnNdviOptions {
    width: auto;
    min-width: 48px;
    max-width: none;
    height: auto;
    min-height: 48px;
    padding: 6px 8px;
    border-radius: 12px;
    font-size: 1.05rem;
    flex-direction: column;
    gap: 2px;
  }
  #view-ndvi #ndviCard .map-btn-label,
  #view-agricola #screen-2 .map-fullscreen-btn .map-btn-label {
    display: block;
    font-size: .62rem;
    font-weight: 700;
    line-height: 1.1;
    white-space: nowrap;
  }

  #ndviMapWrapper .leaflet-top.leaflet-left {
    top: calc(max(10px, env(safe-area-inset-top)) + 156px);
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    width: auto;
  }
  #agricolaMapWrapper .leaflet-top.leaflet-left {
    top: calc(max(10px, env(safe-area-inset-top)) + 62px);
    left: max(10px, env(safe-area-inset-left));
  }
  #view-ndvi #ndviCard .map-toolbar {
    top: calc(max(8px, env(safe-area-inset-top)) + 102px);
    max-width: calc(100% - 16px);
    gap: 6px;
  }
  #view-ndvi #ndviMapWrapper .map-toolbar > button {
    height: 42px;
    min-height: 42px;
    padding: 0 12px;
  }
  #ndviMapWrapper .ndvi-map-chrome {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    top: calc(max(8px, env(safe-area-inset-top)) + 56px);
  }
  #ndviMapWrapper .ndvi-fecha-mapa { order: 1; align-self: center; width: 100%; }
  #ndviMapWrapper .ndvi-map-chrome-right {
    order: 2;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 8px;
  }
  #ndviMapWrapper .ndvi-map-chrome-left {
    order: 3;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    grid-template-areas:
      "zoom tipos"
      "draw tipos";
    width: 100%;
    align-items: start;
    justify-content: stretch;
    gap: 8px;
  }
  #ndviChromeLeft .leaflet-control-zoom { grid-area: zoom; }
  #ndviChromeLeft .ndvi-tipo-switch {
    grid-area: tipos;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    align-content: flex-start;
    width: 100%;
    max-width: none;
    margin: 0;
    gap: 6px;
  }
  #ndviChromeLeft .ndvi-tipo-item {
    flex: 0 1 auto;
    width: auto;
    min-width: 0;
    justify-content: flex-start;
  }
  #ndviChromeLeft .ndvi-tipo-item > button[data-ndvi-tipo] {
    flex: 1 1 auto;
    min-width: 0;
    text-align: center;
    padding: 6px 8px;
    font-size: .78rem;
  }
  #ndviChromeLeft .ndvi-tipo-item > .help-tip {
    width: 32px;
    min-width: 32px;
    height: 32px;
    min-height: 32px;
  }
  #ndviChromeLeft .leaflet-draw {
    grid-area: draw;
    align-self: start;
    flex-direction: column;
    flex-wrap: nowrap;
    width: 36px;
  }
  #ndviChromeLeft .leaflet-draw .leaflet-bar a,
  #ndviChromeLeft .leaflet-control-zoom a {
    width: 36px;
    height: 36px;
    line-height: 36px;
  }
  #view-ndvi #ndviMapWrapper .ndvi-map-chrome .ndvi-fecha-mapa {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    transform: none;
    justify-self: center;
    width: max-content;
    max-width: 100%;
  }
  #view-ndvi #ndviMapWrapper .ndvi-map-chrome .map-toolbar {
    position: static;
    top: auto;
    right: auto;
    left: auto;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
    max-width: 100%;
    justify-content: stretch;
    align-items: stretch;
    gap: 6px;
  }
  #view-ndvi #ndviMapWrapper .ndvi-map-chrome .map-toolbar > button {
    width: 100%;
    min-width: 0;
    height: 44px;
    min-height: 44px;
    padding: 0;
  }
  #view-ndvi #ndviMapWrapper .ndvi-map-chrome .map-toolbar > button .map-btn-label {
    display: none;
  }
  #ndviMapWrapper .ndvi-fecha-dia {
    max-width: min(200px, 52vw);
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #ndviMapWrapper .ndvi-map-chrome-side {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
  }
  #ndviMapWrapper .ndvi-map-chrome-side .leaflet-control,
  #ndviMapWrapper .ndvi-map-chrome-side .ndvi-overlay-toggle {
    float: none;
    clear: none;
    margin: 0;
  }
  #ndviMapWrapper .ndvi-map-chrome-side .ndvi-overlay-toggle { margin-left: 0; }
  #ndviMapWrapper .ndvi-fecha-pill button { min-height: 34px; }
  #ndviMapWrapper #map-ndvi .leaflet-top.leaflet-left {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    max-width: none;
    width: auto;
    gap: 8px;
  }
  #map-ndvi .leaflet-control-zoom { order: 1; flex: 0 0 auto; align-self: flex-start; }
  #map-ndvi .ndvi-tipo-control {
    order: 2;
    flex: 1 0 100%;
    width: 100%;
    box-sizing: border-box;
  }
  #map-ndvi .leaflet-draw { order: 3; align-self: flex-start; }
  #ndviChromeLeft .ndvi-tipo-switch button[data-ndvi-tipo],
  #map-ndvi .ndvi-tipo-control > button[data-ndvi-tipo] {
    flex: 1 1 auto;
    padding: 6px 8px;
    font-size: .84rem;
  }
  #map-ndvi .leaflet-draw {
    display: flex;
    flex-direction: row;
    gap: 6px;
    background: transparent;
    border: 0;
    box-shadow: none;
  }
  #map-ndvi .leaflet-draw .leaflet-draw-section,
  #map-ndvi .leaflet-draw .leaflet-draw-toolbar { margin: 0; }
  #map-ndvi .leaflet-draw .leaflet-bar a {
    width: 36px;
    height: 36px;
    line-height: 36px;
    border-bottom: 0;
    border-radius: 8px;
  }
  #map-ndvi .leaflet-top.leaflet-left .ndvi-overlay-toggle {
    order: 4;
    align-self: center;
    float: none;
    clear: none;
    margin: 0 0 0 auto;
  }
  #ndviMapWrapper .leaflet-top.leaflet-right {
    top: calc(max(10px, env(safe-area-inset-top)) + 156px);
    right: max(10px, env(safe-area-inset-right));
  }
  #agricolaMapWrapper .leaflet-top.leaflet-right {
    top: calc(max(10px, env(safe-area-inset-top)) + 62px);
    right: max(10px, env(safe-area-inset-right));
  }

  /* Mapa a pantalla completa. Análisis = hoja scrolleable, sin mapa debajo. */
  #view-ndvi #ndviCard {
    min-height: 100%;
    height: 100%;
  }
  #view-ndvi #ndviCard.ndvi-options-collapsed {
    overflow: hidden;
  }
  #view-ndvi #ndviCard.ndvi-options-collapsed > :not(.map-wrapper):not(.ndvi-options-toggle) {
    display: none !important;
  }
  #view-ndvi #ndviCard.ndvi-options-collapsed > .map-wrapper {
    flex: 1;
    min-height: 0;
    height: auto;
  }
  #view-ndvi #ndviCard:not(.ndvi-options-collapsed) {
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 12px calc(20px + env(safe-area-inset-bottom));
    background: #eef3f0;
    height: 100%;
  }
  #view-ndvi #ndviCard:not(.ndvi-options-collapsed) > .map-wrapper {
    display: none !important;
  }
  #view-ndvi #ndviCard:not(.ndvi-options-collapsed) > :not(.map-wrapper) {
    width: 100%;
    max-width: 100%;
    margin: 0 0 10px;
    position: relative;
    z-index: 2;
  }
  #view-ndvi #ndviCard:not(.ndvi-options-collapsed) > .ndvi-back-map-btn {
    display: flex;
    flex-shrink: 0;
  }
  #view-ndvi #ndviCard:not(.ndvi-options-collapsed) > .ndvi-panel {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  #view-ndvi .ndvi-secciones {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  #view-ndvi #ndviCard:not(.ndvi-options-collapsed) .ndvi-secciones {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #eef3f0;
  }
  #view-ndvi .ndvi-secciones button,
  #view-ndvi .ndvi-secciones button:last-child {
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;
    padding: 8px 2px;
    font-size: .74rem;
    letter-spacing: 0;
    text-transform: none;
    white-space: normal;
  }
  #view-ndvi .ndvi-seccion .map-search,
  #view-ndvi .ndvi-seccion .coordinate-entry,
  #view-ndvi .ndvi-seccion .coords,
  #view-ndvi .ndvi-seccion .actions,
  #view-ndvi .ndvi-seccion .ndvi-lot-save {
    padding: 12px;
    border: 1px solid #dfe7e2;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 3px 14px rgba(28,67,42,.08);
  }
  #view-ndvi .ndvi-seccion {
    gap: 10px;
    width: 100%;
    max-width: 100%;
  }
  #view-ndvi .analisis-seccion,
  #view-ndvi .ndvi-cal,
  #view-ndvi .ndvi-hitos,
  #view-ndvi .ndvi-cal-grid {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  #view-ndvi .ndvi-hitos { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #view-ndvi button.ndvi-cal-day {
    min-height: 44px;
    padding: 4px 0 10px;
    font-size: .85rem;
  }
  #view-ndvi .ndvi-cal-leyenda { gap: 6px 10px; }
  #view-ndvi .ndvi-result-sections { grid-template-columns: 1fr; }
  #view-ndvi .ndvi-date-row { flex-direction: column; align-items: stretch; }
  #view-ndvi .ndvi-date-row button { width: 100%; }

  #view-agricola #screen-2 .card > :not(.map-wrapper) {
    margin-left: 12px;
    margin-right: 12px;
  }
  #view-agricola #screen-2 .coords {
    margin-top: 8px;
    position: relative;
    z-index: 4;
    border-radius: 14px;
    background: rgba(255,255,255,.94);
    box-shadow: 0 3px 12px rgba(0,0,0,.16);
  }

  .center-wrap { padding: 16px 14px 28px; }
  #map { height: 58dvh; min-height: 280px; }
  #map-ndvi { touch-action: pan-x pan-y; }

  .leaflet-marker-icon.leaflet-editing-icon {
    width: 16px !important;
    height: 16px !important;
    margin-left: -8px !important;
    margin-top: -8px !important;
  }
  .map-only-bar {
    flex-direction: row;
    width: calc(100% - 24px);
    max-width: 420px;
    justify-content: center;
    bottom: max(12px, env(safe-area-inset-bottom));
  }
  .map-only-bar button { flex: 1; }

  .coordinate-row { flex-wrap: wrap; }
  .coordinate-row input[type=number],
  .coordinate-row input[type=text],
  .coordinate-row input[type=datetime-local] { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .coordinate-row input.coordinate-input { flex: 1 1 100%; }
  .coordinate-row button { width: 100%; }
  .ndvi-date-row { flex-direction: column; align-items: stretch; }
  .ndvi-periodo-row { flex-direction: column; align-items: stretch; gap: 4px; }
  .ndvi-periodo-row span { min-width: 0; }

  .prospect-workspace,
  .gps-workspace { grid-template-columns: 1fr; }
  .prospect-panel,
  .gps-panel { max-height: none; overflow: visible; }
  #map-prospect,
  #map-gps { height: min(52vh, 480px); min-height: 280px; }
  .prospect-ha-summary { grid-template-columns: 1fr 1fr; }
  .prospect-secciones button {
    flex: 1 1 30%;
    min-height: 44px;
    white-space: normal;
  }
  #prospectMapWrapper .map-search { margin-top: 58px; }
  .prospect-import-row { flex-wrap: wrap; }
  .prospect-import-row button { width: 100%; }
  .prospect-form-actions { flex-direction: column; }

  .chat-messages { padding: 16px 12px 10px; }
  .assistant-messages { padding: 16px 12px 12px; }
  .assistant-shell { display: flex; flex-direction: column; }
  .assistant-quick-actions { grid-template-columns: 1fr; }
  .assistant-action {
    min-height: 92px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 4px;
    padding: 14px 16px;
  }
  .assistant-action--tool { padding-top: 34px; }
  .tool-badge { top: 8px; font-size: .58rem; }
  .assistant-composer { padding-left: 12px; padding-right: 12px; }
  .assistant-shell.is-chat-colapsado .assistant-options {
    display: none;
  }
  .assistant-chat-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 28px;
    margin: 0 0 6px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: grab;
    touch-action: none;
  }
  .assistant-chat-handle::before {
    content: '';
    width: 42px;
    height: 4px;
    border-radius: 4px;
    background: #c5d5cb;
  }
  .assistant-options-toggle {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    margin: 0 0 8px;
    padding: 6px 12px;
    border: 1px solid #c9ddd0;
    border-radius: 999px;
    background: #f4faf6;
    color: #176b39;
    font-weight: 700;
  }
  .assistant-options:not(.is-open) { display: none; }
  .assistant-lote-row { flex-wrap: wrap; }
  .assistant-lote-row label { flex-basis: 100%; }
  .assistant-suggestion-row { flex-wrap: wrap; margin-right: 0; padding-right: 0; }
  .suggestion-chip {
    flex: 1 0 calc(50% - 8px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: normal;
  }
  .chat-input-bar { padding: 12px 12px max(16px, env(safe-area-inset-bottom)); }
  .chat-input-row { flex-wrap: nowrap; }
  .chat-input-row input[type=text] { flex: 1 1 auto; min-width: 0; }
  .assistant-lote-row select,
  .assistant-crop-combo { flex: 1 1 100%; width: 100%; min-width: 0; }
  #btnStep3Restart { width: 100%; order: 5; }
  .msg.user, .msg.ai { max-width: 94%; }
  .msg img.thumb { max-width: 100%; }
  .actions { flex-direction: column; }
  .actions button { width: 100%; margin-bottom: 0; }
  .ai-text .windy-embed { height: 220px; }

  select, input[type=text], input[type=search], input[type=number], input[type=date], input[type=datetime-local], textarea {
    font-size: 16px;
  }

  .view, .subscreen, .center-wrap, .card, .analisis-seccion, .gps-panel, .prospect-panel {
    min-width: 0;
    max-width: 100%;
  }
  .assistant-welcome h2 { font-size: 1.28rem; }
  .assistant-welcome p { padding: 0 4px; }
  .msg, .ai-text { overflow-wrap: anywhere; }
  .msg img, .ai-text img, .ndvi-result img { max-width: 100%; height: auto; }
  .tabla-scroll, .lote-picker, .ndvi-curva-scroll, .ndvi-precip-scroll {
    max-width: 100%;
    overflow-x: auto;
  }
  #ndviMapWrapper .ndvi-fecha-popover {
    position: fixed;
    top: auto;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 12px;
    right: 12px;
    transform: none;
    width: auto;
    max-height: min(78dvh, 560px);
    z-index: 2600;
  }
  #view-admin .lote-picker-table { min-width: 520px; }
  #view-admin .center-wrap { padding-bottom: max(28px, env(safe-area-inset-bottom)); }
  #ndviMapWrapper .ndvi-cal-leyenda,
  #ndviMapWrapper .ndvi-cal-optimos { font-size: .72rem; }
  #view-ndvi .ndvi-curva-cabecera h4 { font-size: .88rem; }
  .tool-bar { max-width: 100%; }
  .gps-wrap .sub, .prospect-wrap .sub, #view-admin .sub { overflow-wrap: anywhere; }

  /* El mapa agrícola conserva alto propio. Si se aplasta a cero, sus botones
     quedan flotando encima del buscador. */
  #view-agricola #screen-2.subscreen.active {
    display: block;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
  #view-agricola #screen-2 .center-wrap {
    display: block;
    height: auto;
    overflow: visible;
  }
  #view-agricola #screen-2 .card {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: visible;
  }
  #view-agricola #screen-2 .map-wrapper {
    order: 0;
    flex: none;
    position: relative;
    height: 46dvh;
    min-height: 240px;
  }
  #view-agricola #map {
    height: 100%;
    min-height: 240px;
  }
}

@media (max-width: 480px) {
  #view-ndvi #ndviCard .map-btn-label,
  #view-agricola #screen-2 .map-fullscreen-btn .map-btn-label,
  .tool-bar-menu-btn .map-btn-label,
  #view-ndvi .tool-bar-back .map-btn-label,
  #view-prospeccion .tool-bar-back .map-btn-label { display: none; }
  #view-ndvi .tool-bar-back,
  #view-prospeccion .tool-bar-back,
  #view-gps .tool-bar-back,
  #view-admin .tool-bar-back,
  .tool-bar-menu-btn,
  #view-ndvi #ndviCard .map-fullscreen-btn,
  #view-ndvi #ndviMapWrapper #btnMapOnlyNdvi,
  #view-ndvi #ndviMapWrapper #btnNdviOptions {
    min-width: 44px;
    min-height: 44px;
    padding: 0;
  }
  #view-ndvi #ndviMapWrapper .ndvi-map-chrome .map-toolbar { max-width: 100%; }
  .label-full { display: none; }
  .label-short { display: inline; }
  .mapas-secciones button { flex: 1 0 50%; }
  .mapas-head { align-items: flex-start; flex-wrap: wrap; padding: 10px 12px; }
  .mapas-frame-wrap { min-height: 68dvh; }
  .login-card { padding: 24px 16px; }
  .assistant-disclaimer { font-size: .7rem; }
}

/* =========================================
   TELÉFONOS CHICOS (380px): un último ajuste de aire
========================================= */
@media (max-width: 380px) {
  .center-wrap { padding: 14px 10px 24px; }
  .card { padding: 14px; }
  header h1 { font-size: .9rem; }
  #map { height: 52dvh; min-height: 240px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* Hover solo con puntero fino (mouse). En táctil no queda un bloque
   pegado después del tap; el feedback es :active. */
@media (hover: hover) and (pointer: fine) {
  button:hover:not(:disabled) {
    background: var(--btn-hover-bg);
    color: var(--btn-hover-fg);
  }
  .assistant-history-item-wrapper:hover .assistant-history-item:not(:disabled) {
    background: var(--btn-hover-bg);
    color: var(--btn-hover-fg);
  }
  .lote-item:hover { background: #eef4f0; }
  .location-result-item:hover { background: #eef4f0; }
  .prospect-list-item:hover { background: var(--btn-hover-bg); border-color: #b7d4c2; }
  .assistant-action:hover:not(:disabled) {
    background: var(--btn-hover-bg);
    border-color: #2f8f52;
    color: var(--btn-hover-fg);
    box-shadow: 0 8px 22px rgba(47, 143, 82, .16);
    transform: translateY(-1px);
  }
  .assistant-action:hover:not(:disabled) b { color: #176b39; }
  .assistant-action:hover:not(:disabled) small { color: #456254; }
}

@media (hover: none) {
  button:hover:not(:disabled):not(:active) {
    background: var(--btn-bg);
    color: var(--btn-fg);
  }
}

.user-role {
  font-size: .72rem;
  font-weight: 700;
  color: #1f7a43;
  background: #e3f3e8;
  border-radius: 999px;
  padding: 2px 8px;
}
.assistant-lote-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex-wrap: wrap;
}
.assistant-lote-toggle { flex: 1 1 180px; margin: 0; min-height: 42px; }
.assistant-crop-combo { flex: 1 1 180px; min-width: 0; }
.lote-picker {
  margin-bottom: 10px;
  overflow: auto;
  max-height: 240px;
  border: 1px solid #dfe7e2;
  border-radius: 10px;
  background: #fff;
}
.lote-picker-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
.lote-picker-table th, .lote-picker-table td {
  padding: 8px;
  border-bottom: 1px solid #eef3ef;
  text-align: left;
  vertical-align: middle;
}
.lote-picker-table th { color: #1f7a43; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; }
.lote-picker-row { cursor: pointer; }
.lote-picker-row:hover, .lote-picker-row.is-selected { background: #e3f3e8; }
.lote-picker .lote-thumb { width: 40px; height: 40px; }
.cultivo-combo { position: relative; }
.cultivo-combo:focus-within { z-index: 40; }
.cultivo-combo-input {
  width: 100%;
  min-height: 42px;
  margin: 0;
  border-radius: 10px;
  border: 1px solid #cfe4d5;
  padding: 8px 10px;
}
.cultivo-combo-list {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 4px);
  z-index: 40;
  max-height: min(360px, 50vh);
  overflow: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: #fff;
  border: 1px solid #dfe7e2;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(28,67,42,.12);
}
.cultivo-combo-list li { padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.cultivo-combo-list li:hover { background: #e3f3e8; }
.cultivo-combo-empty { color: #5b6d64; cursor: default; }
.tabla-scroll { overflow: auto; max-height: 320px; }
.lote-draw-alert {
  position: absolute;
  z-index: 800;
  left: 10px;
  right: 10px;
  bottom: 10px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #e7b2a8;
  border-radius: 10px;
  background: #fff6f4;
  color: #8d2b1f;
  font-size: .82rem;
  line-height: 1.35;
  pointer-events: none;
}
.lote-draw-alert[hidden] { display: none; }
.plan-nutricional {
  width: 100%;
  margin: 8px 0 12px;
  padding: 14px 12px 12px;
  border: 1px solid #d5e4da;
  border-radius: 14px;
  background: linear-gradient(180deg, #f3f8f4 0%, #fff 88px);
}
.plan-nutricional[hidden] { display: none; }
.plan-kicker {
  margin: 0;
  color: #5b6d64;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.plan-nutricional h3 { margin: 2px 0 0; color: #14552f; font-size: 1.15rem; }
.plan-familia { margin: 0 0 6px; color: #1f7a43; font-size: .78rem; font-weight: 700; }
.plan-criterio { margin: 0 0 8px; color: #33453a; font-size: .8rem; line-height: 1.4; }
.plan-leyenda { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 8px; color: #5b6d64; font-size: .68rem; }
.plan-riel {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(118px, 1fr);
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 10px;
  scroll-snap-type: x proximity;
}
.plan-paso {
  scroll-snap-align: start;
  display: grid;
  grid-template-rows: minmax(78px, auto) auto minmax(64px, auto);
  min-width: 118px;
}
.plan-fila { display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; }
.plan-fila--abajo { justify-content: flex-start; padding-top: 8px; }
.plan-programa {
  color: #6a5344;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.plan-chip {
  display: block;
  padding: 5px 6px;
  border-radius: 7px;
  background: #fff;
  border: 1px solid #d5e0d8;
  color: #1c2b22;
  font-size: .68rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  letter-spacing: .01em;
}
.plan-chip--vacio { opacity: 0; border-color: transparent; background: transparent; min-height: 8px; padding: 0; }
.plan-nodo {
  position: relative;
  z-index: 1;
  margin-top: 8px;
  padding: 8px 6px;
  border-radius: 12px;
  color: #fff;
  text-align: center;
  box-shadow: 0 4px 0 rgba(20, 40, 28, .12);
}
.plan-nodo span { display: block; font-size: .62rem; opacity: .85; }
.plan-nodo b { display: block; font-size: .72rem; line-height: 1.2; }
.plan-paso .plan-nodo::before,
.plan-paso .plan-nodo::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 10px;
  height: 3px;
  background: #c5d5cb;
}
.plan-paso .plan-nodo::before { right: 100%; }
.plan-paso .plan-nodo::after { left: 100%; }
.plan-paso:first-child .plan-nodo::before,
.plan-paso:last-child .plan-nodo::after { display: none; }
.tono-siembra .plan-nodo { background: #8a5a32; }
.tono-emergencia .plan-nodo { background: #3d8f4a; }
.tono-vegetativo .plan-nodo { background: #1c6b3c; }
.tono-floracion .plan-nodo { background: #1d7f86; }
.tono-llenado .plan-nodo { background: #d36a24; }
.tono-maduracion .plan-nodo { background: #a15a28; }
.tono-cosecha .plan-nodo { background: #2f8f52; }
.plan-dosis-titulo { margin: 12px 0 8px; color: #176b39; font-size: .82rem; }
.plan-fuente { margin: 8px 0 0; color: #5b6d64; font-size: .75rem; line-height: 1.35; }
.plan-dosis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.plan-dosis section { padding: 8px; border-radius: 10px; background: #fff; border: 1px solid #dfe7e2; }
.plan-dosis h4 { margin: 0 0 4px; color: #176b39; font-size: .78rem; }
.plan-dosis ul { margin: 0; padding-left: 16px; }
.plan-dosis li { margin: 2px 0; font-size: .75rem; line-height: 1.3; }
.plan-dosis b { color: #1f7a43; }
.msg.ai:has(.plan-nutricional) { max-width: min(920px, 100%); }
.admin-wrap .card { margin-top: 16px; }
.admin-hint-ok { color: #1b5e20; }
.admin-hint-err { color: #8a1f11; }
.gps-legend { font-size: .82rem; color: #33453a; margin: 8px 0; }
.gps-legend-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

button.help-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  min-height: 22px;
  margin: 0 0 0 6px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid #9ecfb0;
  background: #e3f3e8;
  color: #176b39;
  font-size: .75rem;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  box-shadow: none;
}
h2 .help-tip, h3 .help-tip, p .help-tip, .tool-bar-label .help-tip { position: relative; top: -1px; }
.help-popover {
  position: fixed;
  z-index: 5000;
  max-width: 280px;
  max-height: min(46dvh, 320px);
  overflow: auto;
  padding: 10px 12px;
  border-radius: 10px;
  background: #173526;
  color: #f4faf6;
  font-size: .82rem;
  line-height: 1.4;
  box-shadow: 0 8px 24px rgba(0,0,0,.28);
}
.analisis-seccion {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid #dfe7e2;
  border-radius: 12px;
  background: #fff;
  min-width: 0;
  overflow: hidden;
}
.analisis-seccion--suelo {
  overflow: visible;
  position: relative;
  z-index: 3;
}
.analisis-seccion--suelo:focus-within { z-index: 6; }
.analisis-seccion h3 {
  margin: 0 0 8px;
  font-size: .95rem;
  color: #176b39;
}
.ndvi-result-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.ndvi-result-section {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid #dfe7e2;
  border-radius: 12px;
  background: #f8fbf8;
  min-width: 0;
}
.ndvi-result-section h4 { margin: 0 0 8px; color: #176b39; }
.ndvi-result-section--wide { grid-column: 1 / -1; }
.analisis-campanas { width: 100%; }
.analisis-campanas summary {
  cursor: pointer;
  font-weight: 700;
  color: #176b39;
}
.ndvi-cal { display: flex; flex-direction: column; gap: 8px; }
.ndvi-cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
button.ndvi-cal-titulo {
  --btn-bg: transparent;
  --btn-fg: #173526;
  --btn-hover-bg: #e7f5ec;
  --btn-hover-fg: #173526;
  flex: 1;
  min-height: 36px;
  margin: 0;
  padding: 4px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #173526;
  font-size: 1rem;
  font-weight: 700;
  text-transform: capitalize;
}
.ndvi-cal-anios { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
button.ndvi-cal-anio {
  --btn-bg: #fff;
  --btn-fg: #173526;
  --btn-hover-bg: #e7f5ec;
  --btn-hover-fg: #14552f;
  min-height: 42px;
  padding: 8px;
  border: 1px solid #cddcd3;
  border-radius: 10px;
  background: #fff;
  color: #173526;
  font-weight: 700;
}
button.ndvi-cal-anio.is-selected,
button.ndvi-cal-anio.is-selected:active {
  --btn-bg: #176b39;
  --btn-fg: #fff;
  --btn-hover-bg: #14552f;
  --btn-hover-fg: #fff;
  background: #176b39;
  color: #fff;
  border-color: #176b39;
}
.ndvi-cal-nav {
  --btn-bg: #fff;
  --btn-fg: #176b39;
  --btn-hover-bg: #e7f5ec;
  --btn-hover-fg: #176b39;
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border: 1px solid #cddcd3;
  border-radius: 8px;
  background: #fff;
  color: #176b39;
  font-size: 1.2rem;
  line-height: 1;
}
.ndvi-cal-week,
.ndvi-cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.ndvi-cal-week[hidden],
.ndvi-cal-grid[hidden] { display: none; }
.ndvi-cal-week span { text-align: center; font-size: .72rem; font-weight: 700; color: #5b6d64; }
.ndvi-cal-vacio { min-height: 42px; }
button.ndvi-cal-day {
  --btn-bg: #fff;
  --btn-fg: #1c2b22;
  --btn-hover-bg: #f3faf5;
  --btn-hover-fg: #1c2b22;
  position: relative;
  width: 100%;
  min-height: 42px;
  padding: 4px 0 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #fff;
  color: #1c2b22;
  font-size: .9rem;
}
button.ndvi-cal-day.is-hoy { border-color: #9ecfb0; }
button.ndvi-cal-day.is-mejor { box-shadow: inset 0 0 0 2px #1f7a43; }
button.ndvi-cal-day.is-selected,
button.ndvi-cal-day.is-selected:disabled {
  --btn-bg: #176b39;
  --btn-fg: #fff;
  --btn-hover-bg: #14552f;
  --btn-hover-fg: #fff;
  background: #176b39;
  color: #fff;
  border-color: #176b39;
}
button.ndvi-cal-day.is-futuro,
button.ndvi-cal-day.is-futuro.is-hito {
  --btn-bg: #f4f7f5;
  --btn-fg: #8a9a91;
  --btn-hover-bg: #f4f7f5;
  --btn-hover-fg: #8a9a91;
  background: #f4f7f5;
  color: #8a9a91;
  box-shadow: none;
  cursor: not-allowed;
  opacity: .72;
}
button.ndvi-hito.is-futuro,
button.ndvi-hito.is-futuro:active {
  --btn-bg: #f4f7f5;
  --btn-fg: #8a9a91;
  --btn-hover-bg: #f4f7f5;
  --btn-hover-fg: #8a9a91;
  background: #f4f7f5;
  border-color: #d7e3dc;
  color: #8a9a91;
  cursor: not-allowed;
  opacity: .72;
}
button.ndvi-hito.is-futuro b,
button.ndvi-hito.is-futuro span { color: #8a9a91; }
.ndvi-cal-bloqueo {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff6e8;
  color: #9a6700;
  font-size: .84rem;
  font-weight: 700;
  line-height: 1.4;
}
.ndvi-hitos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
}
.ndvi-hito-item { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ndvi-hito-item .ndvi-ver-analisis { width: 100%; justify-content: center; }
button.ndvi-hito {
  --btn-bg: #fff;
  --btn-fg: #1c2b22;
  --btn-hover-bg: #e7f5ec;
  --btn-hover-fg: #14552f;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  min-height: 58px;
  padding: 8px 10px;
  border: 1px solid #9ecfb0;
  border-radius: 10px;
  background: #fff;
  color: #1c2b22;
  text-align: left;
  cursor: pointer;
  opacity: 1;
}
button.ndvi-hito b { color: #176b39; font-size: .95rem; }
button.ndvi-hito span { font-size: .72rem; color: #5b6d64; }
button.ndvi-hito.is-selected,
button.ndvi-hito.is-selected:active {
  --btn-bg: #176b39;
  --btn-fg: #fff;
  --btn-hover-bg: #14552f;
  --btn-hover-fg: #fff;
  background: #176b39;
  color: #fff;
  border-color: #176b39;
}
button.ndvi-hito.is-selected b,
button.ndvi-hito.is-selected span { color: #fff; }
button.ndvi-cal-day.is-hito::after,
button.ndvi-cal-day.is-despejado::before {
  content: "";
  position: absolute;
  bottom: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
button.ndvi-cal-day.is-hito::after { left: calc(50% - 3px); background: #1f7a43; }
button.ndvi-cal-day.is-despejado::before { left: calc(50% - 3px); background: #2f80ed; }
button.ndvi-cal-day.is-hito.is-despejado::after { left: calc(50% + 3px); }
button.ndvi-cal-day.is-hito.is-despejado::before { left: calc(50% - 9px); }
button.ndvi-cal-day.is-selected.is-hito::after,
button.ndvi-cal-day.is-selected.is-despejado::before { background: #fff; }
.ndvi-cal-leyenda { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: .75rem; color: #33453a; }
.ndvi-cal-leyenda i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.ndvi-cal-leyenda .sw-hito { background: #1f7a43; box-shadow: 0 0 0 2px #fff, 0 0 0 3px #1f7a43; }
.ndvi-cal-leyenda .sw-despejado { background: #2f80ed; }
.ndvi-cal-leyenda .sw-elegido { background: #176b39; }
.ndvi-cal-optimos { margin: 0; font-size: .82rem; color: #173526; line-height: 1.4; }
.ndvi-proximos { margin-top: 8px; font-size: .82rem; color: #33453a; }
.ndvi-tipo-switch { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.assistant-chat-handle { display: none; }
#map-ndvi .leaflet-top.leaflet-left {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
}
#map-ndvi .leaflet-top.leaflet-left > .leaflet-control {
  float: none;
  clear: none;
  margin: 0;
}
#map-ndvi .leaflet-control-zoom { order: 1; }
#map-ndvi .ndvi-tipo-control { order: 2; margin-top: 0; }
#map-ndvi .leaflet-draw { order: 3; }
.ndvi-tipo-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 4px;
  background: #fff;
  border: 1px solid #dfe7e2;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
}
.ndvi-tipo-control > .help-tip,
.ndvi-tipo-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 1 auto;
  min-width: 0;
}
.ndvi-tipo-control > button[data-ndvi-tipo],
.ndvi-tipo-switch button[data-ndvi-tipo] {
  flex: 0 1 auto;
  min-height: 30px;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
}
button.ndvi-tipo-switch > button,
.ndvi-tipo-switch > button,
.ndvi-tipo-switch button[data-ndvi-tipo] {
  flex: 0 1 auto;
  min-height: 34px;
  background: #fff;
  color: #176b39;
  border: 1px solid #9ecfb0;
}
.ndvi-tipo-switch > button.is-active,
.ndvi-tipo-switch button[data-ndvi-tipo].is-active {
  background: #176b39;
  color: #fff;
  border-color: #176b39;
}
.ndvi-tipo-control > .help-tip,
.ndvi-tipo-item > .help-tip {
  flex: 0 0 22px;
  width: 22px;
  min-width: 22px;
  height: 22px;
  min-height: 22px;
  margin: 0;
  padding: 0;
}
.ndvi-tipo-control > button[data-ndvi-tipo] {
  flex: 0 1 auto;
  min-height: 34px;
}
.ndvi-indice-native {
  position: absolute;
  width: 1px;
  height: 1px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  opacity: 0;
  pointer-events: none;
}
.plan-nutricional--chat { margin-top: 4px; }
.plan-recomienda { margin: 0 0 8px; font-weight: 700; color: #176b39; }
button.leaflet-locate-btn {
  box-sizing: border-box;
  width: 40px;
  height: 40px;
  min-width: 40px;
  max-width: 40px;
  min-height: 40px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: #fff;
  color: #333;
  font-size: 0;
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.tabla-host { position: relative; }
button.tabla-fullscreen-btn {
  position: sticky;
  top: 0;
  z-index: 2;
  float: right;
  min-height: 32px;
  margin: 0 0 6px 6px;
  padding: 4px 10px;
  border-radius: 8px;
  background: #e3f3e8;
  color: #176b39;
  font-size: .75rem;
  font-weight: 700;
}
.tabla-host.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 4600;
  max-height: none;
  margin: 0;
  padding: max(12px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom));
  overflow: auto;
  background: #fff;
  border-radius: 0;
}
.tabla-host.is-fullscreen table { min-width: 640px; }
body.tabla-fullscreen-open { overflow: hidden; }
body.ndvi-map-only-mode #ndviMapWrapper .leaflet-bottom.leaflet-left {
  bottom: calc(78px + env(safe-area-inset-bottom, 0px));
}
body.ndvi-map-only-mode #ndviMapWrapper .ndvi-map-badge {
  bottom: calc(152px + env(safe-area-inset-bottom, 0px));
}
body.ndvi-map-only-mode #ndviMapWrapper .ndvi-map-legend {
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
}