/* =====================================================================
   GanaderoPro - Hoja de estilos principal
   Paleta del campo: verde pastura, tierra y dorado. Modo claro y oscuro.
   ===================================================================== */

/* ------------------------------------------------------------------ */
/* 1. Variables de color                                               */
/* ------------------------------------------------------------------ */

:root {
  color-scheme: light;

  --verde-900: #1c3a22;
  --verde-800: #24492b;
  --verde-700: #2f5d38;
  --verde-600: #3a7245;
  --verde-500: #4b8b3b;
  --verde-300: #8bbd7a;
  --verde-100: #e7f0e1;
  --verde-050: #f2f7ee;

  --tierra-700: #6f4620;
  --tierra-600: #8a5a2b;
  --tierra-300: #cba97f;
  --tierra-100: #f4ebdf;

  --dorado:      #b8901f;
  --dorado-100:  #fbf1d6;
  --rojo:        #b3352c;
  --rojo-100:    #fbe9e7;
  --ambar:       #a8710f;
  --ambar-100:   #fdf1dc;
  --azul:        #35657f;
  --azul-100:    #e6f0f5;

  --texto:        #1b2718;
  --texto-suave:  #5b6a55;
  --texto-tenue:  #8b9784;
  --borde:        #e0e7da;
  --borde-fuerte: #c8d3c0;
  --fondo:        #f3f6ef;
  --superficie:   #ffffff;
  --superficie-2: #f8faf5;
  --superficie-3: #eef3e8;

  --primario:      var(--verde-500);
  --primario-suave: var(--verde-100);
  --lateral-fondo: linear-gradient(178deg, #1c3a22 0%, #2f5d38 55%, #38663d 100%);
  --lateral-texto: rgba(255, 255, 255, .88);
  --lateral-activo-fondo: #ffffff;
  --lateral-activo-texto: var(--verde-800);

  --radio:    14px;
  --radio-sm: 9px;
  --radio-xs: 6px;
  --sombra:      0 1px 2px rgba(20, 35, 18, .05), 0 6px 18px rgba(20, 35, 18, .06);
  --sombra-alta: 0 14px 44px rgba(20, 35, 18, .18);
  --lateral: 258px;
  --fuente: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --fuente-num: "Segoe UI", system-ui, sans-serif;
}

:root[data-tema="oscuro"] {
  color-scheme: dark;

  --verde-100: #23361f;
  --verde-050: #1d2a1a;
  --verde-300: #8fc47c;
  --verde-500: #6fae5b;

  --tierra-100: #322619;
  --tierra-300: #c9a77c;
  --tierra-600: #c08a52;

  --dorado:     #d8b449;
  --dorado-100: #342c14;
  --rojo:       #e2705f;
  --rojo-100:   #38201c;
  --ambar:      #d99b3c;
  --ambar-100:  #362713;
  --azul:       #7fb2cc;
  --azul-100:   #1b2b33;

  --texto:        #e4ebdd;
  --texto-suave:  #a6b39c;
  --texto-tenue:  #7d8a75;
  --borde:        #2c3628;
  --borde-fuerte: #3d4a37;
  --fondo:        #11150f;
  --superficie:   #1a2016;
  --superficie-2: #202719;
  --superficie-3: #262e1f;

  --primario:       var(--verde-500);
  --primario-suave: #24361e;
  --lateral-fondo:  linear-gradient(178deg, #16210f 0%, #1d2c17 60%, #23331b 100%);
  --lateral-texto:  rgba(228, 235, 221, .82);
  --lateral-activo-fondo: #6fae5b;
  --lateral-activo-texto: #10160c;

  --sombra:      0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .28);
  --sombra-alta: 0 14px 44px rgba(0, 0, 0, .5);
}

@media (prefers-color-scheme: dark) {
  :root[data-tema="auto"] {
    color-scheme: dark;

    --verde-100: #23361f;
    --verde-050: #1d2a1a;
    --verde-300: #8fc47c;
    --verde-500: #6fae5b;

    --tierra-100: #322619;
    --tierra-300: #c9a77c;
    --tierra-600: #c08a52;

    --dorado:     #d8b449;
    --dorado-100: #342c14;
    --rojo:       #e2705f;
    --rojo-100:   #38201c;
    --ambar:      #d99b3c;
    --ambar-100:  #362713;
    --azul:       #7fb2cc;
    --azul-100:   #1b2b33;

    --texto:        #e4ebdd;
    --texto-suave:  #a6b39c;
    --texto-tenue:  #7d8a75;
    --borde:        #2c3628;
    --borde-fuerte: #3d4a37;
    --fondo:        #11150f;
    --superficie:   #1a2016;
    --superficie-2: #202719;
    --superficie-3: #262e1f;

    --primario:       var(--verde-500);
    --primario-suave: #24361e;
    --lateral-fondo:  linear-gradient(178deg, #16210f 0%, #1d2c17 60%, #23331b 100%);
    --lateral-texto:  rgba(228, 235, 221, .82);
    --lateral-activo-fondo: #6fae5b;
    --lateral-activo-texto: #10160c;

    --sombra:      0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .28);
    --sombra-alta: 0 14px 44px rgba(0, 0, 0, .5);
  }
}

/* ------------------------------------------------------------------ */
/* 2. Base                                                             */
/* ------------------------------------------------------------------ */

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--fuente);
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--texto);
  background: var(--fondo);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.18rem; }
h3 { font-size: 1.02rem; }
h4 { font-size: .92rem; }
p  { margin: 0 0 .75rem; }
a  { color: var(--verde-600); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: .82rem; }
hr { border: 0; border-top: 1px solid var(--borde); margin: 1.25rem 0; }
img { max-width: 100%; height: auto; }

:focus-visible {
  outline: 2px solid var(--verde-500);
  outline-offset: 2px;
  border-radius: 4px;
}

.oculto { display: none !important; }
.centro { text-align: center; }
.derecha { text-align: right; }
.nowrap { white-space: nowrap; }
.tenue  { color: var(--texto-suave); }
.mini   { font-size: .8rem; }
.fuerte { font-weight: 650; }
.mt  { margin-top: 1rem; }
.mt2 { margin-top: 1.75rem; }
.mb0 { margin-bottom: 0; }
.ancho-total { width: 100%; }
.saltar-al-contenido {
  position: absolute; left: -9999px;
  background: var(--superficie); padding: .6rem 1rem; z-index: 100; border-radius: var(--radio-sm);
}
.saltar-al-contenido:focus { left: 1rem; top: 1rem; }

/* ------------------------------------------------------------------ */
/* 3. Estructura general                                               */
/* ------------------------------------------------------------------ */

.disposicion { display: flex; min-height: 100vh; }

.lateral {
  width: var(--lateral);
  flex-shrink: 0;
  background: var(--lateral-fondo);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
}

.lateral__marca {
  display: flex; align-items: center; gap: .65rem;
  padding: 1.1rem 1.1rem .95rem;
  border-bottom: 1px solid rgba(255, 255, 255, .13);
}
.lateral__marca strong { font-size: 1.14rem; letter-spacing: .2px; display: block; }
.lateral__marca span { display: block; font-size: .71rem; opacity: .78; font-weight: 400; }

.logo-circulo {
  width: 38px; height: 38px; border-radius: 11px;
  background: rgba(255, 255, 255, .15);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.logo-circulo svg { width: 22px; height: 22px; }

.lateral nav { padding: .7rem .6rem 1.6rem; flex: 1; }
.lateral__grupo { margin-top: .9rem; }
.lateral__grupo-titulo {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .1em;
  opacity: .6; padding: 0 .6rem .35rem; font-weight: 600;
}
.lateral a.nav-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .58rem .68rem;
  border-radius: 10px;
  color: var(--lateral-texto);
  font-size: .92rem;
  margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.lateral a.nav-item:hover { background: rgba(255, 255, 255, .12); text-decoration: none; color: #fff; }
.lateral a.nav-item.activo {
  background: var(--lateral-activo-fondo);
  color: var(--lateral-activo-texto);
  font-weight: 620;
}
.nav-item .icono { width: 20px; height: 20px; flex-shrink: 0; opacity: .92; }
.nav-item .globo { margin-left: auto; }

.principal { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.barra-superior {
  display: flex; align-items: center; gap: .85rem;
  padding: .7rem 1.15rem;
  background: var(--superficie);
  border-bottom: 1px solid var(--borde);
  position: sticky; top: 0; z-index: 30;
}
.barra-superior h1 { font-size: 1.14rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra-superior .acciones { margin-left: auto; display: flex; align-items: center; gap: .45rem; }

.buscador { flex: 1; max-width: 380px; margin-left: .5rem; }
.buscador input {
  width: 100%; padding: .48rem .8rem .48rem 2.1rem;
  border: 1px solid var(--borde); border-radius: 999px;
  background: var(--superficie-2) var(--icono-lupa) no-repeat .7rem center;
  color: var(--texto); font-size: .9rem; font-family: inherit;
}
.buscador input:focus { border-color: var(--verde-500); outline: none; background-color: var(--superficie); }

.menu-movil { display: none; }

.contenido { padding: 1.2rem 1.15rem 3rem; flex: 1; }
.contenido > *:first-child { margin-top: 0; }

.persona { display: flex; align-items: center; gap: .5rem; color: var(--texto); }
.persona:hover { text-decoration: none; }
.persona__datos { display: flex; flex-direction: column; line-height: 1.15; }
.persona__nombre { font-size: .86rem; font-weight: 600; }
.persona__rol { font-size: .72rem; color: var(--texto-suave); }

.avatar-inicial {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--verde-500); color: #fff;
  display: grid; place-items: center;
  font-size: .82rem; font-weight: 650; flex-shrink: 0;
}

/* ------------------------------------------------------------------ */
/* 4. Tarjetas y paneles                                               */
/* ------------------------------------------------------------------ */

.tarjeta {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 1.05rem 1.15rem;
  margin-bottom: 1.1rem;
}
.tarjeta__cabecera {
  display: flex; align-items: center; gap: .7rem;
  margin: -.15rem 0 .85rem;
}
.tarjeta__cabecera h2, .tarjeta__cabecera h3 { margin: 0; }
.tarjeta__cabecera .acciones { margin-left: auto; display: flex; gap: .4rem; flex-wrap: wrap; }
.tarjeta--plana { box-shadow: none; }
.tarjeta--ajustada { padding: 0; overflow: hidden; }
.tarjeta--ajustada .tarjeta__cabecera { padding: 1rem 1.15rem 0; margin-bottom: .6rem; }

.rejilla { display: grid; gap: 1.1rem; }
.rejilla--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.rejilla--3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.rejilla--4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.rejilla--principal { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }

/* Tarjetas de indicadores */
.indicadores { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: .8rem; margin-bottom: 1.2rem; }

.indicador {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-left: 4px solid var(--verde-500);
  border-radius: var(--radio-sm);
  padding: .85rem .95rem;
  box-shadow: var(--sombra);
  display: block; color: inherit;
  container-type: inline-size;
}
.indicador:hover { text-decoration: none; border-color: var(--verde-300); }
.indicador__etiqueta {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--texto-suave); font-weight: 600;
  display: flex; align-items: center; gap: .35rem;
}
.indicador__valor {
  font-size: 1.62rem; font-weight: 680; line-height: 1.15; margin-top: .25rem;
  white-space: nowrap; overflow: hidden; text-overflow: clip;
}
/* Los importes largos se achican solos para no partirse en dos lineas. */
@supports (font-size: 1cqi) {
  .indicador__valor { font-size: clamp(1.02rem, 9.5cqi, 1.62rem); }
}
.indicador__pie { font-size: .78rem; color: var(--texto-suave); margin-top: .1rem; }
.indicador--tierra { border-left-color: var(--tierra-600); }
.indicador--dorado { border-left-color: var(--dorado); }
.indicador--rojo   { border-left-color: var(--rojo); }
.indicador--azul   { border-left-color: var(--azul); }
.indicador--ambar  { border-left-color: var(--ambar); }
.indicador .subida { color: var(--verde-600); font-weight: 600; }
.indicador .bajada { color: var(--rojo); font-weight: 600; }

/* ------------------------------------------------------------------ */
/* 5. Botones                                                          */
/* ------------------------------------------------------------------ */

.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: .42rem;
  padding: .55rem 1rem;
  border-radius: var(--radio-sm);
  border: 1px solid transparent;
  background: var(--verde-600);
  color: #fff;
  font-family: inherit; font-size: .9rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, transform .06s;
  white-space: nowrap;
}
.boton:hover { background: var(--verde-700); text-decoration: none; color: #fff; }
.boton:active { transform: translateY(1px); }
.boton:disabled, .boton[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.boton svg { width: 17px; height: 17px; flex-shrink: 0; }

.boton--tenue {
  background: var(--superficie-2);
  color: var(--texto);
  border-color: var(--borde-fuerte);
}
.boton--tenue:hover { background: var(--superficie-3); color: var(--texto); }

.boton--contorno { background: transparent; color: var(--verde-600); border-color: var(--verde-500); }
.boton--contorno:hover { background: var(--primario-suave); color: var(--verde-700); }

.boton--peligro { background: var(--rojo); }
.boton--peligro:hover { background: #96271f; }

.boton--tierra { background: var(--tierra-600); }
.boton--tierra:hover { background: var(--tierra-700); }

.boton--pequeno { padding: .35rem .68rem; font-size: .82rem; }
.boton--grande  { padding: .75rem 1.5rem; font-size: 1rem; }
.boton--bloque  { width: 100%; }
.boton--icono   { padding: .42rem; border-radius: 50%; }

.grupo-botones { display: flex; gap: .45rem; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------ */
/* 6. Formularios                                                      */
/* ------------------------------------------------------------------ */

.formulario { display: grid; gap: 1rem; }
.campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .9rem 1.1rem; }
.campos--2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.campo--ancho { grid-column: 1 / -1; }

.campo { display: flex; flex-direction: column; gap: .3rem; }
.campo > label, .etiqueta-campo {
  font-size: .81rem; font-weight: 620; color: var(--texto-suave);
}
.campo .ayuda { font-size: .76rem; color: var(--texto-tenue); }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="time"], input[type="search"], input[type="tel"],
input[type="url"], select, textarea {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--borde-fuerte);
  border-radius: var(--radio-sm);
  background: var(--superficie);
  color: var(--texto);
  font-family: inherit; font-size: .93rem;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
select { appearance: none; padding-right: 2rem; background-image: var(--icono-flecha); background-repeat: no-repeat; background-position: right .6rem center; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--verde-500);
  box-shadow: 0 0 0 3px rgba(75, 139, 59, .16);
}
input:disabled, select:disabled, textarea:disabled { background: var(--superficie-3); color: var(--texto-tenue); }
input::placeholder, textarea::placeholder { color: var(--texto-tenue); }

.campo--error input, .campo--error select, .campo--error textarea { border-color: var(--rojo); }
.campo__error { font-size: .78rem; color: var(--rojo); }

.casilla { display: flex; align-items: flex-start; gap: .5rem; font-size: .89rem; }
.casilla input { width: auto; margin-top: .22rem; accent-color: var(--verde-500); }

.interruptor { display: inline-flex; align-items: center; gap: .55rem; cursor: pointer; font-size: .89rem; }
.interruptor input { position: absolute; opacity: 0; width: 0; height: 0; }
.interruptor__pista {
  width: 40px; height: 22px; border-radius: 999px;
  background: var(--borde-fuerte); position: relative; transition: background .18s; flex-shrink: 0;
}
.interruptor__pista::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .18s;
}
.interruptor input:checked + .interruptor__pista { background: var(--verde-500); }
.interruptor input:checked + .interruptor__pista::after { transform: translateX(18px); }
.interruptor input:focus-visible + .interruptor__pista { outline: 2px solid var(--verde-500); outline-offset: 2px; }

.acciones-formulario {
  display: flex; gap: .6rem; flex-wrap: wrap; align-items: center;
  padding-top: .9rem; border-top: 1px solid var(--borde);
}
.acciones-formulario .separador { margin-left: auto; }

fieldset { border: 1px solid var(--borde); border-radius: var(--radio-sm); padding: .9rem 1rem 1.1rem; margin: 0 0 1rem; }
legend { font-size: .82rem; font-weight: 650; color: var(--tierra-600); padding: 0 .4rem; }

/* Filtros compactos sobre las tablas */
.filtros {
  display: flex; flex-wrap: wrap; gap: .55rem; align-items: flex-end;
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: .8rem .9rem;
  margin-bottom: 1rem;
}
.filtros .campo { min-width: 132px; flex: 1 1 132px; gap: .18rem; }
.filtros .campo > label { font-size: .72rem; }
.filtros input, .filtros select { padding: .42rem .6rem; font-size: .87rem; }
.filtros .acciones { display: flex; gap: .4rem; margin-left: auto; }

/* ------------------------------------------------------------------ */
/* 7. Tablas                                                           */
/* ------------------------------------------------------------------ */

.tabla-envoltorio { overflow-x: auto; border-radius: var(--radio); border: 1px solid var(--borde); background: var(--superficie); }
.tabla-envoltorio .tabla { margin: 0; border: 0; }

.tabla { width: 100%; border-collapse: collapse; font-size: .89rem; background: var(--superficie); }
.tabla th, .tabla td { padding: .58rem .75rem; text-align: left; border-bottom: 1px solid var(--borde); vertical-align: middle; }
.tabla thead th {
  background: var(--superficie-3);
  font-size: .74rem; text-transform: uppercase; letter-spacing: .045em;
  color: var(--texto-suave); font-weight: 680; white-space: nowrap;
  position: sticky; top: 0; z-index: 2;
}
.tabla tbody tr:hover { background: var(--superficie-2); }
.tabla tbody tr:last-child td { border-bottom: 0; }
.tabla .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabla .acciones-fila { text-align: right; white-space: nowrap; }
.tabla .acciones-fila .boton { margin-left: .25rem; }
.tabla a { font-weight: 600; }
.tabla--compacta th, .tabla--compacta td { padding: .4rem .6rem; font-size: .85rem; }
.tabla tfoot td { font-weight: 680; background: var(--superficie-3); border-top: 2px solid var(--borde-fuerte); }

.tabla-vacia { padding: 2.4rem 1rem; text-align: center; color: var(--texto-suave); }
.tabla-vacia svg { width: 42px; height: 42px; opacity: .38; margin-bottom: .5rem; }
.tabla-vacia p { margin: .2rem 0 .8rem; }

/* ------------------------------------------------------------------ */
/* 8. Etiquetas de estado                                              */
/* ------------------------------------------------------------------ */

.etiqueta {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .16rem .55rem;
  border-radius: 999px;
  font-size: .75rem; font-weight: 650; white-space: nowrap;
  border: 1px solid transparent;
}
.etiqueta--ok      { background: var(--verde-100);  color: var(--verde-700);  border-color: var(--verde-300); }
.etiqueta--info    { background: var(--azul-100);   color: var(--azul);       border-color: var(--azul); }
.etiqueta--aviso   { background: var(--ambar-100);  color: var(--ambar);      border-color: var(--ambar); }
.etiqueta--peligro { background: var(--rojo-100);   color: var(--rojo);       border-color: var(--rojo); }
.etiqueta--neutro  { background: var(--superficie-3); color: var(--texto-suave); border-color: var(--borde-fuerte); }
.etiqueta--tierra  { background: var(--tierra-100); color: var(--tierra-600); border-color: var(--tierra-300); }

.globo {
  display: inline-grid; place-items: center;
  min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: 999px; background: var(--rojo); color: #fff;
  font-size: .69rem; font-weight: 700; line-height: 1;
}
.globo--tenue { background: var(--verde-500); }

.punto { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.punto--ok { background: var(--verde-500); }
.punto--aviso { background: var(--ambar); }
.punto--peligro { background: var(--rojo); }

/* ------------------------------------------------------------------ */
/* 9. Avisos y mensajes                                                */
/* ------------------------------------------------------------------ */

.aviso {
  display: flex; gap: .7rem; align-items: flex-start;
  padding: .75rem .9rem;
  border-radius: var(--radio-sm);
  border: 1px solid var(--borde);
  background: var(--superficie-2);
  margin-bottom: .85rem;
  font-size: .9rem;
}
.aviso__icono { flex-shrink: 0; width: 18px; height: 18px; margin-top: .12rem; }
.aviso--exito   { background: var(--verde-100);  border-color: var(--verde-300);  color: var(--verde-800); }
.aviso--error   { background: var(--rojo-100);   border-color: var(--rojo);       color: var(--rojo); }
.aviso--aviso   { background: var(--ambar-100);  border-color: var(--ambar);      color: var(--ambar); }
.aviso--info    { background: var(--azul-100);   border-color: var(--azul);       color: var(--azul); }
.aviso a { color: inherit; text-decoration: underline; }
.aviso__cerrar { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; opacity: .6; font-size: 1.1rem; line-height: 1; padding: 0 .2rem; }
.aviso__cerrar:hover { opacity: 1; }

/* Panel de alertas del tablero */
.alertas { display: grid; gap: .5rem; }
.alerta-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .75rem;
  border-radius: var(--radio-sm);
  border: 1px solid var(--borde);
  background: var(--superficie-2);
  color: inherit;
}
.alerta-item:hover { text-decoration: none; border-color: var(--borde-fuerte); background: var(--superficie-3); }
.alerta-item__icono { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; }
.alerta-item__texto { min-width: 0; }
.alerta-item__titulo { font-weight: 640; font-size: .9rem; }
.alerta-item__detalle { font-size: .79rem; color: var(--texto-suave); }
.alerta-item__cantidad { margin-left: auto; font-size: 1.05rem; font-weight: 700; }
.alerta-item--peligro .alerta-item__icono { background: var(--rojo-100); color: var(--rojo); }
.alerta-item--aviso   .alerta-item__icono { background: var(--ambar-100); color: var(--ambar); }
.alerta-item--info    .alerta-item__icono { background: var(--azul-100); color: var(--azul); }
.alerta-item--ok      .alerta-item__icono { background: var(--verde-100); color: var(--verde-700); }

/* ------------------------------------------------------------------ */
/* 10. Graficos                                                        */
/* ------------------------------------------------------------------ */

.grafico { display: block; width: 100%; height: auto; overflow: visible; }
.grafico .g-rejilla { stroke: var(--borde); stroke-width: 1; stroke-dasharray: 2 4; }
.grafico .g-eje     { fill: var(--texto-tenue); font-size: 10px; font-family: var(--fuente); }
.grafico .g-valor   { fill: var(--texto-suave); font-size: 10px; font-weight: 600; font-family: var(--fuente); }
.grafico .g-leyenda { fill: var(--texto); font-size: 11px; font-family: var(--fuente); }
.grafico .g-total   { fill: var(--texto); font-size: 20px; font-weight: 700; font-family: var(--fuente); }
.grafico-vacio { color: var(--texto-tenue); text-align: center; padding: 2rem 1rem; font-size: .9rem; }
.grafico-envoltorio { overflow-x: auto; }

.progreso { display: block; height: 7px; border-radius: 999px; background: var(--superficie-3); overflow: hidden; }
.progreso__valor { display: block; height: 100%; border-radius: 999px; background: var(--verde-500); }

/* ------------------------------------------------------------------ */
/* 11. Ficha de animal y detalles                                      */
/* ------------------------------------------------------------------ */

.ficha-cabecera { display: flex; gap: 1.1rem; flex-wrap: wrap; align-items: flex-start; }
.ficha-foto {
  width: 148px; height: 148px; border-radius: var(--radio);
  object-fit: cover; background: var(--superficie-3); flex-shrink: 0;
  border: 1px solid var(--borde);
}
.ficha-foto--vacia { display: grid; place-items: center; color: var(--texto-tenue); }
.ficha-foto--vacia svg { width: 46px; height: 46px; opacity: .5; }
.ficha-datos { flex: 1; min-width: 240px; }
.ficha-titulo { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .3rem; }
.ficha-titulo h1 { margin: 0; font-size: 1.5rem; }
.ficha-qr { text-align: center; }
.ficha-qr svg, .ficha-qr img { width: 118px; height: 118px; background: #fff; border-radius: 8px; padding: 5px; border: 1px solid var(--borde); }
.ficha-qr small { display: block; margin-top: .3rem; color: var(--texto-suave); font-size: .72rem; letter-spacing: .08em; }

.datos-lista { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: .75rem 1.1rem; }
.datos-lista > div { min-width: 0; }
.datos-lista dt { font-size: .71rem; text-transform: uppercase; letter-spacing: .05em; color: var(--texto-tenue); font-weight: 640; }
.datos-lista dd { margin: .1rem 0 0; font-size: .94rem; font-weight: 550; word-break: break-word; }

.pestanas { display: flex; gap: .2rem; border-bottom: 1px solid var(--borde); margin-bottom: 1rem; overflow-x: auto; }
.pestanas a {
  padding: .55rem .9rem; font-size: .89rem; font-weight: 600;
  color: var(--texto-suave); border-bottom: 2px solid transparent; white-space: nowrap;
}
.pestanas a:hover { color: var(--texto); text-decoration: none; }
.pestanas a.activo { color: var(--verde-600); border-bottom-color: var(--verde-500); }

/* Linea de tiempo del historial */
.linea-tiempo { list-style: none; margin: 0; padding: 0 0 0 1.4rem; position: relative; }
.linea-tiempo::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--borde); }
.linea-tiempo li { position: relative; padding: 0 0 1rem; }
.linea-tiempo li::before {
  content: ""; position: absolute; left: -1.4rem; top: .38rem;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--superficie); border: 2px solid var(--verde-500);
}
.linea-tiempo li.hito-aviso::before  { border-color: var(--ambar); }
.linea-tiempo li.hito-peligro::before { border-color: var(--rojo); }
.linea-tiempo__fecha { font-size: .74rem; color: var(--texto-tenue); text-transform: uppercase; letter-spacing: .04em; }
.linea-tiempo__titulo { font-weight: 640; font-size: .92rem; }
.linea-tiempo__detalle { font-size: .85rem; color: var(--texto-suave); }

/* Genealogia */
.arbol { display: flex; gap: .8rem; align-items: stretch; flex-wrap: wrap; }
.arbol__columna { flex: 1; min-width: 160px; display: grid; gap: .5rem; align-content: start; }
.arbol__nodo {
  border: 1px solid var(--borde); border-radius: var(--radio-sm);
  padding: .5rem .65rem; background: var(--superficie-2); font-size: .85rem;
}
.arbol__nodo strong { display: block; }
.arbol__nodo--vacio { color: var(--texto-tenue); font-style: italic; border-style: dashed; }

/* ------------------------------------------------------------------ */
/* 12. Paginacion                                                      */
/* ------------------------------------------------------------------ */

.paginacion { display: flex; gap: .3rem; align-items: center; justify-content: center; flex-wrap: wrap; margin: 1.1rem 0 .3rem; }
.paginacion a, .paginacion span {
  min-width: 34px; padding: .35rem .6rem; text-align: center;
  border: 1px solid var(--borde); border-radius: var(--radio-xs);
  font-size: .86rem; color: var(--texto); background: var(--superficie);
}
.paginacion a:hover { background: var(--superficie-3); text-decoration: none; }
.paginacion .actual { background: var(--verde-600); color: #fff; border-color: var(--verde-600); font-weight: 650; }
.paginacion .inactivo { opacity: .45; pointer-events: none; }
.paginacion__resumen { font-size: .82rem; color: var(--texto-suave); width: 100%; text-align: center; margin-top: .3rem; }

/* ------------------------------------------------------------------ */
/* 13. Acceso (login)                                                  */
/* ------------------------------------------------------------------ */

.acceso {
  min-height: 100vh; display: grid; place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(75, 139, 59, .16), transparent 60%),
    var(--fondo);
}
.acceso__caja {
  width: 100%; max-width: 420px;
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: 18px;
  box-shadow: var(--sombra-alta);
  padding: 2rem 1.75rem 1.75rem;
}
.acceso__marca { text-align: center; margin-bottom: 1.4rem; }
.acceso__marca .logo-circulo {
  width: 60px; height: 60px; margin: 0 auto .7rem;
  background: var(--verde-600); border-radius: 18px;
}
.acceso__marca .logo-circulo svg { width: 34px; height: 34px; }
.acceso__marca h1 { font-size: 1.42rem; margin: 0; }
.acceso__marca p { color: var(--texto-suave); font-size: .87rem; margin: .15rem 0 0; }
.acceso__pie { text-align: center; margin-top: 1.1rem; font-size: .83rem; color: var(--texto-suave); }

/* ------------------------------------------------------------------ */
/* 14. Utilidades varias                                               */
/* ------------------------------------------------------------------ */

.barra-acciones {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  margin-bottom: 1rem;
}
.barra-acciones h1, .barra-acciones h2 { margin: 0; }
.barra-acciones .separador { margin-left: auto; }

.miga { font-size: .82rem; color: var(--texto-suave); margin-bottom: .5rem; display: flex; gap: .35rem; flex-wrap: wrap; }
.miga a { color: var(--texto-suave); }
.miga span { opacity: .55; }

.lista-simple { list-style: none; margin: 0; padding: 0; }
.lista-simple li {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem 0; border-bottom: 1px solid var(--borde); font-size: .89rem;
}
.lista-simple li:last-child { border-bottom: 0; }
.lista-simple .separador { margin-left: auto; }

.caja-qr { display: inline-block; background: #fff; padding: 8px; border-radius: 10px; border: 1px solid var(--borde); }
.caja-qr svg { display: block; }

.chip-filtro {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .2rem .55rem; border-radius: 999px;
  background: var(--primario-suave); color: var(--verde-700);
  font-size: .78rem; font-weight: 600;
}
.chip-filtro a { color: inherit; opacity: .7; }

.escaner-video {
  width: 100%; max-width: 420px; border-radius: var(--radio);
  background: #000; aspect-ratio: 4 / 3; object-fit: cover;
}

.sin-datos { color: var(--texto-tenue); font-style: italic; }

.contador-lote {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .8rem; color: var(--texto-suave);
}

.selector-animales {
  max-height: 320px; overflow-y: auto;
  border: 1px solid var(--borde); border-radius: var(--radio-sm);
  background: var(--superficie-2);
}
.selector-animales label {
  display: flex; align-items: center; gap: .6rem;
  padding: .42rem .7rem; border-bottom: 1px solid var(--borde); font-size: .87rem; cursor: pointer;
}
.selector-animales label:last-child { border-bottom: 0; }
.selector-animales label:hover { background: var(--superficie-3); }
.selector-animales input { width: auto; accent-color: var(--verde-500); }

/* ------------------------------------------------------------------ */
/* 15. Responsive                                                      */
/* ------------------------------------------------------------------ */

@media (max-width: 1080px) {
  .rejilla--principal { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .lateral {
    position: fixed; z-index: 60; left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: var(--sombra-alta);
  }
  body.menu-abierto .lateral { transform: translateX(0); }
  body.menu-abierto::after {
    content: ""; position: fixed; inset: 0; background: rgba(10, 18, 8, .5); z-index: 55;
  }
  .menu-movil { display: inline-flex; }
  .buscador { display: none; }
  .persona__datos { display: none; }
  .contenido { padding: 1rem .8rem 4.5rem; }
  .barra-superior { padding: .6rem .8rem; }
}

@media (max-width: 620px) {
  body { font-size: 15px; }
  /* En el celular estos accesos ya estan en la barra inferior. */
  .solo-escritorio { display: none !important; }
  .barra-superior { gap: .5rem; }
  .barra-superior h1 { font-size: 1.02rem; }
  .tarjeta { padding: .85rem .9rem; border-radius: 12px; }
  .indicadores { grid-template-columns: repeat(auto-fit, minmax(142px, 1fr)); gap: .6rem; }
  .indicador__valor { font-size: 1.4rem; }
  .filtros { padding: .7rem; }
  .filtros .acciones { margin-left: 0; width: 100%; }
  .acciones-formulario { position: sticky; bottom: 0; background: var(--superficie); padding-bottom: .6rem; }
  .barra-acciones .separador { display: none; }
  .barra-acciones { gap: .45rem; }
  .tabla th, .tabla td { padding: .5rem .55rem; }

  /* Tablas apiladas en el celular */
  .tabla--apilable thead { display: none; }
  .tabla--apilable tbody tr {
    display: block; border: 1px solid var(--borde); border-radius: var(--radio-sm);
    margin-bottom: .6rem; padding: .3rem .1rem; background: var(--superficie);
  }
  .tabla--apilable tbody td {
    display: flex; justify-content: space-between; gap: 1rem;
    border-bottom: 1px dashed var(--borde); text-align: right;
  }
  .tabla--apilable tbody td:last-child { border-bottom: 0; }
  .tabla--apilable tbody td::before {
    content: attr(data-etiqueta);
    font-size: .74rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--texto-tenue); font-weight: 640; text-align: left;
  }
  .tabla--apilable .acciones-fila { justify-content: flex-end; }
}

/* Barra inferior de accesos rapidos en el celular */
.barra-movil { display: none; }
@media (max-width: 900px) {
  .barra-movil {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: var(--superficie); border-top: 1px solid var(--borde);
    padding: .3rem .2rem calc(.3rem + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .barra-movil a {
    display: flex; flex-direction: column; align-items: center; gap: .1rem;
    font-size: .68rem; color: var(--texto-suave); padding: .3rem .5rem; flex: 1;
  }
  .barra-movil a.activo { color: var(--verde-600); }
  .barra-movil a:hover { text-decoration: none; }
  .barra-movil svg { width: 21px; height: 21px; }
}

/* ------------------------------------------------------------------ */
/* 16. Impresion                                                       */
/* ------------------------------------------------------------------ */

@media print {
  .lateral, .barra-superior, .barra-movil, .no-imprimir,
  .filtros, .paginacion, .acciones-formulario, .pestanas { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .contenido { padding: 0; }
  .tarjeta { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; page-break-inside: avoid; }
  .tabla thead th { background: #eee !important; color: #000; position: static; }
  a { color: #000; text-decoration: none; }
  .indicador { border: 1px solid #ccc; }
}

/* ------------------------------------------------------------------ */
/* 17. Iconos embebidos como variables                                 */
/* ------------------------------------------------------------------ */

:root {
  --icono-lupa: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b9784' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  --icono-flecha: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b6a55' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
:root[data-tema="oscuro"] {
  --icono-flecha: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a6b39c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root[data-tema="auto"] {
    --icono-flecha: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a6b39c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
