/* ============================================================
   Caney — estilos (mobile-first, temas claro/oscuro)
   Identidad: Modern Agritech Minimalist (carbón · verde · teal · Hanken).
   ============================================================ */

/* ---- 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 ---- */
:root {
  --ground: #F9F9F8;
  --surface: #FFFFFF;
  --surface-2: #F3F4F3;
  --text: #191C1C;
  --mute: #44474A;
  --border: #E1E3E2;
  --accent: #1D9A8C;
  --accent-bright: #17B0A0;
  --accent-soft: #D4EEE9;

  --success: #4D6450;
  --warning: #B87259;
  --critical: #BA1A1A;
  --info: #1D9A8C;

  --success-soft: #CCE6CD;
  --warning-soft: #FFDBCF;
  --critical-soft: #FCE8E6;
  --info-soft: #D4EEE9;

  --male: #3E7C8C;
  --female: #B87259;

  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --shadow: 0 1px 2px rgba(25,28,28,.04), 0 4px 14px rgba(25,28,28,.05);
  --shadow-lg: 0 10px 30px rgba(26,28,30,.10);

  --sidebar-w: 240px;
  --font-ui: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Consolas", "Liberation Mono", monospace;

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0E1110; --surface: #171A19; --surface-2: #1E2220;
    --text: #EDEFEE; --mute: #9BA0A0; --border: #2A2E2C;
    --accent: #23B5A4; --accent-bright: #35C7B6; --accent-soft: #10302B;
    --success: #6E8F72; --warning: #C98A6E; --critical: #E36258; --info: #23B5A4;
    --success-soft: #16281B; --warning-soft: #2A1D16; --critical-soft: #2C1614; --info-soft: #10302B;
    --male: #5FA0B0; --female: #C98A6E;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.4);
    --shadow-lg: 0 10px 30px rgba(0,0,0,.55);
  }
}
:root[data-theme="dark"] {
  --ground: #0E1110; --surface: #171A19; --surface-2: #1E2220;
  --text: #EDEFEE; --mute: #9BA0A0; --border: #2A2E2C;
  --accent: #23B5A4; --accent-bright: #35C7B6; --accent-soft: #10302B;
  --success: #6E8F72; --warning: #C98A6E; --critical: #E36258; --info: #23B5A4;
  --success-soft: #16281B; --warning-soft: #2A1D16; --critical-soft: #2C1614; --info-soft: #10302B;
  --male: #5FA0B0; --female: #C98A6E;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.4);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.55);
}
:root[data-theme="light"] {
  --ground: #F9F9F8; --surface: #FFFFFF; --surface-2: #F3F4F3;
  --text: #191C1C; --mute: #44474A; --border: #E1E3E2;
  --accent: #1D9A8C; --accent-bright: #17B0A0; --accent-soft: #D4EEE9;
  --success: #4D6450; --warning: #B87259; --critical: #BA1A1A; --info: #1D9A8C;
  --success-soft: #CCE6CD; --warning-soft: #FFDBCF; --critical-soft: #FCE8E6; --info-soft: #D4EEE9;
  --male: #3E7C8C; --female: #B87259;
}

/* ---- Reset ---- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  background: var(--ground);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
  font-size: 15px;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.num { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; border-radius: 6px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* Cross-fade suave al cambiar de tema (clase temporal .theme-anim en <html>). */
@media (prefers-reduced-motion: no-preference) {
  html.theme-anim, html.theme-anim * {
    transition: background-color .28s ease, border-color .24s ease, color .2s ease, fill .24s ease, stroke .24s ease !important;
  }
}

/* ============ LOGIN ============ */
#login {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center; padding: var(--sp-4);
  background:
    radial-gradient(1200px 600px at 80% -10%, var(--accent-soft), transparent 60%),
    var(--ground);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--sp-6) var(--sp-5); box-shadow: var(--shadow-lg);
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.login-brand .wordmark { font-size: 30px; font-weight: 800; letter-spacing: -.03em; }
.login-brand .finca { color: var(--mute); font-size: 13px; }
.field { margin-bottom: var(--sp-3); }
.field label { display: block; font-size: 12.5px; color: var(--mute); margin-bottom: 5px; font-weight: 600; }
.input {
  width: 100%; padding: 12px 14px; min-height: 46px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: var(--radius-sm);
  font-weight: 650; transition: transform .08s, background .15s, border-color .15s;
  background: var(--surface-2); border: 1px solid var(--border);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); width: 100%; }
.btn-primary:hover { background: var(--accent-bright); }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; }
.hint { font-size: 12px; color: var(--mute); text-align: center; margin-top: var(--sp-3); }

/* ============ APP SHELL ============ */
#app { display: none; }
#app.active { display: block; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; min-height: 100dvh; }

/* Sidebar (desktop) */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: var(--sp-4) var(--sp-3);
  z-index: 30;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; }
.sidebar .brand .wordmark { font-weight: 800; font-size: 21px; letter-spacing: -.03em; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  border-radius: 10px; color: var(--mute); font-weight: 550; text-align: left;
  min-height: 44px; transition: background .13s, color .13s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.nav-item svg { flex: 0 0 20px; }
.sidebar-foot { margin-top: auto; padding-top: var(--sp-3); padding-bottom: var(--sp-2); border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; }
.user-chip:hover { background: var(--surface-2); }
.avatar-sm { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; flex: 0 0 auto; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 10px var(--sp-4); background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar .page-title { font-weight: 750; font-size: 18px; letter-spacing: -.02em; margin-right: auto; }
.icon-btn { width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center; color: var(--mute); transition: background .13s, color .13s; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.seg {
  display: inline-flex; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 3px; gap: 2px;
}
.seg button { padding: 6px 11px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--mute); min-height: 34px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Badge de sincronización (estado del store + "sincronizar ahora") */
.sync-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 11px; min-height: 34px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12.5px; font-weight: 650; color: var(--mute);
  cursor: pointer; transition: background .13s, color .13s;
  white-space: nowrap;
}
.sync-badge:hover { background: var(--surface); color: var(--text); }
.sync-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--mute); flex: 0 0 auto; }
.sync-badge.ok .sync-dot { background: var(--success); }
.sync-badge.pending .sync-dot { background: var(--warning); }
.sync-badge.offline .sync-dot { background: var(--warning); }
.sync-badge.error .sync-dot { background: var(--critical); }
.sync-badge.local .sync-dot { background: var(--mute); }
/* CAN-06 y CAN-16: estados que nunca deben verse como "Sincronizado" */
.sync-badge.rechazado .sync-dot, .sync-badge.bloqueada .sync-dot, .sync-badge.lleno .sync-dot { background: var(--critical); }
.sync-badge.rechazado, .sync-badge.lleno { cursor: pointer; }
/* CAN-26: un rol de solo lectura no ve la captura rápida */
body.solo-lectura .fab, body.solo-lectura .fab-desktop { display: none !important; }
.sync-badge.syncing .sync-dot { background: var(--info); animation: syncPulse 1s ease-in-out infinite; }
@keyframes syncPulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@media (max-width: 480px) {
  .sync-badge { padding: 6px 8px; }
  .sync-badge .sync-txt { display: none; } /* en pantallas chicas queda solo el punto de color */
}

/* Mensaje de error/estado del login */
.login-msg { font-size: 13px; color: var(--critical); text-align: center; margin-top: var(--sp-3); min-height: 1em; }
.login-msg.info { color: var(--mute); }

.content { padding: var(--sp-4); padding-bottom: 110px; }

@media (min-width: 820px) {
  .app-shell { padding-left: var(--sidebar-w); }
  .content { padding: var(--sp-5); max-width: 1180px; }
  .mobile-only { display: none !important; }
}
@media (max-width: 819px) {
  .sidebar { display: none; }
  .desktop-only { display: none !important; }
}

/* Screens */
.screen { display: none; animation: fade .22s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============ COMPONENTS ============ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--sp-4); box-shadow: var(--shadow);
}
.card-pad-lg { padding: var(--sp-5); }
.grid { display: grid; gap: var(--sp-3); }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 819px) { .g3, .g4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } .g2.keep { grid-template-columns: repeat(2,1fr); } }

.section-head { display: flex; align-items: center; gap: var(--sp-3); margin: var(--sp-5) 0 var(--sp-3); }
.section-head:first-child { margin-top: 0; }
.section-head h2 { font-size: 16px; font-weight: 750; letter-spacing: -.01em; margin: 0; }
.section-head .spacer { margin-left: auto; }
.muted { color: var(--mute); }
.small { font-size: 12.5px; }

/* KPI */
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-4); }
.kpi .label { font-size: 12.5px; color: var(--mute); font-weight: 600; }
.kpi .value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; }
.kpi .value small { font-size: 14px; font-weight: 600; color: var(--mute); }
.kpi .delta { font-size: 12px; margin-top: 4px; font-weight: 650; }
.up { color: var(--success); } .down { color: var(--critical); }

/* Hero HOY */
.hoy-hero {
  background: linear-gradient(135deg, var(--accent), var(--accent-bright));
  color: #fff; border-radius: var(--radius-lg); padding: var(--sp-5);
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4);
}
.hoy-hero .big { font-size: 46px; font-weight: 850; letter-spacing: -.03em; line-height: 1; }
.hoy-hero .big small { font-size: 18px; font-weight: 600; opacity: .85; }
.hoy-hero .cap { opacity: .9; font-size: 13px; font-weight: 600; }

/* Task / Alert list */
.task { display: flex; align-items: center; gap: var(--sp-3); padding: 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); margin-bottom: 8px; }
.task .dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; background: var(--accent); }
.task .body { flex: 1; min-width: 0; }
.task .t-title { font-weight: 650; }
.task .t-sub { font-size: 12.5px; color: var(--mute); }
.task .done-btn { min-height: 40px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--border); font-weight: 650; font-size: 13px; }
.task.is-done { opacity: .5; }
.task.is-done .t-title { text-decoration: line-through; }

.alert { display: flex; gap: var(--sp-3); padding: 13px; border-radius: var(--radius-sm); border: 1px solid var(--border); border-left-width: 4px; background: var(--surface); margin-bottom: 8px; align-items: flex-start; }
.alert .ico { flex: 0 0 auto; margin-top: 1px; }
.alert .a-title { font-weight: 700; }
.alert .a-sub { font-size: 12.5px; color: var(--mute); margin-top: 1px; }
.alert.crit { border-left-color: var(--critical); background: var(--critical-soft); }
.alert.warn { border-left-color: var(--warning); background: var(--warning-soft); }
.alert.ok   { border-left-color: var(--success); background: var(--success-soft); }
.alert.info { border-left-color: var(--info); background: var(--info-soft); }
.alert .a-act { margin-left: auto; align-self: center; font-size: 12.5px; font-weight: 700; color: var(--accent); white-space: nowrap; }

/* Badges / chips */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); }
.badge.green { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge.amber { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge.red { background: var(--critical-soft); color: var(--critical); border-color: transparent; }
.badge.blue { background: var(--info-soft); color: var(--info); border-color: transparent; }
.dot-sem { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.sem-verde { background: var(--success); } .sem-amarillo { background: var(--warning); } .sem-rojo { background: var(--critical); }

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip { padding: 7px 13px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; font-weight: 600; color: var(--mute); min-height: 38px; display: inline-flex; align-items: center; }
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.sex-m { color: var(--male); font-weight: 800; }
.sex-f { color: var(--female); font-weight: 800; }

/* Search */
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--mute); pointer-events: none; }
.search-input { width: 100%; padding: 13px 14px 13px 42px; min-height: 48px; font-size: 15px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.search-input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
thead th { text-align: left; font-size: 11.5px; font-weight: 700; color: var(--mute); text-transform: uppercase; letter-spacing: .03em; padding: 11px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); position: sticky; top: 0; }
tbody td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; transition: background .12s; }
tbody tr.clickable:hover { background: var(--surface-2); }
td.right, th.right { text-align: right; }

/* Avatar (SVG initials) */
.av { border-radius: 10px; overflow: hidden; flex: 0 0 auto; display: inline-block; }
.av-row { display: flex; align-items: center; gap: 10px; }

/* Photo grid */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--sp-3); }
.photo-cell { border: 1px solid var(--border); border-radius: var(--radius-sm); 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: 7px 9px; font-size: 11.5px; color: var(--mute); }

/* FAB + bottom nav (mobile) */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: flex-end; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 20px rgba(20,30,24,.06);
}
.bn-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; color: var(--mute); font-size: 10.5px; font-weight: 600; min-height: 52px; }
.bn-item.active { color: var(--accent); }
.fab-wrap { flex: 0 0 auto; margin-top: -26px; }
.fab {
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 45%, transparent);
  border: 4px solid var(--surface); font-size: 30px; line-height: 1;
  transition: transform .1s;
}
.fab:active { transform: scale(.94); }
@media (min-width: 820px) { .bottom-nav { display: none; } }

/* FAB de captura rápida en escritorio (misma función que el ＋ móvil) */
.fab-desktop { position: fixed; right: 28px; bottom: 28px; z-index: 60; cursor: pointer; }
.fab-desktop:hover { transform: scale(1.05); }

/* Botones mini para editar/eliminar filas (pesos, sanidad, agenda, palpación) */
.btn-mini { padding: 4px 10px; min-height: 30px; font-size: 12px; border-radius: 8px; }
.mt2 { margin-top: 8px; }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(10,16,13,.5); z-index: 100; display: none; align-items: flex-end; justify-content: center; padding: 0; }
.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: 520px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow-lg);
  animation: slideup .25s ease;
}
@media (min-width: 640px) { .modal { border-radius: var(--radius-lg); } }
@keyframes slideup { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; gap: var(--sp-3); padding: 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: 17px; font-weight: 750; }
.modal-body { padding: var(--sp-4); }

/* Quick capture grid */
.qc-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }
.qc-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: var(--sp-5) var(--sp-3); border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface-2); font-weight: 700; text-align: center; min-height: 108px;
  transition: transform .08s, border-color .13s, background .13s;
}
.qc-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.qc-btn:active { transform: scale(.97); }
.qc-btn .qc-ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: #fff; }

/* Offline banner */
.offline-bar {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  background: var(--warning-soft); color: var(--warning); font-weight: 650; font-size: 12.5px;
  padding: 7px 12px; border-bottom: 1px solid var(--border);
}
.offline-bar.online { background: var(--success-soft); color: var(--success); }

/* Ficha */
.ficha-head { display: flex; gap: var(--sp-4); align-items: flex-start; flex-wrap: wrap; }
.ficha-head .code-big { font-size: 30px; font-weight: 850; letter-spacing: -.02em; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); margin: var(--sp-4) 0; padding-bottom: 0; }
.tab { padding: 10px 13px; font-weight: 650; color: var(--mute); border-bottom: 2px solid transparent; white-space: nowrap; min-height: 44px; }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.on { display: block; }

.def-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; }
.def-list dt { color: var(--mute); font-size: 13px; }
.def-list dd { margin: 0; font-weight: 600; }

/* Timeline */
.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: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.tl-date { font-size: 11.5px; color: var(--mute); font-family: var(--font-mono); }
.tl-title { font-weight: 650; }

/* Progress / meters */
.meter { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }

/* Toast */
.toast { position: fixed; bottom: 88px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--ground); padding: 11px 18px; border-radius: 999px; font-weight: 650; font-size: 13.5px; box-shadow: var(--shadow-lg); z-index: 200; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }
@media (min-width: 820px) { .toast { bottom: 28px; } }

/* Utility */
.row { display: flex; align-items: center; gap: var(--sp-3); }
.wrap { flex-wrap: wrap; }
.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); }
.gap2 { gap: var(--sp-2); } .fill { flex: 1; }
.pill-lg { font-size: 13px; }
select.input, textarea.input { -webkit-appearance: none; appearance: none; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--mute); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.tooltip-inline { border-bottom: 1px dotted var(--mute); cursor: help; }

/* ===== Menú móvil (drawer) ===== */
.menu-btn { margin-right: 2px; }
@media (min-width: 820px) { .menu-btn { display: none !important; } }
.drawer-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); opacity: 0; pointer-events: none; transition: opacity .2s ease; z-index: 70; }
.drawer-back.open { opacity: 1; pointer-events: auto; }
.drawer { position: absolute; top: 0; left: 0; height: 100%; width: 84%; max-width: 320px; background: var(--surface); border-right: 1px solid var(--border); box-shadow: var(--shadow); transform: translateX(-100%); transition: transform .22s ease; display: flex; flex-direction: column; gap: 2px; padding: 14px; overflow-y: auto; }
.drawer-back.open .drawer { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.drawer .nav { flex: 0 0 auto; }
.drawer-seg-label { font-size: 12.5px; color: var(--mute); font-weight: 600; margin: 14px 4px 5px; }
.drawer .seg { display: flex; width: 100%; }
.drawer .seg button { flex: 1; min-height: 40px; }
@media (min-width: 820px) { .drawer-back { display: none; } }
@media (prefers-reduced-motion: reduce) { .drawer, .drawer-back { transition: none; } }

/* ===== Crédito "Creado por" (GI Group) =====
   Discreto e intencional: hairline arriba, etiqueta pequeña, logo con aire.
   La pastilla (contraste en oscuro) vive en .logo-pill, NUNCA en el <img>:
   con box-sizing:border-box el padding sobre el img se comía su altura. */

/* Login: sobre la tarjeta el logo marino respira sin pastilla (tema claro) */
.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;
  max-width: 100%; overflow: hidden;
}
.creado-por > span { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--mute); font-weight: 700; }
.creado-por a { display: inline-flex; max-width: 100%; border-radius: 12px; }
.creado-por img { height: 32px; width: auto; max-width: 160px; display: block; }

/* Sidebar footer: hairline + separación del user-chip; jamás pegado al borde */
.creado-por-foot {
  margin-top: var(--sp-3); padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-decoration: none; opacity: .92; transition: opacity .15s;
  max-width: 100%; overflow: hidden;
}
.creado-por-foot:hover { opacity: 1; }
.creado-por-foot > span { font-size: 9px; letter-spacing: .16em; text-transform: uppercase; color: var(--mute); font-weight: 700; }
.creado-por-foot img { height: 25px; width: auto; max-width: 140px; display: block; }

/* Pastilla contenedora: transparente en claro, blanca limpia en oscuro */
.logo-pill { display: inline-flex; align-items: center; justify-content: center; max-width: 100%; border-radius: 10px; background: transparent; }

@media (prefers-color-scheme: dark) {
  .creado-por .logo-pill, .creado-por-foot .logo-pill {
    background: #FFFFFF; padding: 7px 12px; border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"] .creado-por .logo-pill,
:root[data-theme="dark"] .creado-por-foot .logo-pill {
  background: #FFFFFF; padding: 7px 12px; border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
:root[data-theme="light"] .creado-por .logo-pill,
:root[data-theme="light"] .creado-por-foot .logo-pill {
  background: transparent; padding: 0; box-shadow: none;
}

/* ===== Alertas (reproducción): parto 283 d · monta posparto ===== */
.alerta-meta { text-align: right; flex: 0 0 auto; }
.alerta-dias { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 800; font-size: 15px; letter-spacing: -.01em; }
.alerta-dias.rojo { color: var(--critical); }
.alerta-dias.amarillo { color: var(--warning); }
.alerta-dias.verde { color: var(--success); }
.badge-alerta { font-size: 12.5px; padding: 5px 11px; gap: 6px; }

/* Panel de filtros separados (Animales) */
.filtros-panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; }
.filtro-grupo { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.filtro-grupo > label { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; color: var(--mute); text-transform: uppercase; letter-spacing: .02em; }
.filtro-grupo > label .hico { color: var(--accent); }
.filtro-grupo .input { min-height: 40px; padding: 8px 10px; font-weight: 600; cursor: pointer; width: 100%; }
.filtro-clear { justify-content: flex-end; }
.filtro-clear .btn { min-height: 40px; }
.filtros-count { margin-bottom: 8px; }
select.input option { background: var(--surface); color: var(--text); }
@media (prefers-color-scheme: dark) { select.input option { background: #1E2620; color: #EAF0EA; } }
:root[data-theme="dark"] select.input option { background: #1E2620; color: #EAF0EA; }
:root[data-theme="light"] select.input option { background: #FFFFFF; color: #191C1C; }

/* ============ 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: 20px; font-weight: 800; letter-spacing: -.02em; }
.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: 12px; }
.wz-dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); font-weight: 800; font-size: 13px; transition: background .15s, color .15s; }
.wz-step.on .wz-dot { background: var(--accent); color: #fff; border-color: var(--accent); }
.wz-step.done .wz-dot { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.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: 999px; background: var(--surface-2); overflow: hidden; margin-bottom: var(--sp-4); }
.wz-progress > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-bright)); transition: width .3s ease; }

.wz-body { margin-bottom: var(--sp-4); }
.wz-h { font-size: 17px; font-weight: 750; 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; }
.wz-sec-head b { font-size: 14px; }

.wz-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.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: 40px; }
.wz-mini-form .btn-mini { flex: 0 0 auto; }
.wz-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--mute); font-weight: 600; white-space: nowrap; }

.wz-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.wz-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 6px 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); font-size: 13px; font-weight: 600; }
.wz-chip.add { padding: 6px 12px; color: var(--accent); background: var(--surface); cursor: pointer; }
.wz-chip.add:hover { background: var(--accent-soft); }
.wz-chip-x { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: var(--mute); font-size: 12px; }
.wz-chip-x:hover { background: var(--critical-soft); color: var(--critical); }
.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: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-weight: 600; font-size: 14px; }
.wz-del { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--mute); flex: 0 0 auto; }
.wz-del:hover { background: var(--critical-soft); color: var(--critical); }

.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: 13.5px; }
.wz-banda-row .input { min-height: 38px; padding: 6px 8px; text-align: right; }

.wz-tabs { display: inline-flex; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; margin-bottom: var(--sp-4); }
.wz-tab { padding: 7px 14px; border-radius: 7px; font-weight: 650; font-size: 13px; color: var(--mute); min-height: 38px; }
.wz-tab.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.wz-drop { border: 2px dashed var(--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: 66px; }
  .wz-step-lbl { font-size: 10.5px; }
  .wz-banda-row { grid-template-columns: 1fr 70px auto 70px; }
  .wz-foot .btn { min-width: 92px; }
}

/* ============ Barra de exportación (PDF · Excel · CSV) ============ */
.export-bar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.export-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; font-size: 12.5px; font-weight: 700;
  border: 1px solid var(--line, #DFE5E0); border-radius: 9px;
  background: var(--card, #fff); color: var(--txt, #1B241F);
  cursor: pointer; transition: transform .12s ease, border-color .12s ease;
}
.export-btn:hover { transform: translateY(-1px); border-color: var(--accent); color: var(--accent); }
.export-btn:disabled { opacity: .55; cursor: wait; transform: none; }
.export-btn svg { flex: 0 0 auto; }

/* ============================================================
   SPLASH / PRELOADER (GI Group)
   El CSS crítico vive inline en index.html (pinta antes que este
   archivo). Aquí solo los overrides del tema MANUAL (Ajustes →
   data-theme en <html>), que aplican cuando el splash se re-muestra
   durante el bootstrap de datos tras el login.
   ============================================================ */
/* Splash bajo tema MANUAL — identidad Caney (teal/carbón), no el azul Hato viejo. */
:root[data-theme="dark"] #hato-splash {
  background:
    radial-gradient(1000px 600px at 50% 30%, rgba(35,181,164,.14), rgba(35,181,164,0) 62%),
    #0E1110;
}
:root[data-theme="dark"] #hato-splash .hs-card { background: #171A19; border-color: #2A2E2C; box-shadow: 0 12px 40px rgba(0,0,0,.5), 0 2px 8px rgba(0,0,0,.35); }
:root[data-theme="dark"] #hato-splash .hs-wm { color: #EDEFEE; }
:root[data-theme="dark"] #hato-splash .hs-bar { background: #2A2E2C; }
:root[data-theme="dark"] #hato-splash .hs-runner { background: linear-gradient(90deg, #23B5A4, #6E8F72); }
:root[data-theme="dark"] #hato-splash .hs-caption { color: #9BA0A0; opacity: .9; }

:root[data-theme="light"] #hato-splash {
  background:
    radial-gradient(1000px 600px at 50% 30%, rgba(29,154,140,.10), rgba(29,154,140,0) 60%),
    #F9F9F8;
}
:root[data-theme="light"] #hato-splash .hs-card { background: #FFFFFF; border-color: #E1E3E2; box-shadow: 0 10px 30px rgba(26,28,30,.08); }
:root[data-theme="light"] #hato-splash .hs-wm { color: #000101; }
:root[data-theme="light"] #hato-splash .hs-bar { background: #EDEEED; }
:root[data-theme="light"] #hato-splash .hs-runner { background: linear-gradient(90deg, #1D9A8C, #4D6450); }
:root[data-theme="light"] #hato-splash .hs-caption { color: #44474A; opacity: .75; }

/* ============================================================
   FX — capa ADITIVA de efectos refinados (assets/fx.js).
   Portada desde Caney; token-based (usa --accent verde de Hato).
   No cambia el layout ni oculta nada.
   ============================================================ */

/* Cross-fade suave al cambiar de tema (clase temporal .theme-anim en <html>). */
@media (prefers-reduced-motion: no-preference) {
  html.theme-anim, html.theme-anim * {
    transition: background-color .28s ease, border-color .24s ease, color .2s ease, fill .24s ease, stroke .24s ease !important;
  }
}
:root[data-theme="light"] select.input option { background: #FFFFFF; color: var(--text); }

/* Fondo AURORA (fx.js) + velo de vidrio en las superficies para que el efecto se perciba. */
html { background: var(--ground); }
body { background: transparent; }
#fxAurora { position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: 0; transition: opacity 1.1s ease; }
#fxAurora.on { opacity: 1; }
.kpi, .card, .tbl-hero {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(7px) saturate(1.04);
  backdrop-filter: blur(7px) saturate(1.04);
}
.kpi { transition: transform .2s cubic-bezier(.2,.8,.2,1), box-shadow .18s; }

/* Botón primario: destello especular al pasar el cursor (el magnetismo lo aplica fx.js). */
.btn-primary { position: relative; overflow: hidden; }
.btn-primary::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: var(--fx-sx, -45%); width: 42%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.42), transparent);
  transform: skewX(-18deg); opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 0;
}
@media (hover: hover) { .btn-primary:hover::after { opacity: .6; } }

/* Tarjetas / KPI: borde-spotlight que sigue el cursor (solo el filo, jamás sobre el texto). */
.tbl-card::after, .kpi::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  opacity: 0; transition: opacity .3s; z-index: 3;
  background: radial-gradient(190px circle at var(--gx, 50%) var(--gy, 0%), color-mix(in srgb, var(--accent) 55%, transparent), transparent 55%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); mask-composite: exclude;
}
.kpi { position: relative; }
@media (hover: hover) { .tbl-card:hover::after, .kpi:hover::after { opacity: 1; } }

/* Command palette (⌘K) */
.cmd-back { position: fixed; inset: 0; z-index: 300; display: grid; place-items: start center; padding-top: 12vh;
  background: color-mix(in srgb, var(--text) 40%, transparent); backdrop-filter: blur(5px);
  opacity: 0; pointer-events: none; transition: opacity .18s; }
.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-lg); overflow: hidden; transform: translateY(-8px) scale(.98); opacity: 0;
  transition: transform .24s cubic-bezier(.2,.9,.3,1), opacity .18s; }
.cmd-back.open .cmd { transform: none; opacity: 1; }
.cmd-top { display: flex; align-items: center; gap: 11px; padding: 13px 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: 16px; color: var(--text); }
.cmd-top input::placeholder { color: var(--mute); }
.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; padding: 10px 12px; border-radius: 10px; cursor: pointer; color: var(--mute); }
.cmd-list li .ci { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); color: var(--accent); flex: 0 0 auto; }
.cmd-list li .ct { color: var(--text); font-weight: 650; font-size: 14.5px; }
.cmd-list li .cs { color: var(--mute); font-size: 12px; margin-left: auto; }
.cmd-list li.sel, .cmd-list li:hover { background: var(--accent-soft); }
.cmd-list li.sel .ct { color: var(--accent); }
.cmd-hint { padding: 9px 14px; border-top: 1px solid var(--border); font-size: 11.5px; 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; }

/* Efectos en controles de filtro: chips, segmentados, tabs, mini (fx.js aplica el imán). */
.chip, .seg button, .tab, .wz-tab, .btn-mini, .export-btn, .tbl-meta, .rep-cols .chip, .tblcfg-row {
  transition: transform .14s cubic-bezier(.2,.8,.2,1), background .15s, border-color .15s, box-shadow .18s, color .15s;
}
@media (hover: hover) {
  .chip:not(.on):hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
  .tab:not(.on):hover { color: var(--text); }
  .wz-tab:not(.on):hover { color: var(--text); }
  .export-btn:hover { transform: translateY(-1px); }
  .tbl-meta:hover { transform: translateY(-1px); }
}
.chip:active, .seg button:active, .tab:active, .wz-tab:active, .btn-mini:active, .export-btn:active, .tbl-meta:active { transform: translateY(.5px) scale(.96); }
.chip.on { box-shadow: 0 3px 12px color-mix(in srgb, var(--accent) 32%, transparent); animation: fxChipPop .34s cubic-bezier(.2,.9,.3,1); }
.seg button.on { box-shadow: var(--shadow), 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent); }
@keyframes fxChipPop { 0% { transform: scale(.92); } 60% { transform: scale(1.045); } 100% { transform: none; } }
@media (prefers-reduced-motion: reduce) { .chip.on { animation: none; } }

/* FAB "+" de captura rápida en ESCRITORIO: más visible (lado derecho) + arrastrable (fx.js). */
.fab-desktop {
  z-index: 80; width: 64px; height: 64px; cursor: grab;
  box-shadow: 0 12px 32px color-mix(in srgb, var(--accent) 50%, transparent);
}
.fab-desktop.fab-dragging { cursor: grabbing; }
.fab-desktop::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent);
  animation: fabRing 2.4s ease-out infinite;
}
@keyframes fabRing {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 42%, transparent); }
  70%, 100% { box-shadow: 0 0 0 18px color-mix(in srgb, var(--accent) 0%, transparent); }
}
.fab-desktop:hover::after, .fab-desktop.fab-dragging::after { animation: none; }
.fab-desktop::before {
  content: "Registrar"; position: absolute; right: 100%; margin-right: 12px; top: 50%;
  transform: translateY(-50%) translateX(6px);
  background: var(--text); color: var(--ground); padding: 7px 12px; border-radius: 10px;
  font: 700 13px/1 var(--font-ui, system-ui); white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s; box-shadow: var(--shadow-lg);
}
.fab-desktop:hover::before { opacity: 1; transform: translateY(-50%) translateX(0); }
@media (prefers-reduced-motion: reduce) { .fab-desktop::after { animation: none; } }


/* ===== Tablero ejecutivo + KPIs + drill-down (portado de Caney) ===== */
/* ============================================================
   TABLERO EJECUTIVO (dashboard del dueño) — clases prefijadas tbl-
   ============================================================ */
.tbl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: var(--sp-3); }
.tbl-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 15px 16px 13px; cursor: grab; position: relative; overflow: hidden;
  display: flex; flex-direction: column; min-height: 168px;
  transition: box-shadow .18s, border-color .18s, transform .14s;
}
/* Cinta de color del grupo (acento superior, refuerza el rótulo). */
.tbl-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--gcol, var(--accent)); opacity: .9; }
.tbl-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); border-color: var(--border); }
.tbl-card:active { cursor: grabbing; }
.tbl-card.is-empty { opacity: .8; }
.tbl-card.is-empty::before { opacity: .28; }
.tbl-card.tbl-dragging { opacity: .4; }
.tbl-card.tbl-over { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); transform: translateY(-2px); }

.tbl-top { display: flex; align-items: center; gap: 8px; min-height: 24px; }
.tbl-grupo { display: inline-flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.tbl-grupo i { width: 7px; height: 7px; border-radius: 2px; display: inline-block; }
.tbl-actions { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.tbl-meta { font-size: 11px; font-weight: 700; color: var(--mute); border: 1px solid var(--border); border-radius: 999px; padding: 3px 9px; min-height: 24px; background: transparent; transition: .15s; }
.tbl-meta:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.tbl-grip { color: var(--border); font-size: 15px; cursor: grab; user-select: none; line-height: 1; }
.tbl-card:hover .tbl-grip { color: var(--mute); }

.tbl-label { font-size: 12.5px; color: var(--mute); font-weight: 600; margin-top: 11px; line-height: 1.25; }
.tbl-main { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 3px; }
.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: -.03em; line-height: 1.05; font-variant-numeric: tabular-nums; color: var(--text); }
.tbl-value small { font-size: 13px; font-weight: 600; color: var(--mute); margin-left: 3px; letter-spacing: 0; }
.tbl-value.tbl-nodata { color: var(--border); font-weight: 700; }

/* Dona (gauge %). */
.tbl-donut { flex: 0 0 auto; }
.tbl-donut-t { font: 700 12px/1 "Hanken Grotesk", system-ui, sans-serif; fill: var(--text); font-variant-numeric: tabular-nums; }

/* Delta pill. */
.tbl-delta { font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl-delta.up { color: var(--success); background: var(--success-soft); }
.tbl-delta.down { color: var(--critical); background: var(--critical-soft); }

/* Visual bajo el número (área, barras). */
.tbl-viz { margin-top: 9px; }
.tbl-area { display: block; }
.tbl-bar { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.tbl-bar > span { display: block; height: 100%; border-radius: 999px; transition: width .4s cubic-bezier(.22,.8,.3,1); }
.tbl-segbar { display: flex; height: 9px; border-radius: 999px; overflow: hidden; gap: 2px; background: transparent; }
.tbl-seg { display: block; height: 100%; border-radius: 2px; }
.tbl-segbar .tbl-seg:first-child { border-radius: 999px 2px 2px 999px; }
.tbl-segbar .tbl-seg:last-child { border-radius: 2px 999px 999px 2px; }
.tbl-legs { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; }
.tbl-leg { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--mute); font-weight: 500; }
.tbl-leg i { width: 8px; height: 8px; border-radius: 2px; }
.tbl-leg b { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }

/* Pie: sub + estado. */
.tbl-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 10px; }
.tbl-sub { font-size: 11.5px; color: var(--mute); line-height: 1.3; min-width: 0; }
.tbl-status { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap; flex: 0 0 auto; }
.tbl-status i { width: 6px; height: 6px; border-radius: 50%; }
.tbl-status.s-verde { color: var(--success); background: var(--success-soft); }
.tbl-status.s-verde i { background: var(--success); }
.tbl-status.s-amarillo { color: var(--warning); background: var(--warning-soft); }
.tbl-status.s-amarillo i { background: var(--warning); }
.tbl-status.s-rojo { color: var(--critical); background: var(--critical-soft); }
.tbl-status.s-rojo i { background: var(--critical); }

/* ---- Banda hero (resumen tipo reporte) ---- */
.tbl-hero { display: grid; grid-template-columns: minmax(280px, 1.4fr) minmax(280px, 1fr); gap: var(--sp-4);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; }
.tbl-hero-comp { display: flex; flex-direction: column; justify-content: center; }
.tbl-hero-h { font-size: 13px; font-weight: 600; color: var(--mute); margin-bottom: 12px; }
.tbl-hero-h b { color: var(--text); font-weight: 800; font-variant-numeric: tabular-nums; }
.tbl-hero-comp .tbl-segbar { height: 14px; }
.tbl-hero-comp .tbl-legs { margin-top: 12px; gap: 6px 16px; }
.tbl-hero-comp .tbl-leg { font-size: 12px; }
.tbl-hero-g { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-content: center;
  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 .tbl-donut { width: 46px; height: 46px; }
.tbl-hg-x { min-width: 0; }
.tbl-hg-l { font-size: 12px; font-weight: 700; color: var(--text); line-height: 1.15; }
.tbl-hg-s { font-size: 10.5px; color: var(--mute); line-height: 1.2; margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@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); } }

.tbl-fechas { display: inline-flex; align-items: center; gap: 8px; }
.tbl-fechas .input { min-height: 38px; width: auto; padding: 0 10px; }
@media (max-width: 560px) { .tbl-grid { grid-template-columns: 1fr 1fr; gap: 10px; } .tbl-card { min-height: 150px; padding: 13px; } .tbl-value { font-size: 26px; } .tbl-hero-g { grid-template-columns: 1fr; } }
@media (max-width: 380px) { .tbl-grid { grid-template-columns: 1fr; } }

/* ---- Selector de KPIs (Elegir KPIs) ---- */
.tblcfg { display: flex; flex-direction: column; gap: 14px; }
.tblcfg-gh { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.tblcfg-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.tblcfg-row:hover { background: var(--surface-2); }
.tblcfg-row input { width: 17px; height: 17px; accent-color: var(--accent); flex: 0 0 auto; }
.tblcfg-row span { flex: 1; font-size: 14px; }
.tblcfg-row small { color: var(--mute); font-size: 11px; }

/* ---- Panel experto de KPI (drill-down) ---- */
.kpidet-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.kpidet-big { font-size: 34px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; color: var(--text); line-height: 1; }
.kpidet-big small { font-size: 15px; font-weight: 600; color: var(--mute); margin-left: 4px; }
.tbl-card { cursor: pointer; }

/* ---- Selector de columnas en Reportes ---- */
.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) { opacity: .5; text-decoration: line-through; }

/* ═══════════════════════════════════════════════════════════════════════════
   AJUSTES DE CAMPO — 2026-07-28
   Se trabaja con una mano, con guantes, a pleno sol y con el teléfono sucio.
   Todo lo de abajo sale de medir la app real con Playwright en un 390x844.
   ═══════════════════════════════════════════════════════════════════════════ */

/* 1. LOS FILTROS YA NO TAPAN LA LISTA.
   Siete desplegables apilados ocupaban ~1.400 px: había que scrollear toda esa
   pantalla antes de ver UN animal. Ahora el panel viene plegado y el contenido
   —que es lo que se viene a ver— queda arriba. */
.filtros-panel[hidden] { display: none !important; }
.filtros-toggle {
  display: flex; align-items: center; gap: 8px; width: 100%;
  min-height: 48px; padding: 0 14px; margin-bottom: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: 15px; font-weight: 650; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.filtros-toggle:hover { border-color: var(--brand); }
.filtros-toggle .chev { margin-left: auto; transition: transform .18s ease; }
.filtros-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.filtros-toggle .cuenta {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px;
  background: var(--brand); color: #fff; font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
}
/* Resumen de lo que está filtrando, para no tener que abrir el panel */
.filtros-resumen { font-weight: 500; color: var(--mute); font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 2. OBJETIVOS TÁCTILES. Medidos: 17 por debajo de 44x44, el mínimo que
   aguanta un dedo. Los segmentados eran de 34 px de alto. */
.seg button { min-height: 44px; padding: 6px 13px; font-size: 14px; }
.filtro-grupo select, .filtro-grupo input, .input { min-height: 46px; }
.btn { min-height: 46px; }
.icon-btn { width: 46px; height: 46px; }

/* 3. LEGIBILIDAD. 15 px con interlineado 1,45 es poco para leer a contraluz.
   16/1,55 es el mínimo cómodo y además evita el zoom automático de iOS al
   enfocar un campo, que descuadra la pantalla. */
body { font-size: 16px; line-height: 1.55; }
.small { font-size: 13.5px; }
.input, select, textarea { font-size: 16px; }

/* 4. DENSIDAD EN "HOY". Cada KPI ocupaba ~250 px de alto: cabían tres en
   pantalla. Un encargado quiere ver el estado de un vistazo, no scrolleando. */
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi-grid .kpi { padding: 13px 14px; }
.kpi-grid .kpi .label { font-size: 13px; margin-bottom: 2px; }
.kpi-grid .kpi .value { font-size: 27px; line-height: 1.1; }
.kpi-grid .kpi .delta { font-size: 12.5px; margin-top: 2px; }
@media (min-width: 620px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }

/* 5. El fondo difuminado detrás del contenido restaba contraste al texto.
   Se mantiene la textura pero las tarjetas ahora sí son opacas. */
.card, .kpi { background: var(--surface); }

/* 6. Respeta a quien tiene el sistema en "reducir movimiento". */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}


/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — hallazgos del barrido de 8 tamaños (2026-08-03)
   Medido con Playwright de 320x568 a 1920x1080, incluido telefono acostado.
   ═══════════════════════════════════════════════════════════════════════════ */

/* 1. DESBORDAMIENTO EN TABLET Y ESCRITORIO.
   En 1024x768 la pantalla de Ajustes pedia 1.628 px de ancho -604 de mas- por
   la tabla de rangos de peso; Leche se salia 99 px por la lista de "Ventas y
   consumo" y Pastos 43 px por la fila con el boton de borrar. En telefono no
   pasaba porque ahi todo se apila.
   La regla de fondo: una tabla ancha hace scroll DENTRO de su caja, nunca
   empuja la pagina. */
.card table, .table-wrap { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.card table { border-collapse: collapse; }
.def-list { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; min-width: 0; }
.def-list dt, .def-list dd { min-width: 0; overflow-wrap: anywhere; }
/* Filas con acciones al final: que bajen en vez de empujar */
.card .row { flex-wrap: wrap; min-width: 0; }
.card .row > * { min-width: 0; }
/* Nada dentro de una tarjeta puede ser mas ancho que la tarjeta */
.card, .card * { max-width: 100%; }
.card { overflow-wrap: anywhere; }

/* 2. OBJETIVOS TACTILES. El barrido de las nueve pantallas encontro 17 por
   debajo de 44x44 -antes solo habia medido Animales y salian 6-. */
.chip, .tab, .seg button, .icon-btn, .btn, .filtro-grupo select,
.filtro-grupo input, nav button, nav a, .nav-item, .drawer a, .drawer button {
  min-height: 44px;
}
.icon-btn { min-width: 44px; }
.tab, .chip { display: inline-flex; align-items: center; padding-inline: 12px; }

/* 3. CONTRASTE. Las nueve etiquetas de navegacion daban 4,4:1 contra su fondo,
   justo por debajo del minimo de 4,5 que exige la norma. Se oscurece el gris
   apagado lo justo para pasar. */
:root[data-theme="light"] { --mute: #5B5F63; }
:root[data-theme="light"] .nav-item, :root[data-theme="light"] .nav-item .label, :root[data-theme="light"] nav .label { color: #45494D; }

/* 4. TELEFONO ACOSTADO (844x390). La barra inferior y el boton flotante se
   comen media pantalla cuando el alto es minimo. */
@media (max-height: 460px) and (orientation: landscape) {
  .bottom-nav { padding-block: 2px; }
  .bottom-nav .label { display: none; }
  .fab { transform: scale(.82); }
  .card { padding: 10px 12px; }
}

/* 5. LA CAUSA REAL DEL DESBORDE DE AJUSTES.
   Los hijos de un grid (y de un flex) traen min-width:auto de fabrica, o sea
   "no me encojas por debajo de mi contenido". Por eso la tarjeta de bandas de
   peso se estiraba a 1.628 px en vez de dejar que su tabla hiciera scroll:
   el .table-wrap nunca llegaba a activarse porque la tarjeta cedia primero.
   Con min-width:0 la tarjeta se ajusta a su columna y el scroll ocurre dentro. */
.grid > *, .row > *, .kpi-grid > * { min-width: 0; }
.table-wrap { overflow-x: auto; max-width: 100%; }
.table-wrap > table { min-width: max-content; }

/* 6. CONTRASTE DEL TITULO DE PANTALLA.
   "Hoy", "Animales", "Reproducción"... daban 4,4:1 contra la barra superior:
   por debajo del 4,5 que exige la norma. Es el texto mas grande de la pantalla
   y el que dice donde estas: no puede ser el peor contrastado. */
:root[data-theme="light"] .topbar .page-title { color: #1A1C1E; }

/* 7. LOS 13 OBJETIVOS TACTILES QUE QUEDABAN.
   Uno por uno, medidos: las flechas de mes en Leche (31 px de ancho), los
   botones de Tablero (34 de alto), los segmentados de Ajustes (40), y el
   "Hecho" de Hoy. En el campo se toca con guantes y con el telefono sucio. */
.seg button, .seg > button { min-height: 44px !important; }
.btn-sm, .btn.small, [class*="chip"], .tag { min-height: 44px; display: inline-flex; align-items: center; }
/* Flechas de navegacion de periodo: anchas ademas de altas */
.nav-mes button, .periodo button, button.icon-btn.chevron,
button[aria-label*="anterior"], button[aria-label*="siguiente"] { min-width: 44px; min-height: 44px; }
/* Cualquier boton suelto que se haya quedado corto */
button:not(.fab):not(.bottom-nav button) { min-height: 44px; }
/* La pastilla de estado de sincronizacion es informativa, no se toca:
   se le quita el rol de boton para que no cuente como objetivo tactil. */
.sync-pill { pointer-events: none; }
