/* ============================================================
   Caney, estilos de la PWA (móvil primero, temas claro y oscuro)
   Sección 13 de docs/auditoria-ux: carbón, teal y verde tierra con
   Hanken Grotesk. El color identifica acciones y estados; la
   jerarquía la dan separación, títulos y tamaño. Relieve estático
   en superficies de marca y categorías; movimiento solo al interactuar.
   ============================================================ */

/* ---- Fuente de marca: Hanken Grotesk (offline, woff2 local) ---- */
@font-face{font-family:"Hanken Grotesk";font-style:normal;font-weight:400;font-display:swap;src:url("fonts/hanken-400.woff2") format("woff2");}
@font-face{font-family:"Hanken Grotesk";font-style:normal;font-weight:500;font-display:swap;src:url("fonts/hanken-500.woff2") format("woff2");}
@font-face{font-family:"Hanken Grotesk";font-style:normal;font-weight:600;font-display:swap;src:url("fonts/hanken-600.woff2") format("woff2");}
@font-face{font-family:"Hanken Grotesk";font-style:normal;font-weight:700;font-display:swap;src:url("fonts/hanken-700.woff2") format("woff2");}
@font-face{font-family:"Hanken Grotesk";font-style:normal;font-weight:800;font-display:swap;src:url("fonts/hanken-800.woff2") format("woff2");}

/* ============================================================
   TOKENS (13.2). Claro por defecto; oscuro con [data-theme="dark"],
   que el script del <head> fija antes del primer dibujo.
   ============================================================ */
:root {
  color-scheme: light;
  /* Paleta original de Caney. Solo estos colores; las transparencias derivan de ellos. */
  --ground: #F9F9F8;
  --surface: #FFFFFF;
  --surface-2: #F3F4F3;
  --surface-3: #E1E3E2;
  --text: #191C1C;
  --mute: #44474A;
  --border: #E1E3E2;
  --control-border: #44474A;
  --accent: #1D9A8C;          /* teal de marca */
  --accent-strong: #17B0A0;   /* teal intenso */
  --accent-soft: #D4EEE9;     /* teal suave */
  --earth: #4D6450;           /* verde tierra */
  --earth-soft: #CCE6CD;      /* verde suave */
  --clay: #B87259;            /* barro */
  --clay-soft: #FFDBCF;       /* barro suave */
  --blue: #3E7C8C;            /* azul de categoría */
  --action-bg: #1D9A8C;
  --action-hover: #17B0A0;
  --on-action: #191C1C;
  --selection-bg: #D4EEE9;
  --selection-text: #4D6450;
  --link: #4D6450;
  --focus: #1D9A8C;
  --success-bg: #CCE6CD;
  --success-text: #4D6450;
  --success-ico: #4D6450;
  --warning-bg: #FFDBCF;
  --warning-text: #191C1C;
  --warning-ico: #B87259;
  --critical-bg: #FCE8E6;
  --critical-text: #BA1A1A;
  /* Zonas de marca: navegación, encabezado de Hoy y resumen principal. */
  --brand-nav: #4D6450;
  --brand-nav-text: #FFFFFF;
  --brand-nav-mute: #FFFFFF;
  --brand-nav-active-bg: #D4EEE9;
  --brand-nav-active-text: #191C1C;
  --brand-nav-line: rgba(255, 255, 255, .18);
  --brand-nav-focus: #FFFFFF;
  --brand-hero: #17B0A0;
  --brand-hero-text: #191C1C;
  --brand-hero-mute: #191C1C;
  --brand-panel: #4D6450;
  --brand-panel-2: #4D6450;
  --brand-panel-text: #FFFFFF;
  --brand-panel-mute: #FFFFFF;
  --overlay: rgba(25, 28, 28, .48);
  --shadow-soft: 0 6px 18px rgba(25, 28, 28, .10), 0 1px 3px rgba(25, 28, 28, .06);
  --shadow-pop: 0 10px 28px rgba(25, 28, 28, .14), 0 1px 3px rgba(25, 28, 28, .08);
  --shadow-card: 0 2px 4px rgba(25, 28, 28, .03), 0 8px 24px rgba(25, 28, 28, .04);

  /* Colores de grupo (categoría, nunca estado). */
  --cat-produccion: #1D9A8C;      --cat-produccion-soft: #D4EEE9;
  --cat-reproduccion: #B87259;    --cat-reproduccion-soft: #FFDBCF;
  --cat-crecimiento: #4D6450;     --cat-crecimiento-soft: #CCE6CD;
  --cat-composicion: #3E7C8C;     --cat-composicion-soft: #F3F4F3;
  --cat-sanidad: #3E7C8C;         --cat-sanidad-soft: #F3F4F3;
  --cat-economia: #44474A;        --cat-economia-soft: #F3F4F3;

  /* Alias de compatibilidad para componentes que aún usan los nombres anteriores. */
  --success: var(--success-ico); --warning: var(--warning-ico); --critical: var(--critical-text); --info: var(--accent);
  --success-soft: var(--success-bg); --warning-soft: var(--warning-bg); --critical-soft: var(--critical-bg); --info-soft: var(--accent-soft);
  --accent-bright: var(--accent-strong);
  --male: var(--mute); --female: var(--mute);
  --line: var(--border); --card: var(--surface); --txt: var(--text); --brand: var(--action-bg); --tinta: var(--text);
  --shadow: none; --shadow-lg: var(--shadow-pop);

  --radius: 8px; --radius-sm: 8px; --radius-lg: 12px;
  --sidebar-w: 256px;
  --font-ui: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --t-rapido: 140ms;
  --nav-h: 64px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #0E1110;
  --surface: #171A19;
  --surface-2: #1E2220;
  --surface-3: #2A2E2C;
  --text: #EDEFEE;
  --mute: #9BA0A0;
  --border: #2A2E2C;
  --control-border: #9BA0A0;
  --accent: #23B5A4;
  --accent-strong: #35C7B6;
  --accent-soft: #10302B;
  --earth: #6E8F72;
  --earth-soft: #16281B;
  --clay: #C98A6E;
  --clay-soft: #2A1D16;
  --blue: #5FA0B0;
  --action-bg: #23B5A4;
  --action-hover: #35C7B6;
  --on-action: #191C1C;
  --selection-bg: #10302B;
  --selection-text: #35C7B6;
  --link: #35C7B6;
  --focus: #35C7B6;
  --success-bg: #16281B;
  --success-text: #EDEFEE;
  --success-ico: #6E8F72;
  --warning-bg: #2A1D16;
  --warning-text: #C98A6E;
  --warning-ico: #C98A6E;
  --critical-bg: #2C1614;
  --critical-text: #E36258;
  --brand-nav: #10302B;
  --brand-nav-text: #EDEFEE;
  --brand-nav-mute: #CCE6CD;
  --brand-nav-active-bg: #23B5A4;
  --brand-nav-active-text: #191C1C;
  --brand-nav-line: rgba(237, 239, 238, .12);
  --brand-nav-focus: #35C7B6;
  --brand-hero: #23B5A4;
  --brand-hero-text: #191C1C;
  --brand-hero-mute: #191C1C;
  --brand-panel: #10302B;
  --brand-panel-2: #16281B;
  --brand-panel-text: #EDEFEE;
  --brand-panel-mute: #CCE6CD;
  --overlay: rgba(14, 17, 16, .72);
  --shadow-soft: 0 6px 18px rgba(14, 17, 16, .5);
  --shadow-pop: 0 10px 28px rgba(14, 17, 16, .6);
  --shadow-card: 0 4px 16px rgba(14, 17, 16, .24), inset 0 1px 0 rgba(237, 239, 238, .04);
  --cat-produccion: #23B5A4;      --cat-produccion-soft: #10302B;
  --cat-reproduccion: #C98A6E;    --cat-reproduccion-soft: #2A1D16;
  --cat-crecimiento: #6E8F72;     --cat-crecimiento-soft: #16281B;
  --cat-composicion: #5FA0B0;     --cat-composicion-soft: #1E2220;
  --cat-sanidad: #5FA0B0;         --cat-sanidad-soft: #1E2220;
  --cat-economia: #9BA0A0;        --cat-economia-soft: #1E2220;
}
/* Sin JavaScript (no hay data-theme): se sigue al sistema con la misma paleta oscura. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --ground: #0E1110; --surface: #171A19; --surface-2: #1E2220; --surface-3: #2A2E2C;
    --text: #EDEFEE; --mute: #9BA0A0; --border: #2A2E2C; --control-border: #9BA0A0;
    --accent: #23B5A4; --accent-strong: #35C7B6; --accent-soft: #10302B;
    --action-bg: #23B5A4; --action-hover: #35C7B6; --on-action: #191C1C;
    --selection-bg: #10302B; --selection-text: #35C7B6; --link: #35C7B6; --focus: #35C7B6;
    --success-bg: #16281B; --success-text: #EDEFEE; --success-ico: #6E8F72;
    --warning-bg: #2A1D16; --warning-text: #C98A6E; --warning-ico: #C98A6E;
    --critical-bg: #2C1614; --critical-text: #E36258; --overlay: rgba(14, 17, 16, .72);
    --brand-nav: #10302B; --brand-nav-text: #EDEFEE; --brand-nav-mute: #CCE6CD;
    --brand-nav-active-bg: #23B5A4; --brand-nav-active-text: #191C1C;
    --brand-hero: #23B5A4; --brand-hero-text: #191C1C; --brand-hero-mute: #191C1C;
    --brand-panel: #10302B; --brand-panel-2: #16281B; --brand-panel-text: #EDEFEE; --brand-panel-mute: #CCE6CD;
    --shadow-card: 0 4px 16px rgba(14, 17, 16, .24), inset 0 1px 0 rgba(237, 239, 238, .04);
  }
}

/* ============================================================
   CAMBIO DE TEMA (13.7). La clase .tema-cambiando dura ~200 ms y solo
   la pone CaneyUI.tema ante un cambio voluntario. Fondos y bordes se
   funden; el texto cambia de una vez cuando el fondo cruza la mitad,
   así nunca queda texto claro sobre fondo claro. Sin selector universal
   ni opacidad sobre toda la app. Con movimiento reducido no hay transición.
   ============================================================ */
@media (prefers-reduced-motion: no-preference) {
  html.tema-cambiando,
  html.tema-cambiando :is(body, #login, .login-card, .topbar, .sidebar, .bottom-nav, .drawer, .modal, .menu-pop, .cmd,
    .card, .kpi, .tbl-card, .tbl-hero, .resumen-item, .pend, .callout, .alert, .task, .estado-linea,
    .btn, .icon-btn, .input, .search-input, .seg, .seg button, .chip, .tab, .badge, .sync-badge, .nav-item, .nav-grupo-btn,
    .filtros-toggle, .filtros-panel, .table-wrap, thead th, tbody td, .fila-animal, .lista-animales, .qc-btn, .accion-rapida,
    .picker-lista, .picker-elegido, .export-panel, .export-opcion, .offline-bar, .toast, .paginacion, .grupo-pend, .wz-dot, .tbl-status, .tbl-delta,
    .hoy-cab, .cat-ico, .qc-ico, .brand-tile, .login-banda, .btn-accion, .nav-grupo-btn, .sidebar-foot, .tbl-sec-t) {
    transition: background-color 200ms var(--ease-out), border-color 200ms var(--ease-out), color 0s linear 40ms;
  }
}

/* ---- Base ---- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: var(--ground); -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--ground);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.5;
  font-weight: 400;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
p { margin: 0 0 var(--sp-2); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; }
a { color: var(--link); }
img { max-width: 100%; }
/* Cifras con números tabulares en la fuente de la interfaz; los códigos de animal,
   donde importa distinguir O de 0, van en monoespaciada (.code-big, .picker-cod…). */
.mono { font-variant-numeric: tabular-nums; letter-spacing: 0; }
.code-big, .picker-cod, .fa-cod, .link-ficha .mono, .tl-date { font-family: var(--font-mono); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--mute); }
.small { font-size: 14px; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.saltar { position: absolute; left: 8px; top: -60px; z-index: 500; background: var(--surface); color: var(--text); padding: 10px 14px; border-radius: var(--radius); border: 2px solid var(--focus); }
.saltar:focus { top: 8px; }

/* Foco visible con anillo de superficie: no se confunde con un botón teal. */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; box-shadow: 0 0 0 4px var(--surface); border-radius: 6px; }
:focus:not(:focus-visible) { outline: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
}

/* ============================================================
   ACCESO
   ============================================================ */
#login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: var(--sp-4); background: var(--ground); }
.login-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 0 var(--sp-5) var(--sp-5); box-shadow: var(--shadow-pop); overflow: hidden; }
.login-brand { display: flex; align-items: center; gap: var(--sp-3); margin: 0 calc(-1 * var(--sp-5)) var(--sp-5); padding: var(--sp-5); background: var(--brand-nav); color: var(--brand-nav-text); }
.login-brand .wordmark { font-size: 30px; font-weight: 800; letter-spacing: -.02em; color: var(--brand-nav-text); }
.login-brand .finca { color: var(--brand-nav-mute); font-size: 14px; margin: 0; }
.login-ayuda { margin-top: var(--sp-2); font-size: 14px; }
.login-ayuda summary { cursor: pointer; color: var(--link); font-weight: 600; min-height: 32px; display: inline-flex; align-items: center; }
.login-ayuda p { color: var(--mute); margin: var(--sp-1) 0 0; }
.clave-wrap { position: relative; }
.clave-wrap .input { padding-right: 96px; }
.clave-ver { position: absolute; right: 4px; top: 4px; bottom: 4px; padding: 0 12px; border-radius: 6px; font-weight: 600; font-size: 14px; color: var(--link); }
.clave-ver:hover { background: var(--surface-2); }
.login-msg { font-size: 14px; color: var(--critical-text); margin: var(--sp-3) 0 0; min-height: 1em; }
.login-msg.info { color: var(--text); }
.hint { font-size: 14px; color: var(--mute); text-align: center; margin: var(--sp-3) 0 0; }
.legal-links a { color: var(--mute); }

/* ============================================================
   ESTRUCTURA
   ============================================================ */
#app { display: none; }
#app.active { display: block; }
.app-shell { min-height: 100vh; min-height: 100dvh; }

/* Barra lateral (escritorio): navegación por grupos */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: linear-gradient(155deg, rgba(23, 176, 160, .22), transparent 45%), var(--brand-nav); color: var(--brand-nav-text); display: flex; flex-direction: column; padding: var(--sp-4) var(--sp-3); z-index: 30; border-right: 1px solid var(--brand-nav-line); }
.sidebar .brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 20px; }
.brand-txt { display: flex; flex-direction: column; min-width: 0; }
.brand-finca { font-size: 14px; font-weight: 600; color: var(--brand-nav-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .wordmark { color: var(--brand-nav-text); font-size: 22px; line-height: 1.1; }
/* Isotipo sobre una baldosa clara: el recurso es negro y teal y ocupa la mitad del lienzo. */
.brand-tile { position: relative; width: 40px; height: 40px; flex: 0 0 40px; border-radius: 10px; background: #F9F9F8; overflow: hidden; }
.brand-tile img { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 76px; height: 76px; max-width: none; display: block; }
.brand-tile.sm { width: 32px; height: 32px; flex-basis: 32px; border-radius: 8px; }
.brand-tile.sm img { width: 60px; height: 60px; }
.brand-tile.lg { width: 56px; height: 56px; flex-basis: 56px; border-radius: 14px; }
.brand-tile.lg img { width: 106px; height: 106px; }
.wordmark { font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-grupo + .nav-grupo { margin-top: var(--sp-2); }
.nav-grupo-btn, .nav-grupo-titulo { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 8px 12px; min-height: 36px; font-size: 13px; font-weight: 700; letter-spacing: .02em; color: var(--mute); text-align: left; border-radius: var(--radius); }
.nav-grupo-btn:hover { background: var(--surface-2); color: var(--text); }
.sidebar .nav-grupo-btn { color: var(--brand-nav-mute); }
.sidebar .nav-grupo-btn:hover { background: var(--brand-nav-line); color: var(--brand-nav-text); }
.nav-grupo-btn .chev { transition: transform var(--t-rapido) var(--ease-out); }
.nav-grupo-btn[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.nav-grupo-titulo { margin-top: var(--sp-3); min-height: 28px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-height: 44px; width: 100%; border-radius: var(--radius); color: var(--text); font-weight: 500; text-align: left; transition: background-color var(--t-rapido), color var(--t-rapido); }
.nav-item svg { flex: 0 0 20px; color: var(--mute); }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--selection-bg); color: var(--text); font-weight: 600; }
.nav-item.active svg { color: var(--accent); }
.sidebar .nav-item { color: var(--brand-nav-text); }
.sidebar .nav-item svg { color: var(--brand-nav-mute); }
.sidebar .nav-item:hover { background: var(--brand-nav-line); }
.sidebar .nav-item.active { background: var(--brand-nav-active-bg); color: var(--brand-nav-active-text); font-weight: 700; box-shadow: 0 3px 10px rgba(14, 17, 16, .12); }
.sidebar .nav-item.active svg { color: var(--brand-nav-active-text); }
.sidebar :focus-visible { outline-color: var(--brand-nav-focus); box-shadow: none; }
.nav-cuenta { margin-left: auto; min-width: 24px; padding: 0 7px; border-radius: 12px; background: var(--surface-3); color: var(--text); font-size: 13px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.sidebar .nav-cuenta { background: var(--brand-nav-active-bg); color: var(--brand-nav-active-text); }
.sidebar .nav-item.active .nav-cuenta { background: var(--brand-nav); color: var(--brand-nav-text); }
.sidebar-foot { margin-top: auto; padding-top: var(--sp-3); border-top: 1px solid var(--brand-nav-line); }
.sidebar .user-chip .small, .sidebar .user-chip .muted { color: var(--brand-nav-mute); }
.sidebar .icon-btn { color: var(--brand-nav-text); }
.sidebar .icon-btn:hover { background: var(--brand-nav-line); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 4px; }
.user-txt { min-width: 0; flex: 1; }
.user-nombre { font-weight: 600; font-size: 15px; }
.avatar-sm { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text); font-weight: 700; font-size: 14px; flex: 0 0 auto; }
.sidebar .avatar-sm { background: var(--brand-nav-active-bg); color: var(--brand-nav-active-text); }

/* Barra superior: opaca, sin desenfoque */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--sp-2); padding: 8px var(--sp-4); padding-top: calc(8px + env(safe-area-inset-top)); background: var(--surface); border-bottom: 1px solid var(--border); min-height: 60px; }
.topbar .page-title { font-weight: 700; font-size: 20px; letter-spacing: -.01em; margin-right: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .brand-tile { border: 1px solid var(--border); }
#app:not([data-scr="hoy"]) .topbar .brand-tile { display: none; }
.topbar .page-title:focus { outline: none; box-shadow: none; }
.topbar-registrar { min-height: 44px; }
.icon-btn { width: 44px; height: 44px; min-width: 44px; border-radius: var(--radius); display: grid; place-items: center; color: var(--text); transition: background-color var(--t-rapido); flex: 0 0 auto; }
.icon-btn:hover { background: var(--surface-2); }
.theme-btn { position: relative; }
.theme-btn .ti { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transition: opacity 120ms ease; }
:root[data-theme-pref="light"] .theme-btn .ti-light,
:root[data-theme-pref="dark"] .theme-btn .ti-dark,
:root[data-theme-pref="auto"] .theme-btn .ti-auto { opacity: 1; }

/* Estado de los datos: texto y símbolo siempre (UX-04) */
.sync-badge { display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; min-height: 40px; border-radius: 20px; background: var(--surface-2); border: 1px solid var(--border); font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; max-width: 46vw; }
.sync-badge:hover { border-color: var(--control-border); }
.sync-ico { display: inline-grid; place-items: center; flex: 0 0 auto; }
.sync-txt-corto { display: none; }
.sync-badge.ok .sync-ico { color: var(--success-ico); }
.sync-badge.pending, .sync-badge.offline, .sync-badge.bloqueada { background: var(--warning-bg); color: var(--warning-text); border-color: transparent; }
.sync-badge.rechazado, .sync-badge.lleno, .sync-badge.error { background: var(--critical-bg); color: var(--critical-text); border-color: transparent; }
.sync-badge.syncing .sync-ico { color: var(--selection-text); }
.sync-badge .sync-txt { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) {
  .sync-txt { display: none; }
  .sync-txt-corto { display: inline; }
  .sync-badge { padding: 0 10px; }
}

.content { padding: var(--sp-4); padding-bottom: calc(var(--nav-h) + 32px + env(safe-area-inset-bottom)); }
.content:focus { outline: none; box-shadow: none; }
@media (min-width: 820px) {
  .app-shell { padding-left: var(--sidebar-w); }
  .content { padding: var(--sp-5) var(--sp-6) var(--sp-6); max-width: 1240px; }
  .mobile-only { display: none !important; }
  .topbar { padding-left: var(--sp-6); padding-right: var(--sp-5); }
  .topbar .page-title { font-size: 24px; }
}
@media (max-width: 819px) {
  .sidebar { display: none; }
  .desktop-only { display: none !important; }
}
.screen { display: none; }
.screen.active { display: block; }

/* Aviso de la demo: franja en el flujo, no tapa controles */
.demo-aviso { display: flex; align-items: center; justify-content: space-between; gap: 4px var(--sp-3); flex-wrap: wrap; padding: 4px var(--sp-4); background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 13px; line-height: 1.35; }
.demo-aviso a { font-weight: 600; min-height: 32px; display: inline-flex; align-items: center; }
@media (max-width: 560px) { .demo-aviso span { flex: 1 1 60%; } }

/* Aviso sin señal */
.offline-bar { display: none; align-items: center; gap: 8px; padding: 8px var(--sp-4); background: var(--warning-bg); color: var(--warning-text); font-weight: 600; font-size: 14px; border-bottom: 1px solid var(--border); }

/* Navegación inferior (móvil): opaca, cinco destinos estables */
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; align-items: stretch; background: var(--surface); border-top: 1px solid var(--border); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
.bn-item { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; padding: 4px 2px; border-radius: var(--radius); color: var(--mute); font-size: 13px; font-weight: 600; }
.bn-item .label { white-space: nowrap; }
.bn-item > svg, .bn-ico-wrap { height: 32px; display: grid; place-items: center; }
.bn-item > svg { padding: 5px 0; box-sizing: content-box; height: 22px; }
.bn-item.active { color: var(--text); }
.bn-item.active > svg, .bn-item.active .bn-ico-wrap { background: var(--accent-soft); border-radius: 16px; color: var(--text); }
.bn-item.active > svg { padding: 5px 16px; }
.bn-item.active .bn-ico-wrap { padding: 0 11px; }
.bn-item.active svg { stroke-width: 2.4; }
.bn-ico-wrap { position: relative; display: inline-grid; }
.bn-cuenta { position: absolute; top: -6px; left: 14px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--critical-text); color: var(--surface); font-size: 12px; font-weight: 700; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.bn-registrar { color: var(--text); }
.bn-registrar-ico { display: grid; place-items: center; width: 44px; height: 32px; border-radius: 16px; background: var(--action-bg); color: var(--on-action); }
.bn-registrar:hover .bn-registrar-ico { background: var(--action-hover); }
body.solo-lectura .fab, body.solo-lectura #fabBtnD { display: none !important; }
@media (min-width: 820px) { .bottom-nav { display: none; } }
@media (max-height: 460px) and (orientation: landscape) {
  .bn-item { min-height: 44px; }
  .bottom-nav .label { display: none; }
}

/* Menú «Más» (móvil) */
.drawer-back { position: fixed; inset: 0; background: var(--overlay); opacity: 0; pointer-events: none; transition: opacity 160ms var(--ease-out); z-index: 70; }
.drawer-back.open { opacity: 1; pointer-events: auto; }
.drawer { position: absolute; top: 0; right: 0; height: 100%; width: 86%; max-width: 340px; background: var(--surface); border-left: 1px solid var(--border); transform: translateX(100%); transition: transform 180ms var(--ease-out); display: flex; flex-direction: column; padding: var(--sp-4); padding-top: calc(var(--sp-4) + env(safe-area-inset-top)); overflow-y: auto; }
.drawer-back.open .drawer { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-2); }
.drawer-head .wordmark { font-size: 18px; font-weight: 700; letter-spacing: 0; }
.drawer .nav { flex: 0 0 auto; overflow: visible; }
.drawer-usuario { margin-top: var(--sp-5); padding-top: var(--sp-4); border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: var(--sp-2); align-items: flex-start; }
@media (min-width: 820px) { .drawer-back { display: none; } }

/* ============================================================
   COMPONENTES
   ============================================================ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-4); overflow-wrap: anywhere; }
.card > h3:first-child, .h-card { font-size: 18px; font-weight: 700; margin: 0 0 var(--sp-3); }
.card-pad-lg { padding: var(--sp-5); }
.h-sec { font-size: 20px; font-weight: 700; margin-bottom: var(--sp-2); }
.h-sub { font-size: 16px; font-weight: 700; margin: var(--sp-4) 0 var(--sp-2); }
.grid { display: grid; gap: var(--sp-3); }
.grid > *, .row > * { min-width: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.tight { gap: 0 var(--sp-3); }
@media (max-width: 819px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } .g2.keep { grid-template-columns: repeat(2, 1fr); } }
.row { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.wrap { flex-wrap: wrap; }
.fill { flex: 1; min-width: 0; }
.gap2 { gap: var(--sp-2); }
.mt2 { margin-top: var(--sp-2); } .mt3 { margin-top: var(--sp-3); } .mt4 { margin-top: var(--sp-4); } .mt5 { margin-top: var(--sp-5); }
.mb2 { margin-bottom: var(--sp-2); } .mb3 { margin-bottom: var(--sp-3); }
.section-head { display: flex; align-items: center; gap: var(--sp-2); margin: var(--sp-5) 0 var(--sp-3); flex-wrap: wrap; }
.section-head:first-child { margin-top: 0; }
.section-head h2 { font-size: 18px; font-weight: 700; margin: 0; }
.section-head .spacer, .spacer { margin-left: auto; }
.legend { display: flex; gap: 8px 16px; flex-wrap: wrap; font-size: 14px; color: var(--mute); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.tooltip-inline { border-bottom: 1px dotted var(--mute); cursor: help; }
.vacio { text-align: left; }
.vacio p { color: var(--mute); }

/* ---- Botones ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: var(--radius); font-size: 15px; font-weight: 600; background: var(--surface); color: var(--text); border: 1px solid var(--control-border); text-decoration: none; transition: background-color var(--t-rapido), border-color var(--t-rapido), color var(--t-rapido); white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; opacity: 1; }
.btn-primary { background: var(--action-bg); color: var(--on-action); border-color: var(--action-bg); }
.btn-primary:hover { background: var(--action-hover); border-color: var(--action-hover); color: var(--on-action); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--link); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--critical-text); border-color: var(--critical-text); color: var(--surface); }
.btn-danger:hover { filter: brightness(.92); background: var(--critical-text); }
.btn-danger-ghost { background: transparent; color: var(--critical-text); border-color: var(--critical-text); }
.btn-danger-ghost:hover { background: var(--critical-bg); }
.btn-block { width: 100%; }
.btn-sm, .btn-mini { min-height: 40px; padding: 0 12px; font-size: 14px; }
.link-btn { color: var(--link); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; min-height: 32px; padding: 0 2px; }
.link-btn:hover { text-decoration-thickness: 2px; }
/* Objetivo táctil de 44 px sin agrandar el dibujo */
.btn-mini, .btn-sm { position: relative; }
.btn-mini::after, .btn-sm::after { content: ""; position: absolute; inset: -2px; }

/* ---- Campos ---- */
.field { margin-bottom: var(--sp-4); }
.field > label, .field .label, .filtro-grupo > label, .filtro-grupo legend, .picker > label { display: block; font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.req { color: var(--critical-text); }
.field-help { font-size: 14px; color: var(--mute); margin: 6px 0 0; }
.field-error { display: flex; align-items: flex-start; gap: 6px; font-size: 14px; font-weight: 600; color: var(--critical-text); margin: 6px 0 0; }
.field-error svg { flex: 0 0 auto; margin-top: 2px; }
.input { width: 100%; min-height: 48px; padding: 10px 12px; font-size: 16px; background: var(--surface); color: var(--text); border: 1px solid var(--control-border); border-radius: var(--radius); transition: border-color var(--t-rapido), box-shadow var(--t-rapido); }
.input::placeholder { color: var(--mute); opacity: 1; }
.input:hover { border-color: var(--text); }
.input:focus { border-color: var(--focus); box-shadow: 0 0 0 3px var(--selection-bg); outline: none; }
.input:focus-visible { outline: none; }
.input:disabled { background: var(--surface-2); color: var(--mute); border-color: var(--border); cursor: not-allowed; }
.input[aria-invalid="true"] { border-color: var(--critical-text); border-width: 2px; padding: 9px 11px; }
select.input { -webkit-appearance: none; appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--mute) 50%), linear-gradient(135deg, var(--mute) 50%, transparent 50%); background-position: calc(100% - 18px) 21px, calc(100% - 13px) 21px; background-size: 5px 5px; background-repeat: no-repeat; }
select.input option, select.input optgroup { background: var(--surface); color: var(--text); }
textarea.input { min-height: 96px; }
input[type="date"].input { min-width: 0; }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; accent-color: var(--action-bg); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; cursor: pointer; }
.input.flash { border-color: var(--success-text); box-shadow: 0 0 0 3px var(--success-bg); }

/* Segmentados: estado por superficie, texto y aria-pressed */
.seg { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 3px; gap: 3px; max-width: 100%; }
.seg button { min-height: 42px; padding: 0 14px; border-radius: 6px; font-size: 15px; font-weight: 600; color: var(--mute); }
.seg button:hover { color: var(--text); background: var(--surface-3); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1.5px var(--control-border); }
.seg button:disabled { cursor: not-allowed; opacity: .6; }
.field .seg { display: flex; }
.field .seg button { flex: 1 1 auto; }
.has-error .seg, .seg[aria-invalid="true"] { border-color: var(--critical-text); border-width: 2px; }

/* Chips de filtro o período */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface); font-size: 14px; font-weight: 600; color: var(--text); }
.chip:hover { border-color: var(--control-border); }
.chip.on { background: var(--selection-bg); color: var(--text); border-color: var(--accent); }

/* Insignias de estado: con texto, nunca solo color */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; min-height: 24px; border-radius: 12px; font-size: 13px; font-weight: 600; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); white-space: nowrap; }
.badge.green { background: var(--success-bg); color: var(--success-text); border-color: transparent; }
.badge.green::before, .badge.amber::before, .badge.red::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.badge.green::before { background: var(--success-ico); }
.badge.amber::before { background: var(--warning-ico); transform: rotate(45deg); border-radius: 1px; }
.badge.red::before { background: var(--critical-text); border-radius: 1px; }
.badge.amber { background: var(--warning-bg); color: var(--warning-text); border-color: transparent; }
.badge.red { background: var(--critical-bg); color: var(--critical-text); border-color: transparent; }
.badge.blue { background: var(--surface-2); color: var(--text); }
.badge-alerta { font-size: 13px; }
.dot-sem { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.sem-verde { background: var(--success-ico); } .sem-amarillo { background: var(--warning-ico); } .sem-rojo { background: var(--critical-text); }
.up { color: var(--success-ico); } .down { color: var(--critical-text); }
.sex-m, .sex-f { color: var(--mute); font-weight: 600; }

/* Avisos dentro de formularios y pantallas */
.callout { padding: var(--sp-3) var(--sp-4); border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); margin-bottom: var(--sp-3); }
.callout p:last-child { margin-bottom: 0; }
.callout .row { margin-top: var(--sp-2); }
.callout.warn { background: var(--warning-bg); color: var(--warning-text); border-color: transparent; }
.callout.warn p, .callout.warn b { color: var(--warning-text); }
.callout.info { background: var(--surface-2); }
.callout.warn .btn:not(.btn-primary) { background: var(--surface); color: var(--text); }
.form-alert { padding: var(--sp-3) var(--sp-4); border-radius: var(--radius); background: var(--critical-bg); color: var(--critical-text); margin-bottom: var(--sp-3); font-size: 15px; }
.form-alert:focus { outline: 2px solid var(--critical-text); }
.form-status { min-height: 1.4em; color: var(--mute); margin: var(--sp-2) 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3); }
.form-actions .btn-primary { flex: 1 1 200px; }

/* Alertas heredadas (verificación de datos, importación) */
.alert { display: flex; gap: var(--sp-3); padding: var(--sp-3); border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); margin-bottom: 8px; align-items: flex-start; }
.alert .ico { flex: 0 0 auto; margin-top: 6px; }
.alert .a-title { font-weight: 600; }
.alert .a-sub { font-size: 14px; color: var(--mute); }
.alert.crit { background: var(--critical-bg); border-color: transparent; }
.alert.warn { background: var(--warning-bg); border-color: transparent; }
.alert.ok { background: var(--success-bg); border-color: transparent; }
.alert.crit .a-sub, .alert.warn .a-sub, .alert.ok .a-sub { color: var(--text); }
.alert .a-act { margin-left: auto; align-self: center; font-size: 14px; font-weight: 600; color: var(--selection-text); white-space: nowrap; }

/* Tareas heredadas (genealogía, ficha) */
.task { display: flex; align-items: center; gap: var(--sp-3); padding: 12px 0; border-bottom: 1px solid var(--border); }
.task:last-child { border-bottom: none; }
.task .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--mute); }
.task .body { flex: 1; min-width: 0; }
.task .t-title, .task .t { font-weight: 600; }
.task .t-sub, .task .s { font-size: 14px; color: var(--mute); }

/* ---- Pendientes (UX-06) ---- */
.lista-pend { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.pend { display: grid; grid-template-columns: auto 1fr; gap: 4px var(--sp-3); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); align-items: start; }
.pend:last-child { border-bottom: none; }
.pend-sev { grid-row: 1; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 10px; margin-top: 2px; white-space: nowrap; background: var(--surface-2); color: var(--text); }
.pend-sev.sev-crit { background: var(--critical-bg); color: var(--critical-text); }
.pend-sev.sev-warn { background: var(--warning-bg); color: var(--warning-text); }
.pend-sev.sev-ok { background: var(--success-bg); color: var(--success-text); }
.pend-sev.sev-info { background: var(--surface-2); color: var(--text); }
.pend-body { min-width: 0; }
.pend-titulo { font-weight: 600; }
.pend-sub { font-size: 14px; color: var(--mute); }
.pend-nota { font-size: 14px; color: var(--text); margin-top: 4px; }
.pend-acciones { grid-column: 2; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-top: var(--sp-2); }
.btn-accion { background: var(--accent-soft); color: var(--text); border-color: transparent; font-weight: 600; }
.btn-accion svg { color: var(--accent); flex: 0 0 auto; }
:root[data-theme="dark"] .btn-accion svg { color: var(--accent-strong); }
.btn-accion:hover { background: var(--surface); border-color: var(--accent); }
.pend-acciones .link-btn { min-height: 40px; display: inline-flex; align-items: center; padding: 0 6px; }
.pend-acciones .btn-ghost { color: var(--mute); font-weight: 600; }
.pend.is-revisado .pend-titulo { color: var(--mute); }
.pend-revisar { grid-column: 1 / -1; padding: var(--sp-3); margin-top: var(--sp-2); border-radius: var(--radius); background: var(--surface-2); }
.pend-revisar label { display: block; font-weight: 600; margin-bottom: 6px; }
.pend-revisar .input { margin-bottom: var(--sp-2); }
.grupo-pend { margin-bottom: var(--sp-4); }
.grupo-pend > summary { display: flex; align-items: center; gap: var(--sp-2); min-height: 44px; cursor: pointer; font-size: 18px; font-weight: 700; list-style: none; }
.grupo-pend > summary::-webkit-details-marker { display: none; }
.grupo-pend > summary::before { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--mute); border-bottom: 2px solid var(--mute); transform: rotate(-45deg); transition: transform var(--t-rapido) var(--ease-out); margin-right: 4px; }
.grupo-pend[open] > summary::before { transform: rotate(45deg); }
@media (min-width: 720px) {
  .pend { grid-template-columns: auto 1fr auto; }
  .pend-acciones { grid-column: 3; grid-row: 1; margin-top: 0; justify-content: flex-end; }
}

/* ---- Hoy ---- */
.hoy-cab { position: relative; isolation: isolate; overflow: hidden; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-5); min-height: 156px; padding: var(--sp-5) 180px var(--sp-5) var(--sp-6); margin-bottom: var(--sp-5); border-radius: 20px; background: linear-gradient(110deg, transparent 45%, rgba(255, 255, 255, .20)), var(--brand-hero); color: var(--brand-hero-text); box-shadow: var(--shadow-soft); }
/* Relieve estático de marca, reservado al extremo libre del encabezado. */
.hoy-cab::before, .hoy-cab::after { content: ""; position: absolute; z-index: -1; right: -72px; top: 50%; width: 310px; height: 310px; border: 1px solid rgba(25, 28, 28, .12); border-radius: 50%; transform: translateY(-50%); pointer-events: none; }
.hoy-cab::after { width: 230px; height: 230px; right: -32px; background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .22); }
.hoy-cab-txt { position: relative; z-index: 1; min-width: 0; flex: 1 1 260px; }
.hoy-cab-fecha { font-size: 14px; font-weight: 600; color: var(--brand-hero-mute); margin: 0; }
.hoy-cab-fecha::first-letter { text-transform: uppercase; }
.hoy-cab-finca { font-size: clamp(26px, 2.5vw, 36px); font-weight: 800; letter-spacing: -.035em; line-height: 1.12; margin: 6px 0 10px; overflow-wrap: anywhere; }
.hoy-cab-ctx { font-size: 15px; color: var(--brand-hero-mute); margin: 0; font-weight: 500; }
.hoy-cab-ctx b { color: var(--brand-hero-text); font-weight: 700; }
.hoy-cab-marca { position: absolute; right: -10px; top: 50%; width: 220px; height: 220px; transform: translateY(-50%); opacity: .85; pointer-events: none; }
@media (max-width: 560px) {
  .hoy-cab { min-height: 152px; padding: 20px 76px 20px 20px; border-radius: 16px; }
  .hoy-cab-finca { font-size: 26px; }
  .hoy-cab-ctx { font-size: 14px; }
  .hoy-cab-marca { width: 128px; height: 128px; right: -34px; }
  .hoy-cab::before { width: 210px; height: 210px; right: -130px; }
  .hoy-cab::after { width: 154px; height: 154px; right: -102px; }
}
.hoy-sec + .hoy-sec { margin-top: var(--sp-5); }
/* Icono con superficie tintada por categoría (producción, reproducción, crecimiento, sanidad). */
.cat-ico { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; flex: 0 0 auto; background: var(--surface-2); color: var(--mute); }
.cat-ico[data-cat="produccion"] { background: var(--cat-produccion-soft); color: var(--cat-produccion); }
.cat-ico[data-cat="reproduccion"] { background: var(--cat-reproduccion-soft); color: var(--cat-reproduccion); }
.cat-ico[data-cat="crecimiento"] { background: var(--cat-crecimiento-soft); color: var(--cat-crecimiento); }
.cat-ico[data-cat="sanidad"], .cat-ico[data-cat="composicion"] { background: var(--cat-sanidad-soft); color: var(--cat-sanidad); }
.cat-ico svg { width: 20px; height: 20px; }
.acciones-rapidas { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
@media (min-width: 620px) { .acciones-rapidas { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); } }
.accion-rapida { display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 10px var(--sp-3); border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-card); font-weight: 700; font-size: 15px; text-align: left; color: var(--text); }
.accion-rapida:has([data-cat="crecimiento"]) { background: linear-gradient(115deg, var(--cat-crecimiento-soft), transparent 85%), var(--surface); }
.accion-rapida:has([data-cat="reproduccion"]) { background: linear-gradient(115deg, var(--cat-reproduccion-soft), transparent 85%), var(--surface); }
.accion-rapida:hover { border-color: var(--control-border); }
.accion-rapida:first-child { background: var(--action-bg); color: var(--on-action); border-color: var(--action-bg); box-shadow: var(--shadow-soft); }
.accion-rapida:first-child .cat-ico { background: rgba(255, 255, 255, .55); color: var(--on-action); }
.accion-rapida:first-child:hover { background: var(--action-hover); border-color: var(--action-hover); }
.accion-rapida.mas { border-style: dashed; border-color: var(--control-border); box-shadow: none; }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .accion-rapida, .tbl-card { transition: transform 160ms var(--ease-out), box-shadow 160ms var(--ease-out), border-color 160ms var(--ease-out); }
  .accion-rapida:hover, .tbl-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft); }
  .accion-rapida:active, .tbl-card:active { transform: translateY(0); }
}
.resumen { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: var(--sp-3); }
@media (max-width: 720px) { .resumen { grid-template-columns: 1fr 1fr; } .resumen-leche { grid-column: 1 / -1; } }
.resumen-item { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: var(--sp-4); box-shadow: var(--shadow-card); }
.resumen-lbl { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--mute); font-weight: 600; }
.resumen-lbl .cat-ico { width: 28px; height: 28px; border-radius: 8px; }
.resumen-lbl .cat-ico svg { width: 16px; height: 16px; }
.resumen-val { font-size: 32px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; margin-top: 6px; }
.resumen-val small { font-size: 16px; font-weight: 600; color: var(--mute); }
.resumen-vacio, .value.resumen-vacio { font-size: 20px; font-weight: 700; color: var(--mute); line-height: 1.6; }
.resumen-sub { font-size: 14px; color: var(--mute); margin-top: 4px; }
/* Leche del tanque: el punto de atención del resumen, en la superficie de marca. */
.resumen-leche { background: radial-gradient(ellipse at 100% 0, rgba(35, 181, 164, .30), transparent 65%), var(--brand-panel); border-color: var(--earth); color: var(--brand-panel-text); box-shadow: var(--shadow-soft); padding: var(--sp-4) var(--sp-5); }
.resumen-leche .resumen-lbl, .resumen-leche .resumen-sub, .resumen-leche .resumen-val small, .resumen-leche .resumen-vacio { color: var(--brand-panel-mute); }
.resumen-leche .resumen-val { font-size: 40px; color: var(--brand-panel-text); }
.resumen-leche .cat-ico { background: var(--accent); color: #191C1C; }
.resumen-leche .btn-primary { background: #FFFFFF; border-color: #FFFFFF; color: #191C1C; }
.resumen-leche .btn-primary:hover { background: #F3F4F3; border-color: #F3F4F3; }
.resumen-leche :focus-visible { outline-color: #FFFFFF; box-shadow: none; }
.estado-linea { display: flex; align-items: center; gap: var(--sp-2); width: 100%; min-height: 48px; padding: var(--sp-2) var(--sp-4); border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); text-align: left; font-size: 15px; color: var(--text); }
.estado-linea .estado-ver { margin-left: auto; color: var(--selection-text); font-weight: 600; font-size: 14px; white-space: nowrap; }
.estado-linea.pending, .estado-linea.offline, .estado-linea.bloqueada { background: var(--warning-bg); color: var(--warning-text); border-color: transparent; }
.estado-linea.rechazado, .estado-linea.lleno, .estado-linea.error { background: var(--critical-bg); color: var(--critical-text); border-color: transparent; }
.estado-linea.ok .ico-estado { color: var(--success-ico); }
.estado-linea.pending .ico-estado, .estado-linea.offline .ico-estado { color: var(--warning-ico); }
.lista-simple { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.lista-simple li { display: flex; gap: var(--sp-3); align-items: baseline; padding: 10px var(--sp-4); border-bottom: 1px solid var(--border); font-size: 15px; }
.lista-simple li:last-child { border-bottom: none; }
.lista-simple .hora { color: var(--mute); font-size: 14px; flex: 0 0 auto; }
.lista-estado { list-style: none; margin: 0 0 var(--sp-3); padding: 0; }
.lista-estado li { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }

/* ---- Indicadores (heredado en Leche, Reproducción, Sanidad) ---- */
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-3) var(--sp-4); }
.kpi .label { font-size: 14px; color: var(--mute); font-weight: 500; }
.kpi .value { font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 15px; font-weight: 600; color: var(--mute); }
.kpi .delta { font-size: 14px; margin-top: 2px; color: var(--mute); }
.kpi .delta.up { color: var(--success-ico); } .kpi .delta.down { color: var(--critical-text); }

/* ---- Buscador y filtros (UX-10) ---- */
.anim-barra { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; margin-bottom: var(--sp-3); }
.anim-barra .search-wrap { flex: 1 1 100%; }
@media (min-width: 820px) { .anim-barra .search-wrap { flex: 1 1 320px; } }
.anim-acciones { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--mute); pointer-events: none; }
.search-input { width: 100%; min-height: 52px; padding: 12px 14px 12px 44px; font-size: 16px; background: var(--surface); color: var(--text); border: 1px solid var(--control-border); border-radius: var(--radius); }
.search-input::placeholder { color: var(--mute); }
.search-input:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px var(--selection-bg); }
.filtros-toggle { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 48px; padding: 0 14px; margin-bottom: var(--sp-2); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: 15px; font-weight: 600; text-align: left; }
.filtros-toggle:hover { border-color: var(--control-border); }
.filtros-toggle .chev { margin-left: auto; flex: 0 0 auto; transition: transform var(--t-rapido) var(--ease-out); }
.filtros-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.filtros-toggle .cuenta { min-width: 24px; height: 24px; padding: 0 7px; border-radius: 12px; background: var(--selection-bg); color: var(--selection-text); font-size: 13px; font-weight: 700; display: grid; place-items: center; }
.filtros-resumen { font-weight: 500; color: var(--mute); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.filtros-panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp-3); padding: var(--sp-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: var(--sp-3); }
.filtro-grupo { display: flex; flex-direction: column; min-width: 0; border: 0; padding: 0; margin: 0; }
.filtro-grupo .row { flex-wrap: nowrap; }
.filtro-grupo .input { min-height: 44px; }
.anim-cuenta { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin: var(--sp-2) 0; }
.filtros-count { margin: 0; color: var(--text); font-size: 15px; }
.anim-term { margin-top: var(--sp-4); }
.cols-pop { position: relative; }
.cols-pop > summary { list-style: none; }
.cols-pop > summary::-webkit-details-marker { display: none; }
.cols-pop-panel { position: absolute; right: 0; top: calc(100% + 4px); z-index: 25; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-pop); padding: var(--sp-2) var(--sp-3); min-width: 220px; }

/* Lista compacta de animales en el teléfono */
.lista-animales { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.lista-animales li + li { border-top: 1px solid var(--border); }
.fila-animal { display: flex; align-items: center; gap: var(--sp-3); padding: 10px var(--sp-4); min-height: 64px; color: var(--text); text-decoration: none; }
.fila-animal:hover { background: var(--surface-2); }
.fa-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fa-l1 { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.fa-cod { font-weight: 700; font-size: 17px; }
.fa-nom { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fa-l2 { font-size: 14px; color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fa-peso { font-size: 14px; color: var(--mute); flex: 0 0 auto; }
.paginacion { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-top: var(--sp-3); }
.paginacion:empty { display: none; }
.pag-txt { font-size: 14px; color: var(--mute); padding: 0 var(--sp-2); }

/* ---- Tablas ---- */
.table-wrap, .tablewrap { overflow-x: auto; max-width: 100%; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); -webkit-overflow-scrolling: touch; }
.card .table-wrap { border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
.table-wrap > table { min-width: max-content; }
thead th { text-align: left; font-size: 13px; font-weight: 600; color: var(--mute); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 15px; }
tbody tr:last-child td { border-bottom: none; }
td.right, th.right { text-align: right; }
td.right.mono { font-variant-numeric: tabular-nums; }
tbody tr.clickable { cursor: pointer; }
@media (hover: hover) { tbody tr.clickable:hover { background: var(--surface-2); } }
.th-orden { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; font: inherit; color: inherit; text-transform: none; }
.th-orden:hover { color: var(--text); }
th[aria-sort] .th-orden { color: var(--text); }
.orden-ico { font-size: 10px; min-width: 10px; }
.link-ficha { color: var(--text); font-weight: 700; text-decoration: none; display: inline-flex; min-height: 32px; align-items: center; }
.link-ficha:hover .mono { text-decoration: underline; }
.av { border-radius: 8px; overflow: hidden; flex: 0 0 auto; display: inline-block; object-fit: cover; }
.av-row { display: flex; align-items: center; gap: 10px; }

/* ---- Ficha ---- */
.ficha-nav { margin-bottom: var(--sp-3); }
.ficha-nav .btn { padding-left: 4px; }
.ficha-head { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-3) var(--sp-4); align-items: start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-4); }
.ficha-foto img, .ficha-foto svg { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; display: block; }
.ficha-codigo { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.ficha-nombre { font-size: 18px; font-weight: 600; letter-spacing: 0; }
.ficha-linea { color: var(--mute); margin: 4px 0 6px; font-size: 15px; }
.ficha-badges:empty { display: none; }
.ficha-peso { display: flex; flex-direction: column; grid-column: 1 / -1; }
.ficha-peso-val { font-size: 24px; font-weight: 800; }
.ficha-peso-val small { font-size: 15px; color: var(--mute); font-weight: 600; }
.ficha-acciones { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
@media (min-width: 720px) {
  .ficha-head { grid-template-columns: auto 1fr auto; }
  .ficha-peso { grid-column: 3; grid-row: 1; text-align: right; }
  .ficha-acciones { grid-column: 2 / -1; }
}
.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--border); margin: var(--sp-4) 0; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 0 14px; min-height: 44px; font-weight: 600; font-size: 15px; color: var(--mute); border-bottom: 3px solid transparent; white-space: nowrap; border-radius: 6px 6px 0 0; }
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
#fichaBody:focus { outline: none; box-shadow: none; }
.def-list { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 6px 16px; margin: 0; }
.def-list dt { color: var(--mute); font-size: 15px; }
.def-list dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 0 0 14px 4px; }
.tl-item::before { content: ""; position: absolute; left: -18px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--selection-text); }
.tl-date { font-size: 13px; color: var(--mute); font-family: var(--font-mono); }
.tl-title { font-weight: 500; }
.meter { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--sp-3); }
.photo-cell { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.photo-cell img, .photo-cell .ph-svg { display: block; width: 100%; height: 130px; object-fit: cover; }
.photo-cell .cap { padding: 8px 10px; font-size: 14px; color: var(--mute); }
.alerta-meta { text-align: right; flex: 0 0 auto; }
.alerta-dias { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; }
.alerta-dias.rojo { color: var(--critical-text); } .alerta-dias.amarillo { color: var(--warning-text); } .alerta-dias.verde { color: var(--success-text); }

/* ============================================================
   DIÁLOGOS, MENÚS Y AVISOS
   ============================================================ */
.modal-back { position: fixed; inset: 0; background: var(--overlay); z-index: 100; display: none; align-items: flex-end; justify-content: center; }
.modal-back.open { display: flex; }
@media (min-width: 640px) { .modal-back { align-items: center; padding: var(--sp-4); } }
.modal { background: var(--surface); width: 100%; max-width: 560px; border-radius: 16px 16px 0 0; max-height: 92vh; max-height: 92dvh; overflow-y: auto; border: 1px solid var(--border); box-shadow: var(--shadow-pop); animation: aparecer 180ms var(--ease-out); overscroll-behavior: contain; }
@media (min-width: 640px) { .modal { border-radius: 16px; } }
@keyframes aparecer { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-head h3 { margin: 0; font-size: 19px; font-weight: 700; flex: 1; min-width: 0; }
.modal-head h3:focus { outline: none; box-shadow: none; }
.modal-body { padding: var(--sp-4); padding-bottom: calc(var(--sp-5) + env(safe-area-inset-bottom)); }
.rev-titulo { font-size: 18px; margin-bottom: var(--sp-3); }
.rev-titulo:focus { outline: none; box-shadow: none; }
.rev-lista { padding: var(--sp-3) var(--sp-4); background: var(--surface-2); border-radius: var(--radius); margin-bottom: var(--sp-3); }

/* Rejilla de Registrar */
.qc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
.qc-btn { position: relative; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 0 var(--sp-3); border-radius: var(--radius); border: 1px solid var(--control-border); background: var(--surface); font-weight: 600; font-size: 15px; text-align: left; color: var(--text); }
.qc-btn:hover { background: var(--surface-2); }
.qc-ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--mute); flex: 0 0 auto; }
.qc-ico[data-cat="produccion"] { background: var(--cat-produccion-soft); color: var(--cat-produccion); }
.qc-ico[data-cat="reproduccion"] { background: var(--cat-reproduccion-soft); color: var(--cat-reproduccion); }
.qc-ico[data-cat="crecimiento"] { background: var(--cat-crecimiento-soft); color: var(--cat-crecimiento); }
.qc-ico[data-cat="sanidad"] { background: var(--cat-sanidad-soft); color: var(--cat-sanidad); }
.qc-borr { position: absolute; top: 6px; right: 6px; font-size: 11px; min-height: 18px; padding: 0 6px; }

/* Selector de animal (UX-01) */
.picker { margin-bottom: var(--sp-4); position: relative; }
.picker-buscar { position: relative; }
.picker-buscar svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--mute); pointer-events: none; }
.picker-buscar .input { padding-left: 40px; }
.picker-buscar .input[aria-invalid="true"] { padding-left: 39px; }
.picker-lista { list-style: none; margin: 4px 0 0; padding: 4px; max-height: 300px; overflow-y: auto; background: var(--surface); border: 1px solid var(--control-border); border-radius: var(--radius); box-shadow: var(--shadow-pop); }
.picker-lista li { display: flex; align-items: baseline; gap: 10px; min-height: 44px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.picker-lista li[aria-selected="true"], .picker-lista li:hover { background: var(--selection-bg); }
.picker-lista li[aria-selected="true"] .picker-cod { color: var(--selection-text); }
.picker-cod { font-weight: 700; font-size: 16px; flex: 0 0 auto; }
.picker-desc { color: var(--mute); font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.picker-mas { color: var(--selection-text); font-weight: 600; justify-content: center; }
.picker-elegido { display: flex; align-items: center; gap: var(--sp-3); min-height: 52px; padding: 6px 6px 6px 14px; background: var(--selection-bg); border: 1px solid var(--selection-text); border-radius: var(--radius); }
.picker-elegido-txt { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.picker-elegido .picker-cod { color: var(--selection-text); font-size: 18px; }
.picker-elegido .picker-desc { color: var(--text); }
.picker-ayuda { margin: 6px 0 0; }

/* Menú de tema (13.7) */
.menu-pop { position: fixed; z-index: 150; min-width: 240px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); animation: menuIn 150ms var(--ease-out); }
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.menu-pop [role="menuitemradio"] { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px; border-radius: 8px; font-weight: 500; text-align: left; color: var(--text); }
.menu-pop [role="menuitemradio"]:hover, .menu-pop [role="menuitemradio"]:focus-visible { background: var(--surface-2); }
.menu-pop [role="menuitemradio"] span { flex: 1; }
.menu-pop .menu-check { visibility: hidden; color: var(--selection-text); }
.menu-pop [aria-checked="true"] { font-weight: 700; }
.menu-pop [aria-checked="true"] .menu-check { visibility: visible; }

/* Aviso breve: encima de la navegación inferior, nunca la tapa */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); transform: translate(-50%, 8px); display: flex; align-items: center; gap: var(--sp-3); width: max-content; max-width: min(560px, calc(100vw - 24px)); background: var(--text); color: var(--ground); padding: 12px 16px; border-radius: var(--radius-lg); font-weight: 500; font-size: 15px; box-shadow: var(--shadow-pop); z-index: 200; opacity: 0; pointer-events: none; transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out); }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast-accion { flex: 0 0 auto; min-height: 40px; padding: 0 12px; border-radius: 8px; font-weight: 700; color: var(--ground); text-decoration: underline; }
@media (min-width: 820px) { .toast { bottom: 24px; left: calc(50% + var(--sidebar-w) / 2); } }

/* Búsqueda global (Ctrl+K) */
.cmd-back { position: fixed; inset: 0; z-index: 300; display: grid; place-items: start center; padding-top: 12vh; background: var(--overlay); opacity: 0; pointer-events: none; transition: opacity 150ms var(--ease-out); }
.cmd-back.open { opacity: 1; pointer-events: auto; }
.cmd { width: min(560px, 92vw); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-pop); overflow: hidden; }
.cmd-top { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.cmd-top svg { color: var(--mute); flex: 0 0 auto; }
.cmd-top input { flex: 1; background: none; border: none; outline: none; font-size: 17px; color: var(--text); min-height: 40px; }
.cmd-top input:focus-visible { box-shadow: none; outline: none; }
.cmd-list { list-style: none; margin: 0; padding: 6px; max-height: 52vh; overflow-y: auto; }
.cmd-list li { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 12px; border-radius: 8px; cursor: pointer; }
.cmd-list li .ct { color: var(--text); font-weight: 600; font-size: 15px; }
.cmd-list li .cs { color: var(--mute); font-size: 13px; margin-left: auto; }
.cmd-list li.sel, .cmd-list li:hover { background: var(--selection-bg); }
.cmd-list li.sel .ct { color: var(--selection-text); }
.cmd-list .cmd-vacio { color: var(--mute); cursor: default; }
.cmd-hint { padding: 8px 14px; border-top: 1px solid var(--border); font-size: 13px; color: var(--mute); display: flex; gap: 14px; }
.cmd-hint .kb { font-family: var(--font-mono); background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; }

/* ---- Exportar (UX-15) ---- */
.export-menu { position: relative; display: inline-block; }
.export-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: min(320px, 86vw); padding: var(--sp-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); white-space: normal; }
.export-titulo { font-weight: 700; margin-bottom: 4px; }
.export-alcance { font-size: 14px; color: var(--mute); margin-bottom: var(--sp-2); }
.export-opcion { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 6px 10px; border-radius: 8px; text-align: left; color: var(--text); }
.export-opcion:hover:not(:disabled) { background: var(--surface-2); }
.export-opcion:disabled { opacity: .55; cursor: not-allowed; }
.export-opcion span { display: flex; flex-direction: column; }
.export-opcion small { color: var(--mute); font-size: 13px; }
.export-estado:empty { display: none; }
.export-bar { display: flex; gap: 6px; flex-wrap: wrap; }
.export-btn { min-height: 40px; font-size: 14px; }

/* ============================================================
   TABLERO (UX-13)
   ============================================================ */
.tbl-cab { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.tbl-cab-acc { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.tbl-periodo { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.tbl-periodo .label { font-weight: 600; font-size: 15px; margin-right: 4px; }
.tbl-fechas { display: inline-flex; align-items: center; gap: 8px; }
.tbl-fechas .input { min-height: 44px; width: auto; }
.tbl-sec + .tbl-sec { margin-top: var(--sp-5); }
.tbl-sec-t { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; margin-bottom: var(--sp-3); }
.tbl-sec-t::before { content: ""; width: 12px; height: 12px; border-radius: 3px; background: var(--gcol, var(--accent)); }
.tbl-sec { --gcol: var(--accent); --gsoft: var(--accent-soft); }
.tbl-sec[data-grupo="Producción"] { --gcol: var(--cat-produccion); --gsoft: var(--cat-produccion-soft); }
.tbl-sec[data-grupo="Reproducción"] { --gcol: var(--cat-reproduccion); --gsoft: var(--cat-reproduccion-soft); }
.tbl-sec[data-grupo="Crecimiento"] { --gcol: var(--cat-crecimiento); --gsoft: var(--cat-crecimiento-soft); }
.tbl-sec[data-grupo="Composición"] { --gcol: var(--cat-composicion); --gsoft: var(--cat-composicion-soft); }
.tbl-sec[data-grupo="Sanidad"] { --gcol: var(--cat-sanidad); --gsoft: var(--cat-sanidad-soft); }
.tbl-sec[data-grupo="Económico"] { --gcol: var(--cat-economia); --gsoft: var(--cat-economia-soft); }
.tbl-sec .tbl-label { display: flex; align-items: flex-start; gap: 8px; }
.tbl-sec .tbl-label::before { content: ""; width: 8px; height: 8px; border-radius: 2px; margin-top: 11px; flex: 0 0 auto; background: var(--gcol); }
.tbl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-3); }
@media (max-width: 560px) { .tbl-grid { grid-template-columns: 1fr; } }
.tbl-card { position: relative; display: flex; flex-direction: column; min-height: 176px; background: radial-gradient(ellipse at 100% 0, var(--gsoft, var(--accent-soft)), transparent 70%), var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: var(--sp-4); box-shadow: var(--shadow-card); cursor: pointer; }
@media (hover: hover) { .tbl-card:hover { border-color: var(--control-border); } }
.tbl-card.tbl-dragging { opacity: .5; }
.tbl-card.tbl-over { border-color: var(--focus); box-shadow: 0 0 0 2px var(--selection-bg); }
.tbl-top { display: flex; align-items: flex-start; gap: 8px; }
.tbl-label { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; }
.tbl-abrir { text-align: left; color: var(--text); font-weight: 600; min-height: 32px; }
.tbl-abrir:hover { text-decoration: underline; }
.tbl-actions { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.tbl-meta { font-size: 13px; font-weight: 600; color: var(--selection-text); border: 1px solid var(--border); border-radius: 14px; padding: 0 10px; min-height: 32px; display: inline-flex; align-items: center; background: transparent; }
.tbl-meta:hover { border-color: var(--control-border); }
.tbl-meta.is-fija { color: var(--mute); }
.tbl-grip { color: var(--mute); font-size: 16px; cursor: grab; user-select: none; line-height: 1; padding: 6px 2px; }
.tbl-main { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: var(--sp-2); }
.tbl-figure { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; min-width: 0; }
.tbl-value { font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; color: var(--text); }
.tbl-value small { font-size: 15px; font-weight: 600; color: var(--mute); margin-left: 3px; letter-spacing: 0; }
.tbl-value.tbl-nodata { font-size: 18px; font-weight: 600; color: var(--mute); line-height: 1.5; }
.tbl-donut { flex: 0 0 auto; }
.tbl-donut-t { font: 700 12px/1 var(--font-ui); fill: var(--text); font-variant-numeric: tabular-nums; }
.tbl-delta { font-size: 13px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; background: var(--surface-2); color: var(--text); }
.tbl-viz { margin-top: var(--sp-2); }
.tbl-area { display: block; }
.tbl-bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.tbl-bar > span { display: block; height: 100%; border-radius: 4px; }
.tbl-segbar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; gap: 2px; }
.tbl-seg { display: block; height: 100%; }
.tbl-legs { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; }
.tbl-leg { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--mute); }
.tbl-leg i { width: 10px; height: 10px; border-radius: 2px; }
.tbl-leg b { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.tbl-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: var(--sp-2); }
.tbl-sub { font-size: 14px; color: var(--mute); line-height: 1.35; min-width: 0; }
.tbl-fuente { font-size: 13px; color: var(--mute); margin-top: 6px; }
.tag-origen { font-weight: 600; color: var(--text); }
.tbl-status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; padding: 2px 10px; border-radius: 12px; white-space: nowrap; flex: 0 0 auto; }
.tbl-status i { width: 8px; height: 8px; border-radius: 50%; }
.tbl-status.s-verde { color: var(--success-text); background: var(--success-bg); } .tbl-status.s-verde i { background: var(--success-ico); }
.tbl-status.s-amarillo { color: var(--warning-text); background: var(--warning-bg); } .tbl-status.s-amarillo i { background: var(--warning-ico); border-radius: 1px; transform: rotate(45deg); }
.tbl-status.s-rojo { color: var(--critical-text); background: var(--critical-bg); } .tbl-status.s-rojo i { background: var(--critical-text); border-radius: 1px; }
.tbl-hero { display: grid; grid-template-columns: minmax(260px, 1.4fr) minmax(260px, 1fr); gap: var(--sp-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-4) var(--sp-5); box-shadow: var(--shadow-soft); }
.tbl-hero-comp { display: flex; flex-direction: column; justify-content: center; }
.tbl-hero-h { font-size: 15px; color: var(--mute); margin-bottom: 10px; }
.tbl-hero-h b { color: var(--text); }
.tbl-hero-g { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; border-left: 1px solid var(--border); padding-left: var(--sp-4); }
.tbl-hg { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tbl-hg-l { font-size: 14px; font-weight: 600; }
.tbl-hg-s { font-size: 13px; color: var(--mute); }
@media (max-width: 720px) { .tbl-hero { grid-template-columns: 1fr; } .tbl-hero-g { border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: var(--sp-4); } }
.tblcfg { display: flex; flex-direction: column; gap: var(--sp-3); }
.tblcfg-grp { border: 1px solid var(--border); border-radius: var(--radius); padding: 4px var(--sp-3) var(--sp-2); margin: 0; }
.tblcfg-grp legend { font-weight: 700; padding: 0 6px; }
.tblcfg-row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tblcfg-row:last-child { border-bottom: none; }
.tblcfg-row .check { flex: 1 1 200px; }
.tblcfg-mov { display: inline-flex; gap: 4px; }
.kpidet-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: var(--sp-3); }
.kpidet-big { font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.kpidet-big small { font-size: 16px; font-weight: 600; color: var(--mute); margin-left: 4px; }
.kpi-info { padding: var(--sp-3); background: var(--surface-2); border-radius: var(--radius); }
.rep-cols { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; padding-top: 12px; border-top: 1px solid var(--border); }
.rep-cols .chip:not(.on) { text-decoration: line-through; color: var(--mute); }

/* ============================================================
   AJUSTES
   ============================================================ */
.aj-sec + .aj-sec { margin-top: var(--sp-6); }

/* ============================================================
   ASISTENTE DE PUESTA EN MARCHA (wizard.js)
   ============================================================ */
.wz-wrap { max-width: 900px; }
.wz-topbar { display: flex; align-items: flex-start; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.wz-topbar .wz-title { font-size: 22px; font-weight: 700; }
.wz-topbar .btn-mini { margin-left: auto; flex: 0 0 auto; }
.wz-steps { list-style: none; margin: 0 0 10px; padding: 0; display: flex; gap: 4px; overflow-x: auto; }
.wz-step { flex: 1 1 auto; min-width: 88px; }
.wz-step-btn { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 6px 4px; color: var(--mute); font-weight: 600; font-size: 13px; min-height: 64px; }
.wz-dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--control-border); font-weight: 700; font-size: 14px; color: var(--text); }
.wz-step.on .wz-dot { background: var(--action-bg); color: var(--on-action); border-color: var(--action-bg); }
.wz-step.done .wz-dot { background: var(--selection-bg); color: var(--selection-text); border-color: var(--selection-text); }
.wz-step.on .wz-step-lbl, .wz-step.done .wz-step-lbl { color: var(--text); }
.wz-step-lbl { white-space: nowrap; }
.wz-progress { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin-bottom: var(--sp-4); }
.wz-progress > span { display: block; height: 100%; border-radius: 3px; background: var(--action-bg); transition: width 200ms var(--ease-out); }
.wz-body { margin-bottom: var(--sp-4); }
.wz-h { font-size: 18px; font-weight: 700; margin: 0 0 var(--sp-3); }
.wz-sec { padding: var(--sp-4) 0; border-top: 1px solid var(--border); }
.wz-sec:first-of-type { border-top: none; padding-top: 0; }
.wz-sec-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.wz-sec-head b { font-size: 16px; }
.wz-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.wz-foot .btn { min-width: 120px; }
.wz-mini-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.wz-mini-form .input { flex: 1 1 160px; min-height: 44px; }
.wz-mini-form .btn-mini { flex: 0 0 auto; }
.wz-check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text); font-weight: 500; white-space: nowrap; min-height: 44px; }
.wz-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.wz-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 4px 4px 12px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface-2); font-size: 14px; font-weight: 500; min-height: 36px; }
.wz-chip.add { padding: 4px 12px; color: var(--selection-text); background: var(--surface); cursor: pointer; font-weight: 600; }
.wz-chip-x { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: var(--mute); font-size: 13px; }
.wz-chip-x:hover { background: var(--critical-bg); color: var(--critical-text); }
.wz-presets { margin-bottom: 4px; }
.wz-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.wz-list-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-weight: 500; font-size: 15px; }
.wz-del { width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center; color: var(--mute); flex: 0 0 auto; }
.wz-del:hover { background: var(--critical-bg); color: var(--critical-text); }
.wz-bandas { margin-top: 10px; }
.wz-banda-row { display: grid; grid-template-columns: 1fr 90px auto 90px; align-items: center; gap: 8px; margin-bottom: 6px; }
.wz-banda-lbl { font-weight: 600; font-size: 14px; }
.wz-banda-row .input { min-height: 44px; padding: 6px 8px; text-align: right; }
.wz-tabs { display: inline-flex; gap: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 3px; margin-bottom: var(--sp-4); flex-wrap: wrap; }
.wz-tab { padding: 0 14px; border-radius: 6px; font-weight: 600; font-size: 14px; color: var(--mute); min-height: 40px; }
.wz-tab.on { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1.5px var(--control-border); }
.wz-drop { border: 2px dashed var(--control-border); border-radius: var(--radius); padding: var(--sp-5); text-align: center; background: var(--surface-2); }
.wz-drop input[type="file"] { max-width: 100%; }
@media (max-width: 520px) {
  .wz-step { min-width: 70px; }
  .wz-step-lbl { font-size: 12px; }
  .wz-banda-row { grid-template-columns: 1fr 70px auto 70px; }
}

/* ============================================================
   CRÉDITO GI GROUP
   ============================================================ */
.creado-por { margin-top: var(--sp-4); padding-top: var(--sp-4); border-top: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.creado-por > span, .creado-por-foot > span { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--mute); font-weight: 600; }
.creado-por a { display: inline-flex; max-width: 100%; border-radius: 12px; }
.creado-por-foot { margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--brand-nav-line); display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 10px; text-decoration: none; }
.sidebar .creado-por-foot > span { color: var(--brand-nav-mute); font-size: 11px; }
.sidebar .logo-pill { background: #FFFFFF; padding: 4px 10px; }
.sidebar .logo-pill img { height: 20px !important; }
/* El logo marino necesita fondo claro: en oscuro va sobre una pastilla clara, sin sombra. */
.logo-pill { display: inline-flex; align-items: center; justify-content: center; max-width: 100%; border-radius: 8px; }
:root[data-theme="dark"] .logo-pill { background: #EDEFEE; padding: 6px 12px; }
