/* ==========================================================================
   Mi Finca Resiliente — hoja de estilos
   Tipografía Poppins y paleta tomadas de la Cartilla Climática Comunitaria.
   Las fuentes se sirven desde este mismo origen (la CSP no permite CDNs).
   ========================================================================== */

@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/poppins-400-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/poppins-400-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/poppins-500-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/poppins-500-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/poppins-600-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/poppins-600-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/poppins-700-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/poppins-700-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 800; font-display: swap; src: url('/fonts/poppins-800-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 800; font-display: swap; src: url('/fonts/poppins-800-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  /* Paleta de la cartilla */
  --lima: #BCCF63;        /* banda superior de cada página */
  --oliva: #777F3E;       /* cabeceras de tabla */
  --verde-osc: #1B5E20;   /* títulos */
  --verde: #2E7D32;
  --verde-med: #43A047;
  --verde-claro: #66BB6A;
  --verde-lima: #9CCC65;
  --morado: #621444;      /* marca Paz y Desarrollo */
  --naranja: #FCAC66;
  --rosa: #FB3D95;
  --coral: #FC545A;

  --primary: var(--verde-osc);
  --primary-dark: #14481a;
  --bg: #F1F8E9;          /* fondo verde muy claro de la cartilla */
  --card: #ffffff;
  --band: #EAF3E0;        /* bandas suaves dentro de tarjetas */
  --text: #23301F;
  --muted: #667065;
  --border: #C4CFC7;
  --error: #C62828;
  --ok: #2E7D32;
  --radius: 16px;
  --input-bg: #ffffff;
  --shadow: 0 2px 10px rgba(27, 94, 32, 0.08);
}

:root[data-theme='dark'] {
  --bg: #121A12;
  --card: #1B241A;
  --band: #223022;
  --text: #E6EFE3;
  --muted: #9DB09C;
  --border: #35452F;
  --input-bg: #121A12;
  --primary: #7CB342;
  --primary-dark: #558B2F;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}
[data-theme='dark'] .cred-box { background: #24301f; }
[data-theme='dark'] .cred-box code { background: #0e150e; color: #E6EFE3; }
[data-theme='dark'] .mod-btn { background: linear-gradient(135deg, #245024, #1a3d1a); }
[data-theme='dark'] img.thumb { opacity: 0.94; }

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
}

.view { min-height: 100vh; display: flex; flex-direction: column; }
.hidden { display: none !important; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin: 14px auto;
  width: 100%;
  max-width: 620px;
  box-shadow: var(--shadow);
}

h1, h2, h3 { font-weight: 700; letter-spacing: -0.01em; }
h2 { margin: 2px 0 14px; font-size: 1.2rem; color: var(--verde-osc); }
[data-theme='dark'] h2, [data-theme='dark'] h3 { color: var(--verde-lima); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--error); font-weight: 600; margin-top: 10px; }
.ok-txt { color: var(--ok); font-weight: 600; }

/* ======================== PORTADA ======================== */
#portada-view {
  position: relative; overflow: hidden;
  justify-content: center; align-items: center;
  background: #08140A;
}
.portada-slider { position: absolute; inset: 0; z-index: 0; }
.portada-slider .slide {
  position: absolute; inset: 0; opacity: 0;
  transition: opacity 1.4s ease-in-out;
  background: radial-gradient(120% 120% at 50% 30%, #2E7D32 0%, #1B5E20 45%, #08140A 100%);
}
.portada-slider .slide.active { opacity: 1; }
.portada-slider .slide img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center 42%;
  filter: url(#duotono-verde) saturate(1.05);
  display: block;
}
.portada-scrim {
  position: absolute; inset: 0; z-index: 1;
  background:
    radial-gradient(150% 95% at 50% 18%, rgba(8,20,10,0.10), rgba(8,20,10,0.52) 58%, rgba(8,20,10,0.90) 100%),
    linear-gradient(180deg, rgba(8,20,10,0.42) 0%, rgba(8,20,10,0.08) 36%, rgba(8,20,10,0.78) 100%);
}
.portada-content {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 34px;
  width: 100%; max-width: 460px;
  padding: 44px 24px calc(32px + env(safe-area-inset-bottom));
  text-align: center; color: #fff;
}
.portada-logo { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.logo-hoja {
  width: 116px; height: 116px;
  filter: drop-shadow(0 8px 22px rgba(0,0,0,0.45));
  animation: brote 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.logo-hoja .logo-brote { transform-origin: 60px 104px; }
.logo-word { display: flex; flex-direction: column; }
.logo-word .lw-1 {
  font-size: clamp(2rem, 8vw, 2.9rem); font-weight: 800; line-height: 0.98;
  animation: riseIn 0.7s ease-out 0.35s both;
}
.logo-word .lw-2 {
  font-size: clamp(2rem, 8vw, 2.9rem); font-weight: 800; line-height: 0.98;
  color: var(--lima);
  animation: riseIn 0.7s ease-out 0.5s both;
}
.logo-word .lw-3 {
  font-size: 0.78rem; font-weight: 600; margin-top: 12px;
  letter-spacing: 2.6px; text-transform: uppercase; color: rgba(255,255,255,0.82);
  animation: riseIn 0.7s ease-out 0.66s both;
}
.portada-actions {
  display: flex; flex-direction: column; gap: 12px;
  width: 100%; max-width: 320px;
  animation: riseIn 0.7s ease-out 0.9s both;
}
.pt-btn {
  font: inherit; font-weight: 700; font-size: 1.06rem;
  padding: 16px 20px; border-radius: 999px; cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.12s ease, background 0.2s ease;
}
.pt-btn:active { transform: translateY(1px) scale(0.99); }
.pt-primary { background: #fff; color: var(--verde-osc); box-shadow: 0 10px 26px rgba(0,0,0,0.32); }
.pt-primary:hover { background: #EDF6E3; }
.pt-ghost {
  background: rgba(255,255,255,0.14); color: #fff;
  border-color: rgba(255,255,255,0.72);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.pt-ghost:hover { background: rgba(255,255,255,0.24); }
.portada-pie {
  font-size: 0.82rem; color: rgba(255,255,255,0.78); margin: 0;
  animation: riseIn 0.7s ease-out 1.1s both; line-height: 1.5;
}
@keyframes brote { from { opacity: 0; transform: translateY(14px) scale(0.8) rotate(-6deg); } to { opacity: 1; transform: none; } }
@keyframes riseIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* ======================== LOGIN ======================== */
.login-card { margin-top: 8vh; max-width: 460px; }
.brand { text-align: center; margin-bottom: 16px; }
.brand h1 { font-size: 1.5rem; margin: 10px 0 2px; color: var(--verde-osc); }
[data-theme='dark'] .brand h1 { color: var(--verde-lima); }
.login-back {
  display: inline-block; margin-bottom: 6px; background: none; border: none;
  cursor: pointer; color: var(--muted); font: inherit; font-size: 0.9rem; padding: 4px 2px;
}
.install-help {
  margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border);
  font-size: 0.85rem; color: var(--muted); line-height: 1.5;
}
.install-help p { margin: 6px 0; }
.install-title { font-weight: 700; color: var(--text); }
.install-help strong { color: var(--text); }
.install-note { font-style: italic; }

/* ======================== CABECERA ======================== */
.topbar {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--verde-osc); color: #fff;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  position: sticky; top: 0; z-index: 500;
}
.topbar-top { display: flex; align-items: center; gap: 8px; }
.topbar-top strong { font-size: 1.02rem; font-weight: 700; }
.topbar-back {
  background: none; border: none; color: #fff; font-size: 1.7rem; line-height: 1;
  cursor: pointer; padding: 0 6px 4px 0; font-family: inherit;
}
.topbar-bottom { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; }
.topbar button.link, .topbar a.link { color: #fff; text-decoration: none; font-size: 1.05rem; }
#logout-btn { font-size: 0.86rem; text-decoration: underline; }
.sesion-nombre { color: #fff; opacity: 0.88; font-size: 0.8rem; margin-right: auto; }
.sesion-nombre:empty { display: none; }
.ver { font-size: 0.62rem; opacity: 0.6; margin-left: auto; }
.offline-badge { background: var(--naranja); color: #46300f; font-size: 0.7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; }

/* Barra de finca (gestión) */
.finca-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--lima); color: #3B4220; padding: 8px 14px;
  position: sticky; top: 0; z-index: 400; font-size: 0.88rem; font-weight: 600;
}
.finca-bar select { flex: 1 1 160px; margin: 0; padding: 7px 10px; font-size: 0.9rem; background: #fff; color: #23301F; }
.finca-bar a.link { color: #3B4220; font-weight: 700; text-decoration: none; }

.main { flex: 1; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

/* ======================== BOTONES DE MÓDULO ======================== */
.mod-grid { display: flex; flex-direction: column; gap: 12px; }
.mod-btn {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 16px 18px; border: none; border-radius: 14px; cursor: pointer;
  background: linear-gradient(135deg, var(--verde) 0%, var(--verde-osc) 100%);
  color: #fff; font-family: inherit; text-align: left;
  box-shadow: 0 3px 10px rgba(27, 94, 32, 0.22);
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}
.mod-btn:active { transform: translateY(1px) scale(0.995); }
.mod-btn .mod-ico { font-size: 1.85rem; line-height: 1; flex: none; }
.mod-btn .mod-txt { flex: 1; min-width: 0; }
.mod-btn .mod-label { font-weight: 700; font-size: 1.02rem; display: block; }
.mod-btn .mod-desc { font-size: 0.78rem; opacity: 0.86; display: block; margin-top: 2px; line-height: 1.3; }
.mod-btn .mod-count {
  flex: none; background: rgba(255,255,255,0.22); border-radius: 999px;
  padding: 3px 11px; font-size: 0.78rem; font-weight: 700;
}
.mod-btn.mod-alt { background: linear-gradient(135deg, var(--lima) 0%, var(--oliva) 100%); color: #2C3418; }
.mod-btn.mod-alt .mod-count { background: rgba(255,255,255,0.42); }
.mod-btn.mod-morado { background: linear-gradient(135deg, #8A2464 0%, var(--morado) 100%); }

/* Encabezado tipo cartilla dentro de las pantallas */
.pag-band {
  background: var(--lima); color: #fff; margin: -20px -20px 16px;
  padding: 14px 20px 12px; border-radius: var(--radius) var(--radius) 0 0;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.pag-band h2 { margin: 0; color: #fff; font-size: 1.08rem; text-transform: uppercase; letter-spacing: 0.4px; }
.pag-num {
  background: #fff; color: var(--verde); font-size: 0.74rem; font-weight: 700;
  padding: 3px 12px; border-radius: 999px; white-space: nowrap;
}

/* ======================== FORMULARIOS ======================== */
form label, .campo-lbl { display: block; font-weight: 600; margin: 16px 0 0; font-size: 0.92rem; }
input, select, textarea {
  width: 100%; margin-top: 6px; padding: 12px;
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 1rem; font-family: inherit; background: var(--input-bg); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--verde-med); border-color: var(--verde-med); }
textarea { resize: vertical; line-height: 1.5; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--verde-med); outline-offset: 2px;
}
fieldset { border: none; padding: 0; margin: 16px 0 0; }
legend { font-weight: 700; font-size: 0.95rem; padding: 0; margin-bottom: 6px; color: var(--verde-osc); }
[data-theme='dark'] legend { color: var(--verde-lima); }
.req { color: var(--error); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.col { flex: 1 1 140px; min-width: 0; }
.hint { font-size: 0.8rem; color: var(--muted); margin: 4px 0 0; font-weight: 400; line-height: 1.4; }

button.primary, .as-button {
  display: block; width: 100%; margin-top: 20px; padding: 15px;
  background: var(--verde-osc); color: #fff; border: none; border-radius: 12px;
  font-size: 1.05rem; font-weight: 700; cursor: pointer; text-align: center;
  text-decoration: none; font-family: inherit;
}
button.primary:active, .as-button:active { background: var(--primary-dark); }
button.primary:disabled { opacity: 0.55; cursor: default; }
button.link {
  background: none; border: none; color: var(--verde); cursor: pointer;
  font-size: 0.94rem; font-family: inherit; text-decoration: underline;
}
.btn {
  border: 1.5px solid var(--verde); background: var(--card); color: var(--verde);
  border-radius: 999px; padding: 9px 16px; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.btn:hover { background: var(--band); }
.btn.recording { background: var(--coral); border-color: var(--coral); color: #fff; }
.btn.btn-del { color: var(--error); border-color: var(--error); }
.btn.btn-solid { background: var(--verde); color: #fff; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }

/* Segmentado (Sí / En proc. / No, cultivos, niveles de daño) */
.seg { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.seg button {
  flex: 1 1 auto; min-width: 74px; padding: 10px 8px; border: 1.5px solid var(--border);
  background: var(--card); border-radius: 10px; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; color: var(--text); font-family: inherit;
}
.seg button.active { background: var(--verde); color: #fff; border-color: var(--verde); }
.seg button.active[data-val='proceso'] { background: var(--naranja); border-color: var(--naranja); color: #46300f; }
.seg button.active[data-val='no'] { background: #8A948A; border-color: #8A948A; }
.seg button.active[data-val='alto'] { background: var(--coral); border-color: var(--coral); }
.seg button.active[data-val='medio'] { background: var(--naranja); border-color: var(--naranja); color: #46300f; }
.seg-cultivo button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; }
.seg-cultivo .c-ico { font-size: 1.6rem; line-height: 1; }

/* Pasos del formulario */
.stepper { display: flex; gap: 6px; margin: 0 0 12px; }
.step-chip { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 0.68rem; color: var(--muted); text-align: center; }
.step-chip .step-num {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--border); color: var(--text); font-weight: 700; font-size: 0.82rem;
}
.step-chip.active .step-num { background: var(--verde); color: #fff; }
.step-chip.done .step-num { background: var(--verde-claro); color: #fff; }
.step-chip.active .step-lbl { color: var(--verde); font-weight: 700; }
.step-nav { display: flex; gap: 10px; align-items: center; margin-top: 18px; }
.step-nav .next, .step-nav .save { margin-left: auto; }

/* Campo de texto con voz */
.campo { margin-top: 16px; }
.campo-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.campo-tools .btn { padding: 7px 13px; font-size: 0.84rem; }
.campo-status { font-size: 0.8rem; color: var(--muted); }
.audio-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.audio-item { display: flex; align-items: center; gap: 8px; background: var(--band); border-radius: 10px; padding: 6px 10px; }
.audio-item audio { height: 34px; flex: 1; min-width: 0; }

/* Archivos y miniaturas */
.files-input { display: none; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumb-wrap { position: relative; }
.thumb {
  width: 78px; height: 78px; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--border); background: var(--band); display: block; cursor: pointer;
}
.thumb.thumb-vid { width: 120px; height: 78px; background: #000; }
.thumb-del {
  position: absolute; top: -6px; right: -6px; width: 24px; height: 24px;
  border: none; border-radius: 50%; background: var(--error); color: #fff;
  cursor: pointer; font-size: 0.8rem; line-height: 1; display: grid; place-items: center;
}
.file-chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--band);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font-size: 0.82rem;
}

/* Croquis (dibujo a mano) */
.croquis-wrap { margin-top: 12px; }
.croquis-canvas {
  width: 100%; touch-action: none; border: 2px solid var(--verde-claro);
  border-radius: 12px; background: #fff; display: block; cursor: crosshair;
}
.croquis-tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.color-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent;
  cursor: pointer; padding: 0;
}
.color-btn.active { border-color: var(--text); transform: scale(1.1); }
.leyenda { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 0.82rem; }
.leyenda-item { display: flex; align-items: center; gap: 6px; }
.leyenda-color { width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(0,0,0,.15); flex: none; }
.grosor-sel { width: auto; margin: 0; padding: 7px 10px; font-size: 0.84rem; }

/* ======================== TABLAS / LISTAS ======================== */
.tabla-wrap { overflow-x: auto; margin-top: 12px; -webkit-overflow-scrolling: touch; }
table.cart { border-collapse: collapse; width: 100%; font-size: 0.86rem; }
table.cart th {
  background: var(--oliva); color: #fff; font-weight: 600; text-align: left;
  padding: 9px 10px; white-space: nowrap; position: sticky; top: 0;
}
table.cart td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.cart tbody tr:nth-child(odd) { background: var(--band); }
table.cart tbody tr:hover { background: #E3EFD6; }
[data-theme='dark'] table.cart tbody tr:hover { background: #2a3a29; }

.lista { list-style: none; padding: 0; margin: 10px 0 0; }
.lista > li {
  padding: 12px; border: 1px solid var(--border); border-radius: 12px;
  margin-bottom: 10px; background: var(--card);
}
.lista-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.lista-fecha { font-weight: 700; color: var(--verde); font-size: 0.9rem; }
.lista-meta { color: var(--muted); font-size: 0.82rem; }
.lista-cuerpo { font-size: 0.9rem; margin-top: 6px; white-space: pre-wrap; line-height: 1.45; }
.pill { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.pill-bajo { background: #DCEDC8; color: #33691E; }
.pill-medio { background: #FFE0B2; color: #7A4B0B; }
.pill-alto { background: #FFCDD2; color: #B71C1C; }
.pill-si { background: #C8E6C9; color: #1B5E20; }
.pill-proceso { background: #FFE0B2; color: #7A4B0B; }
.pill-no { background: #E0E0E0; color: #4A4A4A; }
.empty-state { text-align: center; color: var(--muted); padding: 26px 12px; font-size: 0.94rem; line-height: 1.6; }

.filtros { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.filtros input, .filtros select { flex: 1 1 130px; margin: 0; padding: 9px 10px; font-size: 0.88rem; }

/* ======================== CALENDARIO CLIMÁTICO ======================== */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 12px 0 8px; }
.cal-title { font-weight: 700; color: var(--verde-osc); font-size: 1.02rem; text-transform: capitalize; }
[data-theme='dark'] .cal-title { color: var(--verde-lima); }
.cal-nav { display: flex; gap: 6px; }
.cal-nav button { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--card); font-size: 1.1rem; cursor: pointer; color: var(--text); }
/* minmax(0,1fr) + min-width:0: sin esto, una observación larga ensancha su
   columna y descuadra toda la rejilla del mes. */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { font-size: 0.68rem; color: var(--muted); text-align: center; font-weight: 700; padding: 2px 0; }
.cal-cell {
  min-height: 62px; min-width: 0; overflow: hidden;
  border-radius: 10px; padding: 4px; border: 1px solid var(--border);
  background: var(--card); cursor: pointer; display: flex; flex-direction: column; gap: 2px;
  font-family: inherit; text-align: left; color: var(--text);
}
.cal-cell > * { min-width: 0; max-width: 100%; }
.cal-cell.cal-empty { background: transparent; border: none; cursor: default; }
.cal-cell.hoy { border-color: var(--verde); border-width: 2px; }
.cal-cell.tiene { background: var(--band); }
.cal-day { font-size: 0.74rem; font-weight: 700; color: var(--muted); }
.cal-cell.tiene .cal-day { color: var(--verde-osc); }
.cal-mm { font-size: 0.76rem; font-weight: 700; color: #0277BD; }
.cal-t { font-size: 0.72rem; color: var(--coral); }
.cal-obs { font-size: 0.62rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-sem-btn { display: block; width: 100%; }
.semana-list { margin-top: 12px; }
.semana-row { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.semana-row b { flex: 0 0 84px; color: var(--verde); }

/* Rejilla del calendario climático de Manabí (pág. 29) */
.manabi-grid { overflow-x: auto; margin-top: 12px; }
.manabi-tabla { border-collapse: collapse; min-width: 520px; width: 100%; font-size: 0.84rem; }
.manabi-tabla th { background: var(--oliva); color: #fff; padding: 8px 6px; font-weight: 600; }
.manabi-tabla th:first-child { text-align: left; min-width: 120px; }
.manabi-tabla td { border: 1px solid var(--border); padding: 0; text-align: center; }
.manabi-tabla td.rot { text-align: left; padding: 8px 10px; font-weight: 600; background: var(--band); }
.manabi-cell { width: 100%; height: 40px; border: none; background: transparent; cursor: pointer; }
.manabi-cell.on { box-shadow: inset 0 0 0 2px rgba(0,0,0,.12); }

/* ======================== MAPA ======================== */
#mapa-box { height: 62vh; min-height: 320px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); margin-top: 12px; }
.mapa-capas { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.mapa-capas button { flex: 1 1 auto; }
.mapa-leyenda { margin-top: 12px; background: var(--band); border-radius: 12px; padding: 12px; }
.mapa-leyenda h3 { margin: 0 0 6px; font-size: 0.88rem; color: var(--verde-osc); }
.esc { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.78rem; }
.esc-item { display: flex; align-items: center; gap: 5px; }
.esc-color { width: 18px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.18); }
.leaflet-popup-content { font-family: 'Poppins', sans-serif; font-size: 0.85rem; }
.leaflet-popup-content b { color: var(--verde-osc); }
.pop-linea { margin: 2px 0; }
.marker-finca {
  border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,.4);
  display: grid; place-items: center; font-size: 13px;
}

/* ======================== ALERTAS ======================== */
.alerta {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px;
  border-radius: 12px; border-left: 5px solid var(--naranja);
  background: var(--band); margin-bottom: 10px;
}
.alerta.nivel-alto { border-left-color: var(--coral); background: #FFEBEE; }
.alerta.nivel-inamhi { border-left-color: #0288D1; background: #E1F5FE; }
[data-theme='dark'] .alerta.nivel-alto { background: #3a1e1e; }
[data-theme='dark'] .alerta.nivel-inamhi { background: #10303c; }
.alerta-tit { font-weight: 700; font-size: 0.94rem; }
.alerta-txt { font-size: 0.86rem; color: var(--muted); margin-top: 2px; line-height: 1.45; }
.alerta-meta { font-size: 0.72rem; color: var(--muted); margin-top: 4px; }
.pron-dias { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-top: 10px; }
.pron-dia {
  flex: 0 0 84px; background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 8px; text-align: center;
}
.pron-fecha { font-size: 0.72rem; font-weight: 700; color: var(--verde); text-transform: capitalize; }
.pron-mm { font-size: 0.95rem; font-weight: 700; color: #0277BD; margin-top: 4px; }
.pron-t { font-size: 0.78rem; color: var(--muted); }

/* ======================== GESTIÓN ======================== */
.kpis { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0 14px; }
.kpi { flex: 1 1 100px; background: var(--band); border-radius: 12px; padding: 12px 10px; text-align: center; }
.kpi-n { font-size: 1.6rem; font-weight: 800; color: var(--verde-osc); line-height: 1; }
[data-theme='dark'] .kpi-n { color: var(--verde-lima); }
.kpi-l { font-size: 0.7rem; color: var(--muted); margin-top: 4px; }
.prod-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.prod-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.prod-nombre { font-weight: 700; }
.prod-finca { color: var(--verde); font-weight: 600; font-size: 0.9rem; }
.prod-meta { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
.prod-conteo { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.conteo-chip { background: var(--band); border-radius: 999px; padding: 2px 9px; font-size: 0.72rem; }
.cred-box {
  background: #EDF6E3; border: 1px solid var(--verde-claro); border-radius: 10px;
  padding: 10px 12px; margin: 10px 0; font-size: 0.9rem; line-height: 1.7;
}
.cred-box code { background: #fff; padding: 2px 8px; border-radius: 5px; font-size: 0.95rem; user-select: all; font-weight: 600; }

/* ======================== MODALES / AVISOS ======================== */
.nv-modal {
  position: fixed; inset: 0; background: rgba(10, 26, 12, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 14px; z-index: 900;
}
.nv-card {
  background: var(--card); border-radius: var(--radius); width: 100%; max-width: 560px;
  max-height: 88vh; overflow-y: auto; padding: 20px; box-shadow: 0 12px 44px rgba(0,0,0,0.3);
}
.nv-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.nv-head h2 { margin: 0; }
.nv-entry { padding: 12px 0; border-bottom: 1px solid var(--border); }
.nv-entry:last-child { border-bottom: none; }
.nv-ver { font-size: 0.74rem; color: var(--muted); font-weight: 700; }
.nv-title { font-weight: 700; margin: 2px 0 6px; color: var(--verde); }
.nv-items { margin: 0; padding-left: 18px; }
.nv-items li { margin: 4px 0; font-size: 0.9rem; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--verde-osc); color: #fff; padding: 12px 16px; border-radius: 12px;
  display: flex; align-items: center; gap: 14px; z-index: 950; max-width: 92%;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3); font-size: 0.9rem;
}
.overlay {
  position: fixed; inset: 0; background: rgba(241, 248, 233, 0.9);
  display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 940;
}
[data-theme='dark'] .overlay { background: rgba(18, 26, 18, 0.92); }
.spinner {
  width: 44px; height: 44px; border: 4px solid var(--border); border-top-color: var(--verde);
  border-radius: 50%; animation: spin 0.8s linear infinite; margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 960; display: flex; align-items: center; justify-content: center; padding: 16px; }
.lightbox img, .lightbox video { max-width: 100%; max-height: 86vh; border-radius: 10px; }
.lightbox-close {
  position: absolute; top: 14px; right: 14px; background: #fff; color: #222; border: none;
  border-radius: 999px; padding: 9px 16px; font-weight: 700; cursor: pointer; font-family: inherit; z-index: 2;
}

/* Éxito */
.success-card { text-align: center; }
.check { width: 64px; height: 64px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 2rem; line-height: 64px; margin: 0 auto 12px; }

/* Escritorio: dos columnas cómodas */
@media (min-width: 900px) {
  .card { max-width: 760px; }
  .mod-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
}
