@font-face {
  font-family: "Figtree";
  src: url("/static/fonts/figtree-latin-wght-normal.woff2") format("woff2");
  font-weight: 300 900;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f3f5f2;
  --surface: #ffffff;
  --surface-2: #eaeee9;
  --ink: #14201b;
  --muted: #56635d;
  --line: #d6ddd7;
  --primary: #0e6b52;
  --primary-hover: #0b5a45;
  --primary-soft: #dcefe6;
  --on-primary: #ffffff;
  --danger: #b8392a;
  --danger-soft: #f8e3df;
  --warn: #8a5a0b;
  --warn-soft: #f7ecd2;
  --ok: #17784d;
  --focus: #2563eb;
  --shadow: 0 1px 2px rgba(20, 32, 27, 0.06), 0 6px 20px -8px rgba(20, 32, 27, 0.14);
  --radius: 16px;
  --radius-sm: 12px;
  --scale: 1;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --tabbar: 4.25rem;
}
:root[data-size="grande"] { --scale: 1.125; }
:root[data-size="extra"] { --scale: 1.25; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1311; --surface: #161c19; --surface-2: #1f2723; --ink: #e6ece8; --muted: #9eaba4;
    --line: #2b3530; --primary: #3cc692; --primary-hover: #5bd4a5; --primary-soft: #16362a;
    --on-primary: #05241a; --danger: #f07a64; --danger-soft: #3a1c17; --warn: #e6b955;
    --warn-soft: #36290f; --ok: #4fca8f; --focus: #7aa7ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -10px rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1311; --surface: #161c19; --surface-2: #1f2723; --ink: #e6ece8; --muted: #9eaba4;
  --line: #2b3530; --primary: #3cc692; --primary-hover: #5bd4a5; --primary-soft: #16362a;
  --on-primary: #05241a; --danger: #f07a64; --danger-soft: #3a1c17; --warn: #e6b955;
  --warn-soft: #36290f; --ok: #4fca8f; --focus: #7aa7ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -10px rgba(0, 0, 0, 0.6);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: calc(100% * var(--scale)); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 1rem/1.5 "Figtree", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.0625rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--primary); text-underline-offset: 0.2em; font-weight: 600; }
::selection { background: var(--primary-soft); color: var(--ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
.lead { max-width: 62ch; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { width: 1.25rem; height: 1.25rem; flex: none; }
/* Leaflet dibuja sus marcadores en un <svg> propio: sin esto quedan de 20 px. */
.leaflet-container svg { width: auto; height: auto; }
* { scrollbar-color: var(--line) transparent; }

/* ---------- Shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 0.75rem;
  padding: calc(0.625rem + env(safe-area-inset-top)) 1rem 0.625rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 0.5rem; }
.mark {
  display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 9px;
  background: var(--primary); color: var(--on-primary); font-weight: 800; font-size: 1.05rem;
}
.brand-name { display: none; font-weight: 700; }
.galpon-pick { position: relative; flex: 1; min-width: 0; }
.galpon-pick select {
  appearance: none; width: 100%; min-height: 2.75rem; padding: 0 2.5rem 0 0.875rem;
  font: 700 1.0625rem "Figtree", sans-serif; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  text-overflow: ellipsis;
}
.galpon-pick svg { position: absolute; right: 0.75rem; top: 50%; translate: 0 -50%; pointer-events: none; color: var(--muted); }

.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column;
  padding: 0.375rem 0.25rem calc(0.375rem + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabs a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.125rem; min-height: 3.5rem; border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-size: 0.8125rem; font-weight: 600;
}
.tabs a .ico { display: grid; place-items: center; width: 3.5rem; height: 1.875rem; border-radius: 999px; transition: background-color 200ms var(--ease); }
.tabs a svg { width: 1.5rem; height: 1.5rem; }
.tabs a[aria-current="page"] { color: var(--primary); }
.tabs a[aria-current="page"] .ico { background: var(--primary-soft); }
.badge {
  position: absolute; top: 0.125rem; left: calc(50% + 0.625rem);
  min-width: 1.25rem; height: 1.25rem; padding: 0 0.3rem; border-radius: 999px;
  background: var(--primary); color: var(--on-primary); font-size: 0.75rem; font-weight: 700; line-height: 1.25rem; text-align: center;
}

main { padding: 1.25rem 1rem calc(var(--tabbar) + 2rem + env(safe-area-inset-bottom)); max-width: 76rem; margin: 0 auto; }
.view-head { margin-bottom: 1rem; display: grid; gap: 0.375rem; }
.view-head.row { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 3rem; padding: 0 1.125rem; border-radius: var(--radius-sm);
  font: 650 1rem "Figtree", sans-serif; cursor: pointer; text-decoration: none;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  transition: background-color 180ms var(--ease), border-color 180ms var(--ease), color 180ms var(--ease), transform 120ms var(--ease);
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); padding-inline: 0.625rem; }
.btn.ghost:hover { color: var(--ink); background: var(--surface-2); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.armed { flex-direction: column; gap: 0; line-height: 1.15; background: var(--ink); color: var(--bg); border-color: transparent; }
/* Rojo solo al confirmar una baja: el resto arma en tinta. */
.aviso[data-tipo="candidato_mortalidad"] .btn.primary.armed { background: var(--danger); color: #fff; }
.btn .sub { font-size: 0.8125rem; font-weight: 500; opacity: 0.9; }
.actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.25rem; }
.spinner { width: 1.125rem; height: 1.125rem; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin 700ms linear infinite; flex: none; }
@keyframes spin { to { rotate: 360deg; } }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.1875rem 0.625rem;
  border-radius: 999px; font-size: 0.8125rem; font-weight: 650; white-space: nowrap;
  background: var(--surface-2); color: var(--muted);
}
.chip::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: currentColor; }
.chip.plain::before { display: none; }
.chip.ok { background: var(--primary-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Revisar ---------- */
.revisar-grid { display: grid; gap: 1.25rem; }
.lote-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.125rem; display: grid; gap: 1rem;
}
.lote-top { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.dia { font-size: 2.25rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.dia small { font-size: 1rem; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-left: 0.25rem; }
.timeline { position: relative; height: 0.75rem; border-radius: 999px; background: var(--surface-2); }
.timeline .fill { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--primary); transform-origin: left; animation: grow 900ms var(--ease) both; }
@keyframes grow { from { transform: scaleX(0); } }
.timeline .tick { position: absolute; z-index: 2; top: -0.25rem; width: 0.25rem; height: 1.25rem; border-radius: 2px; background: var(--danger); translate: -50% 0; }
.timeline .peak { position: absolute; z-index: 1; top: 0; height: 100%; background: color-mix(in srgb, var(--ink) 16%, transparent); }
.timeline-legend { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.8125rem; color: var(--muted); margin-top: 0.5rem; }
.legend { display: inline-flex; align-items: center; gap: 0.375rem; }
.legend i { width: 0.25rem; height: 0.75rem; border-radius: 2px; }
.legend .l-baja { background: var(--danger); }
.stats { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); gap: 0.5rem; margin: 0; }
.stats div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 0.5rem 0.75rem; min-width: 0; }
.stats dt { font-size: 0.8125rem; color: var(--muted); }
.stats dd { margin: 0; font-size: clamp(1.125rem, 5.2vw, 1.375rem); font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stats .alert dd { color: var(--danger); }
.lote-note { font-size: 0.9375rem; color: var(--muted); }
.lote-empty { display: grid; gap: 0.75rem; justify-items: start; }

.tray { display: grid; gap: 1rem; }
.aviso {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
  transition: opacity 260ms var(--ease), transform 260ms var(--ease);
}
.aviso.leaving { opacity: 0; transform: translateX(24px); }
.aviso-img { position: relative; aspect-ratio: 16 / 9; background: #0b0f0d; }
.aviso-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.aviso-img .box { position: absolute; border: 2.5px solid #ffcf4a; border-radius: 4px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); pointer-events: none; }
.no-img { display: grid; place-items: center; height: 100%; color: #b9c4be; text-align: center; padding: 1rem; font-size: 0.9375rem; }
.aviso-body { padding: 1rem; display: grid; gap: 0.875rem; }
.aviso-tags { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.aviso-top { display: grid; gap: 0.5rem; }
.aviso-top-x { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; margin: 0; }
.meta dt { font-size: 0.75rem; color: var(--muted); }
.meta dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.decide { display: grid; grid-template-columns: 1fr 1fr; gap: 0.625rem; }
.decide .btn { min-height: 3.5rem; font-size: 1.0625rem; }

.empty {
  display: grid; justify-items: center; text-align: center; gap: 0.5rem;
  padding: 2.5rem 1.25rem; border: 1.5px dashed var(--line); border-radius: var(--radius); color: var(--muted);
}
.empty h3 { color: var(--ink); }
.empty .icon { width: 3rem; height: 3rem; display: grid; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary); margin-bottom: 0.25rem; }
.empty .icon svg { width: 1.5rem; height: 1.5rem; }
.empty .btn { margin-top: 0.5rem; }

/* ---------- Cámaras ---------- */
.cam-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.cam-row {
  width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 0.875rem;
  min-height: 4rem; padding: 0.75rem 1rem; text-align: left; cursor: pointer;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: inherit;
}
.cam-row:hover { border-color: var(--muted); }
.cam-row[aria-expanded="true"] { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.cam-row[aria-expanded="true"] > svg { rotate: 180deg; }
.cam-row > svg { color: var(--muted); transition: rotate 220ms var(--ease); }
.cam-row .dot { width: 0.75rem; height: 0.75rem; border-radius: 50%; background: var(--line); }
.cam-row[data-status="up"] .dot { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent); }
.cam-row[data-status="down"] .dot, .cam-row[data-status="config_invalida"] .dot { background: transparent; box-shadow: inset 0 0 0 2.5px var(--ink); }
.cam-row strong { display: block; }
.cam-row .sub { display: block; font-size: 0.875rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cam-row .state { font-size: 0.875rem; font-weight: 650; color: var(--muted); }
.cam-row[data-status="up"] .state { color: var(--ok); }
.cam-row[data-status="down"] .state, .cam-row[data-status="config_invalida"] .state { color: var(--ink); font-weight: 700; }
.cam-editor {
  background: var(--surface); border: 1px solid var(--line); border-top: 0;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm); padding: 1rem;
}

.wizard {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.125rem; margin-bottom: 1.25rem; display: grid; gap: 1.25rem;
}
.wizard-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.steps { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: 0.375rem; list-style: none; margin: 0; padding: 0; }
.steps li { font-size: 0.75rem; font-weight: 600; color: var(--muted); display: grid; gap: 0.375rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.steps li::before { content: ""; height: 0.3125rem; border-radius: 999px; background: var(--surface-2); }
.steps li[data-state="done"]::before, .steps li[data-state="now"]::before { background: var(--primary); }
.steps li[data-state="now"] { color: var(--ink); }
.brands { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 0.625rem; }
.brand-tile {
  display: grid; gap: 0.25rem; align-content: start; text-align: left; min-height: 5rem;
  padding: 0.875rem; border-radius: var(--radius-sm); cursor: pointer; font: inherit; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line);
  transition: border-color 160ms var(--ease), background-color 160ms var(--ease);
}
.brand-tile:hover { border-color: var(--primary); }
.brand-tile[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); }
.brand-tile strong { font-size: 1.0625rem; }
.brand-tile span { font-size: 0.8125rem; color: var(--muted); }
.brand-tile.unsupported { border-style: dashed; }
.brand-tile.unsupported strong { color: var(--muted); }
.tipo-opts { display: grid; gap: 0.5rem; }
.tipo-opt {
  display: grid; grid-template-columns: auto 1fr; gap: 0.125rem 0.75rem; align-items: center; text-align: left;
  padding: 0.875rem 1rem; border-radius: var(--radius-sm); border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; font: inherit;
}
.tipo-opt .radio { grid-row: span 2; width: 1.25rem; height: 1.25rem; border-radius: 50%; border: 2px solid var(--line); transition: box-shadow 160ms var(--ease), border-color 160ms var(--ease); }
.tipo-opt[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); }
.tipo-opt[aria-pressed="true"] .radio { border-color: var(--primary); box-shadow: inset 0 0 0 3px var(--surface), inset 0 0 0 10px var(--primary); }
.tipo-opt span:last-child { font-size: 0.875rem; color: var(--muted); }
.canales { display: grid; grid-template-columns: repeat(auto-fill, minmax(3rem, 1fr)); gap: 0.375rem; }
.canal {
  min-height: 3rem; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface);
  color: var(--ink); font: 650 1rem "Figtree", sans-serif; cursor: pointer;
}
.canal[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.canales-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.preview { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.375rem; }
.preview li { padding: 0.625rem 0.75rem; border-radius: 10px; background: var(--surface-2); display: grid; gap: 0.125rem; min-width: 0; }
code { font: 500 0.8125rem/1.45 ui-monospace, "SF Mono", Menlo, monospace; overflow-wrap: anywhere; }
.preview code { color: var(--muted); }
.snippet { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.5rem 0.5rem 0.875rem; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.snippet code { flex: 1; color: var(--ink); }
.callout { padding: 1rem; border-radius: var(--radius-sm); background: var(--primary-soft); display: grid; gap: 0.625rem; }
.callout.warn { background: var(--warn-soft); }
.callout.danger { background: var(--danger-soft); }
.callout.danger > strong { color: var(--danger); }
.tipo-opt strong { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.tipo-opt strong .chip { font-size: 0.75rem; }
.tipo-opt[aria-pressed="true"] strong .chip { background: var(--surface); }
.guia { border-radius: var(--radius-sm); background: var(--surface-2); padding: 0 1rem; }
.guia summary { list-style: none; cursor: pointer; min-height: 3rem; display: flex; align-items: center; justify-content: space-between; font-weight: 650; }
.guia summary::-webkit-details-marker { display: none; }
.guia summary svg { width: 1.125rem; height: 1.125rem; color: var(--muted); transition: rotate 220ms var(--ease); }
.guia[open] summary svg { rotate: 180deg; }
.guia ol { margin: 0; padding: 0 0 1rem 1.25rem; display: grid; gap: 0.5rem; max-width: 65ch; }
.pistas { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 0.375rem 1rem; }
.pistas dt { font-weight: 650; }
.pistas dd { margin: 0; }
.fields > *, .callout > * { min-width: 0; }
.snippet pre { margin: 0; overflow-x: auto; min-width: 0; padding-block: 0.375rem; }
.snippet:has(pre) { flex-direction: column; align-items: stretch; }
.snippet:has(pre) .btn { align-self: flex-end; }
.head-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.wizard-nav { display: flex; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }

/* ---------- Formularios ---------- */
.fields { display: grid; gap: 1rem; }
.field { display: grid; gap: 0.375rem; align-content: start; }
.field label, .field .label { font-weight: 650; font-size: 0.9375rem; margin: 0; }
.field input, .field select {
  width: 100%; min-height: 3rem; padding: 0 0.875rem; font: 500 1rem "Figtree", sans-serif;
  color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field input::placeholder { color: var(--muted); opacity: 0.85; }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.hint { font-size: 0.875rem; color: var(--muted); }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
@media (max-width: 30rem) { .row2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 59.99rem) { #tray-sub { display: none; } }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 3rem; }
.switch-row label { font-weight: 650; }
.switch { appearance: none; flex: none; width: 3.25rem; height: 2rem; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; transition: background-color 180ms var(--ease); margin: 0; }
.switch::after { content: ""; position: absolute; top: 0.1875rem; left: 0.1875rem; width: 1.625rem; height: 1.625rem; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: translate 200ms var(--ease); }
.switch:checked { background: var(--primary); }
.switch:checked::after { translate: 1.25rem 0; }

/* ---------- Ajustes ---------- */
.settings-grid { display: grid; gap: 1rem; }
.col { display: grid; gap: 1rem; align-content: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.125rem; display: grid; gap: 0.875rem; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); padding: 0.25rem; gap: 0.25rem; background: var(--surface-2); border-radius: var(--radius-sm); }
.segmented button {
  min-height: 2.75rem; border: 0; border-radius: 9px; background: transparent; color: var(--muted);
  font: 650 0.9375rem "Figtree", sans-serif; cursor: pointer; padding: 0 0.5rem;
  transition: background-color 180ms var(--ease), color 180ms var(--ease);
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14); }
.pref { display: grid; gap: 0.5rem; }
.pref > p { font-weight: 650; font-size: 0.9375rem; }
.profile { border-top: 1px solid var(--line); }
.profile summary { list-style: none; cursor: pointer; min-height: 3.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: 0.5rem; }
.profile summary::-webkit-details-marker { display: none; }
.profile summary h3 { text-transform: capitalize; }
.profile summary .muted { font-size: 0.875rem; }
.profile summary svg { transition: rotate 220ms var(--ease); color: var(--muted); }
.profile[open] summary svg { rotate: 180deg; }
.profile .fields { padding-bottom: 1.125rem; }
.table-wrap { overflow-x: auto; }
.status-table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.status-table th { text-align: left; font-size: 0.8125rem; color: var(--muted); font-weight: 650; padding: 0 0.5rem 0.5rem 0; text-transform: capitalize; }
.status-table td { padding: 0.625rem 0.5rem 0.625rem 0; border-top: 1px solid var(--line); vertical-align: middle; }
.status-table td:first-child { font-weight: 650; }

/* ---------- Entrenar ---------- */
.loop { list-style: none; display: flex; flex-wrap: wrap; gap: 0.375rem; padding: 0; margin: 0 0 1.25rem; font-size: 0.875rem; font-weight: 650; color: var(--muted); }
.loop li { display: flex; align-items: center; gap: 0.375rem; }
.loop li span { padding: 0.25rem 0.75rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.loop li:not(:last-child)::after { content: ""; width: 0.875rem; height: 1.5px; background: var(--muted); opacity: 0.5; }
#modelos { display: grid; gap: 1rem; }
.modelo { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.125rem; display: grid; gap: 1.125rem; }
.modelo-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; flex-wrap: wrap; }
.modelo-top p { font-size: 0.9375rem; }
.progress { display: grid; gap: 0.5rem; }
.progress-row { display: flex; justify-content: space-between; gap: 0.75rem; font-size: 0.9375rem; flex-wrap: wrap; }
.bar { height: 0.625rem; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; background: var(--primary); border-radius: inherit; transform-origin: left; transition: transform 600ms var(--ease); }
.particiones { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; margin: 0; }
.particiones div { padding: 0.75rem; border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.particiones dt { font-size: 0.8125rem; color: var(--muted); }
.particiones dd { margin: 0; font-size: 1.375rem; font-weight: 750; }
.job { padding: 0.875rem 1rem; border-radius: var(--radius-sm); display: flex; gap: 0.75rem; align-items: flex-start; background: var(--surface-2); }
.job.ok { background: var(--primary-soft); }
.job.warn { background: var(--warn-soft); }
.job.danger { background: var(--danger-soft); }
.job > div { display: grid; gap: 0.125rem; }
.historial { border-top: 1px solid var(--line); }
.historial summary { cursor: pointer; font-weight: 650; min-height: 3rem; display: flex; align-items: center; justify-content: space-between; list-style: none; }
.historial summary::-webkit-details-marker { display: none; }
.historial summary svg { color: var(--muted); transition: rotate 220ms var(--ease); }
.historial[open] summary svg { rotate: 180deg; }
.historial ul { list-style: none; margin: 0; padding: 0; }
.historial li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.375rem 0.75rem; align-items: center; padding: 0.75rem 0; border-top: 1px solid var(--line); }
.historial .v { font-weight: 750; }
.historial .when { font-size: 0.875rem; color: var(--muted); }
.historial .metricas { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 0.375rem; }

/* ---------- Aviso breve ---------- */
.toast {
  position: fixed; z-index: 20; left: 1rem; right: 1rem; bottom: calc(var(--tabbar) + 1rem + env(safe-area-inset-bottom));
  margin: 0 auto; max-width: 30rem; padding: 0.875rem 1rem; border-radius: var(--radius-sm);
  background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: var(--shadow);
  animation: toast-in 260ms var(--ease);
}
.toast.error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; translate: 0 8px; } }

/* ---------- Escritorio ---------- */
@media (min-width: 60rem) {
  .shell { display: grid; grid-template-columns: 15rem minmax(0, 1fr); grid-template-rows: auto 1fr; min-height: 100vh; }
  .topbar { grid-column: 1 / -1; padding-inline: 1.5rem; }
  .brand-name { display: inline; }
  .galpon-pick { flex: 0 1 20rem; margin-left: auto; }
  .tabs {
    position: sticky; top: 4.1rem; align-self: start; inset: auto; grid-template-columns: 1fr; grid-auto-flow: row; grid-auto-columns: auto; gap: 0.25rem;
    padding: 1rem 0.75rem; background: none; border: 0;
  }
  .tabs a { flex-direction: row; justify-content: flex-start; gap: 0.5rem; min-height: 3rem; padding: 0 0.5rem; font-size: 1rem; }
  .tabs a .ico { width: 2rem; background: none !important; }
  .tabs a:hover { background: var(--surface-2); color: var(--ink); }
  .tabs a[aria-current="page"] { background: var(--primary-soft); }
  .badge { position: static; margin-left: auto; }
  main { padding: 1.75rem 2rem 3rem; margin: 0; width: 100%; }
  .revisar-grid { grid-template-columns: 20rem minmax(0, 1fr); align-items: start; gap: 1.75rem; }
  .lote-col { position: sticky; top: 5.5rem; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats div:first-child { grid-column: 1 / -1; }
  .tray { grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr)); align-items: start; }
  .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  #modelos { grid-template-columns: repeat(auto-fill, minmax(26rem, 1fr)); align-items: start; }
  .toast { bottom: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
.wizard h3[tabindex="-1"]:focus { outline: none; }

/* Teléfonos chicos: la primera tarjeta con sus dos botones tiene que
   entrar sobre la barra de pestañas sin desplazar (contrato, FIRST VIEWPORT). */
@media (max-width: 59.99rem) {
  .stats dt { white-space: nowrap; font-size: 0.75rem; }
  #revisar .view-head { margin-bottom: 0.625rem; }
  #revisar h1 { font-size: 1.375rem; }
  .revisar-grid { gap: 1rem; }
}
@media (max-width: 59.99rem) and (max-height: 820px) {
  .aviso-img { aspect-ratio: 2 / 1; }
  .aviso-body { gap: 0.625rem; padding: 0.875rem 1rem; }
  main { padding-top: 1rem; }
}

/* ---------- En vivo ---------- */
.vivo-grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr)); }
.vivo-tile { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: grid; }
.vivo-tile > button { all: unset; cursor: pointer; display: grid; }
.vivo-tile > button:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.vivo-img { position: relative; aspect-ratio: 16 / 9; background: #0b0f0d; }
.vivo-img img, .vivo-img canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.vivo-img .sin-senal { position: absolute; inset: 0; display: grid; place-items: center; padding: 1rem; text-align: center; color: #c9d3ce; font-size: 0.875rem; }
.vivo-tile figcaption { display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem; padding: 0.625rem 0.875rem; }
.vivo-tile figcaption span { color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.vivo-tile[data-viejo="true"] figcaption span { color: var(--ink); font-weight: 650; }
.vivo-grid[data-foco] { grid-template-columns: minmax(0, 1fr); }
.vivo-grid[data-foco] .vivo-tile:not([data-foco]) { display: none; }
.vivo-foco { display: grid; gap: 0.75rem; padding: 0 0.875rem 0.875rem; }

/* ---------- Ubicación: plano y mapa ---------- */
.cam-modo { margin-bottom: 0.75rem; }
.ubicacion { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.ubic-chips { display: flex; gap: 0.375rem; overflow-x: auto; padding-bottom: 0.25rem; scrollbar-width: thin; }
.ubic-chips .chip-btn { flex: none; }
.chip-btn {
  min-height: 2.75rem; padding: 0 0.875rem; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); font: 600 0.9375rem "Figtree", sans-serif; cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.5rem;
}
.chip-btn[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); }
.chip-btn .sin-ubicar { font-size: 0.75rem; font-weight: 500; color: var(--muted); }
.plano-wrap { overflow-x: auto; }
.plano { display: block; width: 100%; min-width: 36rem; height: auto; cursor: crosshair; touch-action: manipulation; }
.plano-galpon { fill: var(--surface-2); stroke: var(--ink); stroke-width: 3; }
.plano-grilla { stroke: var(--line); stroke-width: 2; }
.plano-cono { fill: color-mix(in srgb, var(--ink) 10%, transparent); }
.plano-cono.sel { fill: color-mix(in srgb, var(--primary) 28%, transparent); }
.plano-cam { fill: var(--ink); stroke: var(--surface); stroke-width: 3; }
.plano-cam.sel { fill: var(--primary); }
.plano-extremo { font: 600 20px "Figtree", sans-serif; fill: var(--muted); }
.plano-label { font: 600 22px "Figtree", sans-serif; fill: var(--ink); paint-order: stroke; stroke: var(--surface-2); stroke-width: 6px; }
.mapa { height: min(60vh, 28rem); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); z-index: 0; }
input[type="range"] { width: 100%; min-height: 2.75rem; accent-color: var(--primary); }
.qr-video { width: 100%; max-height: 50vh; border-radius: var(--radius-sm); background: #0b0f0d; object-fit: cover; }

/* ---------- IA asistente ---------- */
.ia-op { background: var(--surface-2); border-radius: var(--radius-sm); padding: 0.625rem 0.75rem; display: grid; gap: 0.25rem; }
.ia-op p { margin: 0; }
.ia-pedir .btn { width: 100%; }
#orden-ia { margin-top: 0.5rem; }
.aviso-txt { color: var(--ink); font-weight: 650; }
.acuerdo { font-size: 1.0625rem; margin: 0; }

/* ---------- VPN ---------- */
.vpn-estado { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.vpn-equipos { margin: 0; padding-left: 1.25rem; display: grid; gap: 0.25rem; }

/* ---------- Alertas ---------- */
.sub-bloque { display: grid; gap: 0.75rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.sub-bloque:first-child { border-top: 0; padding-top: 0; }
.sub-form { background: var(--surface-2); border-radius: var(--radius-sm); padding: 1rem; }
.lista-simple { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.lista-simple li { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; padding: 0.625rem 0; border-bottom: 1px solid var(--line); }
.lista-simple li > div:first-child { min-width: 0; flex: 1 1 12rem; overflow-wrap: anywhere; }
.fila-acciones { display: flex; gap: 0.375rem; }
.checks { border: 0; margin: 0; padding: 0; display: grid; gap: 0.375rem; }
.checks legend { font-weight: 650; font-size: 0.9375rem; margin-bottom: 0.375rem; padding: 0; }
.check { display: flex; align-items: center; gap: 0.625rem; min-height: 2.75rem; }
.check input { width: 1.25rem; height: 1.25rem; accent-color: var(--primary); }

/* ---------- Sensores ---------- */
.sensores-lote { list-style: none; margin: 0; padding: 0.75rem 0 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: 0.5rem; }
.sensores-lote li { display: grid; gap: 0.125rem; font-size: 0.8125rem; color: var(--muted); }
.sensores-lote strong { font-size: 1.0625rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.sensores-lote li[data-estado="fuera"] strong { color: var(--danger); }
.capacidades { display: grid; gap: 0.5rem; }
.capacidades p { margin: 0; }
.codigos { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem; margin-top: 0.375rem; }

/* ---------- Ajustes: índice con estado y secciones ---------- */
.ajustes { display: grid; gap: 1.25rem; align-items: start; }
.ajustes-indice { display: grid; gap: 0.5rem; }
.indice-grupo { font-size: 0.875rem; font-weight: 650; color: var(--muted); margin: 0.75rem 0 0; letter-spacing: 0; }
.indice-grupo:first-child { margin-top: 0; }
.ajustes-indice ul { list-style: none; margin: 0; padding: 0.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.ajustes-indice li + li { border-top: 1px solid var(--line); }
.ajustes-indice a { border-radius: calc(var(--radius) - 4px); }
.ajustes-indice a {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 0.75rem;
  min-height: 3.5rem; padding: 0.5rem 0.75rem 0.5rem 1rem; color: var(--ink); text-decoration: none;
  transition: background-color 160ms var(--ease);
}
.ajustes-indice a:hover { background: var(--surface-2); }
.ajustes-indice a:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.indice-nombre { font-weight: 600; }
.indice-resumen { font-size: 0.875rem; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.indice-resumen[data-tono="danger"] { color: var(--danger); font-weight: 650; }
.indice-resumen[data-tono="warn"] { color: var(--ink); font-weight: 650; }
.indice-resumen[data-tono="ok"] { color: var(--ok); font-weight: 650; }
.ajustes-indice a svg { width: 1.125rem; height: 1.125rem; color: var(--muted); }
.seccion h2:focus { outline: none; }
.volver { display: inline-flex; align-items: center; gap: 0.25rem; min-height: 2.75rem; color: var(--primary); font-weight: 650; text-decoration: none; justify-self: start; margin: -0.5rem 0 -0.25rem -0.25rem; }
.volver svg { width: 1.25rem; height: 1.25rem; }
.ajustes[data-abierta="true"] .ajustes-indice { display: none; }
@media (min-width: 60rem) {
  .ajustes { grid-template-columns: 22rem minmax(0, 1fr); gap: 1.75rem; }
  /* En escritorio no hace falta el botón de ancho completo del pulgar. */
  .ajustes-detalle .sub-bloque > .btn, .ajustes-detalle .fields > .btn, .ajustes-detalle .fields > a.btn { justify-self: start; }
  .ajustes[data-abierta] .ajustes-indice { display: grid; position: sticky; top: 5.5rem; }
  .ajustes-indice a[aria-current] { background: var(--primary-soft); }
  .ajustes-indice a[aria-current] .indice-nombre { color: var(--primary); }
  .volver { display: none; }
  .cam-modo { max-width: 30rem; }
  .ajustes-detalle .panel { max-width: 48rem; }
}

/* ---------- Informe ---------- */
.lote-col { display: grid; gap: 0.75rem; align-content: start; }
.informe-btn {
  margin-left: auto; width: 2.75rem; height: 2.75rem; display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--primary); cursor: pointer; flex: none;
}
.informe-btn svg { width: 1.375rem; height: 1.375rem; }
.informe-btn:hover { background: var(--surface-2); }
.informe-btn[aria-expanded="true"] { background: var(--primary-soft); border-color: transparent; }
.informe { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.125rem; display: grid; gap: 0.75rem; }
.informe h2 { font-size: 1.0625rem; }
.informe p { margin: 0; max-width: 65ch; }

/* ---------- Acceso (login) ---------- */
body.acceso { min-height: 100vh; display: grid; place-items: center; background: var(--bg); }
.acceso-main { width: min(100% - 2rem, 26rem); display: grid; gap: 1.25rem; padding-block: 2rem; }
.acceso-marca { display: flex; align-items: center; gap: 0.625rem; font-weight: 700; font-size: 1.125rem; }
.acceso-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; display: grid; gap: 1rem; }
.acceso-card h1 { font-size: 1.5rem; }
.acceso-card > .muted { margin: -0.5rem 0 0; }
.acceso-links { display: flex; flex-wrap: wrap; gap: 0.25rem; justify-content: center; }
.acceso-pie { font-size: 0.875rem; text-align: center; margin: 0; }
