/* ============================================================
   AVÍCOLA CARTUJA — Sistema Web de Costos
   Design System · Tokens · Components · Layout
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&family=Inter:wght@300;400;500;600&display=swap');

/* ── 1. CSS Custom Properties (Design Tokens) ── */
:root {
  /* Brand Colors */
  --verde-bosque:      #2F5A34;
  --verde-tinta:       #1E3A24;
  --verde-hoja:        #5C8452;
  --verde-suave:       #EEF3EC;
  --verde-menta:       #D4E8D0;
  --terracota:         #C1572F;
  --terracota-claro:   #F0E4DD;
  --terracota-dark:    #9E3F1E;

  /* Neutrals */
  --gris-texto:        #6B6B6B;
  --gris-borde:        #E2E5E0;
  --fondo-hueso:       #FAFBF9;
  --blanco:            #FFFFFF;
  --negro-suave:       #1A1A1A;

  /* Semantic */
  --ambar:             #E0A62E;
  --ambar-claro:       #FDF3DC;
  --rojo:              #C0392B;
  --rojo-claro:        #FDECEA;
  --azul-info:         #2563EB;
  --azul-claro:        #EFF6FF;

  /* Sidebar */
  --sidebar-bg:        #1E3A24;
  --sidebar-text:      #C8DCC4;
  --sidebar-active-bg: #2F5A34;
  --sidebar-active-txt:#FFFFFF;
  --sidebar-hover-bg:  rgba(255,255,255,0.08);
  --sidebar-width:     260px;
  --sidebar-collapsed: 72px;

  /* Topbar */
  --topbar-height:     64px;
  --topbar-bg:         #FFFFFF;
  --topbar-border:     #E2E5E0;

  /* Shadows */
  --shadow-xs:   0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.07);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.12);
  --shadow-card: 0 2px 8px rgba(47,90,52,0.07);

  /* Border Radius */
  --radius-sm:   6px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-xl:   24px;
  --radius-full: 9999px;

  /* Spacing (8pt grid) */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Typography */
  --font-display: 'Poppins', sans-serif;
  --font-body:    'Inter', sans-serif;
  --text-xs:   11px;
  --text-sm:   13px;
  --text-base: 15px;
  --text-md:   16px;
  --text-lg:   18px;
  --text-xl:   20px;
  --text-2xl:  24px;
  --text-3xl:  30px;
  --text-4xl:  36px;
  --text-5xl:  48px;

  /* Transitions */
  --transition-fast:   all 0.15s ease;
  --transition-base:   all 0.25s ease;
  --transition-slow:   all 0.4s ease;
  --transition-spring: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Z-index */
  --z-base:    0;
  --z-raised:  10;
  --z-overlay: 20;
  --z-drawer:  40;
  --z-modal:   100;
  --z-toast:   1000;
}

/* ── 2. Reset & Base ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--negro-suave);
  background: var(--fondo-hueso);
  line-height: 1.6;
  min-height: 100dvh;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
ul, ol { list-style: none; }
img { max-width: 100%; height: auto; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ── 3. Layout Shell ── */
.app-shell {
  display: flex;
  min-height: 100dvh;
}

/* ── 4. Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100dvh;
  z-index: var(--z-drawer);
  transition: width 0.3s cubic-bezier(0.4,0,0.2,1), transform 0.3s ease;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5); /* Reduje padding vertical */
  border-bottom: 1px solid rgba(255,255,255,0.08);
  min-height: 120px; /* Incrementé alto mínimo para acomodar el logo */
}

.sidebar-logo {
  width: 110px;  /* Incrementado de 72px a 110px */
  height: 110px;
  object-fit: contain;
  flex-shrink: 0;
  mix-blend-mode: screen;
}

.sidebar-brand-text {
  display: none;
}

.sidebar-brand-title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: 0.04em;
  line-height: 1.2;
  white-space: nowrap;
}

.sidebar-brand-sub {
  font-size: var(--text-xs);
  color: var(--sidebar-text);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

/* Navigation */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-3) 0;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: var(--radius-full); }

.nav-section {
  margin-bottom: var(--space-2);
}

.nav-section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: rgba(200,220,196,0.5);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: var(--space-3) var(--space-5) var(--space-1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-5);
  color: var(--sidebar-text);
  font-size: var(--text-sm);
  font-weight: 400;
  border-radius: 0;
  transition: var(--transition-fast);
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  margin: 1px var(--space-2);
  border-radius: var(--radius-sm);
}

.nav-item:hover {
  background: var(--sidebar-hover-bg);
  color: #fff;
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-txt);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 24px;
  background: var(--terracota);
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
  opacity: 1;
}

.nav-badge {
  margin-left: auto;
  background: var(--terracota);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: var(--space-3);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
}

.user-pill:hover { background: var(--sidebar-hover-bg); }

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--terracota) 0%, var(--terracota-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.user-info { overflow: hidden; }
.user-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: var(--text-xs);
  color: var(--sidebar-text);
  white-space: nowrap;
}

/* ── 5. Main Area ── */
.main-area {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  transition: margin-left 0.3s cubic-bezier(0.4,0,0.2,1);
}

/* ── 6. Topbar ── */
.topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: var(--z-overlay);
  box-shadow: var(--shadow-xs);
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--gris-texto);
}

.topbar-breadcrumb span:last-child {
  color: var(--negro-suave);
  font-weight: 600;
}

.topbar-sep { color: var(--gris-borde); }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.search-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--fondo-hueso);
  border: 1px solid var(--gris-borde);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--gris-texto);
  width: 240px;
  transition: var(--transition-fast);
}

.search-bar:focus-within {
  border-color: var(--verde-hoja);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(92,132,82,0.12);
}

.search-bar input {
  border: none;
  background: transparent;
  color: var(--negro-suave);
  width: 100%;
  outline: none;
  font-size: var(--text-sm);
}

.search-bar input::placeholder { color: var(--gris-texto); }

.topbar-filter {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--fondo-hueso);
  border: 1px solid var(--gris-borde);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--negro-suave);
  cursor: pointer;
  transition: var(--transition-fast);
}

.topbar-filter:hover {
  border-color: var(--verde-hoja);
  background: var(--verde-suave);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--fondo-hueso);
  border: 1px solid var(--gris-borde);
  color: var(--gris-texto);
  cursor: pointer;
  transition: var(--transition-fast);
  position: relative;
}

.icon-btn:hover {
  background: var(--verde-suave);
  border-color: var(--verde-hoja);
  color: var(--verde-bosque);
}

.notif-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--terracota);
  border-radius: var(--radius-full);
  border: 2px solid white;
}

/* ── 7. Page Content ── */
.page-content {
  flex: 1;
  padding: var(--space-6) var(--space-8);
  overflow-x: hidden;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
}

.page-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--verde-tinta);
  line-height: 1.2;
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--gris-texto);
  margin-top: var(--space-1);
}

.last-update {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--gris-texto);
  background: var(--fondo-hueso);
  border: 1px solid var(--gris-borde);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
}

.live-dot {
  width: 7px;
  height: 7px;
  background: var(--verde-hoja);
  border-radius: var(--radius-full);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* ── 8. KPI Cards Grid ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.kpi-card {
  background: var(--blanco);
  border: 1px solid var(--gris-borde);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  cursor: default;
  transition: var(--transition-base);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--verde-menta);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.kpi-card.kpi-verde::before  { background: var(--verde-hoja); }
.kpi-card.kpi-ambar::before  { background: var(--ambar); }
.kpi-card.kpi-rojo::before   { background: var(--rojo); }
.kpi-card.kpi-terra::before  { background: var(--terracota); }
.kpi-card.kpi-azul::before   { background: var(--azul-info); }

.kpi-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.kpi-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--gris-texto);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.3;
}

.kpi-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-icon-wrap.bg-verde  { background: var(--verde-suave); color: var(--verde-bosque); }
.kpi-icon-wrap.bg-ambar  { background: var(--ambar-claro); color: #B07D1A; }
.kpi-icon-wrap.bg-rojo   { background: var(--rojo-claro); color: var(--rojo); }
.kpi-icon-wrap.bg-terra  { background: var(--terracota-claro); color: var(--terracota); }
.kpi-icon-wrap.bg-azul   { background: var(--azul-claro); color: var(--azul-info); }

.kpi-value {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--verde-tinta);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin-bottom: var(--space-2);
}

.kpi-value small {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--gris-texto);
}

.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.kpi-delta.up   { color: var(--rojo); background: var(--rojo-claro); }
.kpi-delta.down { color: #1a8f5c; background: #e8f5ef; }
.kpi-delta.ok   { color: #1a8f5c; background: #e8f5ef; }

.kpi-compare {
  font-size: var(--text-xs);
  color: var(--gris-texto);
  margin-top: var(--space-2);
}

/* ── 9. Charts Row ── */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1.2fr;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

/* ── 10. Card Base ── */
.card {
  background: var(--blanco);
  border: 1px solid var(--gris-borde);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--gris-borde);
}

.card-title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--verde-tinta);
}

.card-subtitle {
  font-size: var(--text-xs);
  color: var(--gris-texto);
  margin-top: 2px;
}

.card-actions {
  display: flex;
  gap: var(--space-2);
}

.card-body {
  padding: var(--space-5);
}

/* ── 11. Chart Wrapper ── */
.chart-wrap {
  padding: var(--space-4) var(--space-5);
  position: relative;
}

.chart-area {
  width: 100%;
  height: 220px;
  position: relative;
}

/* ── 12. Tabs ── */
.tabs {
  display: flex;
  gap: 2px;
  padding: var(--space-1);
  background: var(--fondo-hueso);
  border-radius: var(--radius-md);
  border: 1px solid var(--gris-borde);
}

.tab-btn {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--gris-texto);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  background: transparent;
}

.tab-btn.active {
  background: var(--blanco);
  color: var(--verde-bosque);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

.tab-btn:hover:not(.active) {
  background: rgba(255,255,255,0.6);
  color: var(--negro-suave);
}

/* ── 13. Donut Chart ── */
.donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-4) var(--space-5);
}

.donut-svg {
  width: 160px;
  height: 160px;
}

.donut-legend {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  justify-content: space-between;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.legend-name {
  font-size: var(--text-sm);
  color: var(--negro-suave);
  flex: 1;
}

.legend-val {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--verde-tinta);
  font-variant-numeric: tabular-nums;
}

/* ── 14. Data Table ── */
.data-row {
  display: grid;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--gris-borde);
  transition: var(--transition-fast);
  align-items: center;
}

.data-row:last-child { border-bottom: none; }
.data-row:hover { background: var(--verde-suave); }

.table-head {
  display: grid;
  padding: var(--space-2) var(--space-5);
  background: var(--fondo-hueso);
  border-bottom: 1px solid var(--gris-borde);
}

.th {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--gris-texto);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.td { font-size: var(--text-sm); color: var(--negro-suave); }
.td.mono { font-variant-numeric: tabular-nums; font-weight: 500; }

/* ── 15. Status Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1;
}

.badge-verde  { background: #e8f5ef; color: #1a8f5c; }
.badge-ambar  { background: var(--ambar-claro); color: #B07D1A; }
.badge-rojo   { background: var(--rojo-claro); color: var(--rojo); }
.badge-terra  { background: var(--terracota-claro); color: var(--terracota); }
.badge-gris   { background: #F0F0F0; color: #666; }

/* ── 16. Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  border: 1px solid transparent;
  white-space: nowrap;
  font-family: var(--font-body);
  touch-action: manipulation;
  min-height: 36px;
}

.btn-primary {
  background: var(--verde-bosque);
  color: white;
  border-color: var(--verde-bosque);
}
.btn-primary:hover {
  background: var(--verde-tinta);
  border-color: var(--verde-tinta);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(47,90,52,0.3);
}

.btn-action {
  background: var(--terracota);
  color: white;
  border-color: var(--terracota);
}
.btn-action:hover {
  background: var(--terracota-dark);
  border-color: var(--terracota-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(193,87,47,0.3);
}

.btn-outline {
  background: transparent;
  color: var(--verde-bosque);
  border-color: var(--verde-bosque);
}
.btn-outline:hover {
  background: var(--verde-suave);
}

.btn-ghost {
  background: transparent;
  color: var(--gris-texto);
  border-color: var(--gris-borde);
}
.btn-ghost:hover {
  background: var(--fondo-hueso);
  color: var(--negro-suave);
}

.btn-sm {
  padding: 5px var(--space-3);
  font-size: var(--text-xs);
  min-height: 28px;
}

/* ── 17. Gauge / Progress ── */
.gauge-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.gauge-label {
  font-size: var(--text-sm);
  color: var(--negro-suave);
  flex: 1;
  white-space: nowrap;
}
.gauge-track {
  flex: 2;
  height: 8px;
  background: var(--gris-borde);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.gauge-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 1s cubic-bezier(0.4,0,0.2,1);
}
.gauge-val {
  font-size: var(--text-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--verde-tinta);
  min-width: 52px;
  text-align: right;
}

/* ── 18. Alert Banner ── */
.alert-banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid;
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.alert-banner.alert-ambar {
  background: var(--ambar-claro);
  border-color: #F0C84A;
  color: #6B4F00;
}

.alert-banner.alert-rojo {
  background: var(--rojo-claro);
  border-color: #F0A5A0;
  color: #6B0F0F;
}

.alert-banner.alert-verde {
  background: #e8f5ef;
  border-color: var(--verde-menta);
  color: #104024;
}

.alert-title { font-weight: 600; }
.alert-body { font-size: var(--text-xs); opacity: 0.85; margin-top: 2px; }

/* ── 19. Trend Lines (sparkline SVG) ── */
.sparkline {
  width: 80px;
  height: 32px;
}

/* ── 20. Section Grids ── */
.bottom-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.three-col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

/* ── 21. Sensor Status ── */
.sensor-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--gris-borde);
  transition: var(--transition-fast);
}
.sensor-item:last-child { border-bottom: none; }
.sensor-item:hover { background: var(--verde-suave); }

.sensor-status-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}
.sensor-status-dot.online { background: var(--verde-hoja); animation: pulse-dot 2.5s infinite; }
.sensor-status-dot.offline { background: var(--rojo); }
.sensor-status-dot.warning { background: var(--ambar); }

.sensor-name { font-size: var(--text-sm); font-weight: 500; flex: 1; }
.sensor-val { font-size: var(--text-sm); font-variant-numeric: tabular-nums; font-weight: 500; color: var(--verde-tinta); }
.sensor-unit { font-size: var(--text-xs); color: var(--gris-texto); margin-left: 2px; }

/* ── 22. Activity Feed ── */
.activity-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--gris-borde);
  position: relative;
}
.activity-item:last-child { border-bottom: none; }

.activity-icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.activity-text { font-size: var(--text-sm); line-height: 1.5; }
.activity-user { font-weight: 600; color: var(--verde-tinta); }
.activity-time { font-size: var(--text-xs); color: var(--gris-texto); margin-top: 2px; }

/* ── 23. Chip tabs (category) ── */
.chip-row {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.chip {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  border: 1px solid transparent;
}

.chip-aaa  { background: var(--verde-suave); color: var(--verde-bosque); border-color: var(--verde-menta); }
.chip-aa   { background: #EAF0FF; color: #1D4ED8; border-color: #BFD0FF; }
.chip-a    { background: var(--ambar-claro); color: #854D0E; border-color: #F0C84A; }
.chip-ind  { background: var(--terracota-claro); color: var(--terracota-dark); border-color: #F0C0AD; }
.chip-merma{ background: var(--rojo-claro); color: var(--rojo); border-color: #F0A5A0; }

/* ── 24. Toast notification ── */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: var(--z-toast);
  pointer-events: none;
}

.toast {
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 280px;
  max-width: 360px;
  pointer-events: all;
  animation: slide-in-right 0.3s cubic-bezier(0.34,1.56,0.64,1);
  border-left: 4px solid var(--verde-hoja);
}

.toast.toast-success { border-left-color: var(--verde-hoja); }
.toast.toast-warning { border-left-color: var(--ambar); }
.toast.toast-error   { border-left-color: var(--rojo); }

@keyframes slide-in-right {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── 25. Modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  transform: scale(0.95) translateY(12px);
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
}

.modal-backdrop.open .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--gris-borde);
}

.modal-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--verde-tinta);
}

.modal-body { padding: var(--space-6); }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--gris-borde);
}

/* ── 26. Form Fields ── */
.field-group { margin-bottom: var(--space-4); }
.field-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--negro-suave);
  margin-bottom: var(--space-2);
}
.field-label .required { color: var(--terracota); }

.field-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--gris-borde);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--negro-suave);
  background: var(--blanco);
  outline: none;
  transition: var(--transition-fast);
  min-height: 44px;
}

.field-input:focus {
  border-color: var(--verde-hoja);
  box-shadow: 0 0 0 3px rgba(92,132,82,0.12);
}

.field-helper {
  font-size: var(--text-xs);
  color: var(--gris-texto);
  margin-top: var(--space-1);
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

/* ── 27. Sidebar toggle button ── */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: calc(var(--z-drawer) + 1);
  width: 36px;
  height: 36px;
  background: var(--verde-bosque);
  border-radius: var(--radius-md);
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  box-shadow: var(--shadow-md);
}

/* ── 28. Cost breakdown ── */
.cost-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) 0;
  font-size: var(--text-sm);
  border-bottom: 1px dashed var(--gris-borde);
}
.cost-line:last-child { border-bottom: none; }
.cost-label { color: var(--gris-texto); flex: 1; }
.cost-amount { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--verde-tinta); }
.cost-total { border-top: 2px solid var(--verde-bosque); border-bottom: none; margin-top: var(--space-2); padding-top: var(--space-3); }
.cost-total .cost-label { color: var(--negro-suave); font-weight: 700; }
.cost-total .cost-amount { color: var(--verde-bosque); font-size: var(--text-lg); }

/* ── 29. Kanban Board ── */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}

.kanban-col {
  background: var(--fondo-hueso);
  border: 1px solid var(--gris-borde);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.kanban-col-header {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--gris-borde);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  font-size: var(--text-sm);
}

.kanban-count {
  background: white;
  border: 1px solid var(--gris-borde);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
}

.kanban-items { padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-2); }

.kanban-card {
  background: white;
  border: 1px solid var(--gris-borde);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: var(--transition-base);
}

.kanban-card:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
  border-color: var(--verde-menta);
}

.kanban-card-title { font-size: var(--text-sm); font-weight: 600; color: var(--negro-suave); margin-bottom: var(--space-1); }
.kanban-card-sub { font-size: var(--text-xs); color: var(--gris-texto); }
.kanban-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: var(--space-2); }

/* ── 30. Responsive ── */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .bottom-row { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  :root {
    --sidebar-width: var(--sidebar-collapsed);
  }

  .sidebar-brand-text,
  .nav-section-label,
  .nav-item span,
  .user-info,
  .nav-badge {
    display: none;
  }

  .nav-item {
    justify-content: center;
    padding: var(--space-3);
  }

  .nav-item.active::before { display: none; }

  .page-content { padding: var(--space-4) var(--space-4); }
}

@media (max-width: 640px) {
  .sidebar { display: none; }
  .sidebar.open { display: flex; width: var(--sidebar-width); }
  .sidebar-brand-text, .nav-item span, .user-info, .nav-section-label, .nav-badge { display: block; }
  .sidebar-toggle { display: flex; }
  .main-area { margin-left: 0; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .three-col, .kanban-board { grid-template-columns: 1fr; }
  .form-row-2 { grid-template-columns: 1fr; }
  .search-bar { display: none; }
}

/* ── 31. Animations ── */
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fade-in-up 0.4s ease both;
}

.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.10s; }
.delay-3 { animation-delay: 0.15s; }
.delay-4 { animation-delay: 0.20s; }
.delay-5 { animation-delay: 0.25s; }
.delay-6 { animation-delay: 0.30s; }

/* ── 32. Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── 33. Misc utilities ── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-muted { color: var(--gris-texto); }
.text-green { color: var(--verde-bosque); }
.font-bold { font-weight: 700; }
.font-semi { font-weight: 600; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}

/* ── 34. Page transitions (JS-driven) ── */
.page-view {
  display: none;
}
.page-view.active {
  display: block;
  animation: fade-in-up 0.35s ease both;
}

/* ── 35. Gradient accents ── */
.gradient-terra {
  background: linear-gradient(135deg, var(--terracota) 0%, #E8722A 100%);
}

.gradient-verde {
  background: linear-gradient(135deg, var(--verde-bosque) 0%, var(--verde-hoja) 100%);
}

/* ── 36. Lote status pill in table ── */
.status-postura { background: #e8f5ef; color: #1a8f5c; }
.status-levante { background: var(--ambar-claro); color: #854D0E; }
.status-descarte { background: var(--gris-borde); color: var(--gris-texto); }

/* ── 37. Navigation page overlay transition ── */
.transition-overlay {
  position: fixed;
  inset: 0;
  background: var(--verde-tinta);
  z-index: 9999;
  transform: translateY(-100%);
  pointer-events: none;
}

/* ── 38. Login Screen (Glassmorphism Premium) ── */
.login-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image: url('bg_avicola.png');
  background-size: cover;
  background-position: center;
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.6s;
}

.login-fullscreen::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(30, 58, 36, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#login-view.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.login-glass-card {
  position: relative;
  z-index: 1;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 24px;
  padding: 48px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 24px 48px rgba(0,0,0,0.2);
  animation: floatUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
  transform: translateY(40px);
}

@keyframes floatUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-logo-container {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo-img {
  width: 120px;
  height: auto;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.1));
  animation: pulse 4s ease-in-out infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.login-title-center {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--verde-tinta);
  text-align: center;
  margin-bottom: 8px;
}

.login-subtitle-center {
  font-size: 15px;
  color: var(--gris-texto);
  text-align: center;
  margin-bottom: 32px;
}

.login-form .field-label {
  color: var(--verde-tinta);
  font-weight: 600;
}

.glass-input {
  background: rgba(255, 255, 255, 0.6) !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  transition: all 0.3s ease;
}

.glass-input:focus {
  background: rgba(255, 255, 255, 1) !important;
  border-color: var(--verde-bosque) !important;
  box-shadow: 0 0 0 4px rgba(47, 90, 52, 0.1) !important;
}

.login-forgot {
  color: var(--terracota);
  font-weight: 500;
  font-size: 13px;
  text-decoration: none;
  transition: color 0.2s;
}

.login-forgot:hover {
  color: #a34522;
}

.login-btn-submit {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  margin-top: 16px;
  box-shadow: 0 8px 16px rgba(47, 90, 52, 0.25);
  transition: transform 0.2s, box-shadow 0.2s;
}

.login-btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 20px rgba(47, 90, 52, 0.35);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}
