:root {
  /* Paleta Verde Oficial AgriSoft */
  --agri-dark: #287E1D;
  --agri-primary: #469B38;
  --agri-mid: #64B752;
  --agri-light: #81D46D;
  --agri-pale: #9FF188;

  /* Neutros y Superficies */
  --bg-main: #f4f6f5;
  --bg-surface: #ffffff;
  --border-color: #e2e8f0;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --topbar-h: 46px;

  /* Sombras */
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.15);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ========================================================= */
/* PANTALLA DE SETUP Y LOGIN (CENTRADOR ABSOLUTO)            */
/* ========================================================= */
.standalone-setup-page {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(135deg, #1b4d14 0%, #287E1D 50%, #469B38 100%);
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 1.5rem;
  overflow-y: auto;
  z-index: 9999;
}

.standalone-setup-card {
  background: #ffffff;
  width: 500px;
  max-width: 95vw;
  margin: auto !important;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  animation: cardFadeIn 0.3s ease-out;
}

@keyframes cardFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.setup-brand-banner {
  background: #205c17;
  color: #ffffff;
  padding: 1.75rem;
  text-align: center;
  border-bottom: 3px solid var(--agri-pale);
}

.setup-brand-banner i {
  font-size: 2.5rem;
  color: var(--agri-pale);
  margin-bottom: 8px;
}

.setup-brand-banner h2 {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.setup-brand-banner p {
  font-size: 0.85rem;
  opacity: 0.9;
  margin-top: 4px;
}

.setup-body {
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
}

.form-group input, .form-group select {
  padding: 9px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
  border-color: var(--agri-primary);
  box-shadow: 0 0 0 3px rgba(70, 155, 56, 0.18);
}

.btn-setup-submit {
  background: var(--agri-primary);
  color: #ffffff;
  border: none;
  padding: 12px;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
  transition: background 0.2s, transform 0.1s;
}

.btn-setup-submit:hover {
  background: var(--agri-dark);
}

/* ========================================================= */
/* PANTALLA PRINCIPAL ERP                                    */
/* ========================================================= */
.agri-app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* TOPBAR ESTILO ODOO */
.agri-topbar {
  height: var(--topbar-h);
  background-color: var(--agri-dark);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  user-select: none;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
  position: relative;
  z-index: 9999;
}

.agri-topbar-left, .agri-topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* TASA DE CAMBIO BCV PERMANENTE EN TOPBAR */
.agri-topbar-rate {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.22);
  padding: 4px 11px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.agri-topbar-rate:hover {
  background: rgba(0, 0, 0, 0.35);
  border-color: var(--agri-pale);
}

.agri-topbar-rate .rate-pill-icon {
  color: var(--agri-pale);
  font-size: 0.85rem;
}

.agri-topbar-rate .rate-pill-val {
  color: #ffffff;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.agri-waffle-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 1.15rem;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.agri-waffle-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.agri-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.3px;
}

.agri-brand span {
  color: var(--agri-pale);
}

/* SUBMENÚS DINÁMICOS POR MÓDULO (ESTILO ODOO TOPBAR) */
.agri-submenus {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 0.75rem;
  height: 100%;
}

.agri-submenus.hidden {
  display: none !important;
}

.agri-sub-group {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
}

.agri-sub-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.90);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.agri-sub-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.agri-sub-btn.active, .agri-sub-btn.open {
  background: rgba(255, 255, 255, 0.26);
  color: #ffffff;
  font-weight: 700;
}

.agri-sub-btn.active:not(.has-children) {
  box-shadow: inset 0 -2px 0 var(--agri-pale);
}

.agri-sub-btn i {
  font-size: 0.82rem;
  opacity: 0.9;
}

.agri-sub-btn .sub-caret {
  font-size: 0.72rem;
  margin-left: 2px;
  opacity: 0.8;
  transition: transform 0.2s ease;
}

.agri-sub-btn.open .sub-caret {
  transform: rotate(180deg);
}

/* MENÚ DESPLEGABLE ANIDADO ELEGANTE (ODOO ENTERPRISE DROPDOWN) */
.agri-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 220px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  padding: 6px 0;
  display: none;
  flex-direction: column;
  z-index: 100000;
  animation: fadeInMenu 0.15s ease-out;
}

.agri-dropdown-menu.show {
  display: flex;
}

@keyframes fadeInMenu {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.agri-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  font-size: 0.86rem;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
}

.agri-dropdown-item:hover {
  background: #f0fdf4;
  color: var(--agri-primary);
  padding-left: 20px;
}

.agri-dropdown-item.active {
  background: #ecfdf5;
  color: var(--agri-primary);
  font-weight: 600;
}

.agri-dropdown-item i {
  font-size: 0.85rem;
  width: 18px;
  text-align: center;
  color: #64748b;
}

.agri-dropdown-item:hover i, .agri-dropdown-item.active i {
  color: var(--agri-primary);
}

.agri-dropdown-divider {
  height: 1px;
  background: #f1f5f9;
  margin: 4px 0;
}

/* SELECTOR MULTIFINCA */
.agri-finca-selector {
  position: relative;
  margin-left: 0.5rem;
}

.agri-finca-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.84rem;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.agri-finca-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.finca-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  min-width: 230px;
  z-index: 2000;
  display: none;
}

.finca-dropdown.show {
  display: block;
}

.finca-item {
  padding: 9px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.88rem;
  border-bottom: 1px solid #f1f5f9;
}

.finca-item:hover {
  background: #f8fafc;
}

.finca-item.active {
  background: rgba(100, 183, 82, 0.15);
  font-weight: 600;
  color: var(--agri-dark);
}

/* APP SWITCHER ODOO (PANTALLA DE INICIO COMPLETA) */
.agri-app-switcher {
  position: absolute;
  top: var(--topbar-h);
  left: 0;
  width: 100vw;
  height: calc(100vh - var(--topbar-h));
  background: radial-gradient(circle at center, #1e4b17 0%, #0d2309 100%);
  z-index: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 5rem;
  overflow-y: auto;
}

.agri-app-switcher.hidden {
  display: none !important;
}

/* En modo overlay dentro de una app, si se abre el waffle, se comporta como overlay */
.agri-app-switcher.overlay-mode {
  position: fixed;
  background: radial-gradient(circle at center, rgba(30, 75, 23, 0.96) 0%, rgba(13, 35, 9, 0.98) 100%);
  backdrop-filter: blur(12px);
}

.switcher-close-btn {
  position: absolute;
  top: 1.5rem;
  right: 2rem;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.15rem;
  transition: all 0.2s ease;
}

.switcher-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 120px));
  justify-content: center;
  max-width: 900px;
  width: 90%;
  gap: 2.5rem 2rem;
}

.app-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.2s ease;
  color: #ffffff;
}

.app-tile:hover {
  transform: translateY(-5px);
}

.app-icon-box {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  box-shadow: 0 6px 14px rgba(0,0,0,0.35);
}

.app-title {
  font-size: 0.9rem;
  font-weight: 500;
  text-align: center;
}

/* CONTENIDO PRINCIPAL */
.agri-content-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.agri-control-panel {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.agri-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.18rem;
  font-weight: 700;
  color: var(--agri-dark);
  letter-spacing: -0.2px;
}

.agri-breadcrumbs i {
  color: var(--agri-primary);
  font-size: 1.15rem;
}

.agri-actions-bar {
  display: flex;
  gap: 10px;
  align-items: center;
}

.agri-search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.agri-search-box input {
  height: 36px;
  padding: 0 12px 0 34px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.85rem;
  color: #1e293b;
  background-color: #f8fafc;
  outline: none;
  width: 250px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.agri-search-box input:focus {
  width: 320px;
  background-color: #ffffff;
  border-color: var(--agri-primary);
  box-shadow: 0 0 0 3px rgba(70, 155, 56, 0.2);
}

.agri-search-box input::placeholder {
  color: #94a3b8;
  font-size: 0.82rem;
}

.agri-search-box i {
  position: absolute;
  left: 11px;
  color: #64748b;
  font-size: 0.85rem;
  pointer-events: none;
}

.btn-agri-primary {
  background: var(--agri-primary);
  color: #ffffff;
  border: none;
  height: 36px;
  padding: 0 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 1px 2px rgba(40, 126, 29, 0.2);
  transition: all 0.15s ease-in-out;
}

.btn-agri-primary:hover {
  background: var(--agri-dark);
  box-shadow: 0 2px 4px rgba(40, 126, 29, 0.3);
  transform: translateY(-1px);
}

.btn-agri-secondary {
  background: #ffffff;
  color: #334155;
  border: 1px solid #d1d5db;
  height: 36px;
  padding: 0 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease-in-out;
}

.btn-agri-secondary:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

.view-modes {
  display: flex;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  overflow: hidden;
  height: 36px;
}

.view-mode-btn {
  background: #ffffff;
  border: none;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #64748b;
  border-right: 1px solid #e2e8f0;
  transition: all 0.15s ease;
}

.view-mode-btn:last-child {
  border-right: none;
}

.view-mode-btn:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.view-mode-btn.active {
  background: #e8f5e9 !important;
  color: var(--agri-dark) !important;
  font-weight: 600;
}

.view-viewport {
  flex: 1;
  padding: 1.25rem;
  overflow-y: auto;
}

/* ========================================================= */
/* KANBAN VIEW                                               */
/* ========================================================= */
.kanban-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.kanban-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.15rem;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.15s, border-color 0.15s;
  border-left: 5px solid var(--agri-mid);
}

.kanban-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-left-color: var(--agri-primary);
  border-color: #cbd5e1;
}

.card-title {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text-main);
  margin-bottom: 6px;
}

.card-meta {
  font-size: 0.84rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-green {
  background: rgba(100, 183, 82, 0.2);
  color: var(--agri-dark);
}

/* ========================================================= */
/* LIST / TREE VIEW (TABLA DINÁMICA ESTILO ODOO)             */
/* ========================================================= */
.agri-list-table-container {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.agri-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.agri-table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.agri-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-main);
}

.agri-table tr:hover {
  background: #f8faf9;
  cursor: pointer;
}

.agri-table tr:last-child td {
  border-bottom: none;
}

/* ========================================================= */
/* FORM VIEW (VISTA FORMULARIO CON STATUSBAR Y TABS)         */
/* ========================================================= */
.form-sheet {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  max-width: 1000px;
  margin: 0 auto;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.form-statusbar {
  border-bottom: 1px solid var(--border-color);
  background: #f8fafc;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.statusbar-btns {
  display: flex;
  gap: 8px;
}

.statusbar-stages {
  display: flex;
  gap: 2px;
}

.stage-badge {
  padding: 4px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  background: #e2e8f0;
  border-radius: 4px;
}

.stage-badge.active {
  background: var(--agri-primary);
  color: #ffffff;
}

.form-body {
  padding: 2rem;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 1rem;
}

/* Notebook y Pestañas estilo Odoo */
.odoo-tabs-header {
  display: flex;
  border-bottom: 2px solid var(--border-color);
  margin-top: 2rem;
  gap: 8px;
}

.odoo-tab-btn {
  background: transparent;
  border: none;
  padding: 8px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.odoo-tab-btn:hover {
  color: var(--agri-dark);
}

.odoo-tab-btn.active {
  color: var(--agri-primary);
  border-bottom-color: var(--agri-primary);
}

.odoo-tab-content {
  padding-top: 1.25rem;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  background: #f8fafc;
  padding: 1rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* ========================================================= */
/* ODOO-LIKE CHATTER & AUDIT TRAIL                           */
/* ========================================================= */
.odoo-chatter {
  margin-top: 2rem;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
  padding: 1.5rem 2rem;
}

.chatter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.chatter-actions {
  display: flex;
  gap: 10px;
}

.btn-chatter {
  background: #ffffff;
  border: 1px solid #d1d5db;
  color: #334155;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-chatter:hover {
  background: #f1f5f9;
  border-color: var(--agri-primary);
  color: var(--agri-dark);
}

.chatter-composer {
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.chatter-composer textarea {
  width: 100%;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 0.88rem;
  resize: vertical;
  min-height: 60px;
  color: #1e293b;
}

.chatter-composer-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
}

.chatter-timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chatter-item {
  display: flex;
  gap: 12px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.chatter-item.audit {
  background: #fcfcfc;
  border-left: 4px solid var(--agri-mid);
}

.chatter-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  flex-shrink: 0;
}

.chatter-avatar.audit-icon {
  background: rgba(70, 155, 56, 0.15);
  color: var(--agri-dark);
}

.chatter-content {
  flex: 1;
}

.chatter-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 0.82rem;
}

.chatter-author {
  font-weight: 600;
  color: #1e293b;
}

.chatter-date {
  color: #94a3b8;
  font-size: 0.76rem;
}

.chatter-badge {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  background: #e2e8f0;
  color: #475569;
}

.chatter-badge.badge-audit {
  background: #e8f5e9;
  color: var(--agri-dark);
}

.chatter-body {
  font-size: 0.86rem;
  color: #334155;
  line-height: 1.45;
}

/* ========================================================= */
/* AJUSTES GLOBALES Y MULTIMONEDA BCV                        */
/* ========================================================= */
.settings-layout {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.settings-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.settings-card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fafbfc;
}

.settings-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e293b;
}

.settings-card-title i {
  color: var(--agri-primary);
  font-size: 1.15rem;
}

.settings-card-body {
  padding: 1.5rem;
}

.rates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
  margin-bottom: 1.5rem;
}

.rate-badge-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rate-badge-card.highlight {
  border-color: var(--agri-primary);
  background: #f0fdf4;
}

.rate-badge-currency {
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rate-badge-val {
  font-size: 1.4rem;
  font-weight: 800;
  color: #0f172a;
}

/* SUBMENÚS Y SUBSECCIONES */
.module-empty-view {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 3.5rem 2rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  max-width: 800px;
  margin: 1.5rem auto;
}

.module-empty-view i.hero-icon {
  font-size: 3.2rem;
  color: var(--agri-primary);
  margin-bottom: 1.25rem;
}

.module-empty-view h3 {
  font-size: 1.3rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 0.5rem;
}

.module-empty-view p {
  color: #64748b;
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.smtp-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
}

.smtp-status-badge.connected {
  background: #dcfce7;
  color: #166534;
}

.smtp-status-badge.disconnected {
  background: #fee2e2;
  color: #991b1b;
}

/* ========================================================= */
/* MODAL OVERLAY Y CARD (Formularios emergentes)             */
/* ========================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
  animation: modalFadeIn 0.18s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-card {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.35);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideUp 0.2s ease-out;
}

@keyframes modalSlideUp {
  from { transform: translateY(18px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  background: #ffffff;
  z-index: 1;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-close-modal {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s;
}

.btn-close-modal:hover {
  background: #fee2e2;
  color: #dc2626;
}

/* ========================================================= */
/* SUBMENÚS ANIDADOS DROPDOWN (Odoo Enterprise style)        */
/* ========================================================= */
.agri-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 220px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.15);
  z-index: 8888;
  padding: 6px 0;
  animation: dropdownFadeIn 0.15s ease-out;
}

.agri-dropdown-menu.show {
  display: block;
}

@keyframes dropdownFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.agri-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 16px;
  background: transparent;
  border: none;
  font-size: 0.875rem;
  color: #334155;
  cursor: pointer;
  text-align: left;
  transition: background 0.14s, color 0.14s;
  white-space: nowrap;
}

.agri-dropdown-item:hover {
  background: #f0fdf4;
  color: var(--agri-primary);
}

.agri-dropdown-item.active {
  background: #dcfce7;
  color: #166534;
  font-weight: 600;
}

.agri-dropdown-item i {
  width: 16px;
  text-align: center;
  font-size: 0.82rem;
  flex-shrink: 0;
}

/* Flecha del botón padre con hijos */
.sub-caret {
  font-size: 0.7rem !important;
  opacity: 0.75;
  transition: transform 0.2s ease;
  margin-left: 2px;
}

.agri-sub-btn.open .sub-caret {
  transform: rotate(180deg);
}

/* ========================================================= */
/* TABLERO DE CONTROL Y SEGUIMIENTO DE LOTE AVÍCOLA          */
/* ========================================================= */
.lot-dashboard-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.lot-dashboard-header {
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.lot-header-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.lot-avatar-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: #f0fdf4;
  color: var(--agri-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  border: 1px solid #bbf7d0;
}

.lot-header-text h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lot-header-text p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.lot-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* Barra de Acciones Rápidas para el Campo */
.lot-quick-actions-bar {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.quick-actions-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.quick-actions-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-field-action {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #1e293b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}

.btn-field-action:hover {
  background: #f8fafc;
  border-color: var(--agri-primary);
  color: var(--agri-dark);
  transform: translateY(-1px);
}

.btn-field-action.primary-feed {
  background: #fefce8;
  border-color: #fef08a;
  color: #854d0e;
}
.btn-field-action.primary-feed:hover {
  background: #fef9c3;
  border-color: #eab308;
}

.btn-field-action.primary-egg {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}
.btn-field-action.primary-egg:hover {
  background: #dcfce7;
  border-color: #22c55e;
}

.btn-field-action.primary-health {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}
.btn-field-action.primary-health:hover {
  background: #dbeafe;
  border-color: #3b82f6;
}

/* Grilla de Métricas y KPIs de Campo */
.lot-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
}

.lot-kpi-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-left: 4px solid #cbd5e1;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.lot-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.lot-kpi-card.kpi-birds { border-left-color: #22c55e; }
.lot-kpi-card.kpi-mortality { border-left-color: #ef4444; }
.lot-kpi-card.kpi-weight { border-left-color: #3b82f6; }
.lot-kpi-card.kpi-feed { border-left-color: #eab308; }
.lot-kpi-card.kpi-egg { border-left-color: #10b981; }
.lot-kpi-card.kpi-iee { border-left-color: #3b82f6; }
.lot-kpi-card.kpi-ica { border-left-color: #16a34a; }

/* Banners y Modales de Liquidación */
.lot-settlement-banner {
  transition: all 0.2s ease;
}
.lot-settlement-banner:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.lot-kpi-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.lot-kpi-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.03em;
}

.lot-kpi-icon {
  font-size: 1.1rem;
  color: #94a3b8;
}

.lot-kpi-val {
  font-size: 1.7rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.1;
  margin-bottom: 6px;
}

.lot-kpi-val small {
  font-size: 0.85rem;
  font-weight: 600;
  color: #64748b;
}

.lot-kpi-bottom {
  font-size: 0.75rem;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Tabs internas del Tablero */
.lot-dashboard-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid #e2e8f0;
  margin-top: 0.5rem;
}

.lot-dash-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: -2px;
  transition: all 0.15s ease;
}

.lot-dash-tab-btn:hover {
  color: #1e293b;
}

.lot-dash-tab-btn.active {
  color: var(--agri-primary);
  border-bottom-color: var(--agri-primary);
}

.lot-tab-pane {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

/* ========================================================= */
/* PESTAÑAS POR TIPO DE ANIMAL / REBAÑO                      */
/* ========================================================= */
.species-pills-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.species-pill-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
}

.species-pill-btn:hover {
  background: #f8fafc;
  color: #1e293b;
  border-color: #94a3b8;
}

.species-pill-btn.active {
  background: #287e1d;
  color: #ffffff;
  border-color: #287e1d;
  box-shadow: 0 2px 6px rgba(40, 126, 29, 0.25);
}

/* ========================================================= */
/* TABLERO DE KPIS ZOOTÉCNICOS Y REPRODUCTIVOS               */
/* ========================================================= */
.livestock-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.15rem;
}

.livestock-kpi-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.18s ease;
  border-left: 4px solid #94a3b8;
}

.livestock-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px -4px rgba(0, 0, 0, 0.08);
}

.livestock-kpi-card.active-filter {
  border-color: var(--agri-primary);
  background: #f0fdf4;
  box-shadow: 0 0 0 2px rgba(40, 126, 29, 0.25);
}

.livestock-kpi-card.kpi-total { border-left-color: #3b82f6; }
.livestock-kpi-card.kpi-pregnant { border-left-color: #10b981; }
.livestock-kpi-card.kpi-imminent { border-left-color: #f59e0b; }
.livestock-kpi-card.kpi-served { border-left-color: #8b5cf6; }
.livestock-kpi-card.kpi-open { border-left-color: #ef4444; }
.livestock-kpi-card.kpi-milking { border-left-color: #06b6d4; }
.livestock-kpi-card.kpi-weight { border-left-color: #6366f1; }

.livestock-kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.livestock-kpi-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 0.02em;
}

.livestock-kpi-icon {
  font-size: 1.1rem;
  opacity: 0.85;
}

.livestock-kpi-val {
  font-size: 1.55rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}

.livestock-kpi-sub {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 4px;
}

/* ========================================================= */
/* BOTONES UNIVERSALES DE EXCEL EN BARRA SUPERIOR            */
/* ========================================================= */
.btn-agri-excel {
  background: #ffffff;
  color: #107c41;
  border: 1px solid #107c41;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-agri-excel:hover {
  background: #f0fdf4;
  color: #0d5f32;
  border-color: #0d5f32;
  box-shadow: 0 2px 5px rgba(16, 124, 65, 0.15);
}

.btn-agri-excel-import {
  background: #ffffff;
  color: #1e40af;
  border: 1px solid #3b82f6;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-agri-excel-import:hover {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #2563eb;
}



/* ===== GANADERIA MULTIESPECIE: Species Pill Filter Bar ===== */
.species-pills-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.species-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 999px;
  background: #ffffff;
  color: #475569;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.species-pill-btn:hover {
  background: #f0fdf4;
  border-color: #86efac;
  color: #15803d;
}

.species-pill-btn.active {
  background: #15803d;
  border-color: #15803d;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(21, 128, 61, 0.3);
}

/* ===== GANADERIA: Modales Generales (Batch Weigh, Vaccinate, Rotate) ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-card {
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  width: 100%;
  overflow: hidden;
  animation: modalSlideUp 0.2s ease;
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.modal-header h3 {
  margin: 0;
  font-size: 1rem;
  color: #1e293b;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  transition: color 0.15s;
}

.modal-close:hover { color: #dc2626; }

.modal-body {
  padding: 16px 18px;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: #f8fafc;
}

/* ===== Herd Card: Tarjeta Enriquecida del Rebao ===== */
.herd-card {
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.herd-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}
