/* ============================================================
   app-shell.css – Sistema «cuaderno de campo» (docs/diseno.md):
   tokens, cabecera, barra inferior, Hoy, Calendario, hojas,
   avisos, finca de ejemplo y asistente de alta.
   ============================================================ */

:root {
  /* Color (docs/diseno.md) */
  --ink: #1c2119;
  --stone: #646b60;
  --paper: #f7f8f5;
  --sheet: #ffffff;
  --line: #e3e6df;
  --leaf: #2e7d32;
  --forest: #1b5e20;
  --soil: #8a5a3b;
  --frost: #2f6aa3;
  --heat: #c2410c;

  /* Derivados: fondos suaves y estados */
  --line-strong: #cdd2c7;
  --hover: #f1f3ee;
  --leaf-tint: #eaf3ea;
  --frost-tint: #ebf2f9;
  --heat-tint: #fbefe8;
  --soil-tint: #f6efe9;
  --stone-light: #9aa095;

  /* Forma y profundidad */
  --r-sheet: 16px;
  --r-ctl: 10px;
  --shadow-float: 0 10px 32px rgba(28, 33, 25, 0.16), 0 2px 6px rgba(28, 33, 25, 0.06);
  --focus-ring: 0 0 0 3px rgba(46, 125, 50, 0.35);
  --font: 'DM Sans', system-ui, -apple-system, sans-serif;

  /* Tokens heredados de styles.css, ahora sobre la paleta nueva */
  --color-bg: var(--paper);
  --color-text: var(--ink);
  --color-text-light: var(--stone);
  --color-primary: var(--leaf);
  --color-primary-dark: var(--forest);
  --color-line: var(--line);
  --color-card: var(--sheet);
  --color-earth: var(--soil);
  --color-earth-soft: var(--soil-tint);
  --color-late: var(--heat);
  --color-late-soft: var(--heat-tint);

  --tabbar-h: 0px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body {
  height: 100vh;
  height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
}

button, input, select, textarea { font-family: inherit; }

main {
  position: relative;
}

/* El mapa forma su propio contexto de apilado: sus controles (z-index altos de
   Leaflet) quedan por debajo de las secciones que se pintan encima */
#map-container {
  isolation: isolate;
}

:where(.section-view, .sheet-overlay, .tab-bar, #app-header, .action-toast, #sample-banner) :focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ===== Cabecera ===== */

#app-header {
  background: var(--forest);
  box-shadow: none;
}

.header-left {
  gap: 18px;
}

.parcel-name-input { font-weight: 600; }
.parcel-switcher { border-radius: var(--r-ctl); }

.section-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.section-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 6px 10px;
  border-radius: var(--r-ctl);
  color: rgba(255, 255, 255, 0.72);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.15s;
}

.section-link:hover { color: #fff; }

.section-link.active {
  color: #fff;
  font-weight: 600;
}

.section-link.active::after {
  content: '';
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 2px;
  height: 2px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.85);
}

.section-link-icon svg,
.tab-item-icon svg,
.header-settings-btn svg,
.icon svg,
.icon-btn > svg,
svg.icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
  flex-shrink: 0;
}

.icon { display: inline-flex; }

.header-settings-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.8);
  margin-right: 6px;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.header-settings-btn:hover,
.header-settings-btn.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.header-auth-btn,
.header-user-btn {
  min-height: 36px;
  border-radius: var(--r-ctl);
  border: none;
  background: rgba(255, 255, 255, 0.12);
  font-weight: 500;
}

.header-auth-btn:hover,
.header-user-btn:hover { background: rgba(255, 255, 255, 0.2); }

.header-user-dropdown {
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-float);
}

.dropdown-label {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.8rem;
  font-weight: 500;
}

a.dropdown-item {
  color: var(--ink);
  text-decoration: none;
}

.dropdown-item:hover { background: var(--hover); }
.dropdown-logout { color: var(--heat); }

@media (max-width: 1180px) {
  .parcel-municipality { display: none !important; }
}

@media (max-width: 980px) and (min-width: 769px) {
  .section-link-label { display: none; }
  .section-link { padding: 8px 10px; }
}

/* En las secciones (fuera de Diseño) sobran los pasos del editor y el panel */
body.shell-in-section .header-subnav,
body.shell-in-section .export-menu-wrap,
body.shell-in-section .sidebar-toggle {
  display: none !important;
}

body.shell-in-section #panel-lateral {
  visibility: hidden;
}

/* Durante la bienvenida (landing) no hay navegación */
body.shell-landing .section-nav,
body.shell-landing .tab-bar,
body.shell-landing .header-settings-btn {
  display: none !important;
}

/* ===== Contenedor de secciones ===== */

.section-view {
  position: absolute;
  inset: 0;
  z-index: 850;
  background: var(--paper);
  color: var(--ink);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
}

.section-view[hidden],
.section-pane[hidden],
.tab-bar[hidden] {
  display: none !important;
}

.section-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 28px 20px 56px;
}

.section-inner-wide {
  max-width: 1080px;
}

/* Título de pantalla: 28/32, 700 */
.section-header h1,
.screen-title {
  font-size: 1.75rem;
  line-height: 2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 20px;
}

/* Título de sección: 17/24, 600, en minúscula de frase */
.group-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 1.0625rem;
  line-height: 1.5rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 8px;
}

.group-count {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--stone);
  font-variant-numeric: tabular-nums;
}

.group-sub {
  margin: -4px 0 10px;
  color: var(--stone);
  font-size: 0.875rem;
  line-height: 1.25rem;
}

.num { font-variant-numeric: tabular-nums; }

.loading-state {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--stone);
  padding: 48px 0;
  justify-content: center;
}

.spinner-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--leaf);
  animation: spin 0.7s linear infinite;
}

/* ===== Listas (hoja blanca con separadores finos) ===== */

.list {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--r-sheet);
  overflow: hidden;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 12px 16px;
  position: relative;
  color: var(--ink);
  text-decoration: none;
  font-size: 1rem;
}

.list-row + .list-row::before {
  content: '';
  position: absolute;
  top: 0;
  left: 16px;
  right: 0;
  border-top: 1px solid var(--line);
}

a.list-row:hover,
button.list-row:hover,
label.list-row:hover { background: var(--hover); }

button.list-row {
  width: 100%;
  border: none;
  background: none;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.list-row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.list-row-sub { color: var(--stone); font-size: 0.875rem; line-height: 1.25rem; }
.list-row-value { color: var(--stone); text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.list-row-chevron { color: var(--stone-light); display: inline-flex; }

/* ===== Botones ===== */

.btn-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: var(--r-ctl);
  border: 1px solid var(--line-strong);
  background: var(--sheet);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.25;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-pill:hover { background: var(--hover); }
.btn-pill:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-pill-primary {
  background: var(--leaf);
  border-color: var(--leaf);
  color: #fff;
  font-weight: 600;
}

.btn-pill-primary:hover { background: var(--forest); border-color: var(--forest); }
.btn-pill-primary:active { background: var(--forest); }

.btn-pill-danger {
  color: var(--heat);
  border-color: var(--line-strong);
}

.btn-pill-danger:hover { background: var(--heat-tint); }

.btn-pill-sm {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.875rem;
}

/* Botón de texto: acciones secundarias */
.btn-text,
.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 8px;
  margin: 0 -8px;
  border: none;
  background: none;
  border-radius: var(--r-ctl);
  color: var(--leaf);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}

.btn-text:hover,
.btn-link:hover { background: var(--leaf-tint); }

.btn-text-muted { color: var(--stone); }
.btn-text-muted:hover { background: var(--hover); color: var(--ink); }
.btn-text-danger { color: var(--heat); }
.btn-text-danger:hover { background: var(--heat-tint); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--stone);
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn:hover { background: var(--hover); color: var(--ink); }

/* ===== Aviso tranquilo (sin bordes de color) ===== */

.notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--hover);
  color: var(--ink);
  font-size: 0.9375rem;
  line-height: 1.4;
}

.notice > .icon { margin-top: 1px; }
.notice p { margin: 0; }
.notice-title { font-weight: 600; }
.notice-frost { background: var(--frost-tint); }
.notice-frost > .icon, .notice-frost .notice-title { color: var(--frost); }
.notice-heat { background: var(--heat-tint); }
.notice-heat > .icon, .notice-heat .notice-title { color: var(--heat); }
.notice-leaf { background: var(--leaf-tint); }
.notice-leaf > .icon, .notice-leaf .notice-title { color: var(--forest); }
.notice-soil { background: var(--soil-tint); }
.notice-soil > .icon, .notice-soil .notice-title { color: var(--soil); }

/* ===== Estados vacíos ===== */

.empty-state {
  text-align: center;
  padding: 40px 20px;
  margin: 8px 0 20px;
}

.empty-state-lg { padding: 56px 20px; }

.empty-state-art {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--leaf-tint);
  color: var(--leaf);
  font-size: 1.6rem;
  line-height: 1;
  margin-bottom: 16px;
}

.empty-state-art svg { width: 26px; height: 26px; }

.empty-state h2 {
  font-size: 1.25rem;
  line-height: 1.75rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--stone);
  line-height: 1.5;
  max-width: 440px;
  margin: 0 auto 20px;
}

.empty-state-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.soon-pill {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--soil);
  margin-bottom: 4px;
}

.soon-list {
  list-style: none;
  max-width: 380px;
  margin: 0 auto 24px;
  text-align: left;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--r-sheet);
}

.soon-list li {
  padding: 12px 16px;
  color: var(--ink);
  font-size: 0.9375rem;
}

.soon-list li + li { border-top: 1px solid var(--line); }

/* ===== Hoy: cabecera (lo memorable) ===== */

.today-header {
  margin-bottom: 28px;
}

.today-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 32px;
}

.today-date {
  color: var(--soil);
  font-size: 0.9375rem;
  font-weight: 500;
}

.today-title {
  font-size: 1.75rem;
  line-height: 2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  overflow-wrap: anywhere;
  margin-top: 2px;
}

/* Zona climática: texto tranquilo que abre la hoja de zona */
.zone-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  max-width: 60%;
  margin: -6px -8px -6px 0;
  padding: 6px 8px;
  border: none;
  border-radius: var(--r-ctl);
  background: none;
  color: var(--stone);
  font-size: 0.875rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  text-align: right;
}

.zone-chip:hover { background: var(--hover); color: var(--ink); }
.zone-chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zone-chip .icon svg { width: 16px; height: 16px; }

/* Franja de la semana */
.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin: 20px 0 0;
}

.week-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 72px;
  padding: 8px 0 6px;
  border: none;
  border-radius: 12px;
  background: none;
  color: var(--ink);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background 0.15s;
}

.week-day:hover { background: var(--hover); }

.week-day-dow {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--stone);
  line-height: 1rem;
}

.week-day-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1rem;
  font-weight: 600;
}

.week-day.is-today .week-day-num {
  background: var(--forest);
  color: #fff;
}

.week-day.is-today .week-day-dow { color: var(--forest); font-weight: 600; }

.week-day.is-selected:not(.is-today) .week-day-num {
  box-shadow: inset 0 0 0 1.5px var(--forest);
  color: var(--forest);
}

.week-day.is-selected { background: var(--leaf-tint); }

.week-day-dots {
  display: flex;
  gap: 3px;
  height: 6px;
  align-items: center;
}

.week-day-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--leaf);
}

.week-day-dots i.is-late { background: var(--heat); }

/* Línea de almanaque */
.almanac {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
}

.almanac strong { font-weight: 600; color: var(--forest); }

.today-filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.today-filter .group-title { margin: 0; }

.today-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: 4px;
  padding: 0 8px;
}

/* ===== Grupos y filas de tarea ===== */

.task-group {
  margin-bottom: 28px;
}

.task-group.flash .task-list { box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.25); }

.task-list {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--r-sheet);
  overflow: hidden;
  transition: box-shadow 0.4s;
}

.task-group-late .group-title { color: var(--heat); }

details.task-group-done > summary {
  cursor: pointer;
  list-style: none;
  min-height: 44px;
  align-items: center;
  border-radius: var(--r-ctl);
}

details.task-group-done > summary::-webkit-details-marker { display: none; }
details.task-group-done > summary .group-count { display: inline-flex; align-items: center; gap: 4px; }
details.task-group-done > summary .icon svg { width: 16px; height: 16px; transition: transform 0.15s; }
details.task-group-done[open] > summary .icon svg { transform: rotate(180deg); }

.task {
  position: relative;
  display: grid;
  grid-template-columns: 56px 1fr;
  transition: opacity 0.25s, background 0.15s;
}

.task + .task::before {
  content: '';
  position: absolute;
  top: 0;
  left: 56px;
  right: 0;
  border-top: 1px solid var(--line);
}

/* Casilla redonda de 24px dentro de un área de 44px+ */
.task-check {
  grid-row: 1 / span 2;
  align-self: start;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 56px;
  height: 100%;
  min-height: 56px;
  padding: 14px 0 0;
  border: none;
  background: none;
  cursor: pointer;
}

.task-check-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--stone-light);
  color: #fff;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.task-check-circle svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s, transform 0.2s;
}

.task-check:hover .task-check-circle { border-color: var(--leaf); background: var(--leaf-tint); }
.task-check:focus-visible { box-shadow: none !important; }
.task-check:focus-visible .task-check-circle { box-shadow: var(--focus-ring); }

.task-check[aria-checked="true"] .task-check-circle,
.task.is-checking .task-check-circle {
  background: var(--leaf);
  border-color: var(--leaf);
}

.task-check[aria-checked="true"] .task-check-circle svg,
.task.is-checking .task-check-circle svg {
  opacity: 1;
  transform: none;
}

.task.is-checking .task-check-circle { transform: scale(1.08); }
.task.is-checking { opacity: 0.45; }

.task-skipped .task-check-circle { border-style: dashed; }

.task-head {
  display: block;
  width: 100%;
  min-height: 56px;
  padding: 14px 16px 14px 0;
  border: none;
  background: none;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
}

.task-head:focus-visible { outline: 2px solid var(--leaf); outline-offset: -3px; box-shadow: none !important; border-radius: 0 var(--r-ctl) var(--r-ctl) 0; }

.task-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.task-title {
  font-size: 1rem;
  line-height: 1.5rem;
  font-weight: 500;
  color: var(--ink);
  overflow-wrap: anywhere;
  min-width: 0;
}

.task-due {
  flex-shrink: 0;
  max-width: 45%;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--stone);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.task-due.is-late { color: var(--heat); font-weight: 500; }
.task-due.is-soon { color: var(--soil); font-weight: 500; }

.task-meta {
  display: block;
  margin-top: 2px;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--stone);
  overflow-wrap: anywhere;
}

.task-meta-emoji { margin-right: 6px; }

.task-done .task-title,
.task-skipped .task-title {
  color: var(--stone);
  text-decoration: line-through;
  text-decoration-color: var(--stone-light);
}

.task-done .task-meta-emoji,
.task-skipped .task-meta-emoji { opacity: 0.6; filter: grayscale(0.6); }

/* Detalle desplegado */
.task-more {
  grid-column: 2;
  padding: 0 16px 12px 0;
}

.task-more[hidden] { display: none; }

.task.is-open { background: #fbfcfa; }

.task-detail {
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--ink);
  overflow-wrap: anywhere;
  white-space: pre-line;
  margin-bottom: 8px;
}

.task-facts {
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--stone);
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}

.task-legal {
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--stone);
  background: var(--paper);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 4px 0 8px;
}

.task-legal a { color: var(--leaf); }

.task-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 24px;
}

.task-actions .btn-text-edit { margin-left: auto; margin-right: 0; }

/* ===== Calendario ===== */

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.cal-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cal-title {
  font-size: 1.75rem;
  line-height: 2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  min-width: 190px;
}

.cal-arrows { display: flex; }

.cal-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cal-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 -20px;
  padding: 2px 20px 4px;
  scrollbar-width: none;
}

.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--sheet);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--stone);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
}

/* Área táctil de 44px aunque el chip mida 36 */
.chip::after { content: ''; position: absolute; inset: -4px 0; }

.chip:hover { color: var(--ink); background: var(--hover); }

.chip.active {
  background: var(--leaf-tint);
  border-color: transparent;
  color: var(--forest);
  font-weight: 600;
}

.cal-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  color: var(--stone);
  cursor: pointer;
  min-height: 44px;
  align-self: flex-start;
}

.cal-toggle input { width: 18px; height: 18px; accent-color: var(--leaf); }

.cal-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media (min-width: 900px) {
  .cal-layout {
    grid-template-columns: 320px 1fr;
    align-items: start;
    gap: 32px;
  }
  .cal-grid {
    position: sticky;
    top: 16px;
  }
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--r-sheet);
  padding: 12px 8px;
}

.cal-dow {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--stone);
  padding: 0 0 6px;
}

.cal-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  min-height: 44px;
  padding: 4px 0 2px;
  border: none;
  border-radius: var(--r-ctl);
  background: transparent;
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}

.cal-day:hover { background: var(--hover); }
.cal-day.is-selected { background: var(--leaf-tint); box-shadow: inset 0 0 0 1px var(--leaf); }
.cal-day.is-out { color: var(--stone-light); }
.cal-day.is-out .cal-day-dots { opacity: 0.4; }

.cal-day-num {
  font-size: 0.875rem;
  font-weight: 500;
  width: 28px;
  height: 28px;
  line-height: 28px;
  text-align: center;
  border-radius: 50%;
}

.cal-day.is-today .cal-day-num {
  background: var(--forest);
  color: #fff;
  font-weight: 600;
}

.cal-day-dots {
  display: flex;
  gap: 2px;
  height: 5px;
}

.cal-day-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--leaf);
}

/* Cabeceras de día fijas al desplazar */
.day-group { margin-bottom: 20px; }

.day-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 -4px 8px;
  padding: 10px 4px 6px;
  background: var(--paper);
  font-size: 1.0625rem;
  line-height: 1.5rem;
  font-weight: 600;
  color: var(--ink);
}

.day-head.is-today { color: var(--forest); }
.day-head-sub { font-size: 0.875rem; font-weight: 500; color: var(--stone); }

.week-sep {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--stone);
  margin: 28px 0 4px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.week-sep:first-child { margin-top: 0; padding-top: 0; border-top: none; }

.day-group.flash .task-list { box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.25); }

.calm-note {
  padding: 20px 4px;
  color: var(--stone);
  line-height: 1.5;
}

.calm-note strong { color: var(--ink); font-weight: 600; }

/* ===== Ajustes básicos (shell.js, sin ajustes.js) ===== */

.settings-card {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--r-sheet);
  padding: 16px;
  margin-bottom: 24px;
}

.settings-card h2 {
  font-size: 1.0625rem;
  line-height: 1.5rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
}

.settings-card p { line-height: 1.5; margin-bottom: 12px; }
.settings-strong { font-weight: 600; margin-bottom: 2px !important; }
.settings-note { color: var(--stone); font-size: 0.875rem; }

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 1rem;
}

.settings-row span { color: var(--ink); }
.settings-row strong { text-align: right; font-weight: 400; color: var(--stone); overflow-wrap: anywhere; }
.settings-row + .btn-pill { margin-top: 14px; }

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ===== Modales / hojas ===== */

.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  background: rgba(28, 33, 25, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.2s;
  font-family: var(--font);
  color: var(--ink);
}

.sheet-overlay.open { opacity: 1; }
.sheet-overlay:not(.open) { pointer-events: none; }
body.has-open-sheet .section-view { overflow: hidden; }

.sheet {
  width: 100%;
  max-width: 480px;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  background: var(--sheet);
  border-radius: var(--r-sheet);
  box-shadow: var(--shadow-float);
  transform: translateY(12px);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sheet-small { max-width: 400px; }
.sheet:focus { outline: none; }

.sheet-overlay.open .sheet { transform: none; }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 12px 4px 20px;
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--sheet);
}

.sheet-title {
  font-size: 1.25rem;
  line-height: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.sheet-close {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: none;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--stone);
  cursor: pointer;
  flex-shrink: 0;
}

.sheet-close:hover { background: var(--hover); color: var(--ink); }

.sheet-body { padding: 8px 20px 24px; }

.sheet-sub {
  color: var(--stone);
  font-size: 0.9375rem;
  margin-bottom: 16px;
  line-height: 1.45;
}

.sheet-options {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.sheet-option {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  min-height: 56px;
  padding: 12px 44px 12px 16px;
  border: none;
  background: var(--sheet);
  text-align: left;
  font-family: inherit;
  cursor: pointer;
}

.sheet-option + .sheet-option { border-top: 1px solid var(--line); }
.sheet-option strong { font-size: 1rem; font-weight: 500; color: var(--ink); }
.sheet-option span { font-size: 0.875rem; color: var(--stone); line-height: 1.4; }
.sheet-option:hover { background: var(--hover); }

.sheet-option.selected strong { color: var(--forest); font-weight: 600; }

.sheet-option.selected::after {
  content: '';
  position: absolute;
  right: 18px;
  top: 50%;
  width: 6px;
  height: 12px;
  margin-top: -8px;
  border: solid var(--leaf);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.sheet-option:disabled { opacity: 0.6; cursor: wait; }

.sheet-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sheet-form label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
  margin-top: 10px;
}

.sheet-form label small { color: var(--stone); font-weight: 400; }

.sheet-form input,
.sheet-form select,
.sheet-form textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl);
  font-family: inherit;
  font-size: 16px; /* evita el zoom automático de iOS */
  background: var(--sheet);
  color: var(--ink);
}

.sheet-form textarea { resize: vertical; }

.sheet-form input:focus,
.sheet-form select:focus,
.sheet-form textarea:focus {
  outline: none;
  border-color: var(--leaf);
  box-shadow: var(--focus-ring);
}

.sheet-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.sheet-form-row > div { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.sheet-inline {
  padding-top: 4px;
}

.sheet-inline .btn-pill { margin-top: 8px; }

.sheet-error {
  color: var(--heat);
  font-size: 0.875rem;
  margin-top: 6px;
}

.sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.sheet-actions .btn-pill-danger,
.sheet-actions .btn-text-danger { margin-right: auto; margin-left: -8px; }

/* ===== Avisos (toasts) ===== */

.save-toast {
  width: max-content;
  max-width: calc(100vw - 32px);
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.4;
  background: var(--ink);
  color: #fff;
  border-radius: 12px;
  padding: 12px 20px;
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 500;
  box-shadow: var(--shadow-float);
}

.action-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 16px);
  transform: translateX(-50%) translateY(12px);
  z-index: 3500;
  display: flex;
  align-items: center;
  gap: 12px;
  width: max-content; /* con left: 50% el ancho se encogería a media pantalla */
  max-width: calc(100vw - 32px);
  padding: 6px 6px 6px 16px;
  min-height: 52px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-family: var(--font);
  font-size: 0.9375rem;
  box-shadow: var(--shadow-float);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.action-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.action-toast-msg { line-height: 1.35; padding: 8px 0; }

.action-toast-btn {
  flex-shrink: 0;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: none;
  color: #a5d6a7;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
}

.action-toast-btn:hover { background: rgba(255, 255, 255, 0.08); }

/* ===== Diseño: árboles por plantar y cultivos del bancal ===== */

.tree-marker-planned {
  opacity: 0.45;
  filter: grayscale(0.4);
}

.tree-marker-planned .tree-marker-emoji {
  outline: 2px dashed rgba(255, 255, 255, 0.9);
  outline-offset: 2px;
  border-radius: 50%;
}

.tree-list-planned {
  font-size: 0.75rem;
  color: var(--soil);
  background: var(--soil-tint);
  border-radius: 999px;
  padding: 1px 8px;
}

.tree-planned-toggle {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.875rem;
  cursor: pointer;
  margin: 4px 0 8px;
}

.tree-planned-toggle input { margin-top: 2px; accent-color: var(--leaf); }
.tree-planned-toggle small { color: var(--stone); }

.bed-crops h4 { margin: 10px 0 2px; }

.bed-crops-hint {
  font-size: 0.8rem;
  color: var(--stone);
  margin-bottom: 8px;
  line-height: 1.4;
}

.bed-crop {
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  padding: 8px 10px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bed-crop-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
}

.bed-crop-name { font-weight: 600; flex: 1; }
.bed-crop-count { font-size: 0.75rem; color: var(--stone); }

.bed-crop-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bed-crop-row select { flex-basis: 100%; }

.bed-crop-row select,
.bed-crop-row input,
.bed-crop-variety {
  min-width: 0;
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-size: 0.82rem;
  font-family: inherit;
  background: var(--sheet);
}

.bed-crop-row input[hidden] { display: none; }

/* ===== Barra inferior (móvil) ===== */

.tab-bar { display: none; }

@media (max-width: 768px) {
  body.has-shell:not(.shell-landing) {
    --tabbar-h: calc(58px + var(--safe-bottom));
  }

  .section-nav { display: none; }

  .tab-bar {
    display: flex;
    flex-shrink: 0;
    height: var(--tabbar-h);
    padding-bottom: var(--safe-bottom);
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--line);
    z-index: 1100;
    position: relative;
  }

  .tab-item {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--stone);
    font-family: var(--font);
    font-size: 0.6875rem;
    font-weight: 500;
    -webkit-tap-highlight-color: transparent;
  }

  .tab-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 24px;
  }

  .tab-item-icon svg { width: 22px; height: 22px; }

  .tab-item.active { color: var(--forest); font-weight: 600; }
  .tab-item.active .tab-item-icon svg { stroke-width: 2; }

  .tab-item:focus-visible { box-shadow: inset var(--focus-ring) !important; }

  .tab-item-label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Lo que estaba anclado abajo sube por encima de la barra */
  body.has-shell #panel-lateral { bottom: var(--tabbar-h); }
  body.has-shell .sidebar-toggle { bottom: calc(var(--tabbar-h) + 12px); }
  body.has-shell #demo-banner { bottom: calc(var(--tabbar-h) + 10px); }
  body.has-shell .save-toast { bottom: calc(var(--tabbar-h) + 16px); }

  /* Cabecera compacta: que quepa en 360 px */
  .header-topbar { gap: 6px; }
  .header-left { gap: 0; }
  /* Los nombres no pueden ocupar el espacio reservado a marca y controles. El
     tamaño intrínseco de select y botón antes los hacía invadir la marca. */
  .header-center .parcel-switcher {
    flex: 1 1 0;
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }
  .header-center .parcel-name-input { flex: 1 1 0; min-width: 0; width: 100%; }
  .header-user-btn { max-width: clamp(76px, 28vw, 112px); }
  #header-user-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .header-user-arrow { flex-shrink: 0; }
  .header-settings-btn { margin-right: 2px; }
  .header-auth-btn {
    padding: 6px 14px;
    font-size: 0.875rem;
    white-space: nowrap;
    min-height: 40px;
  }
  .header-auth-btn .header-auth-long { display: none; }
  .header-auth-btn .header-auth-short { display: inline; }
  /* En las secciones el nombre de la finca ya es el título: arriba, la marca */
  body.shell-in-section .parcel-name-input,
  body.shell-in-section .parcel-municipality { display: none !important; }
  body.shell-in-section .header-brand-name { display: inline-block; }
  body.shell-in-section .header-center { justify-content: flex-end; }

  .export-menu-wrap #export-btn { font-size: 0; padding: 6px 10px; }
  .export-menu-wrap #export-btn::before { content: '⬇'; font-size: 0.9rem; }
  .parcel-switcher { max-width: min(44vw, 180px); text-overflow: ellipsis; }

  .section-inner { padding: 20px 20px 40px; }

  .cal-header { gap: 8px; }
  .cal-nav { flex: 1; min-width: 0; }
  .cal-title { min-width: 0; flex: 1; font-size: 1.5rem; }

  /* Modales como hoja inferior */
  .sheet-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .sheet,
  .sheet-small {
    max-width: none;
    border-radius: var(--r-sheet) var(--r-sheet) 0 0;
    max-height: 90dvh;
    padding-bottom: var(--safe-bottom);
    transform: translateY(40px);
  }
  .sheet-actions { flex-direction: row; }
}

@media (max-width: 380px) {
  .sheet-form-row { grid-template-columns: 1fr; }
  .section-inner { padding-left: 16px; padding-right: 16px; }
  .chip-row { margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
  .task { grid-template-columns: 48px 1fr; }
  .task-check { width: 48px; }
  .task + .task::before { left: 48px; }
  .task-due { max-width: 42%; }
  .week-day-num { width: 30px; height: 30px; font-size: 0.9375rem; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet-overlay, .sheet, .action-toast, .task, .task-list,
  .task-check-circle, .task-check-circle svg, .week-day {
    transition: none !important;
  }
}

/* ===== Finca de ejemplo (?demo=1) =====
   Franja fija sobre la barra inferior que reserva su propio espacio: no tapa
   tareas ni botones (main se acorta lo mismo que mide). */

body.has-sample-banner { --sample-h: 52px; }

#sample-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--tabbar-h);
  height: var(--sample-h, 52px);
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 8px 0 16px;
  background: var(--sheet);
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--font);
  font-size: 0.875rem;
}

#sample-banner > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--stone); }
#sample-banner > span strong { color: var(--ink); font-weight: 600; }

body.has-sample-banner main { margin-bottom: var(--sample-h); }

.sample-banner-cta {
  flex-shrink: 0;
  min-height: 44px;
  margin-left: 4px;
  padding: 6px 10px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--leaf);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.sample-banner-cta:hover { background: var(--leaf-tint); }

.sample-banner-close {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--stone);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.sample-banner-close:hover { background: var(--hover); color: var(--ink); }

/* Los avisos flotan por encima de la franja */
body.has-sample-banner .action-toast,
body.has-sample-banner .save-toast { bottom: calc(var(--tabbar-h) + var(--sample-h) + 16px); }

@media (max-width: 768px) {
  body.has-shell.has-sample-banner #panel-lateral { bottom: calc(var(--tabbar-h) + var(--sample-h)); }
  body.has-shell.has-sample-banner .sidebar-toggle { bottom: calc(var(--tabbar-h) + var(--sample-h) + 104px); }
}

@media (max-width: 380px) {
  #sample-banner { padding-left: 12px; gap: 0; }
}

/* ===== Asistente de alta: ¿qué tienes o quieres plantar? ===== */

.onb-h {
  margin: 20px 0 10px;
  font-size: 1.0625rem;
  line-height: 1.5rem;
  font-weight: 600;
  color: var(--ink);
}

.onb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.onb-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 14px 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--sheet);
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--ink);
  cursor: pointer;
}

.onb-chip:hover { background: var(--hover); }

.onb-chip.active {
  /* Mismo peso que sin marcar: si el chip cambiara de ancho, los demás se recolocarían
     al marcarlo y el siguiente toque caería en otro */
  border-color: var(--leaf);
  background: var(--leaf-tint);
  color: var(--forest);
}

.onb-chip-emoji { font-size: 1.1rem; line-height: 1; }

.onb-counts {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.onb-count {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 8px 4px 16px;
  min-height: 52px;
  font-size: 1rem;
}

.onb-count + .onb-count { border-top: 1px solid var(--line); }

.onb-count-name { display: inline-flex; align-items: center; gap: 8px; }

.onb-stepper {
  display: flex;
  align-items: center;
  gap: 2px;
}

.onb-stepper button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: none;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--leaf);
  cursor: pointer;
}

.onb-stepper button:hover { background: var(--leaf-tint); }

.onb-stepper-val {
  width: 52px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: var(--sheet);
  font: inherit;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  -moz-appearance: textfield;
}
.onb-stepper-val::-webkit-outer-spin-button,
.onb-stepper-val::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.onb-stepper-val:focus { outline: none; border-color: var(--leaf); box-shadow: var(--focus-ring); }
.onb-stepper .onb-step5 { width: auto; min-width: 44px; padding: 0 8px; border-radius: 999px; font-size: 0.9375rem; font-weight: 600; }

.onb-planted {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  font-size: 0.9375rem;
  color: var(--stone);
}

.onb-seg {
  display: inline-flex;
  padding: 2px;
  border-radius: var(--r-ctl);
  background: var(--hover);
}

.onb-seg button {
  min-height: 40px;
  padding: 6px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--stone);
  cursor: pointer;
}

.onb-seg button.active {
  background: var(--sheet);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(28, 33, 25, 0.12);
}

.onb-note {
  margin-top: 12px;
  font-size: 0.875rem;
  color: var(--stone);
  line-height: 1.45;
}

.onb-note[hidden],
.onb-counts[hidden],
.onb-planted[hidden] { display: none; }

.onb-actions {
  position: sticky;
  bottom: 0;
  margin: 20px -20px -24px;
  padding: 12px 20px calc(16px + var(--safe-bottom));
  background: var(--sheet);
  border-top: 1px solid var(--line);
  flex-wrap: wrap-reverse;
}

.onb-actions .btn-pill-primary:disabled { opacity: 0.45; cursor: not-allowed; }

@media (max-width: 420px) {
  .onb-actions .btn-pill { flex: 1 1 auto; }
}

/* ===== Diseño: aviso de dibujo y confirmar lindes en móvil ===== */

.map-toast {
  top: 16px;
  width: max-content;
  max-width: calc(100% - 128px); /* deja libres el zoom y el selector de capas */
  white-space: normal;
  text-align: center;
  line-height: 1.4;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(28, 33, 25, 0.88);
  font-family: var(--font);
  font-size: 0.875rem;
}

.map-continue-btn {
  border-radius: var(--r-ctl);
  font-family: var(--font);
  box-shadow: var(--shadow-float);
}

.map-confirm-btn { display: none; }

@media (max-width: 768px) {
  .map-confirm-btn.visible {
    display: block;
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: calc(16px + var(--safe-bottom));
    z-index: 790; /* por debajo del panel desplegado, que ya lo tiene */
    min-height: 48px;
    border: none;
    border-radius: var(--r-ctl);
    background: var(--leaf);
    color: #fff;
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 600;
    box-shadow: var(--shadow-float);
    cursor: pointer;
  }
  .map-confirm-btn:active { background: var(--forest); }
  /* Ayuda y créditos del mapa suben por encima del botón */
  #map-container:has(.map-confirm-btn.visible) .leaflet-bottom { bottom: calc(72px + var(--safe-bottom)); }
  /* El botón de mostrar el panel sube para no taparlo */
  body.has-shell .sidebar-toggle { bottom: calc(var(--tabbar-h) + 104px); }
}

/* ===== Aviso de modo prueba (app.js, #demo-banner) ===== */

#demo-banner {
  gap: 4px 8px;
  padding: 6px 6px 6px 16px;
  border-radius: 12px;
  background: var(--sheet);
  border: 1px solid var(--line);
  color: var(--stone);
  font-family: var(--font);
  font-size: 0.875rem;
  line-height: 1.4;
  box-shadow: var(--shadow-float);
}

#demo-banner strong { color: var(--ink); font-weight: 600; }

#demo-banner-cta {
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 8px;
  background: none;
  color: var(--leaf);
  font-family: inherit;
  font-weight: 600;
}

#demo-banner-cta:hover { background: var(--leaf-tint); }

#demo-banner-close {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  color: var(--stone);
  font-size: 1.4rem;
}

#demo-banner-close:hover { background: var(--hover); color: var(--ink); }

/* Diseño › Árboles: modo «Añadir árboles en el mapa» (solo se planta con él activo) */
.tree-add-toggle {
  display: block;
  width: 100%;
  min-height: 44px;
  margin: 12px 0 4px;
  background: var(--sheet);
  color: var(--leaf);
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
}
.tree-add-toggle:hover { background: var(--leaf-tint, #eef5ee); border-color: var(--leaf); }
.tree-add-toggle.is-active { background: var(--leaf); border-color: var(--leaf); color: #fff; }

/* Cabecera: «Entrar» compacto en móvil, texto completo en escritorio */
.header-auth-short { display: none; }

/* Registro: mostrar contraseña, nombre opcional y enlace a los Términos */
.auth-pw-wrap { position: relative; display: flex; }
.auth-pw-wrap input { flex: 1; min-width: 0; padding-right: 84px !important; }
.auth-pw-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  min-height: 36px;
  padding: 0 12px;
  border: none;
  border-radius: 8px;
  background: none;
  color: #66bb6a;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.auth-pw-toggle:hover { background: rgba(255, 255, 255, 0.08); }
.auth-optional { font-weight: 400; color: rgba(255, 255, 255, 0.5); }
.auth-terms { margin: 0; font-size: 0.78rem; line-height: 1.4; color: rgba(255, 255, 255, 0.6); text-align: left; }
.auth-terms a { color: #66bb6a; }

/* ===== Hoy: riego de esta semana (riego-semana.js) ===== */
.water-list {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--r-sheet);
  overflow: hidden;
}
.water-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  min-height: 56px;
}
.water-row + .water-row { border-top: 1px solid var(--line); }
.water-emoji { width: 24px; flex: 0 0 24px; font-size: 1.15rem; line-height: 1.5rem; text-align: center; }
.water-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.water-main { font-size: 0.9375rem; line-height: 1.5rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.water-sub { font-size: 0.875rem; line-height: 1.25rem; color: var(--stone); }
.water-row.is-dry .water-main { color: var(--stone); }

/* ===== Detalle de tarea: guía «Cómo hacerlo» ===== */
.task-guide {
  margin: 4px 0 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.task-guide > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 8px 0;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  color: var(--leaf);
}
.task-guide > summary::-webkit-details-marker { display: none; }
.task-guide > summary .icon { transition: transform 0.2s; color: var(--stone); display: inline-flex; }
.task-guide[open] > summary .icon { transform: rotate(180deg); }
.task-guide-meta { margin-left: auto; font-weight: 400; font-size: 0.875rem; color: var(--stone); }
.task-guide-body { padding: 0 0 12px; font-size: 0.9375rem; line-height: 1.5rem; color: var(--ink); }
.task-guide-body p { margin: 0 0 8px; }
.task-guide-body h4 { margin: 12px 0 4px; font-size: 0.9375rem; font-weight: 600; }
.task-guide-body ol, .task-guide-body ul { margin: 0; padding-left: 20px; }
.task-guide-body li + li { margin-top: 4px; }
.task-guide-safety { color: var(--stone); font-size: 0.875rem; line-height: 1.25rem; }
@media (prefers-reduced-motion: reduce) { .task-guide > summary .icon { transition: none; } }

/* La hoja del alta tiene alto fijo: si creciera al marcar un frutal (aparecen las
   cantidades), al estar centrada (o anclada abajo en móvil) movería los chips bajo el dedo */
.onb-sheet {
  height: min(calc(100dvh - 40px), 860px);
  display: flex;
  flex-direction: column;
}
.onb-sheet .sheet-body { flex: 1 0 auto; display: flex; flex-direction: column; }
.onb-sheet .onb { flex: 1 0 auto; display: flex; flex-direction: column; }
.onb-sheet .onb-actions { margin-top: auto; }
@media (max-width: 768px) {
  .onb-sheet { height: 90dvh; }
}

/* Diseño y acceso: etiquetas en minúscula de frase (docs/diseno.md, sin mayúsculas) */
#panel-lateral h3,
.input-group label,
.advanced-toggle,
.sidebar-plan-label {
  text-transform: none;
  letter-spacing: 0;
}

/* Línea de la guía concretada para la especie de la tarea */
.task-guide-species {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--sheet);
  border: 1px solid var(--line);
  color: var(--ink);
}

/* Con una hoja abierta, los avisos del mapa no se superponen a sus botones */
body:has(.sheet-overlay.open) .save-toast,
body:has(.sheet-overlay.open) .map-toast { opacity: 0; pointer-events: none; }

/* El acceso a la cuenta comparte el papel, los controles y el ritmo de la agenda. */
#auth-popup {
  padding: 16px;
  background: rgba(28, 33, 25, 0.4);
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: none;
}
#auth-popup .auth-popup {
  width: 100%;
  max-width: 420px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 32px 28px;
  background: var(--sheet);
  color: var(--ink);
  border-radius: var(--r-sheet);
  box-shadow: var(--shadow-float);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  animation: none;
}
#auth-popup .auth-popup:focus { outline: none; }
#auth-popup :focus-visible { outline: 2px solid var(--leaf); outline-offset: 3px; }
#auth-popup .landing-logo { margin-bottom: 20px; font-size: 36px; animation: none; }
#auth-popup .logo-crop,
#auth-popup .logo-tia { color: var(--forest); }
#auth-popup .landing-title { color: var(--ink); font-size: 1.25rem; font-weight: 600; }
#auth-popup .auth-popup-subtitle,
#auth-popup .auth-forgot-desc,
#auth-popup .auth-optional,
#auth-popup .auth-terms { color: var(--stone); }
#auth-popup .landing-auth-tabs { background: var(--paper); border-radius: var(--r-ctl); }
#auth-popup .landing-auth-tab { min-height: 44px; color: var(--stone); }
#auth-popup .landing-auth-tab.active { background: var(--leaf-tint); color: var(--forest); }
#auth-popup .input-group label { color: var(--ink); font-size: 0.875rem; }
#auth-popup .input-group input {
  min-height: 48px;
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--sheet);
  color: var(--ink);
  font-size: 1rem;
}
#auth-popup .input-group input::placeholder { color: var(--stone); }
#auth-popup .input-group input:focus { border-color: var(--leaf); box-shadow: var(--focus-ring); }
#auth-popup .auth-popup-close-btn { width: 44px; height: 44px; color: var(--stone); border-radius: var(--r-ctl); }
#auth-popup .auth-popup-close-btn:hover { color: var(--ink); background: var(--hover); }
#auth-popup .auth-forgot-link,
#auth-popup .auth-pw-toggle { min-height: 44px; color: var(--leaf); }
#auth-popup .auth-terms a { color: var(--leaf); }
#auth-popup .landing-btn-primary { min-height: 48px; background: var(--leaf); color: #fff; box-shadow: none; }
#auth-popup .landing-btn-primary:hover { background: var(--forest); }
#auth-popup button:disabled { opacity: 0.65; cursor: wait; }
#auth-popup .landing-error { background: var(--heat-tint); color: var(--heat); }
#auth-popup .auth-forgot-success { background: var(--leaf-tint); color: var(--forest); }

.inventory-sheet { max-width: 560px; }
.inventory-form { gap: 8px; }
.inventory-form > label { margin-top: 8px; }
.inventory-help { color: var(--stone); font-size: 0.8125rem; line-height: 1.4; margin: 0; }
.inventory-add { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.inventory-add .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.inventory-add select { min-width: 0; flex: 1; }
.inventory-rows { display: grid; gap: 12px; }
.inventory-row { border: 1px solid var(--line); border-radius: var(--r-ctl); margin: 0; padding: 8px 12px 4px; min-width: 0; }
.inventory-row legend { padding: 0 4px; font-weight: 600; }
.inventory-row-fields { display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 12px; }
.inventory-row-fields > div { min-width: 0; }
.inventory-row label { display: block; font-size: 0.8125rem; margin-bottom: 4px; color: var(--stone); }
.inventory-row input, .inventory-row select { width: 100%; min-width: 0; }
.inventory-date { margin-top: 12px; }
.inventory-date[hidden], .inventory-empty[hidden] { display: none; }
.inventory-row-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 4px; }
.inventory-empty { color: var(--stone); font-size: 0.875rem; line-height: 1.5; margin: 4px 0; }
.inventory-actions { position: sticky; bottom: -24px; margin: 16px -20px -24px; padding: 12px 20px calc(16px + var(--safe-bottom)); background: var(--sheet); border-top: 1px solid var(--line); }
.inventory-actions .btn-pill { width: 100%; }
.inventory-manage { margin-top: 8px; }
#inventory-map-note { position: absolute; z-index: 810; left: 64px; right: 64px; top: 12px; max-width: 440px; margin: 0 auto; padding: 12px 16px; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-ctl); box-shadow: var(--shadow-float); font-size: 0.875rem; }
#inventory-map-note p { margin: 0 0 8px; line-height: 1.4; }
@media (max-width: 420px) { #inventory-map-note { left: 52px; right: 52px; padding: 12px; } }
@media (max-width: 420px) {
  #auth-popup { padding: 12px; }
  #auth-popup .auth-popup { padding: 28px 20px 20px; max-height: calc(100dvh - 24px); }
}
