/* ============================================================================
   Sistema de Bodegas Agrícolas — Hoja de estilos centralizada
   TODO el diseño vive acá — ninguna plantilla debe llevar style="" propio
   (excepción: imprimir_ticket.html, un documento de impresión aparte).

   Dirección de diseño
   --------------------
   Paleta: verde de campo cultivado + acento trigo/cosecha (dorado), sobre
   un fondo papel cálido — no el verde-Bootstrap plano ni un gris frío.
   Tipografía: Georgia (serif, con carácter) SOLO para el nombre del
   sistema y los títulos de tarjeta — el resto (formularios, tablas, texto
   de trabajo) usa la sans del sistema, que es la que mejor rinde en
   pantallas densas de datos. Los códigos de producto/maquinaria usan una
   mono — se leen como referencia, no como texto corrido.
   Firma visual: una marca de trigo dibujada a mano (SVG inline) en el
   encabezado, en vez de un emoji genérico.

   Organización: 1) Fuentes  2) Variables  3) Reset  4) Layout
   5) Header/Nav (con submenú "Inventario" y hamburguesa)
   6) Componentes  7) Utilidades  8) Responsive
   ============================================================================ */

/* ── 1. VARIABLES ──────────────────────────────────────────────────────── */
:root {
  /* Paleta — verde de campo cultivado + acento trigo/cosecha */
  --color-ink:            #1E2A1C;
  --color-primary:        #2F5D3A;
  --color-primary-dark:   #1F3F27;
  --color-primary-light:  #4C7A52;
  --color-primary-soft:   #E7EFE2;
  --color-primary-soft-hover: #DAE9D4;
  --color-primary-border: #BFD6BB;

  --color-accent:      #B9862F;   /* trigo / cosecha — usar con moderación */
  --color-accent-soft: #F6ECD9;
  --color-accent-dark: #8F6A22;

  --color-info:      #2E6D8E;
  --color-info-soft: #E4EFF3;

  --color-warn:      #B4681E;
  --color-warn-soft: #FBEEE0;
  --color-warn-border: #EAD2AE;

  --color-danger:      #A83A3A;
  --color-danger-soft: #F8E9E7;
  --color-danger-border: #E9C6C0;

  --color-purple:      #6E4A85;
  --color-purple-soft: #EFE6F3;

  --color-canvas:         #F6F4EE;
  --color-surface:        #FFFFFF;
  --color-surface-sunken: #F1EEE4;
  --color-border:         #E1DDCF;
  --color-border-strong:  #CFC9B4;

  --color-text:        var(--color-ink);
  --color-text-muted:  #55604F;
  --color-text-faint:  #8A9280;
  --color-text-on-primary: #ffffff;

  --font-display: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  --font-base:    'Segoe UI', Roboto, 'Helvetica Neue', Arial, system-ui, sans-serif;
  --font-mono:    'SF Mono', Consolas, 'Cascadia Mono', 'Liberation Mono', monospace;

  --fs-xs:  .74rem;
  --fs-sm:  .85rem;
  --fs-base: .93rem;
  --fs-md:  1.05rem;
  --fs-lg:  1.3rem;
  --fs-xl:  1.75rem;

  --sp-1: .25rem;
  --sp-2: .5rem;
  --sp-3: .75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2.25rem;
  --sp-7: 3rem;

  --radius-sm: 7px;
  --radius-md: 11px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(30,42,28,.07), 0 1px 1px rgba(30,42,28,.05);
  --shadow-md: 0 4px 16px rgba(30,42,28,.10);
  --shadow-lg: 0 14px 36px rgba(30,42,28,.18);

  --tap-min: 44px;
  --header-h: 62px;
  --content-max: 1180px;
  --content-max-header: 1650px;
  --content-narrow: 460px;
}

/* ── 2. RESET ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-base);
  background: var(--color-canvas);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: var(--fs-base);
  line-height: 1.5;
}
a { color: inherit; }
img { max-width: 100%; display: block; }
button { font-family: inherit; }
:focus-visible { outline: 2.5px solid var(--color-accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ── 3. LAYOUT ─────────────────────────────────────────────────────────── */
main {
  max-width: var(--content-max);
  margin: var(--sp-5) auto var(--sp-7);
  padding: 0 var(--sp-5);
  width: 100%;
  flex: 1;
}
footer {
  text-align: center;
  padding: var(--sp-4);
  color: var(--color-text-faint);
  font-size: var(--fs-xs);
  border-top: 1px solid var(--color-border);
  margin-top: auto;
}

/* ── 4. HEADER / NAVEGACIÓN ────────────────────────────────────────────── */
header.app-header {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: #fff;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: var(--content-max-header);
  margin: 0 auto;
  padding: 0 var(--sp-5);
  display: flex;
  align-items: center;
  min-height: var(--header-h);
  gap: var(--sp-4);
  position: relative;
}
.header-brand {
  display: flex; align-items: center; gap: var(--sp-2);
  text-decoration: none; color: #fff;
  font-family: var(--font-display);
  font-weight: 700; font-size: 1.2rem; letter-spacing: .01em;
  white-space: nowrap;
}
.header-brand .brand-mark { width: 30px; height: 30px; flex-shrink: 0; color: var(--color-accent); }
.header-brand img.brand-logo { height: 1.9rem; width: auto; border-radius: 4px; }

.nav-toggle-checkbox { display: none; }
.nav-toggle-btn {
  display: none;
  margin-left: auto;
  width: var(--tap-min); height: var(--tap-min);
  align-items: center; justify-content: center;
  font-size: 1.4rem; cursor: pointer;
  border-radius: var(--radius-sm);
  color: #fff;
  flex-shrink: 0;
}
.nav-toggle-btn:hover { background: rgba(255,255,255,.15); }

nav.app-nav {
  margin-left: auto;
  display: flex; align-items: center; gap: var(--sp-1);
  flex-wrap: wrap;
  padding: var(--sp-2) 0;
}
.app-nav a.nav-link,
.app-nav summary.nav-link {
  color: #cfe4cf; text-decoration: none;
  padding: var(--sp-2) var(--sp-2);
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 600;
  transition: background .15s, color .15s;
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: .3rem;
  cursor: pointer; list-style: none;
}
.app-nav summary.nav-link::-webkit-details-marker { display: none; }
.app-nav summary.nav-link::after { content: '▾'; font-size: .65em; opacity: .8; margin-left: -.1rem; transition: transform .15s; }
.app-nav a.nav-link:hover,
.app-nav a.nav-link.active,
.app-nav summary.nav-link:hover,
.app-nav summary.nav-link.active { background: rgba(255,255,255,.16); color: #fff; }
.app-nav .nav-icon { font-size: 1em; line-height: 1; }
.nav-dropdown[open] > summary.nav-link::after { transform: rotate(180deg); }

/* Submenús del header — <details> nativo: dropdown flotante y sólido en
   escritorio, sección plegable en el menú móvil (misma marcación, dos
   presentaciones, ver media queries). El clic para abrir/cerrar y la
   exclusión mutua entre ellos los maneja el <script> de base.html. */
.nav-dropdown { position: relative; }
.nav-dropdown-menu {
  display: flex; flex-direction: column; gap: 1px;
}
.nav-dropdown-heading {
  padding: var(--sp-2) var(--sp-3) .3rem;
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .02em;
  text-transform: uppercase; color: var(--color-text-faint);
}

.nav-sep {
  width: 1px; align-self: stretch; margin: var(--sp-1) var(--sp-2);
  background: rgba(255,255,255,.22);
}

/* ── FLASH MESSAGES ────────────────────────────────────────────────────── */
.flash-wrap { max-width: var(--content-max); margin: var(--sp-3) auto 0; padding: 0 var(--sp-5); width: 100%; }
.flash {
  padding: var(--sp-3) var(--sp-4); border-radius: var(--radius-sm); font-size: var(--fs-sm);
  margin-bottom: var(--sp-2); display: flex; align-items: center; gap: var(--sp-2);
  box-shadow: var(--shadow-sm);
}
.flash.ok    { background: var(--color-primary-soft); color: var(--color-primary-dark); border-left: 4px solid var(--color-primary); }
.flash.error { background: var(--color-danger-soft); color: var(--color-danger); border-left: 4px solid var(--color-danger); }

/* ── 5. COMPONENTES ────────────────────────────────────────────────────── */

.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  padding: var(--sp-5);
  scroll-margin-top: calc(var(--header-h) + var(--sp-4));
  margin-bottom: var(--sp-5);
}
.card-alt { background: var(--color-surface-sunken); }
.card-warn { background: var(--color-warn-soft); border-color: var(--color-warn-border); }
.card-danger-outline { border-color: var(--color-danger-border); border-width: 1.5px; }
.card-title {
  font-family: var(--font-display);
  font-size: var(--fs-md); font-weight: 700; color: var(--color-primary-dark);
  margin-bottom: var(--sp-4); display: flex; align-items: center; gap: var(--sp-2);
  flex-wrap: wrap;
}
.card-title .card-title-meta {
  margin-left: auto; font-family: var(--font-base); font-size: var(--fs-sm); font-weight: 400; color: var(--color-text-faint);
}
.card-title-sm { font-size: var(--fs-base); }
.card-title-danger { color: var(--color-danger); }
.card-title-warn { color: var(--color-warn); }

/* Bloque informativo de texto secundario dentro de una tarjeta */
.info-block { font-size: var(--fs-sm); color: var(--color-text-muted); line-height: 1.9; }
.notice {
  margin-top: var(--sp-3); padding: var(--sp-3); border-radius: var(--radius-sm); font-size: var(--fs-xs);
}
.notice-warn { background: var(--color-warn-soft); color: var(--color-warn); }
.notice-banner { padding: var(--sp-3) var(--sp-4); border-radius: var(--radius-sm); font-size: var(--fs-sm); margin-top: var(--sp-3); border-left: 4px solid; }
.notice-banner-info { background: var(--color-info-soft); border-left-color: var(--color-info); }
.notice-banner-warn { background: var(--color-warn-soft); border-left-color: var(--color-warn); }
.text-base { font-size: var(--fs-base); }
.leading-relaxed { line-height: 1.7; }
.card-subtitle { font-size: var(--fs-sm); color: var(--color-text-muted); margin-bottom: var(--sp-4); line-height: 1.65; }

.back-link {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  color: var(--color-text-muted); text-decoration: none; font-size: var(--fs-sm); font-weight: 600;
  margin-bottom: var(--sp-4); min-height: var(--tap-min);
}
.back-link:hover { color: var(--color-primary); }

.panel-narrow { max-width: var(--content-narrow); margin: 0 auto; }
.panel-narrow.panel-top { margin-top: var(--sp-6); }

/* Tarjeta centrada de login / mi-cuenta */
.login-card { padding: var(--sp-6) var(--sp-5); }
.login-icon { font-size: 2.6rem; margin-bottom: var(--sp-3); }
.login-title { font-family: var(--font-display); color: var(--color-primary-dark); margin-bottom: var(--sp-5); font-size: var(--fs-lg); }
.login-form .form-group { text-align: left; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--sp-4) var(--sp-4); }
.form-grid.form-grid-1col { grid-template-columns: 1fr; }
.form-grid.form-grid-wide { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.form-group { display: flex; flex-direction: column; gap: var(--sp-1); }
.form-group.span-all { grid-column: 1 / -1; }
.form-group label { font-size: var(--fs-sm); font-weight: 600; color: var(--color-text-muted); }
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="file"],
.form-group select,
.form-group textarea,
input.field-inline {
  padding: .6rem .75rem; border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-sm); font-size: var(--fs-base); color: var(--color-text);
  background: var(--color-surface-sunken); transition: border-color .15s, background .15s, box-shadow .15s;
  width: 100%; min-height: var(--tap-min); font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus, input.field-inline:focus {
  outline: none; border-color: var(--color-primary); background: #fff;
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}
.form-group textarea { resize: vertical; min-height: 76px; }
.form-hint { font-size: var(--fs-xs); color: var(--color-text-faint); }
.preview-box {
  margin-top: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  background: var(--color-primary-soft); border-radius: var(--radius-sm);
  font-size: var(--fs-sm); color: var(--color-text-muted);
}
.form-inline { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.form-inline.align-end { align-items: end; }

/* Fieldset de filtro/fecha embebido en un card-title */
.inline-filter-form { font-weight: 400; font-size: var(--fs-sm); }
.inline-filter-form label { font-size: var(--fs-sm); }
.field-inline-sm {
  padding: .3rem .5rem; border-radius: 6px; border: 1px solid var(--color-border-strong);
  min-height: auto; font-size: var(--fs-sm); background: var(--color-surface-sunken); font-family: inherit;
}
.card-title-split { justify-content: space-between; }
.cell-resumen { font-size: var(--fs-sm); color: var(--color-text-muted); line-height: 1.4; }
.flex-2 { flex: 2; }
.mt-5 { margin-top: var(--sp-5); }

/* Carrito de transacción en lote (Movimientos) */
.cart-container { margin-top: var(--sp-5); }
.btn-submit-lg { margin-top: var(--sp-4); font-size: var(--fs-md); }
.cart-qty { font-weight: 700; color: var(--color-primary); }
.cart-qty-unit { font-weight: 400; font-size: var(--fs-xs); color: var(--color-text-faint); }
.search-dropdown-empty { padding: var(--sp-3) var(--sp-4); color: var(--color-text-faint); font-size: var(--fs-sm); }
.search-dropdown-item .item-name { flex: 1; font-size: var(--fs-base); }
.search-dropdown-item .item-stock { font-size: var(--fs-xs); white-space: nowrap; }

/* Checkbox "card" */
.check-section { margin-top: var(--sp-4); }
.section-label { font-size: var(--fs-sm); font-weight: 600; color: var(--color-text-muted); display: block; margin-bottom: var(--sp-2); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp-2); margin-top: var(--sp-1); }
.check-card {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3); border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: border-color .15s, background .15s;
  font-size: var(--fs-sm); color: var(--color-text);
  min-height: var(--tap-min);
}
.check-card:hover { border-color: var(--color-primary); background: var(--color-primary-soft); }
.check-card input[type="checkbox"] { accent-color: var(--color-primary); width: 18px; height: 18px; flex-shrink: 0; }
.check-card.checked { border-color: var(--color-primary); background: var(--color-primary-soft); }
.check-card .check-desc { font-size: var(--fs-xs); color: var(--color-text-faint); display: block; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: .65rem 1.25rem; border: none; border-radius: var(--radius-sm);
  font-size: var(--fs-sm); font-weight: 700; cursor: pointer;
  transition: opacity .15s, transform .1s, background .15s;
  min-height: var(--tap-min); text-decoration: none; line-height: 1;
}
.btn:active { transform: translateY(1px); }
.btn-primary   { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: var(--color-primary-soft); color: var(--color-primary-dark); border: 1.5px solid var(--color-primary-border); }
.btn-secondary:hover { background: var(--color-primary-soft-hover); }
.btn-danger    { background: var(--color-danger); color: #fff; }
.btn-danger:hover { opacity: .88; }
.btn-warning   { background: var(--color-accent); color: #fff; }
.btn-warning:hover { background: var(--color-accent-dark); }
.btn-sm        { padding: var(--sp-2) var(--sp-3); font-size: var(--fs-xs); min-height: 36px; }
.btn-block     { width: 100%; }
.btn-row { margin-top: var(--sp-4); display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.btn-row-note { font-size: var(--fs-xs); color: var(--color-text-faint); }

/* Tablas — con colapso a "tarjetas" en pantallas angostas */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.data-table thead th {
  background: var(--color-primary-soft); color: var(--color-primary-dark); font-weight: 700;
  padding: var(--sp-3); text-align: left; white-space: nowrap;
}
.data-table tbody tr { border-bottom: 1px solid var(--color-border); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--color-surface-sunken); }
.data-table tbody td { padding: var(--sp-3); vertical-align: middle; }
.data-table .cell-num { text-align: right; }
.data-table .cell-center { text-align: center; }
.data-table .cell-nowrap { white-space: nowrap; }
.data-table .cell-actions { display: flex; gap: var(--sp-1); justify-content: center; flex-wrap: wrap; }
.data-table .cell-strong { font-weight: 700; }
.data-table .cell-muted { color: var(--color-text-muted); font-size: var(--fs-xs); }
code, .cell-code {
  font-family: var(--font-mono);
  background: var(--color-surface-sunken); padding: .12rem .42rem; border-radius: 4px;
  font-size: .84em; white-space: nowrap; color: var(--color-primary-dark);
}
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: var(--radius-sm); }
.thumb-sm { width: 40px; height: 40px; }
.thumb-md { width: 100px; height: 100px; border-radius: var(--radius-sm); }
.thumb-lg { width: 180px; height: 180px; border-radius: var(--radius-md); border: 1.5px solid var(--color-border-strong); }
.thumb-placeholder { color: var(--color-border-strong); font-size: 1.3rem; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .28rem .65rem; border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: 700; white-space: nowrap;
}
.badge-ok     { background: var(--color-primary-soft); color: var(--color-primary-dark); }
.badge-warn   { background: var(--color-warn-soft); color: var(--color-warn); }
.badge-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.badge-info   { background: var(--color-info-soft); color: var(--color-info); }
.badge-purple { background: var(--color-purple-soft); color: var(--color-purple); }
.badge-neutral{ background: var(--color-surface-sunken); color: var(--color-text-muted); }
.badge-accent { background: var(--color-accent-soft); color: var(--color-accent-dark); }

.empty { text-align: center; color: var(--color-text-faint); padding: var(--sp-7) var(--sp-4); font-size: var(--fs-base); }

/* Panel de estadísticas (dashboard) */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-5); }
.stat-tile {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--sp-4);
  text-align: center; box-shadow: var(--shadow-sm);
  display: block; text-decoration: none; color: inherit;
  transition: box-shadow .15s, border-color .15s, transform .1s;
}
a.stat-tile:hover { box-shadow: var(--shadow-md); border-color: var(--color-primary); transform: translateY(-1px); }
.stat-tile .stat-icon { font-size: 1.4rem; }
.stat-tile .stat-value { font-size: 1.9rem; font-weight: 700; color: var(--color-primary); line-height: 1.15; font-family: var(--font-display); }
.stat-tile .stat-value.stat-warn { color: var(--color-warn); }
.stat-tile .stat-value.stat-danger { color: var(--color-danger); }
.stat-tile .stat-label { font-size: var(--fs-xs); color: var(--color-text-muted); margin-top: var(--sp-1); }

/* Centro de Reportes */
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: var(--sp-4); }
.report-card { display: flex; flex-direction: column; }
.report-card-icon { font-size: 1.8rem; margin-bottom: var(--sp-2); }
.report-card-title { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-md); color: var(--color-primary-dark); margin-bottom: var(--sp-2); display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.report-card-desc { font-size: var(--fs-sm); color: var(--color-text-muted); line-height: 1.6; margin-bottom: var(--sp-4); flex: 1; }

/* Estadísticas — gráficos de barra con <progress>, sin librerías de JS */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--sp-4); }
.chart-card-wide { grid-column: span 2; }
@media (max-width: 720px) { .chart-card-wide { grid-column: span 1; } }
.chart-row { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-2); }
.chart-label {
  flex: 0 0 40%; font-size: var(--fs-sm); color: var(--color-text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chart-value { flex: 0 0 auto; font-size: var(--fs-sm); font-weight: 700; color: var(--color-primary-dark); min-width: 2ch; text-align: right; }
progress.chart-bar {
  flex: 1; height: 14px; border-radius: var(--radius-pill); overflow: hidden;
  border: none; appearance: none;
}
progress.chart-bar::-webkit-progress-bar { background: var(--color-surface-sunken); border-radius: var(--radius-pill); }
progress.chart-bar::-webkit-progress-value { background: var(--color-primary); border-radius: var(--radius-pill); }
progress.chart-bar::-moz-progress-bar { background: var(--color-primary); border-radius: var(--radius-pill); }

/* Buscador */
.search-box { position: relative; }
.search-box input { padding-right: 2.4rem !important; }
.search-box .search-icon {
  position: absolute; right: .8rem; top: 50%; transform: translateY(-50%);
  font-size: 1rem; color: var(--color-text-faint); pointer-events: none;
}
.search-dropdown {
  /* la visibilidad la controla exclusivamente .is-hidden (ver Utilidades) —
     así JS puede mostrarla quitando esa clase, sin pelear con un display
     fijo acá. */
  position: absolute; top: 100%; left: 0; right: 0;
  background: #fff; border: 1.5px solid var(--color-primary); border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm); max-height: 260px; overflow-y: auto;
  z-index: 20; box-shadow: var(--shadow-lg);
}
.search-dropdown-item {
  padding: var(--sp-3); cursor: pointer; border-bottom: .5px solid var(--color-border);
  display: flex; align-items: center; gap: var(--sp-3); transition: background .1s;
  min-height: var(--tap-min);
}
.search-dropdown-item:hover { background: var(--color-primary-soft); }

/* Input con acción incrustada (mostrar/ocultar contraseña) */
.input-with-action { position: relative; }
.input-with-action input { padding-right: 2.6rem !important; }
.input-with-action .input-action {
  position: absolute; right: .3rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 1.05rem;
  color: var(--color-text-muted); width: 36px; height: 36px; border-radius: var(--radius-sm);
}
.input-with-action .input-action:hover { background: var(--color-primary-soft); }

/* Resultados de búsqueda en vivo (Inicio) */
.search-result-item {
  border: 1.5px solid var(--color-border); border-radius: var(--radius-md);
  margin-bottom: var(--sp-2); padding: var(--sp-3) var(--sp-4);
}
.search-result-main { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.search-result-main .sr-nombre { display: block; }
.search-result-actions {
  display: flex; gap: var(--sp-2); margin-top: var(--sp-3); flex-wrap: wrap;
}
.search-result-detail { margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px dashed var(--color-border); }

/* Dos columnas (editar usuario: datos + acciones) */
.two-col-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: var(--sp-5); align-items: start; }

/* Chip de lista editable (Mantenimiento) */
.chip-list { display: flex; flex-direction: column; gap: var(--sp-1); }
.chip-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3); background: var(--color-surface-sunken); border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
}
.chip-row.is-inactive span { opacity: .5; text-decoration: line-through; }
.chip-row form { flex-shrink: 0; }
.list-editor-title { font-weight: 700; color: var(--color-primary-dark); font-size: var(--fs-base); margin-bottom: var(--sp-2); }
.btn-chip-toggle { padding: .15rem .5rem; min-height: 32px; }

/* Reseteo de inventario de una finca (Mantenimiento) */
.reset-finca-item {
  margin-bottom: var(--sp-2); border: 1px solid var(--color-danger-border);
  border-radius: var(--radius-sm); padding: var(--sp-2) var(--sp-4);
}
.reset-finca-summary {
  cursor: pointer; font-size: var(--fs-base); font-weight: 600; color: var(--color-danger); list-style: none;
}
.reset-finca-summary::-webkit-details-marker { display: none; }
.reset-finca-form { margin-top: var(--sp-3); }
.confirm-input { max-width: 220px; }
.finca-input-group { flex: 1; min-width: 200px; }

/* Detalle "ficha" (Pozos/Maquinaria) */
.detail-head { display: flex; flex-wrap: wrap; gap: var(--sp-4); align-items: flex-start; }
.detail-facts { font-size: var(--fs-base); color: var(--color-text-muted); line-height: 1.9; flex: 1; min-width: 220px; }

/* ── 6. UTILIDADES ─────────────────────────────────────────────────────── */
.text-muted { color: var(--color-text-muted); }
.text-faint { color: var(--color-text-faint); }
.text-danger { color: var(--color-danger); }
.text-warn { color: var(--color-warn); }
.text-primary { color: var(--color-primary); }
.text-xs { font-size: var(--fs-xs); }
.text-sm { font-size: var(--fs-sm); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-nowrap { white-space: nowrap; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-end { align-items: end; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.flex-1 { flex: 1; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.ml-auto { margin-left: auto; }
.w-full { width: 100%; }
.is-hidden { display: none !important; }
.hr-dashed { margin: var(--sp-5) 0; border: none; border-top: 1px dashed var(--color-border-strong); }

/* ── 7. RESPONSIVE ─────────────────────────────────────────────────────── */

/* Escritorio real (≥901px): el submenú Inventario flota como dropdown */
@media (min-width: 901px) {
  .nav-dropdown-menu {
    position: absolute; top: calc(100% + 8px); left: 0; z-index: 110;
    width: 240px;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg); padding: var(--sp-1);
  }
  .nav-dropdown-right .nav-dropdown-menu { left: auto; right: 0; }
  .nav-dropdown:not([open]) .nav-dropdown-menu { display: none; }
  .nav-dropdown-menu a.nav-link {
    width: 100%; color: var(--color-text); font-weight: 500;
    padding: var(--sp-3) var(--sp-3); border-radius: var(--radius-sm);
  }
  .nav-dropdown-menu a.nav-link:hover,
  .nav-dropdown-menu a.nav-link.active {
    background: var(--color-primary-soft); color: var(--color-primary-dark);
  }
  .nav-dropdown-menu .nav-dropdown-heading { border-bottom: 1px solid var(--color-border); margin-bottom: var(--sp-1); }
}

/* Por debajo de este ancho: menú hamburguesa de pantalla completa */
@media (max-width: 900px) {
  main { padding: 0 var(--sp-4); }
  .nav-toggle-btn { display: inline-flex; }
  nav.app-nav {
    display: none;
    position: absolute; left: 0; right: 0; top: 100%;
    background: var(--color-primary-dark);
    flex-direction: column; align-items: stretch;
    padding: var(--sp-2); gap: 0;
    box-shadow: var(--shadow-lg);
    max-height: calc(100vh - var(--header-h));
    overflow-y: auto;
  }
  .nav-toggle-checkbox:checked ~ nav.app-nav { display: flex; }
  .app-nav a.nav-link, .app-nav summary.nav-link { padding: var(--sp-3) var(--sp-4); width: 100%; }
  .nav-dropdown-menu { padding-left: var(--sp-4); }
  .nav-dropdown-menu a.nav-link { font-weight: 500; }
  .nav-dropdown-heading { padding-left: var(--sp-4); color: #cfe4cf; }
  .nav-sep { display: none; }
  .two-col-grid { grid-template-columns: 1fr; }
}

/* Móvil: formularios a una columna, tablas como tarjetas apiladas */
@media (max-width: 640px) {
  main { padding: 0 var(--sp-3); }
  .card { padding: var(--sp-4); border-radius: var(--radius-md); }
  .form-grid, .form-grid.form-grid-wide { grid-template-columns: 1fr; }

  .btn-row { flex-direction: column; align-items: stretch; }
  .btn-row .btn { width: 100%; }
  .btn-row .btn-row-note { text-align: center; }

  .table-wrap { overflow-x: visible; }
  .data-table.cards-on-mobile thead { display: none; }
  .data-table.cards-on-mobile, .data-table.cards-on-mobile tbody { display: block; width: 100%; }
  .data-table.cards-on-mobile tr {
    display: block; margin-bottom: var(--sp-3); border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md); padding: var(--sp-2) var(--sp-3);
    box-shadow: var(--shadow-sm); background: var(--color-surface);
  }
  .data-table.cards-on-mobile tr:hover { background: var(--color-surface); }
  .data-table.cards-on-mobile td {
    display: flex; justify-content: space-between; align-items: center;
    gap: var(--sp-3); text-align: right; padding: .55rem 0;
    border-bottom: 1px dashed var(--color-border);
  }
  .data-table.cards-on-mobile td:last-child { border-bottom: none; }
  .data-table.cards-on-mobile td::before {
    content: attr(data-label); font-weight: 600; color: var(--color-text-muted);
    text-align: left; font-size: var(--fs-xs); flex-shrink: 0; margin-right: var(--sp-2);
  }
  .data-table.cards-on-mobile td.cell-actions { justify-content: flex-end; }
  .data-table.cards-on-mobile td.cell-actions::before { content: none; }
  .data-table.cards-on-mobile td[data-label=""]::before,
  .data-table.cards-on-mobile td:not([data-label])::before { content: none; }

  .header-brand span:not(.brand-mark) { font-size: 1.05rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Registro rápido (accesos grandes para celular) ─────────────────────── */
.quick-actions {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: var(--sp-3); margin-top: var(--sp-2);
}
.quick-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-1); padding: var(--sp-4) var(--sp-2); border-radius: var(--radius-md);
  border: 1.5px solid var(--color-border); background: var(--color-surface);
  font-size: 1.8rem; text-decoration: none; color: var(--color-text);
  transition: box-shadow .15s, transform .15s, border-color .15s;
  min-height: 84px; text-align: center;
}
.quick-btn span { font-size: var(--fs-sm); font-weight: 600; }
.quick-btn:hover { border-color: var(--color-primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }

/* ── Galería de fotos (lotes, animales, movimientos) ────────────────────── */
.photo-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--sp-2); margin-top: var(--sp-2);
}
.photo-thumb {
  position: relative; display: block; border-radius: var(--radius-md); overflow: hidden;
  border: 1.5px solid var(--color-border); aspect-ratio: 1 / 1;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb .photo-date {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 6px;
  background: rgba(0,0,0,.55); color: #fff; font-size: var(--fs-xs); text-align: center;
}

/* ── Fila de checks compacta (jornada mañana/tarde en asistencia) ───────── */
.jornada-checks { display: flex; gap: var(--sp-3); align-items: center; justify-content: center; }
.jornada-checks label { display: flex; align-items: center; gap: 4px; font-size: var(--fs-xs); cursor: pointer; }

/* ── Modo offline: banner de "sin conexión" + badge de pendientes ───────── */
.offline-banner {
  background: var(--color-warn); color: #3a2a00; font-weight: 600; text-align: center;
  padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm);
}
.offline-badge {
  position: fixed; right: var(--sp-3); bottom: var(--sp-3); z-index: 40;
  background: var(--color-primary); color: #fff; border: none; border-radius: 999px;
  padding: .6rem 1rem; font-size: var(--fs-xs); font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow-md); max-width: min(90vw, 320px);
}
.offline-badge:hover { filter: brightness(1.08); }
.campo-form-hint { color: var(--color-text-faint); font-size: var(--fs-xs); margin-bottom: var(--sp-2); }
