/* =========================================================
   Pistacho en tu parcela — estilos
   Paleta: tierra cálida + verde pistacho + acento terracota
   Tipografía: Fraunces (display) + Manrope (texto)
   ========================================================= */

:root {
  --bg:        #F6F2E8;
  --bg-soft:   #EFE9DB;
  --paper:    #FFFDF7;
  --ink:       #2A2620;
  --ink-soft:  #5B5346;
  --line:      #DDD3BD;
  --line-soft: #ECE4D0;
  --brand:     #3D5631;        /* verde oliva oscuro */
  --brand-2:   #6E8A4E;        /* verde pistacho */
  --brand-3:   #B7C893;        /* verde claro */
  --accent:    #C7522A;        /* terracota */
  --accent-2:  #E6A23C;        /* mostaza */
  --good:      #3F8A4A;
  --warn:      #C58A1B;
  --bad:       #B23B2E;
  --info:      #2E6CA0;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;

  --shadow-1: 0 1px 2px rgba(40,30,10,.04), 0 1px 1px rgba(40,30,10,.03);
  --shadow-2: 0 4px 14px rgba(40,30,10,.06), 0 1px 2px rgba(40,30,10,.04);
  --shadow-3: 0 14px 40px rgba(40,30,10,.10), 0 4px 10px rgba(40,30,10,.05);

  --sb-w: 264px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Manrope', system-ui, -apple-system, Segoe UI, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { font-family: 'Fraunces', Georgia, serif; font-weight: 600; letter-spacing: -.01em; color: var(--ink); margin: 0; }
h1 { font-size: 28px; line-height: 1.15; }
h2 { font-size: 22px; line-height: 1.2; }
h3 { font-size: 17px; line-height: 1.3; }
small, .muted { color: var(--ink-soft); }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font: inherit; cursor: pointer; }

/* ========================== Layout ========================== */
.layout {
  display: grid;
  grid-template-columns: var(--sb-w) 1fr;
  min-height: 100vh;
}

/* ---- Sidebar (desktop) ---- */
.side {
  position: sticky; top: 0; left: 0;
  height: 100vh;
  background: linear-gradient(180deg, #3D5631 0%, #2F4327 100%);
  color: #F1ECDB;
  display: flex; flex-direction: column;
  padding: 18px 14px 14px;
  border-right: 1px solid rgba(0,0,0,.2);
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 18px; }
.brand__mark { width: 36px; height: 36px; color: var(--brand-3); }
.brand__title { font-family: 'Fraunces', serif; font-weight: 700; font-size: 19px; display: block; line-height: 1; }
.brand__sub { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--brand-3); }

.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; padding-right: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  color: #E8E1CD; text-decoration: none;
  font-weight: 500; font-size: 14.5px;
  transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255,255,255,.06); }
.nav a.active {
  background: rgba(183,200,147,.18);
  color: #F8F3DE;
  box-shadow: inset 3px 0 0 var(--brand-3);
}
.nav__ico {
  width: 22px; text-align: center; opacity: .8;
  font-family: 'Fraunces', serif; font-size: 16px;
}

.side__foot { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.parcel-pill {
  display: block; font-size: 12.5px; padding: 8px 10px;
  background: rgba(255,255,255,.08); border-radius: 10px;
  color: #F1ECDB; margin-bottom: 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.health { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #CFC8B0; padding: 0 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #888; display: inline-block; }
.dot[data-state="ok"]    { background: #7BB573; box-shadow: 0 0 0 3px rgba(123,181,115,.22); }
.dot[data-state="err"]   { background: #D9695A; box-shadow: 0 0 0 3px rgba(217,105,90,.22); }
.dot[data-state="unknown"] { background: #B2A98C; }

/* ---- Top bar (móvil) ---- */
.topbar {
  display: none;
  position: sticky; top: 0; z-index: 30;
  background: var(--paper); border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  gap: 10px; align-items: center;
}
.iconbtn { background: transparent; border: 1px solid var(--line); border-radius: 10px; padding: 6px; color: var(--ink); }
.topbar__title { font-family: 'Fraunces', serif; font-weight: 600; font-size: 17px; flex: 1; }
.topbar__select { max-width: 50%; padding: 7px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); font: inherit; }

/* ---- Backdrop (móvil) ---- */
.backdrop {
  position: fixed; inset: 0; background: rgba(20,15,5,.45);
  opacity: 0; pointer-events: none; transition: opacity .2s;
  z-index: 35;
}
.backdrop.open { opacity: 1; pointer-events: auto; }

/* ---- Main view ---- */
.view {
  padding: 28px clamp(16px, 4vw, 40px) 80px;
  max-width: 1200px;
}
.view__head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 22px; gap: 16px; flex-wrap: wrap;
}
.view__head h1 { display: flex; align-items: baseline; gap: 12px; }
.view__head h1::after {
  content: "";
  flex: 1; height: 1px; background: var(--line);
  align-self: center; margin-left: 8px; min-width: 30px;
}
.view__sub { color: var(--ink-soft); margin-top: 4px; font-size: 14.5px; }

/* ========================== Cards ========================== */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(12, 1fr); }
.col-12 { grid-column: span 12; }
.col-8  { grid-column: span 8; }
.col-6  { grid-column: span 6; }
.col-4  { grid-column: span 4; }
.col-3  { grid-column: span 3; }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 18px 18px;
  box-shadow: var(--shadow-1);
}
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card__head h2, .card__head h3 { margin: 0; }
.card__hint { font-size: 12.5px; color: var(--ink-soft); }

/* ========================== Forms ========================== */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-soft); letter-spacing: .01em; }
.field input, .field select, .field textarea {
  font: inherit; color: var(--ink);
  background: var(--paper);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(110,138,78,.18);
}
.row { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
.row-3 { display: grid; gap: 12px; grid-template-columns: repeat(3, 1fr); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px;
  border-radius: 10px; border: 1px solid var(--brand);
  background: var(--brand); color: #F8F3DE;
  font-weight: 600; font-size: 14px; letter-spacing: .01em;
  transition: transform .05s, background .15s, border-color .15s;
}
.btn:hover { background: #2F4327; border-color: #2F4327; }
.btn:active { transform: translateY(1px); }
.btn--ghost { background: transparent; color: var(--brand); border-color: var(--brand); }
.btn--ghost:hover { background: rgba(61,86,49,.06); }
.btn--soft   { background: var(--bg-soft); color: var(--ink); border-color: var(--line); }
.btn--soft:hover { background: #E4DCC4; }
.btn--accent { background: var(--accent); border-color: var(--accent); color: #FFF9F0; }
.btn--accent:hover { background: #A8431F; border-color: #A8431F; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn--sm { padding: 6px 10px; font-size: 13px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ========================== KPI / RAG ========================== */
.kpi { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); }
.kpi__item {
  background: var(--bg-soft); border: 1px solid var(--line-soft);
  border-radius: 12px; padding: 12px 14px;
}
.kpi__lab { font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-soft); }
.kpi__val { font-family: 'Fraunces', serif; font-size: 24px; font-weight: 600; margin-top: 2px; }
.kpi__sub { font-size: 12px; color: var(--ink-soft); }

.rag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 4px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.rag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.rag--green  { background: #E2EFD8; color: var(--good); }
.rag--yellow { background: #FBEFC7; color: var(--warn); }
.rag--red    { background: #F7D9D3; color: var(--bad); }
.rag--gray   { background: var(--bg-soft); color: var(--ink-soft); }
.rag--blue   { background: #DCE7F0; color: var(--info); }

/* ========================== Tables ========================== */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; }
.table th { font-weight: 600; color: var(--ink-soft); font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
.table tbody tr:hover { background: var(--bg-soft); }

/* ========================== Misc ========================== */
.loader { display: flex; justify-content: center; padding: 64px; }
.loader__spin {
  width: 28px; height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
  padding: 28px; text-align: center; color: var(--ink-soft);
  background: var(--paper);
}

.toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(380px, 90vw);
}
.toast {
  background: var(--ink); color: #F1ECDB;
  padding: 10px 14px; border-radius: 10px;
  box-shadow: var(--shadow-3);
  font-size: 14px;
  animation: toastIn .25s ease-out;
}
.toast--ok  { background: #2E5734; }
.toast--err { background: #7A2A22; }
.toast--warn{ background: #855E0F; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.tag { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--bg-soft); color: var(--ink-soft); border: 1px solid var(--line-soft); }

.pre {
  font-family: 'JetBrains Mono', 'Menlo', monospace; font-size: 12.5px;
  background: #1F1B14; color: #E2DAC4; padding: 12px 14px; border-radius: 10px;
  overflow-x: auto; white-space: pre-wrap; word-break: break-word;
  max-height: 360px; overflow-y: auto;
}

.list { display: flex; flex-direction: column; gap: 8px; }
.list__item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--bg-soft); border: 1px solid var(--line-soft);
}
.list__item strong { font-weight: 600; }

iframe.map {
  width: 100%; height: 460px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
}

/* Mapa Leaflet grande (Catastro) */
.map-card { padding: 0; overflow: hidden; }
.map-card .card__head { padding: 14px 18px; border-bottom: 1px solid var(--line-soft); }
.leaflet-big {
  width: 100%;
  height: calc(100vh - 320px);
  min-height: 480px;
  background: #e8e4d8;
}
.leaflet-control-layers { font-family: 'Manrope', sans-serif !important; font-size: 13px !important; }
.leaflet-popup-content { font-family: 'Manrope', sans-serif; font-size: 13px; line-height: 1.5; }
.leaflet-popup-content strong { font-family: 'Fraunces', serif; font-size: 15px; }

.crit-list li, .conc-list li { margin-bottom: 4px; }

.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-soft); margin-top: 8px; }

/* ========================== Responsive ========================== */
@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .side {
    position: fixed; top: 0; left: 0;
    width: min(86vw, 320px);
    transform: translateX(-105%);
    transition: transform .25s ease;
    box-shadow: var(--shadow-3);
  }
  .side.open { transform: translateX(0); }
  .topbar { display: flex; }
  .view { padding: 20px 16px 60px; }
  .row, .row-3 { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(6,1fr); }
  .col-8, .col-6, .col-4, .col-3 { grid-column: span 6; }
  h1 { font-size: 24px; }
  iframe.map { height: 360px; }
  .leaflet-big { height: 60vh; min-height: 380px; }
}

/* ========================== Print (informe) ========================== */
@media print {
  .side, .topbar, .toasts, .backdrop, .actions { display: none !important; }
  body { background: #fff; }
  .layout { grid-template-columns: 1fr; }
  .view { padding: 0; max-width: 100%; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
}


/* ── Adiciones seguras ────────────────────────────────── */

/* Columnas de grid adicionales */
.col-1  { grid-column: span 1; }
.col-2  { grid-column: span 2; }
.col-5  { grid-column: span 5; }
.col-7  { grid-column: span 7; }
.col-9  { grid-column: span 9; }
.col-10 { grid-column: span 10; }

/* Input standalone */
.input {
  font: inherit; color: var(--ink);
  background: var(--paper);
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  transition: border-color .15s, box-shadow .15s;
  font-size: 14px;
  width: 100%;
}
.input:focus {
  outline: none; border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(110,138,78,.18);
}

/* Separador de sección */
.section-sep {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink-soft); font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
  margin: 14px 0 6px;
}
.section-sep::before, .section-sep::after {
  content: ""; flex: 1; height: 1px; background: var(--line-soft);
}

/* Filas de 3 columnas */
.row-3 { display: grid; gap: 12px; grid-template-columns: repeat(3, 1fr); }
.row-4 { display: grid; gap: 10px; grid-template-columns: repeat(4, 1fr); }

/* Tabla compacta */
.table--sm { font-size: 12.5px; }
.table--sm th, .table--sm td { padding: 6px 8px; }

/* KPI compacto */
.kpi--sm { gap: 8px; }
.kpi--sm .kpi__val { font-size: 18px; }

/* Colores de variables UX (no sobrescriben nada crítico) */
:root {
  --good:    #2E7D32;
  --good-bg: #E8F5E9;
  --warn:    #B45309;
  --warn-bg: #FFF8E1;
  --bad:     #C62828;
  --bad-bg:  #FFEBEE;
  --info:    #1565C0;
  --info-bg: #E3F2FD;
  --tap-min:      56px;
  --tap-critical: 64px;
  --tap-sm:       44px;
}

/* RAG accesible */
.rag { min-height: 34px; font-size: 13px; font-weight: 700; padding: 5px 12px 5px 10px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; }
.rag::before { width: 8px; height: 8px; flex-shrink: 0; }
.rag--green  { background: var(--good-bg); color: var(--good); border: 1px solid #A5D6A7; }
.rag--yellow { background: var(--warn-bg); color: var(--warn); border: 1px solid #FFD54F; }
.rag--red    { background: var(--bad-bg);  color: var(--bad);  border: 1px solid #EF9A9A; }
.rag--gray   { background: var(--bg-soft); color: var(--ink-soft); border: 1px solid var(--line); }
.rag--blue   { background: var(--info-bg); color: var(--info); border: 1px solid #90CAF9; }

/* Botón CTA campo (ancho completo) */
.btn--cta {
  width: 100%;
  font-size: 17px;
  font-weight: 700;
  border-radius: 14px;
}

/* Dashboard inicio */
.parcel-status-card {
  background: linear-gradient(135deg, #2F4327, #3D5631);
  color: #F1ECDB;
  border-radius: var(--r-lg);
  padding: 22px;
  box-shadow: var(--shadow-2);
}
.parcel-status-card h2 { color: #F1ECDB; font-size: 20px; }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.quick-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-height: 56px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 12px;
  color: #F1ECDB;
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; padding: 10px;
  transition: background .15s;
}
.quick-btn:hover { background: rgba(255,255,255,.18); }

/* Alert bell */
#alert-bell {
  position: fixed; bottom: 88px; right: 24px; z-index: 998;
  width: 44px; height: 44px; border-radius: 50%;
  background: #fff; border: 2px solid var(--line);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 20px; box-shadow: 0 2px 8px rgba(0,0,0,.12);
  transition: border-color .15s;
}
#alert-badge {
  position: absolute; top: -4px; right: -4px;
  background: #dc2626; color: #fff; border-radius: 10px;
  font-size: 10px; font-weight: 700; padding: 1px 5px;
  min-width: 16px; text-align: center; display: none;
}
#alert-panel {
  position: fixed; bottom: 140px; right: 24px; z-index: 997;
  width: 360px; max-height: 70vh; overflow-y: auto;
  background: #fff; border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,.18);
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
#alert-panel.open { opacity: 1; pointer-events: all; }

/* Legacy inputs */
.card > label, section.card > label {
  display: block; margin-top: 12px; margin-bottom: 5px;
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
}
.card > input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=reset]):not([type=file]),
section.card > input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=reset]):not([type=file]) {
  display: block; width: 100%; padding: 9px 12px;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink);
  font: inherit; font-size: 14px; box-sizing: border-box;
  transition: border-color .15s;
}
.card > select:not(.topbar__select), section.card > select:not(.topbar__select) {
  display: block; width: 100%; padding: 9px 12px;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink);
  font: inherit; font-size: 14px;
}
section.card button:not([class]), .card button:not([class]) {
  padding: 9px 16px; border-radius: 10px;
  border: 1px solid var(--brand); background: var(--brand);
  color: #F8F3DE; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
}
.muted-help { color: var(--ink-soft); font-size: 13.5px; line-height: 1.5; margin-bottom: 8px; }
.phenology-risk-options { display: flex; flex-wrap: wrap; gap: 10px 18px; margin: 12px 0; padding: 12px; background: var(--bg-soft); border-radius: 10px; border: 1px solid var(--line-soft); }

/* Legacy outlet */
#legacy-outlet { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
#legacy-outlet[hidden] { display: none !important; }

/* tfm-summary-grid clima AEMET */
.tfm-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 12px 0;
}
.tfm-card {
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 12px 14px;
}

/* ========================================================
   MEJORAS RESPONSIVE MOBILE — Fix junio 2026
   ======================================================== */

/* Topbar movil mejorado */
.topbar {
  padding: 10px 14px;
  gap: 10px;
  min-height: 56px;
}
.topbar__title { font-size: 16px; }
.topbar__select {
  max-width: 160px;
  font-size: 14px;
  padding: 6px 8px;
}

/* View principal */
.view {
  padding: 16px 14px 100px;
}

/* Grid: colapsar todo en móvil pequeño */
@media (max-width: 640px) {
  .grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  .col-12, .col-8, .col-7, .col-6, .col-5,
  .col-4, .col-3, .col-2, .col-1 {
    grid-column: 1 / -1 !important;
  }
  .row, .row-3, .row-4 {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .view { padding: 12px 12px 90px; }
  .kpi { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi__val { font-size: 20px; }
  h1 { font-size: 22px; }
  h2 { font-size: 18px; }
  .view__head { margin-bottom: 14px; }
  .card { padding: 14px; }
  .table { font-size: 13px; }
  .table th, .table td { padding: 7px 6px; }
}

/* Grid colapso entre 640 y 880 */
@media (max-width: 880px) {
  .topbar { display: flex; }
  .view { padding: 16px 14px 90px; }
  .col-8, .col-7, .col-5 { grid-column: span 6; }
}

/* Botones en móvil: área táctil correcta */
@media (max-width: 880px) {
  .btn { min-height: 48px; font-size: 15px; }
  .btn--sm { min-height: 40px; font-size: 13px; }
  .btn--cta { min-height: 56px; font-size: 16px; }
  .field input, .field select { min-height: 48px; font-size: 15px; }
  .field select { min-height: 52px; }
  .field label { font-size: 14px; }
  .nav__ico { font-size: 18px; }
}

/* Alert bell y agente: no chocar en móvil */
@media (max-width: 880px) {
  #alert-bell { bottom: 76px; right: 16px; width: 48px; height: 48px; }
  #ast-btn { bottom: 16px; right: 16px; width: 52px; height: 52px; }
  #ast-panel { width: min(95vw, 360px); right: 8px; bottom: 76px; }
  #soil-age-banner { bottom: 76px; left: 8px; max-width: calc(100vw - 80px); }
}

/* Tabla responsive: scroll horizontal */
@media (max-width: 640px) {
  .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { min-width: 400px; }
}

/* Card head en móvil: wrap si es largo */
@media (max-width: 640px) {
  .card__head { flex-wrap: wrap; gap: 8px; }
  .card__head h2, .card__head h3 { font-size: 16px; }
}

/* Section sep texto no overflow */
.section-sep span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

/* KPI items en móvil: texto no se corta */
@media (max-width: 640px) {
  .kpi__item { padding: 10px 12px; }
  .kpi__lab { font-size: 10px; }
  .kpi__val { font-size: 18px; }
}

/* Acciones (botones) en móvil */
@media (max-width: 640px) {
  .actions { flex-wrap: wrap; }
  .actions .btn:not(.btn--sm):not(.btn--ghost) { flex: 1; min-width: 120px; }
}

/* ── tfm-summary-grid: 2 columnas en móvil (Clima AEMET) ── */
.tfm-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 12px 0;
}
@media (min-width: 640px) {
  .tfm-summary-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (min-width: 1024px) {
  .tfm-summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}
.tfm-card {
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 12px 14px;
}
.tfm-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.tfm-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}
.tfm-sub { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
/* tfm-grid-mobile-fix */

/* ── Fix overflow horizontal en móvil ── */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}
.layout {
  overflow-x: hidden;
}
.view {
  overflow-x: hidden;
  box-sizing: border-box;
}
/* En móvil: contenido nunca más ancho que la pantalla */
@media (max-width: 880px) {
  .view {
    max-width: 100vw;
    width: 100%;
    box-sizing: border-box;
  }
  .card {
    max-width: 100%;
    overflow: hidden;
  }
  /* Riego ETc: KPIs en 2 columnas */
  #riego-kpi-grid, .riego-kpi {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
@media (max-width: 640px) {
  /* Forzar kpi a 2 columnas siempre */
  .kpi {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .kpi__val { font-size: 18px; }
  /* Texto que no desborde */
  p, span, div { max-width: 100%; }
  /* Listas de módulos: ancho completo */
  .list__item { min-height: 52px; }
  /* Tablas: scroll */
  .card { overflow-x: auto; }
  table { min-width: unset; }
}
/* overflow-mobile-fix */
/* Marco de plantacion */
.planting-grid .field input,
.planting-grid .field select,
.planting-grid .field textarea {
  width: 100%;
}

.planting-kpis {
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
}

.planting-visual {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(220px, .75fr);
  gap: 18px;
  align-items: start;
  margin-top: 18px;
}

.planting-visual h3 {
  margin: 0 0 8px;
  font-family: Fraunces, serif;
  font-size: 18px;
}

.planting-svg {
  display: block;
  width: 100%;
  max-width: 520px;
  height: auto;
  background: #F6F2E8;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.planting-pie-wrap {
  display: grid;
  gap: 10px;
  justify-items: center;
}

.planting-pie {
  width: min(220px, 100%);
  aspect-ratio: 1;
  border-radius: 999px;
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px rgba(61, 86, 49, .22);
  color: #fff;
  text-align: center;
}

.planting-pie strong,
.planting-pie span {
  display: block;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .24);
}

.planting-pie strong {
  font-size: 24px;
}

.planting-pie span {
  font-size: 12px;
  font-weight: 700;
}

.planting-legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  color: var(--ink-soft);
  font-size: 13px;
}

.planting-note {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  margin-top: 12px;
  color: var(--ink-soft);
  font-size: 13px;
}

.planting-note p {
  margin: 4px 0;
}

.wind-layout {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.wind-title {
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
}

.wind-compass {
  width: 120px;
  height: 120px;
  display: block;
}

.wind-recommendation {
  white-space: normal;
}

.wind-notes {
  margin-top: 12px;
  font-size: 13px;
}

@media (max-width: 760px) {
  .planting-visual,
  .wind-layout {
    grid-template-columns: 1fr;
  }

  .wind-compass {
    justify-self: center;
  }
}

/* Anteproyecto de riego por goteo */
.irrigation-design-intro {
  margin: 0 0 14px;
}

.irrigation-design-form .field input,
.irrigation-design-form .field select {
  width: 100%;
}

.irrigation-design-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}

.irrigation-notes-field {
  grid-column: 1 / -1;
}

.irrigation-design-actions {
  margin-top: 12px;
}

.irrigation-save-status {
  margin-top: 8px;
  font-size: 12px;
}

.irrigation-result {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.irrigation-kpi {
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
}

.irrigation-section h3 {
  margin: 0 0 10px;
  font-family: Fraunces, serif;
  font-size: 18px;
}

.irrigation-flow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
}

.irrigation-node {
  min-width: 128px;
  flex: 1 1 128px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 10px;
  padding: 10px 12px;
}

.irrigation-node strong,
.irrigation-node span {
  display: block;
}

.irrigation-node strong {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.2;
}

.irrigation-node span {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.35;
}

.irrigation-arrow {
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  font-weight: 800;
  min-width: 18px;
}

.irrigation-parts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.irrigation-part {
  border: 1px solid var(--line-soft);
  background: #fff;
  border-radius: 10px;
  padding: 12px;
}

.irrigation-part strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
}

.irrigation-part ul,
.irrigation-warning ul {
  margin: 0;
  padding-left: 18px;
}

.irrigation-part li,
.irrigation-warning li {
  margin: 3px 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.irrigation-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}

.irrigation-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  background: #fff;
}

.irrigation-table th,
.irrigation-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  font-size: 13px;
}

.irrigation-table th {
  background: var(--bg-soft);
  color: var(--ink);
  font-weight: 800;
}

.irrigation-budget-total td,
.irrigation-budget-grand td {
  font-weight: 800;
  color: var(--ink);
}

.irrigation-budget-grand td {
  background: #f0fdf4;
  border-bottom: 0;
}

.irrigation-budget-note {
  margin: 8px 0 0;
  font-size: 12px;
}

.irrigation-warning {
  border-left: 4px solid #f59e0b;
  background: #fffbeb;
  border-radius: 0 10px 10px 0;
  padding: 12px 14px;
}

.irrigation-warning strong {
  display: block;
  margin-bottom: 6px;
  color: #78350f;
}

@media (max-width: 640px) {
  .irrigation-design-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .irrigation-kpi {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .irrigation-flow {
    display: grid;
    grid-template-columns: 1fr;
  }

  .irrigation-arrow {
    min-height: 10px;
    transform: rotate(90deg);
  }
}
