/**
 * BovinoSAG Offline - Design System & Stylesheet
 * Optimizada para uso táctil en zonas rurales por adultos mayores
 * 100% Offline, sin dependencias externas
 */

:root {
  --color-primary: #14532d;       /* Verde bosque profundo SAG */
  --color-primary-hover: #166534;
  --color-primary-light: #dcfce7;
  --color-accent: #0284c7;        /* Azul informativo */
  --color-warning: #b45309;       /* Ámbar alerta */
  --color-danger: #b91c1c;        /* Rojo sanitario urgente */
  --color-danger-light: #fee2e2;
  --color-bg: #f8fafc;            /* Fondo de alto contraste */
  --color-surface: #ffffff;
  --color-surface-alt: #f1f5f9;
  --color-text: #0f172a;          /* Texto ultra legible */
  --color-text-muted: #475569;
  --color-border: #cbd5e1;

  --font-family-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --touch-target-min: 56px;
  --safe-thumb-bottom: env(safe-area-inset-bottom, 16px);
}

/* Reset y accesibilidad */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

svg {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

html, body {
  height: 100vh;
  max-height: 100vh;
  font-family: var(--font-family-base);
  background-color: var(--color-bg);
  color: var(--color-text);
  font-size: 16px;
  line-height: 1.4;
  overflow: hidden; /* Cero scroll en la ventana principal */
}

/* Layout Principal de 2 Paneles (Sidebar Fijo + Viewport 100vh) */
.app-layout {
  display: flex;
  height: 100vh;
  max-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
}

/* App Sidebar Fijo Izquierdo */
.app-sidebar {
  width: 270px;
  min-width: 270px;
  height: 100vh;
  max-height: 100vh;
  background: #0f291e;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 16px;
  box-shadow: 4px 0 16px rgba(0, 0, 0, 0.15);
  z-index: 50;
  overflow-y: auto;
  scrollbar-width: none;
}

.sidebar-brand {
  margin-bottom: 20px;
}

.sidebar-rup-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 800;
  background: #fef08a;
  color: #713f12;
  margin-bottom: 8px;
}

.sidebar-rup-badge svg {
  width: 14px;
  height: 14px;
}

.sidebar-title {
  font-size: 1.55rem;
  font-weight: 900;
  color: #ffffff;
  margin: 0;
  letter-spacing: -0.02em;
}

.sidebar-subtitle {
  font-size: 0.88rem;
  color: #86efac;
  font-weight: 600;
  margin: 2px 0 0 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.sidebar-nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: #d1fae5;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.sidebar-nav-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.sidebar-nav-btn.active {
  background: #15803d;
  color: #ffffff;
  border-color: #4ade80;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.sidebar-nav-btn svg {
  width: 20px;
  height: 20px;
}

.sidebar-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
  margin: 10px 0;
}

.sidebar-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #22c55e;
  color: #052e16;
  font-size: 0.95rem;
  font-weight: 800;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(34, 197, 94, 0.3);
  transition: transform 0.15s, background 0.15s;
  margin-bottom: 6px;
}

.sidebar-action-btn:hover {
  background: #4ade80;
  transform: translateY(-1px);
}

.sidebar-action-btn.secondary {
  background: #0284c7;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.3);
}

.sidebar-action-btn.secondary:hover {
  background: #38bdf8;
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-footer-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.sidebar-footer-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.sidebar-status-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: #86efac;
  font-weight: 600;
  padding: 4px 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e;
}

/* Backdrop oscuro para Drawer en Móvil */
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 998;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.sidebar-backdrop.is-active {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* Botón de cierre en Drawer (visible en móvil) */
.sidebar-close-btn {
  display: none;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #ffffff;
  padding: 6px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

.sidebar-close-btn svg {
  width: 20px;
  height: 20px;
}

/* Botón Hamburguesa en Topbar (visible en móvil) */
.btn-mobile-menu {
  display: none;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  color: #0f291e;
  min-height: 42px;
  min-width: 42px;
  padding: 8px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-mobile-menu svg {
  width: 22px;
  height: 22px;
}

/* Barra de Navegación Móvil Táctil Inferior (Thumb Zone) */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #0f291e;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.25);
  z-index: 990;
  align-items: center;
  justify-content: space-around;
  box-sizing: border-box;
}

.mobile-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
  flex: 1;
  min-height: 52px;
  transition: color 0.15s, transform 0.1s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-btn svg {
  width: 22px;
  height: 22px;
}

.mobile-nav-btn.active {
  color: #4ade80;
}

.mobile-nav-btn.active svg {
  stroke: #4ade80;
}

.mobile-nav-btn:active {
  transform: scale(0.92);
}

.mobile-nav-btn.btn-accent-nav {
  background: #22c55e;
  color: #052e16;
  border-radius: 14px;
  margin: 0 4px;
  padding: 6px 8px;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
}

.mobile-nav-btn.btn-accent-nav svg {
  color: #052e16;
  stroke: #052e16;
}

/* App Viewport (Lado Derecho 100vh) */
.app-viewport {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #f8fafc;
}

.app-topbar {
  height: 54px;
  min-height: 54px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.topbar-inner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.main-workspace {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  height: calc(100vh - 54px);
  max-height: calc(100vh - 54px);
  padding: 14px 24px 48px 24px;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

/* Tipografía de alta jerarquía */
h1 { font-size: 1.6rem; font-weight: 800; line-height: 1.2; letter-spacing: -0.02em; }
h2 { font-size: 1.3rem; font-weight: 700; line-height: 1.25; }
h3 { font-size: 1.15rem; font-weight: 700; }
p, span, label { font-size: 1rem; }

/* Badges */
.badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-tag svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.badge-sag {
  background-color: #fef08a;
  color: #713f12;
  border: 1px solid #facc15;
}

/* 4 KPIs en Fila con fondo de color sólido y letras blancas GIGANTES */
.kpi-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.kpi-card {
  border-radius: 18px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 125px;
  cursor: pointer;
  user-select: none;
  border: 3px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.16);
}

.kpi-card:active {
  transform: scale(0.98);
}

/* Fondos Saturados y Vibrantes para KPIs */
.kpi-card.kpi-bg-green {
  background: linear-gradient(135deg, #14532d 0%, #16a34a 100%);
}

.kpi-card.kpi-bg-red {
  background: linear-gradient(135deg, #991b1b 0%, #ef4444 100%);
}

.kpi-card.kpi-bg-amber {
  background: linear-gradient(135deg, #9a3412 0%, #f97316 100%);
}

.kpi-card.kpi-bg-blue {
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
}

/* Letras blancas y grandes */
.kpi-card .kpi-label {
  font-size: 1.05rem;
  font-weight: 800;
  color: #ffffff !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.01em;
}

.kpi-card .kpi-label svg {
  width: 22px;
  height: 22px;
  color: #ffffff !important;
  stroke: #ffffff !important;
}

.kpi-card .kpi-number {
  font-size: 3.1rem;
  font-weight: 900;
  line-height: 1;
  color: #ffffff !important;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  margin-top: 6px;
  margin-bottom: 2px;
}

/* Estado activo cuando se selecciona un KPI */
.kpi-card.is-active {
  border-color: #ffffff !important;
  box-shadow: 0 0 0 4px #0f172a, 0 10px 24px rgba(0, 0, 0, 0.25) !important;
  transform: translateY(-3px);
}

/* Cuadrícula para Ganado en Predio y Registro de Animales (Contención estricta al 100%) */
.ganado-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 10px 0 32px 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

@media (max-width: 1200px) {
  .ganado-grid-4 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .ganado-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .ganado-grid-4 {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Tarjeta individual de bovino ergonómica con acciones claras y contención estricta */
.bovino-card {
  background: var(--color-surface);
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  min-height: 180px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
}

.bovino-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
}

/* Paginador de Ganado sin Scroll */
.ganado-pager {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 4px 10px;
}

.pager-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1e293b;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.15s;
}

.pager-btn:hover:not(:disabled) {
  background: #f1f5f9;
}

.pager-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.pager-btn svg {
  width: 16px;
  height: 16px;
}

.pager-info {
  font-size: 0.85rem;
  font-weight: 800;
  color: #334155;
  white-space: nowrap;
}

.bovino-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  flex-wrap: wrap;
}

.bovino-diio-badge {
  font-family: monospace, monospace;
  font-size: 1.15rem;
  font-weight: 900;
  background: #f1f5f9;
  color: #1e293b;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  letter-spacing: 0.04em;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Chips de Filtro Rápido (Toros, Crías, Cruzas, etc.) */
.filter-chip {
  min-height: 42px;
  padding: 6px 14px;
  border-radius: 9999px;
  border: 2px solid #cbd5e1;
  background: #ffffff;
  font-size: 0.92rem;
  font-weight: 800;
  color: #334155;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.filter-chip:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.filter-chip.active {
  background: #0f172a;
  border-color: #0f172a;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Badges de Categoría con colores bien diferenciados */
.cat-badge {
  font-size: 0.78rem;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.cat-badge-ordenia {
  background-color: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.cat-badge-preniada {
  background-color: #f3e8ff;
  color: #6b21a8;
  border: 1px solid #d8b4fe;
}

.cat-badge-seca {
  background-color: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.cat-badge-vaquilla {
  background-color: #e0f2fe;
  color: #0369a1;
  border: 1px solid #7dd3fc;
}

.cat-badge-ternera {
  background-color: #fce7f3;
  color: #9d174d;
  border: 1px solid #f472b6;
}

.cat-badge-toro {
  background-color: #0f172a;
  color: #f8fafc;
  border: 1px solid #334155;
}

.cat-badge-cria {
  background-color: #fef08a;
  color: #713f12;
  border: 1px solid #facc15;
}

.cat-badge-cruza {
  background-color: #e0e7ff;
  color: #3730a3;
  border: 1px solid #a5b4fc;
}

.cat-badge-otro {
  background-color: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

/* Badges de Estado Sanitario */
.bovino-health-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 800;
  padding: 6px 10px;
  border-radius: 9999px;
  margin: 10px 0 6px 0;
  width: fit-content;
}

.bovino-health-badge.urgente {
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #f87171;
}

.bovino-health-badge.alerta {
  background-color: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
}

.bovino-health-badge.ok {
  background-color: #dcfce7;
  color: #15803d;
  border: 1px solid #4ade80;
}

.bovino-health-badge svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Botón Cargar Más */
.btn-cargar-mas {
  background: #ffffff;
  border: 2px dashed #94a3b8;
  border-radius: 14px;
  color: #334155;
  font-size: 1.05rem;
  font-weight: 800;
  padding: 14px 24px;
  width: 100%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 16px 0 24px 0;
  transition: all 0.2s ease;
}

.btn-cargar-mas:hover {
  background: #f8fafc;
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-cargar-mas svg {
  width: 22px;
  height: 22px;
}

/* Indicador de puntos (dots) para carrusel táctil */
.carrusel-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.carrusel-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #cbd5e1;
  transition: all 0.2s;
}

.carrusel-dot.active {
  width: 28px;
  border-radius: 9999px;
  background: var(--color-primary);
}

/* Ficha y Tarjeta de Bovino */
.diio-tag {
  font-family: monospace, monospace;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  background: #e2e8f0;
  color: #0f172a;
  padding: 6px 12px;
  border-radius: 8px;
  display: inline-block;
}

.vaca-nombre {
  font-size: 1.5rem;
  font-weight: 800;
  margin-top: 8px;
  color: var(--color-text);
}

/* Semáforos Sanitarios */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 9999px;
  font-size: 0.95rem;
  font-weight: 800;
  margin-top: 10px;
}

.status-pill svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.status-pill.ok {
  background: #dcfce7;
  color: #14532d;
  border: 1px solid #86efac;
}

.status-pill.alerta {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.status-pill.urgente {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

/* Sistema de Pestañas (Tabs) para información densa */
.tabs-nav {
  display: flex;
  background: #e2e8f0;
  border-radius: 14px;
  padding: 4px;
  margin: 20px 0 16px 0;
  gap: 4px;
}

.tab-btn {
  flex: 1;
  min-height: var(--touch-target-min);
  border: none;
  background: transparent;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text-muted);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

.tab-btn.active {
  background: #ffffff;
  color: var(--color-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* Botones Táctiles Estructurados */
.btn-touch {
  min-height: 52px;
  padding: 12px 20px;
  font-size: 1.1rem;
  font-weight: 700;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  transition: background-color 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  width: 100%;
}

.btn-touch svg {
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  flex-shrink: 0;
}

.btn-touch:active {
  transform: translateY(1px);
}

.btn-primary {
  background-color: var(--color-primary);
  color: #ffffff;
}

.btn-primary:hover, .btn-primary:focus {
  background-color: var(--color-primary-hover);
}

.btn-secondary {
  background-color: #334155;
  color: #ffffff;
}

.btn-accent {
  background-color: var(--color-accent);
  color: #ffffff;
}

.btn-danger {
  background-color: var(--color-danger);
  color: #ffffff;
}

.btn-outline {
  background-color: #ffffff;
  border: 2px solid var(--color-border);
  color: var(--color-text);
  box-shadow: none;
}

/* Tarjetas de Acción Rápida Estructuradas (Dashboard) */
.dashboard-actions-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 20px 0 28px 0;
}

@media (min-width: 640px) {
  .dashboard-actions-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.action-card-btn {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: 16px;
  padding: 14px 18px;
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s;
}

.action-card-btn:active {
  transform: scale(0.99);
}

.action-card-btn.primary {
  border-color: #86efac;
  background: #f0fdf4;
}

.action-card-btn.accent {
  border-color: #bae6fd;
  background: #f0f9ff;
}

.action-icon-circle {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.action-icon-circle.primary {
  background: var(--color-primary);
  color: #ffffff;
}

.action-icon-circle.accent {
  background: var(--color-accent);
  color: #ffffff;
}

.action-icon-circle svg {
  width: 22px;
  height: 22px;
}

.action-card-body {
  flex: 1;
  min-width: 0;
}

.action-card-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--color-text);
  display: block;
  line-height: 1.25;
}

.action-card-desc {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  display: block;
  margin-top: 2px;
}

.action-arrow {
  color: #94a3b8;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.action-arrow svg {
  width: 20px;
  height: 20px;
}

/* Mobile Sticky Thumb Bar (Dock Táctil Inferior Flotante) */
.mobile-sticky-thumb-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: #ffffff;
  border-top: 2px solid #e2e8f0;
  padding: 10px 16px calc(10px + var(--safe-thumb-bottom)) 16px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
}

.thumb-bar-inner {
  max-width: 960px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 8px;
}

.thumb-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  border: none;
  border-radius: 14px;
  font-size: 0.85rem;
  font-weight: 800;
  color: #ffffff;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  padding: 6px 4px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.12);
}

.thumb-nav-btn svg {
  width: 24px;
  height: 24px;
  margin-bottom: 2px;
  stroke: #ffffff;
  color: #ffffff;
}

.thumb-nav-btn span {
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

/* Colores de fondo individuales para cada botón inferior */
.thumb-nav-btn.btn-tab-inicio {
  background-color: #15803d; /* Verde bosque */
}

.thumb-nav-btn.btn-tab-vacas {
  background-color: #1d4ed8; /* Azul */
}

.thumb-nav-btn.btn-tab-nueva {
  background-color: #7e22ce; /* Violeta / Púrpura */
}

.thumb-nav-btn.btn-tab-sanidad {
  background-color: #c2410c; /* Naranja rojizo */
}

.thumb-nav-btn:active {
  transform: scale(0.95);
}

.thumb-nav-btn.active {
  box-shadow: 0 0 0 3px #0f172a, 0 4px 12px rgba(0, 0, 0, 0.25);
  transform: translateY(-2px);
}

/* Toasts Accesibles en Tercio Superior (top: calc(72px + env(safe-area-inset-top))) */
.toast-container {
  position: fixed;
  top: calc(72px + env(safe-area-inset-top, 0px));
  left: 16px;
  right: 16px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast-item {
  pointer-events: auto;
  max-width: 500px;
  margin: 0 auto;
  width: 100%;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 16px;
  padding: 16px 20px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  border-left: 6px solid var(--color-primary);
  animation: slideDownToast 0.25s ease-out;
}

@keyframes slideDownToast {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.toast-item.urgente {
  border-left-color: var(--color-danger);
  background: #fff5f5;
}

.toast-item.alerta {
  border-left-color: var(--color-warning);
  background: #fffbeb;
}

.toast-item.exito {
  border-left-color: var(--color-primary);
  background: #f0fdf4;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 2px;
}

.toast-msg {
  font-size: 1rem;
  color: var(--color-text-muted);
}

.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-close svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Modales y Formularios */
body.modal-open {
  overflow: hidden !important;
}

body.modal-open .mobile-bottom-nav {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 2500 !important;
  display: flex;
  align-items: center !important;
  justify-content: center !important;
  padding: 16px !important;
  box-sizing: border-box;
}

@media (min-width: 768px) {
  .modal-overlay {
    padding: 24px !important;
  }
}

.modal-content, .modal-card {
  background: #ffffff;
  width: 100%;
  max-width: 580px;
  border-radius: 20px !important;
  max-height: 88dvh;
  max-height: 88svh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 20px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.4);
  animation: zoomInModal 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  z-index: 2501;
  box-sizing: border-box;
  margin: auto;
}

@media (min-width: 768px) {
  .modal-content, .modal-card {
    border-radius: 24px !important;
    padding: 28px;
    max-height: 85vh;
  }
}

@keyframes zoomInModal {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Botón de cierre grande y visible para modales */
.modal-close-btn-large {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border-radius: 50%;
  background: #f1f5f9;
  border: 2px solid #cbd5e1;
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.modal-close-btn-large:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
  transform: scale(1.05);
}

.modal-close-btn-large svg {
  width: 26px;
  height: 26px;
  stroke-width: 2.8;
}

/* Cabecera visual moderna de modales */
.modal-header-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e2e8f0;
}

.modal-header-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #dcfce7;
  color: #15803d;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-header-icon.icon-vaccine {
  background: #e0f2fe;
  color: #0369a1;
}

.modal-header-icon svg {
  width: 24px;
  height: 24px;
}

.modal-pretitle {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  margin-bottom: 2px;
}

.modal-title {
  font-size: 1.35rem;
  font-weight: 900;
  color: #0f291e;
  margin: 0;
  line-height: 1.2;
}

/* Tarjeta de sección dentro del modal */
.modal-section-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
}

.modal-section-title {
  font-size: 0.86rem;
  font-weight: 800;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

@media (max-width: 640px) {
  .modal-form-grid-2 {
    grid-template-columns: 1fr;
  }
}

.form-group-compact {
  margin-bottom: 12px;
}

.form-label-compact {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 6px;
}

.form-input-compact, .form-select-compact {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  font-size: 1rem;
  font-weight: 600;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  background: #ffffff;
  color: #0f172a;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.form-input-compact:focus, .form-select-compact:focus {
  border-color: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18);
}

/* Ficha modal presentada y ergonómica */
.ficha-modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ficha-header-box {
  background: #f8fafc;
  border: 2px solid #cbd5e1;
  border-radius: 18px;
  padding: 16px 20px;
}

.ficha-data-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.ficha-data-item {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 8px 12px;
}

.ficha-data-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  font-weight: 700;
  text-transform: uppercase;
}

.ficha-data-value {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--color-text);
  margin-top: 2px;
}

/* Inputs táctiles grandes para dedos rurales */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: 8px;
}

.form-input, .form-select {
  width: 100%;
  min-height: 56px;
  padding: 12px 16px;
  font-size: 1.25rem;
  font-weight: 600;
  border: 2px solid var(--color-border);
  border-radius: 14px;
  background: #ffffff;
  color: var(--color-text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus, .form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(20, 83, 45, 0.15);
}

.form-input.diio-input {
  font-family: monospace, monospace;
  font-size: 1.5rem;
  letter-spacing: 0.12em;
  text-align: center;
  background: #f8fafc;
}

/* Banner de Cookies / Ley 19.628 */
.legal-banner {
  position: fixed;
  bottom: 80px;
  left: 16px;
  right: 16px;
  max-width: 600px;
  margin: 0 auto;
  background: #1e293b;
  color: #f8fafc;
  padding: 16px 20px;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  z-index: 45;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Vista Sanidad en 2 columnas para 100vh */
.sanidad-layout-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

@media (max-width: 900px) {
  .sanidad-layout-2col {
    grid-template-columns: 1fr;
  }
}

.sanidad-panel {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  max-height: calc(100vh - 160px);
}

@media (min-width: 640px) {
  .legal-banner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

/* ==========================================================================
   OPTIMIZACIONES MÓVILES EXCLUSIVAS (< 768px) - Lead Frontend Showcase
   ========================================================================== */
@media (max-width: 768px) {
  html, body {
    height: auto !important;
    min-height: 100dvh !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    width: 100% !important;
    max-width: 100% !important;
  }

  .app-layout {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 100dvh !important;
    max-height: none !important;
    overflow-x: hidden !important;
    position: relative;
  }

  /* App Sidebar convertido en Drawer Off-Canvas Móvil */
  .app-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 82% !important;
    max-width: 320px !important;
    min-width: 0 !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    z-index: 999 !important;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.5) !important;
    display: flex !important;
  }

  .app-sidebar.is-open {
    transform: translateX(0) !important;
  }

  .sidebar-close-btn {
    display: flex !important;
  }

  /* Topbar en Móvil */
  .btn-mobile-menu {
    display: flex !important;
  }

  .app-topbar {
    height: 56px !important;
    min-height: 56px !important;
    padding: 0 12px !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 40 !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06) !important;
  }

  .topbar-desktop-only {
    display: none !important;
  }

  /* Main Workspace en Móvil con contención estricta */
  .app-viewport {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 100dvh !important;
    max-height: none !important;
    overflow-x: hidden !important;
  }

  .main-workspace {
    height: auto !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: visible !important;
    padding: 12px 14px !important;
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 16px)) !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  /* Barra de Navegación Inferior (Thumb Bar) */
  .mobile-bottom-nav {
    display: flex !important;
  }

  /* 4 KPIs en Móvil: Cuadrícula 2x2 armónica y de alto impacto */
  .kpi-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
    margin-bottom: 12px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .kpi-card {
    min-height: 100px !important;
    padding: 12px 14px !important;
    border-radius: 14px !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .kpi-card .kpi-label {
    font-size: 0.88rem !important;
    gap: 6px !important;
  }

  .kpi-card .kpi-label svg {
    width: 18px !important;
    height: 18px !important;
  }

  .kpi-card .kpi-number {
    font-size: 2.2rem !important;
    margin-top: 4px !important;
  }

  /* Ganado en Predio 1 Columna en Móvil con contención estricta al 100% */
  .ganado-grid-4 {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .bovino-card {
    min-height: auto !important;
    padding: 14px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  /* Sanidad en 1 Columna en Móvil */
  .sanidad-layout-2col {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 14px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .sanidad-panel {
    max-height: none !important;
    overflow-y: visible !important;
  }

  /* Toasts arriba adaptados a móvil */
  .toast-container {
    left: 10px !important;
    right: 10px !important;
    top: calc(64px + env(safe-area-inset-top, 0px)) !important;
  }

  /* Modales centrados en Smartphone */
  .modal-overlay {
    align-items: center !important;
    justify-content: center !important;
    padding: 14px !important;
    z-index: 2500 !important;
  }

  .modal-content, .modal-card {
    width: 100% !important;
    max-width: 480px !important;
    border-radius: 20px !important;
    max-height: 86dvh !important;
    max-height: 86svh !important;
    padding: 20px 16px !important;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.45) !important;
    animation: zoomInModal 0.22s cubic-bezier(0.16, 1, 0.3, 1) !important;
    margin: auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    box-sizing: border-box !important;
  }
}

/* ==========================================================================
   MODAL COMPACTO 100VH / 100DVH (CERO SCROLL)
   ========================================================================== */
.modal-overlay.modal-full-viewport {
  padding: 8px !important;
  align-items: center !important;
  justify-content: center !important;
}

.modal-content-full-100vh {
  background: #ffffff;
  width: 100% !important;
  max-width: 660px !important;
  height: 96vh !important;
  height: 96dvh !important;
  max-height: 96dvh !important;
  border-radius: 20px !important;
  padding: 14px 18px !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
  overflow: hidden !important; /* Cero scroll garantizado */
  box-sizing: border-box !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45);
  margin: auto !important;
}

@media (max-width: 768px) {
  .modal-overlay.modal-full-viewport {
    padding: 0 !important;
  }
  .modal-content-full-100vh {
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    padding: 12px 14px !important;
  }
}

.modal-compact-form {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
  min-height: 0;
  gap: 8px;
}

/* ==========================================================================
   ESTILOS FORMALES PARA PLANILLA OFICIAL SAG (SOLO LECTURA E IMPRESIÓN)
   ========================================================================== */
.planilla-formal-box {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
  margin-bottom: 24px;
}

.planilla-predio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 18px;
  margin: 16px 0;
}

.planilla-predio-item label {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  display: block;
  margin-bottom: 2px;
}

.planilla-predio-item span {
  font-size: 0.95rem;
  font-weight: 800;
  color: #0f172a;
}

.formal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.formal-table th {
  background: #0f291e;
  color: #ffffff;
  padding: 9px 10px;
  font-weight: 800;
  text-align: left;
  border: 1px solid #0f291e;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.formal-table td {
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  color: #1e293b;
  font-size: 0.86rem;
}

.formal-table tr:nth-child(even) td {
  background: #f8fafc;
}

/* ==========================================================================
   ESTILOS DE IMPRESIÓN OFICIAL SAG
   ========================================================================== */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    overflow: visible !important;
  }
  .app-sidebar, .app-topbar, .mobile-bottom-nav, .toast-container, .btn-touch, .modal-overlay, #btn-print-sag-screen, #planilla-toolbar, .topbar-demo-badge {
    display: none !important;
  }
  .app-layout, .app-viewport, .main-workspace {
    display: block !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
  }
  .planilla-formal-box {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .formal-table th {
    background: #e2e8f0 !important;
    color: #000000 !important;
    border: 1px solid #333333 !important;
  }
  .formal-table td {
    border: 1px solid #333333 !important;
    color: #000000 !important;
  }
}

