:root {
  color-scheme: light;
  --bg: #eef1ec;
  --bg-accent: #e4ece6;
  --ink: #14201a;
  --muted: #5d6a63;
  --line: #d5ddd7;
  --line-strong: #c3cdc6;
  --card: #ffffff;
  --accent: #1f7a4d;
  --accent-ink: #0f3d2e;
  --accent-soft: #e3f3ea;
  --ok: #157a45;
  --ok-bg: #e3f6ea;
  --wait: #9a6700;
  --wait-bg: #fff4d6;
  --bad: #b42318;
  --bad-bg: #fde8e6;
  --info: #175cd3;
  --info-bg: #e8f0fe;
  --shadow: 0 1px 2px rgba(20, 32, 26, 0.06), 0 8px 24px rgba(20, 32, 26, 0.05);
  --radius: 14px;
  --radius-sm: 10px;
  --header-h: 7.5rem;
  --nav-h: 0px;
  --pad: 24px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  font-family: var(--font);
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
  max-width: 100%;
  width: 100%;
}

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 420px at 0% -10%, var(--bg-accent), transparent 60%),
    var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  line-height: 1.45;
  overflow-x: hidden;
  max-width: 100%;
  width: 100%;
}

img, svg { max-width: 100%; display: block; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { touch-action: manipulation; }

a { color: var(--accent); }
a:hover { color: var(--accent-ink); }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, white);
  outline-offset: 2px;
}

.hidden { display: none !important; }

/* ——— Header ——— */
.chrome {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.top {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  justify-content: space-between;
  padding: 12px var(--pad);
  padding-top: calc(12px + env(safe-area-inset-top));
  max-width: 100%;
  min-width: 0;
}
.ambiente-aviso {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px var(--pad);
  background: #fff0b8;
  color: #6f4800;
  border-top: 1px solid #edc653;
  border-bottom: 1px solid #dca51c;
  font-size: 0.94rem;
  text-align: center;
  justify-content: center;
}
.ambiente-aviso b { letter-spacing: 0.06em; }
.ambiente-aviso-icon { font-size: 1.2rem; line-height: 1; }
.top > .sesion {
  /* mobile grid overrides; desktop uses order below */
}
.fecha-mas {
  border: 0;
  padding: 0;
  margin: 0;
}
.fecha-mas > summary {
  list-style: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  padding: 6px 0;
}
.fecha-mas > summary::-webkit-details-marker { display: none; }
.fecha-mas > summary::after {
  content: " ▾";
  font-size: 0.85em;
}

.brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo img,
.logo svg {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(31, 122, 77, 0.28);
  object-fit: contain;
  flex-shrink: 0;
}
.brand-text { min-width: 0; }
.brand-text h1 {
  overflow-wrap: anywhere;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent-ink);
}

.top-tools {
  grid-area: tools;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.fecha {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.fecha input,
.fecha select,
.panel input:not([type="checkbox"]):not([type="radio"]),
.panel select,
.panel textarea,
.form input:not([type="checkbox"]):not([type="radio"]),
.form select,
.form textarea,
.page-liq input:not([type="checkbox"]):not([type="radio"]),
.page-liq select,
.page-liq textarea,
.sel-row select,
.ord-exec select,
.ord-exec input:not([type="checkbox"]):not([type="radio"]) {
  appearance: none;
  background-color: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 8px 10px;
  min-height: 40px;
  width: 100%;
}

select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%235d6a63' d='M1 1.5 L6 6.5 L11 1.5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.fecha input,
.fecha select { min-width: 11.5rem; }

input[type="checkbox"],
input[type="radio"] {
  appearance: auto;
  -webkit-appearance: checkbox;
  accent-color: var(--accent);
  width: 1.35rem;
  height: 1.35rem;
  min-height: 1.35rem;
  min-width: 1.35rem;
  padding: 0;
  margin: 0;
  border-radius: 4px;
  background-color: #fff;
  border: 1px solid var(--line-strong);
  flex: 0 0 auto;
  cursor: pointer;
  vertical-align: middle;
}

.page-liq input[type="checkbox"],
.page-liq input[type="radio"],
.form input[type="checkbox"],
.check-row input[type="checkbox"] {
  appearance: auto;
  -webkit-appearance: checkbox;
  width: 1.35rem;
  height: 1.35rem;
  min-width: 1.35rem;
  min-height: 1.35rem;
  accent-color: var(--accent);
}

.page-liq label.check-row {
  display: flex !important;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
}

td.td-liq {
  width: 2.75rem;
  text-align: center;
  vertical-align: middle;
}
input[type="file"] {
  min-height: 0;
  padding: 6px;
}

.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  min-width: 0;
  padding: 0 var(--pad) 10px;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.tab svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab:hover { background: var(--accent-soft); color: var(--accent-ink); }
.tab.on {
  background: var(--accent-ink);
  color: #fff;
  border-color: var(--accent-ink);
}

.tab-short { display: none; }

/* ——— Stats ——— */
.resumen {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding: 16px var(--pad) 0;
  width: min(1440px, 100%);
  margin-inline: auto;
}

.resumen:empty,
.resumen.is-hidden { display: none; }

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.stat b {
  display: block;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  font-weight: 720;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.stat span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

main {
  padding: 18px var(--pad) 48px;
  width: min(1440px, 100%);
  margin-inline: auto;
}

.page { display: grid; gap: 16px; }
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  justify-content: flex-start;
}
.page-head > div { flex: 1; min-width: 12rem; }
.page-head h2,
.page h2,
.form h2,
.panel h2 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
}
.lede, .muted { color: var(--muted); }
.lede { margin: 4px 0 0; }

.card,
.form,
.otro-cliente-top,
.ck-resumen {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card { padding: 16px 18px; overflow: hidden; }
.card-title,
h3.step {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.card > .table-wrap {
  margin: 12px -18px -16px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
}

.liq-main table { min-width: 520px; }
.form table, .cat-add table { min-width: 0; }
/* table-cards min-width solo desktop — ver @media (min-width: 861px) */

#asiento-detalle { margin-top: 8px; }
#asiento-detalle .table-wrap { margin-top: 12px; }

/* ——— Tables ——— */
.table-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  background: var(--card);
}

th, td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: #f7f9f6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

tbody tr:last-child td { border-bottom: 0; }

table.data { table-layout: auto; }
table.data .col-lote { width: 4.5rem; }
table.data .col-anim { width: 5.75rem; }
table.data .col-money { width: 7.5rem; }
table.data .col-estado { width: 8.5rem; }
table.tablero .col-lote { width: 6%; }
table.tablero .col-prov { width: 42%; }
table.tablero .col-anim { width: 9%; }
table.tablero .col-money { width: 13%; }
table.tablero .col-estado { width: 17%; }
table.data td.prov {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nowrap { white-space: nowrap; }
.num, th.num, td.num,
.money, th.money, td.money {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
th.money, td.money { min-width: 6.75rem; }
th.num, td.num { min-width: 4.5rem; }

.estado {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: #eef1ee;
  color: var(--muted);
  max-width: 100%;
  white-space: nowrap;
}
.estado.listo { color: var(--ok); background: var(--ok-bg); }
.estado.espera,
.estado.incompleto,
.estado.parcial,
.estado.registrado { color: var(--wait); background: var(--wait-bg); }
.estado.liquidado,
.estado.cumplido { color: var(--muted); background: #eef1ee; }
.estado.no_vendido { color: var(--bad); background: var(--bad-bg); }

.row-btn { cursor: pointer; }
.row-btn:hover { background: var(--accent-soft); }
.row-done { opacity: 0.55; }
.row-hi { background: var(--wait-bg) !important; box-shadow: inset 3px 0 0 #e2b65c; }

/* ——— Buttons ——— */
button,
.btn,
a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid var(--accent-ink);
  background: var(--accent-ink);
  color: #fff;
  cursor: pointer;
  font-weight: 650;
  font-size: 14px;
  text-decoration: none;
  min-height: 40px;
}

button:hover,
.btn:hover,
a.button:hover { filter: brightness(1.08); }

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

.ghost,
.actions .ghost,
.form-actions .ghost,
a.button.ghost,
button.ghost {
  background: var(--card);
  color: var(--accent-ink);
  border-color: var(--line-strong);
}

.danger,
.actions .danger {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}

.actions, .form-actions, .sel-row, .ord-exec, .chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.actions, .form-actions { margin-top: 16px; }
.sel-row { margin: 8px 0 12px; }
.sel-row label { font-size: 13px; color: var(--muted); font-weight: 600; }
.sel-row select { width: auto; min-width: 10rem; }

/* ——— Forms ——— */
.grid-2 {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.form { padding: 18px; max-width: none; }
.form label,
.panel label,
.page-liq label {
  display: block;
  margin: 12px 0 5px;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
}

.search-list {
  border: 1px solid var(--line);
  max-height: 180px;
  overflow: auto;
  background: #fff;
  border-radius: 10px;
  margin-top: 6px;
}
.search-list:empty { display: none; }
.search-list button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  min-height: 0;
  font-weight: 500;
}
.search-list button:last-child { border-bottom: 0; }
.search-list button:hover { background: var(--accent-soft); }

.chip {
  font: inherit;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  min-height: 36px;
}
.chip.on {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.labelink, .linkish {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  font-size: 0.9rem;
}

.file-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 650;
}
.file-btn input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  opacity: 0;
}

table.pagos input,
table.pagos select { width: 100%; min-width: 4rem; }
#pagos-suma.warn { color: #b45309; font-weight: 600; }
.animal-pago { min-width: 8rem; max-width: 12rem; }
table.pagos .pago-monto[readonly] { background: #f5f5f4; color: #111; }

.page-liq { padding: 0; max-width: none; }
.page-liq input:not([type="checkbox"]):not([type="radio"]),
.page-liq select,
.page-liq textarea { max-width: none; }

.liq-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 16px;
  align-items: start;
}
.liq-side { display: grid; gap: 16px; position: sticky; top: calc(var(--header-h) + 12px); }
.liquidaciones-parciales { padding: 16px; }
.partial-list { display: grid; gap: 10px; margin-top: 12px; }
.partial-item { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fffdf7; }
.partial-item p { margin: 5px 0 0; }
.partial-actions { display: grid; grid-template-columns: minmax(180px, 1fr) auto; gap: 8px; align-items: end; margin-top: 10px; }
.partial-actions .danger { white-space: nowrap; }
.liq-totals {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 12px;
  background: var(--accent-soft);
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}
.liq-totals p { margin: 0; }
.liq-totals b { font-size: 1.05rem; }

.otro-cliente-top { padding: 14px 16px; margin: 0; }
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 10px;
  cursor: pointer;
}
.check-row input { width: auto; max-width: none; min-height: 18px; accent-color: var(--accent); }

.ck-resumen { padding: 12px 14px; margin: 0; background: var(--accent-soft); box-shadow: none; }
.ck-resumen p { margin: 4px 0; }

.animal-incluir, .animal-otro { width: auto; max-width: none; accent-color: var(--accent); }

.done-liq .ck-list { list-style: none; padding: 0; margin: 0; }
.done-liq .ck-list li { display: flex; gap: 12px; align-items: center; margin: 8px 0; }
.done-liq a.btn { color: #fff; }

.ord-exec {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.ord-cfg, .ord-run {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.ord-step {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  min-width: 4.5rem;
}
.ord-trf-hint { margin: 0; font-size: 12px; width: 100%; }
.ord-exec select,
.ord-exec input { width: auto; min-width: 7rem; max-width: 14rem; padding: 6px 8px; min-height: 38px; }
.ord-exec .ord-medio { min-width: 11.5rem; max-width: 14rem; }
.ord-exec .ord-num, .ord-exec .ord-ref { min-width: 9rem; max-width: 12rem; }
.ord-exec .ord-banco { min-width: 7rem; max-width: 9rem; }
.ord-evid { font-size: 0.9rem; display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px 16px !important;
}

.panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(460px, 100%);
  height: 100dvh;
  max-height: 100dvh;
  background: var(--card);
  border-left: 1px solid var(--line);
  overflow: auto;
  padding: 20px;
  z-index: 45;
  box-shadow: -12px 0 40px rgba(20, 32, 26, 0.12);
}

.toast {
  position: fixed;
  bottom: calc(16px + var(--nav-h) + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-ink);
  color: #fff;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15, 30, 22, 0.28);
  z-index: 60;
  max-width: min(92vw, 420px);
  text-align: center;
}

code {
  font-size: 0.9em;
  background: var(--bg-accent);
  padding: 1px 5px;
  border-radius: 4px;
}


.td-more-toggle { display: none; }
button.linkish {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent-ink);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}
.ord-cta-empty { display: inline-block; max-width: 16rem; line-height: 1.35; padding: 6px 0; }

/* ——— Nav overflow «Más» (mobile) ——— */
.tab-more { display: none; position: relative; flex: 0 0 auto; }
.tab-more-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 4px;
  min-width: 160px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 60;
}
.tab-more-menu.hidden { display: none; }
.tab-more-link {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
  min-height: 44px;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}
.tab-more-link:hover,
.tab-more-link.on { background: var(--accent-soft); color: var(--accent-ink); }
.tab-more-toggle.on { background: var(--accent-soft); color: var(--accent-ink); }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.chip .chip-badge {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--bg-accent);
  border-radius: 999px;
  padding: 1px 6px;
  vertical-align: middle;
}
.stat-secondary { display: none; }
.resumen-more {
  align-self: stretch;
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: pointer;
  min-width: 120px;
}
.resumen.is-expanded .stat-secondary { display: block; }
.resumen.is-expanded .resumen-more { display: none; }
.empty-tone { color: var(--muted); text-align: center; padding: 18px 12px; }
.empty-state {
  display: grid;
  gap: 10px;
  justify-items: start;
  padding: 18px 16px;
  background: var(--accent-soft);
  border: 1px dashed color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: var(--radius);
  max-width: 100%;
}
.empty-state h3 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--accent-ink);
  letter-spacing: -0.02em;
  text-transform: none;
}
.empty-state p { margin: 0; color: var(--muted); max-width: 36rem; }
.empty-state .btn,
.empty-state button[type="button"] {
  margin-top: 4px;
}
#form-cuenta-banco.is-spotlight {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, white);
  outline-offset: 4px;
  border-radius: var(--radius-sm);
}

/* ——— Responsive tables as cards ——— */
@media (max-width: 860px) {
  :root {
    --pad: 14px;
    --nav-h: 76px;
    --header-h: auto;
  }

  .resumen,
  main { width: 100%; max-width: 100%; }

  .chrome { border-bottom: 1px solid var(--line); max-width: 100%; }
  .chrome { overflow: visible; }
  .top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand sesion"
      "tools tools";
    gap: 8px 10px;
    padding: 8px var(--pad) 10px;
    padding-top: calc(8px + env(safe-area-inset-top));
    align-items: center;
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
    overflow-y: visible;
  }
  .top > .brand {
    grid-area: brand;
    min-width: 0;
    max-width: 100%;
    position: relative;
    z-index: 1;
  }
  .top > .sesion {
    grid-area: sesion;
    margin-left: 0;
    width: auto;
    max-width: 42vw;
    justify-self: end;
    align-self: start;
    position: relative;
    z-index: 1;
  }
  .top > .top-tools {
    grid-area: tools;
    justify-content: stretch;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    position: relative;
    z-index: 0;
    overflow-x: clip;
    overflow-y: visible;
  }
  .fecha { flex: 1; min-width: 0; width: 100%; max-width: 100%; }
  .fecha input, .fecha select { min-width: 0 !important; width: 100%; max-width: 100%; font-size: 16px; }
  .fecha-hint { white-space: normal !important; overflow-wrap: anywhere; max-width: 100%; }
  .fecha-wrap { max-width: 100%; min-width: 0; }
  .fecha-mas { max-width: 100%; min-width: 0; }
  .logo img,
  .logo svg { width: 28px; height: 28px; border-radius: 7px; }
  h1 { font-size: 1.1rem; }
  .eyebrow { font-size: 10px; letter-spacing: 0.1em; }

  .tabs {
    position: fixed !important;
    top: unset !important;
    bottom: 0 !important;
    left: 0;
    right: 0;
    width: 100%;
    grid-area: unset;
    z-index: 50;
    display: flex;
    flex-wrap: nowrap;
    gap: 2px;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--card) 94%, transparent);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  /* Primary 4 + Más: no aplastar 6 tabs con flex:1 */
  .tab.tab-pri {
    flex: 1 1 0;
    min-width: 0;
  }
  .tab.tab-overflow { display: none !important; }
  .tab-more {
    display: flex;
    justify-content: center;
    flex: 1 1 0;
    min-width: 0;
    overflow: visible;
    position: relative;
    z-index: 80;
  }
  .tabs {
    overflow: visible;
    z-index: 70;
  }
  /* Menú fuera del bar: no lo tape overflow/backdrop del nav */
  .tab-more-menu {
    position: fixed;
    bottom: calc(var(--nav-h) + 10px);
    right: 10px;
    left: auto;
    min-width: 180px;
    max-width: calc(100vw - 20px);
    z-index: 90;
    box-shadow: 0 12px 40px rgba(20, 32, 26, 0.22);
  }

  .tab {
    flex-direction: column;
    gap: 3px;
    border-radius: 10px;
    padding: 6px 2px;
    font-size: 11px;
    min-height: 52px;
    border: 0;
  }
  .tab-more-toggle {
    width: 100%;
    flex-direction: column;
    gap: 3px;
    border-radius: 10px;
    padding: 6px 2px;
    font-size: 11px;
    min-height: 52px;
    border: 0;
  }
  .tab svg, .tab-more-toggle svg { width: 20px; height: 20px; }
  .tab.on {
    background: var(--accent-soft);
    color: var(--accent-ink);
  }
  .tab-full { display: none; }
  .tab-short { display: inline; }

  /* Tablero cards: primario Lote·Proveedor·Estado */
  .table-cards.tablero td[data-col="Animales"],
  .table-cards.tablero td[data-col="Bruto"],
  .table-cards.tablero td[data-col="Adelanto vivo"] {
    display: none;
  }
  .table-cards.tablero tr.is-open td[data-col="Animales"],
  .table-cards.tablero tr.is-open td[data-col="Bruto"],
  .table-cards.tablero tr.is-open td[data-col="Adelanto vivo"] {
    display: flex;
  }
  .table-cards.tablero td.td-more-toggle {
    display: flex;
    border-bottom: 0;
    padding-top: 2px;
  }
  .table-cards.tablero td.td-more-toggle::before { display: none; }
  .table-cards.tablero tr.is-open td.td-more-toggle .btn-more-detalle::after {
    content: " · menos";
  }

  .chip-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    max-width: 100%;
    width: 100%;
    min-width: 0;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    overscroll-behavior-x: contain;
  }
  .chip-row .chip {
    flex: 0 0 auto;
    scroll-snap-align: start;
  }

  .resumen {
    display: flex;
    overflow-x: auto;
    max-width: 100%;
    min-width: 0;
    width: 100%;
    gap: 10px;
    scroll-snap-type: x mandatory;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    contain: inline-size;
    scrollbar-width: none;
  }
  .resumen::-webkit-scrollbar { display: none; height: 0; }
  .stat {
    min-width: 0;
    flex: 0 0 auto;
    width: clamp(132px, 42vw, 160px);
    max-width: calc(100% - 4px);
    scroll-snap-align: start;
  }
  .stat b { font-size: 1.15rem; }

  main { padding: 14px var(--pad) calc(var(--nav-h) + 20px); }
  .grid-2, .liq-grid { grid-template-columns: 1fr; }
  .liq-side { position: static; }
  .partial-actions { grid-template-columns: 1fr; }
  .card { overflow: visible; }

  .table-cards thead { display: none; }
  .table-cards,
  .table-cards tbody,
  .table-cards tr,
  .table-cards td { display: block; width: 100%; min-width: 0; }
  /* Beat base `table` / `table.table-cards` min-width (760/720) so cards don't force page scroll @390 */
  table,
  table.table-cards,
  table.data.table-cards,
  table.tablero.table-cards {
    min-width: 0 !important;
    width: 100%;
    max-width: 100%;
  }
  .table-cards { min-width: 0; }
  .table-cards colgroup { display: none; }
  .table-cards { table-layout: auto; }
  .table-wrap:has(.table-cards),
  .page,
  main {
    max-width: 100%;
    min-width: 0;
  }
  .table-wrap:has(.table-cards) {
    background: transparent;
    border: 0;
    box-shadow: none;
    overflow-x: clip;
    overflow-y: visible;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
  }
  html, body, #app {
    overflow-x: clip;
    max-width: 100%;
  }
  .page {
    overflow-x: clip;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
  }
  .table-cards tr {
    max-width: 100%;
    box-sizing: border-box;
  }
  .table-cards tbody { display: grid; gap: 10px; }
  .table-cards tr {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 10px 12px 6px;
  }
  .table-cards td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px dashed var(--line);
    text-align: right;
    white-space: normal;
  }
  .table-cards td.prov,
  .table-cards td.money,
  .table-cards td.num,
  .table-cards td.nowrap { white-space: normal; text-align: right; }
  .table-cards td:last-child { border-bottom: 0; }
  .table-cards td::before {
    content: attr(data-col);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: left;
    flex: 0 0 42%;
  }
  .table-cards td[colspan]::before,
  .table-cards td.empty::before { display: none; }
  .table-cards td[colspan],
  .table-cards td.empty {
    display: block;
    text-align: center;
  }
  .table-cards td[data-col="Acción"],
  .table-cards td[data-col="Acciones"],
  .table-cards td[data-col="Estado"],
  .table-cards td[data-col="Evidencia"] {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
  }
  .table-cards td[data-col="Acción"]::before,
  .table-cards td[data-col="Acciones"]::before {
    flex: none;
    margin-bottom: 6px;
  }
  .table-cards .ord-exec {
    width: 100%;
    justify-content: stretch;
  }
  .table-cards .ord-exec select,
  .table-cards .ord-exec input { max-width: none; flex: 1 1 100%; width: 100%; }
  .card > .table-wrap {
    margin: 12px 0 0;
    overflow: visible;
  }

  .page-head { align-items: stretch; max-width: 100%; min-width: 0; }
  .page-head > div { min-width: 0; flex: 1 1 auto; }
  .page-head .estado { align-self: flex-start; }
  .table-wrap {
    max-width: 100%;
    min-width: 0;
    overscroll-behavior-x: contain;
  }
  .tabs {
    max-width: 100%;
    overscroll-behavior-x: contain;
  }

  input, select, textarea { font-size: 16px; }
}

@media (max-width: 520px) {
  h1 { font-size: 1.05rem; }
  .logo img,
  .logo svg { width: 26px; height: 26px; }
  .top-tools { flex-direction: column; }
  .actions, .form-actions { flex-direction: column; align-items: stretch; }
  .actions button, .form-actions button, .btn { width: 100%; }
  .ord-exec button { flex: 1 1 auto; }
  .sesion strong { max-width: 7.5rem; }
}

@media (max-width: 480px) {
  /* KPIs apilados: evita scrollWidth > clientWidth en phones angostos */
  .resumen {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: hidden !important;
    width: 100%;
    max-width: 100%;
    gap: 8px;
    scroll-snap-type: none !important;
    contain: none;
  }
  .stat {
    min-width: 0 !important;
    width: auto !important;
    max-width: 100% !important;
    flex: unset !important;
    padding: 10px 12px;
  }
  .resumen-more { grid-column: 1 / -1; width: 100%; }
}

@media (max-width: 400px) {
  :root { --pad: 10px; }
  html, body, #app, .chrome, main, .resumen, .page, .page-head {
    max-width: 100%;
    min-width: 0;
  }
  html, body { overflow-x: hidden; }
  .top {
    gap: 6px 8px;
    padding: 8px var(--pad) 8px;
    padding-top: calc(8px + env(safe-area-inset-top));
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  .brand {
    gap: 8px;
    max-width: 100%;
    min-width: 0;
  }
  .brand-text {
    min-width: 0;
    overflow: hidden;
  }
  .brand-text h1 {
    font-size: 0.95rem;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .eyebrow {
    letter-spacing: 0.06em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .logo { flex-shrink: 0; }
  .logo img,
  .logo svg { width: 24px; height: 24px; border-radius: 6px; }
  h1 { font-size: 0.95rem; }
  .top > .sesion {
    max-width: 42vw;
    min-width: 0;
  }
  .sesion strong {
    max-width: 100%;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* KPIs: stack/wrap — no carrusel que expanda scrollWidth */
  .resumen {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    gap: 8px;
    scroll-snap-type: none;
    padding-left: var(--pad);
    padding-right: var(--pad);
    box-sizing: border-box;
  }
  .stat {
    min-width: 0 !important;
    flex: unset !important;
    width: auto;
    max-width: 100%;
    padding: 10px 12px;
    box-sizing: border-box;
  }
  .stat b { font-size: 1.05rem; }
  .resumen-more {
    grid-column: 1 / -1;
    width: 100%;
    box-sizing: border-box;
  }
  .page-head h2 { font-size: 1.05rem; }
  .tabs { max-width: 100%; box-sizing: border-box; }
}

@media (max-width: 1400px) {
  #sesion-rol { display: none; }
}
@media (min-width: 861px) and (max-width: 1180px) {
  .top { flex-wrap: wrap; }
}


@media (max-width: 400px) {
  .chip .chip-badge { display: none; }
  .chip {
    padding: 6px 10px;
    font-size: 13px;
    min-height: 34px;
  }
  .chip-row {
    gap: 6px;
    scrollbar-width: none;
    padding-right: 12px; /* peek / no cortar último */
  }
  .chip-row::-webkit-scrollbar { display: none; }
}


/* Dual lede / chip labels: short on mobile (≤860 = same as bottom nav) */
.lede-short { display: none; }
.chip-label-short { display: none; }
.chip-label-long { display: inline; }
.form-mas-datos {
  grid-column: 1 / -1;
  margin: 4px 0;
  padding: 8px 10px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm, 8px);
  background: var(--bg-accent, transparent);
}
.form-mas-datos > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  font-size: 13px;
}
.form-mas-datos[open] > summary { margin-bottom: 8px; }
.form-mas-datos label { display: block; margin-top: 8px; }
.form-cuenta-wizard {
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  align-items: start;
}
.form-cuenta-wizard .cuenta-pick,
.form-cuenta-wizard .cuenta-pick,
.form-cuenta-wizard .check-row,
.form-cuenta-wizard > button { grid-column: 1 / -1; }
.sistema-catalogo {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  background: var(--card);
}
.sistema-catalogo > summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.02em;
}
.sistema-catalogo[open] > summary { margin-bottom: 12px; }
.sistema-catalogo-grid { margin-top: 4px; }
.btn-asignar-access { margin-bottom: 8px; }
.bancos-cuentas-first > .empty-state { order: 0; }

@media (max-width: 860px) {
  .lede-full { display: none; }
  .lede-short { display: block; }
  .chip-label-long { display: none; }
  .chip-label-short { display: inline; }
}

@media (max-width: 480px) {
  .resumen:not(.is-hidden) {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: hidden !important;
    width: 100%;
    max-width: 100%;
    gap: 8px;
    scroll-snap-type: none;
  }
  .resumen .stat {
    min-width: 0 !important;
    width: auto !important;
    max-width: 100% !important;
    flex: unset !important;
    box-sizing: border-box;
  }
  html, body, #app, .chrome, main, .page, .table-wrap {
    max-width: 100%;
    box-sizing: border-box;
  }
  .table-cards,
  .table-cards tr,
  .table-cards td {
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0 !important;
  }
  .table-wrap:has(.table-cards) {
    overflow-x: hidden;
    max-width: 100%;
  }
}

@media (max-width: 400px) {
  .empty-state {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--accent-soft);
    box-shadow: 0 8px 16px color-mix(in srgb, var(--bg) 70%, transparent);
  }
  .empty-state .lede-short { display: block; margin: 0; }
  .empty-state .lede-full { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

body.locked { overflow: hidden; }
.login {
  position: fixed;
  inset: 0;
  z-index: 80;
  background:
    radial-gradient(1200px 420px at 0% -10%, var(--bg-accent), transparent 60%),
    var(--bg);
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.login-brand { margin-bottom: 8px; }
.login-brand h2 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  color: var(--accent-ink);
}
.login-card h2 { margin: 8px 0 16px; }
.login-card label {
  display: block;
  margin: 10px 0 4px;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
}
.login-card input,
.login-card select {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #fff;
}
.login-card button[type="submit"] { width: 100%; margin-top: 16px; }
.login-error { color: var(--bad); font-size: 14px; font-weight: 600; }
.sesion {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.sesion strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.sesion #sesion-rol {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sesion-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.sesion .ghost { min-height: 32px; padding: 4px 10px; font-size: 12px; }
.sistema-grid { display: grid; gap: 18px; }
.sistema-card { padding: 16px 18px; }
.asiento-mapa { display: grid; gap: 12px; }
.destino {
  display: grid;
  grid-template-columns: 4.8rem minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 16px 18px;
}
.destino-lado {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding-top: 4px;
}
.destino.debe { border-left: 4px solid var(--ok); }
.destino.haber { border-left: 4px solid var(--wait); }
.destino h3 { margin: 0 0 4px; font-size: 1.05rem; }
.destino-cuenta {
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
  margin: 10px 0 8px;
}
.destino-cuenta code { font-size: 1.05rem; background: var(--bg-accent); padding: 2px 8px; border-radius: 6px; }
.cuenta-pick { max-width: 36rem; }
.cuenta-pick input { width: 100%; margin-top: 4px; }
.cat-add {
  display: grid;
  grid-template-columns: minmax(8rem, 12rem) minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: end;
  margin-top: 12px;
}
.cat-add label { margin: 0; }
.cat-add input[type="checkbox"] { width: auto; min-height: 18px; }
.user-add {
  display: grid;
  grid-template-columns: 8rem 1fr 10rem auto;
  gap: 8px;
  align-items: end;
  margin-top: 12px;
}
@media (max-width: 900px) {
  .cat-add, .user-add { grid-template-columns: 1fr; }
}
@media (min-width: 861px) {
  .fecha-mas > summary { display: none; }
  .fecha-mas:not([open]) > *:not(summary) { display: block !important; }
  .top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
  }
  .top > .brand { order: 1; }
  .top > .top-tools {
    order: 2;
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
  }
  .top > .sesion { order: 3; margin-left: 12px; }
}

.form-adel-slim { margin-bottom: 16px; }
.adel-fields {
  display: grid;
  grid-template-columns: minmax(12rem, 2fr) minmax(7rem, 1fr) minmax(10rem, 1.4fr);
  gap: 12px;
  align-items: start;
}
.adel-field-prov { min-width: 0; }
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.pill-liq { background: var(--info-bg); color: var(--info); }
.pill-adel { background: var(--wait-bg); color: var(--wait); }
@media (max-width: 720px) {
  .adel-fields { grid-template-columns: 1fr; }
}

.fecha-wrap { display: flex; flex-direction: column; gap: 2px; justify-content: flex-end; }
.fecha-hint { font-size: 0.75rem; white-space: nowrap; }
.fecha-ventana { font-size: 0.85rem; align-items: center; gap: 6px; }
@media (max-width: 720px) {
  .fecha-hint { white-space: normal; }
}


.page-liq .lede,
.page-liq .page-head h2 {
  overflow: visible;
  text-overflow: unset;
  white-space: normal;
}


.liq-lock-warn {
  margin: 10px 0 6px;
  padding: 10px 12px;
  border: 1px solid #f59e0b;
  background: #fffbeb;
  border-radius: 10px;
  color: #78350f;
  font-size: 14px;
}
.liq-lock-warn p { margin: 0; }
.liq-confirm {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 24, 22, 0.45);
  padding: 16px;
}
.liq-confirm.hidden { display: none; }
.liq-confirm-card {
  background: var(--card, #fff);
  border: 1px solid var(--line-strong, #ccc);
  border-radius: 12px;
  padding: 18px 20px;
  max-width: 26rem;
  width: 100%;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
}
.liq-confirm-card h3 { margin: 0 0 8px; }
.liq-confirm-card p { margin: 0 0 14px; color: var(--muted, #555); }


@media (min-width: 861px) {
  /* Desktop: tablas anchas con scroll horizontal en .table-wrap */
  table:not(.table-cards) {
    min-width: 760px;
  }
  table.table-cards {
    min-width: 720px;
  }
}
