/* Henderseeds · sistema de gestión. Pensado para compu/notebook; en el celular sólo se consulta.
   Colores de la marca (los de Astra): azul marino para la estructura, ámbar sólo para marcar dónde estás y lo que
   importa. Archivo para títulos, Public Sans para leer; cifras siempre alineadas en columna. */
:root {
  --navy: #0d2d5e;
  --navy-deep: #0a2149;
  --amber: #f5a623;
  --ink: #15233a;
  --muted: #5b6b82;
  --line: #dde3ec;
  --paper: #f4f6f9;
  --surface: #ffffff;
  --hover: #eef2f8;
  --ok: #1f7a4d;
  --ok-soft: #e9f5ef;
  --error: #b42318;
  --error-soft: #fdeceb;
  --warn: #9a5b00;
  --warn-soft: #fff5e3;
  --radius: 10px;
  --display: "Archivo", "Segoe UI", system-ui, sans-serif;
  --body: "Public Sans", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 var(--body);
  color: var(--ink);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
}

a { color: var(--navy); text-underline-offset: 2px; }
a:hover { color: var(--navy-deep); }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ---- Estructura: barra lateral fija y área de trabajo ---- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 232px;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding: 1rem 0 .75rem;
  background: var(--navy);
  color: #dce5f2;
  overflow-y: auto;
}
.sidebar .brand { display: block; padding: 0 1.25rem; }
.sidebar .brand img { display: block; width: 123px; height: auto; }
/* Compacta para que entre entera en una notebook (768 px de alto), «Salir» incluido. */
.sidebar nav { display: grid; gap: .9rem; }
.nav-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 0 0 .35rem;
  padding: 0 1.25rem;
  font: 600 .72rem/1 var(--display);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #9fb2d0;
}
.nav-title svg {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.nav-group a {
  display: block;
  padding: .34rem 1.25rem .34rem 2.75rem;
  color: #dce5f2;
  text-decoration: none;
  border-left: 3px solid transparent;
}
.nav-group a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-group a[aria-current="page"] {
  background: rgba(255, 255, 255, .09);
  border-left-color: var(--amber);
  color: #fff;
  font-weight: 600;
}
.sidebar .who {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .7rem 1.25rem 0;
  border-top: 1px solid rgba(255, 255, 255, .12);
  font-size: .85rem;
  /* Con poca altura (notebook con la barra del navegador) el menú se desplaza y «Salir» queda siempre a la vista. */
  position: sticky;
  bottom: -.75rem;
  padding-bottom: .75rem;
  background: var(--navy);
}
.sidebar .who span { display: grid; color: #9fb2d0; }
.sidebar .who strong { color: #fff; }
.sidebar .who .link-button { color: #dce5f2; }

main { padding: 1.75rem 2.25rem 3rem; max-width: 84rem; }
body.with-sidebar main { margin-left: 232px; }
body.bare { background: var(--navy); }
body.bare main { max-width: 24rem; margin: 14vh auto 0; padding: 0; }
.login { padding: 2rem; background: var(--surface); border-radius: 14px; box-shadow: 0 24px 60px rgba(0, 0, 0, .28); }
.login-brand { display: block; width: 150px; margin: 0 auto 1.25rem; padding: .9rem 1rem; background: var(--navy); border-radius: 10px; }
.login h1 { text-align: center; font-size: 1.25rem; }
.login button { width: 100%; padding: .7rem; }

.test-base {
  padding: .45rem 2.25rem;
  background: var(--warn-soft);
  border-bottom: 2px solid var(--amber);
  color: var(--warn);
  font-weight: 700;
}
body.with-sidebar .test-base { margin-left: 232px; }

/* ---- Tipografía ---- */
h1 {
  margin: 0 0 1.25rem;
  font: 700 1.65rem/1.2 var(--display);
  letter-spacing: -.01em;
  color: var(--navy);
}
h2 {
  margin: 1.75rem 0 .6rem;
  font: 600 1.1rem/1.3 var(--display);
  color: var(--navy);
}
.muted { color: var(--muted); font-size: .9rem; }

/* ---- Inicio ---- */
.home-search { max-width: 36rem; margin-bottom: 1.75rem; }
.home-search label { display: block; margin-bottom: .35rem; font-weight: 600; }
.home-search div { display: flex; gap: .5rem; }
.home-search input {
  flex: 1;
  padding: .7rem .9rem;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.shortcuts { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; }
.shortcuts a {
  display: grid;
  gap: .3rem;
  padding: 1.1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
}
.shortcuts a strong { font: 600 1.05rem var(--display); color: var(--navy); }
.shortcuts a span { color: var(--muted); font-size: .9rem; }
.shortcuts a:hover { border-color: var(--navy); box-shadow: inset 3px 0 var(--amber); }

/* ---- Acciones de cada pantalla ---- */
.menu { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1.25rem; }
.menu a {
  padding: .5rem 1rem;
  border: 1px solid var(--navy);
  border-radius: 999px;
  color: var(--navy);
  background: var(--surface);
  text-decoration: none;
  font-weight: 600;
  font-size: .92rem;
}
.menu a:hover { background: var(--navy); color: #fff; }
.menu a[aria-current="page"] { background: var(--navy); color: #fff; box-shadow: inset 0 -3px var(--amber); }

button {
  padding: .6rem 1.15rem;
  font: 600 .95rem var(--body);
  color: #fff;
  background: var(--navy);
  border: 1px solid var(--navy);
  border-radius: 8px;
  cursor: pointer;
}
button:hover { background: var(--navy-deep); }
button.secondary { color: var(--navy); background: var(--surface); }
button.secondary:hover { background: var(--hover); }
button.small { padding: .25rem .6rem; font-size: .85rem; margin-top: .35rem; }
button.link-button {
  padding: 0; border: 0; color: var(--navy); background: none; font-weight: 500; text-decoration: underline;
}
.actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }

/* ---- Formularios ---- */
.form-stack { display: grid; gap: 1rem; max-width: 44rem; }
.form-stack.wide { max-width: none; }
.form-stack label { display: block; font-weight: 600; margin-bottom: .25rem; font-size: .92rem; }
.form-stack input, .form-stack select, .form-stack textarea,
.filters input, .filters select {
  width: 100%;
  padding: .55rem .7rem;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid #c9d2df;
  border-radius: 8px;
}
.form-stack input:focus, .form-stack select:focus, .form-stack textarea:focus,
.filters input:focus, .filters select:focus, .home-search input:focus {
  outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(13, 45, 94, .15);
}
.form-stack input[type="checkbox"] { width: auto; }
.form-stack .helptext { display: block; color: var(--muted); font-size: .82rem; }
/* La ayuda va debajo del campo: así los campos de un mismo renglón quedan alineados. */
.form-grid > div { display: flex; flex-direction: column; }
.form-grid > div[hidden] { display: none; }
.form-grid > div > .helptext { order: 3; margin-top: .25rem; }
.form-grid > div > .errorlist { order: 4; }
.form-stack > button { justify-self: start; }
/* Dentro de un formulario (una grilla con separación propia), el subtítulo va pegado a su aclaración: sin márgenes dobles. */
.form-stack > h2 { margin: .6rem 0 -.4rem; }
.form-stack > p { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; }
/* Campos más angostos (seis por renglón en una notebook): los de un mismo grupo (comprobante, importes) no quedan sueltos abajo. */
.form-grid.dense { grid-template-columns: repeat(auto-fill, minmax(8.75rem, 1fr)); }
.form-grid > .group-title { grid-column: 1 / -1; margin: 0 0 -.45rem; font: 600 .74rem/1.3 var(--display); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; margin-bottom: 1rem; }
.filters label { display: grid; gap: .25rem; font-weight: 600; font-size: .88rem; }
.filters .search { flex: 1 1 22rem; }
.filters label.check { display: flex; align-items: center; gap: .4rem; padding-bottom: .6rem; font-weight: 500; }
.filters input, .filters select { width: auto; }
.filters .search input { width: 100%; }
.allocations { display: grid; grid-template-columns: repeat(auto-fill, minmax(26rem, 1fr)); gap: .75rem 1.5rem; }
.allocation label { font-weight: 400; }
details.more summary, details.history summary { cursor: pointer; color: var(--navy); font-weight: 600; }
details.more[open] summary { margin-bottom: .75rem; }
details.history { margin: 1.5rem 0; }
details.history summary { margin-bottom: .5rem; }

/* Bloques opcionales de un formulario (tarjeta, retenciones). */
fieldset.panel, details.panel { margin: 0; padding: .9rem 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
fieldset.panel legend { padding: 0 .35rem; font: 600 .95rem var(--display); color: var(--navy); }
details.panel summary { cursor: pointer; font: 600 .95rem var(--display); color: var(--navy); }
details.panel[open] summary { margin-bottom: .5rem; }
details.panel table input, details.panel table select { min-width: 6rem; }

.panel-inline { margin: 1rem 0; padding: .75rem 1rem; border-left: 4px solid var(--amber); background: var(--warn-soft); border-radius: 0 8px 8px 0; }
.panel-inline p { margin: 0 0 .5rem; }

/* ---- Datos en resumen (fichas y revisiones) ---- */
dl.summary {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .4rem 1.5rem;
  margin: 0 0 1.25rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
/* Ficha del cliente: cuatro pares por renglón, para que la cuenta quede a la vista sin bajar. */
dl.summary.ficha { grid-template-columns: repeat(4, max-content minmax(0, 1fr)); }
@media (max-width: 1100px) { dl.summary.ficha { grid-template-columns: repeat(2, max-content minmax(0, 1fr)); } }
dl.summary dt { color: var(--muted); }
dl.summary dd { margin: 0; }
p.balance {
  display: inline-block;
  margin: .25rem 0 1rem;
  padding: .55rem .9rem;
  font-size: 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  border-radius: 8px;
}
p.balance strong { font: 700 1.2rem var(--display); color: var(--navy); margin-left: .25rem; }
p.balance .sep { color: var(--line); margin: 0 .5rem; }

/* ---- Avisos ---- */
.errorlist { margin: .25rem 0 0; padding: 0; list-style: none; color: var(--error); font-weight: 600; font-size: .9rem; }
.notices { margin: 0 0 1.25rem; padding: 0; list-style: none; display: grid; gap: .5rem; }
.notices li { padding: .75rem 1rem; border-left: 4px solid var(--ok); background: var(--ok-soft); border-radius: 0 8px 8px 0; }
.notices li.error { border-color: var(--error); background: var(--error-soft); }
p.warning:empty { display: none; }
p.warning { margin: 0; padding: .55rem .8rem; border-left: 4px solid var(--amber); background: var(--warn-soft); border-radius: 0 8px 8px 0; }

/* Control de completitud del estado de cuenta: una línea si está bien, abierto si algo falla. */
details.control { margin: 0 0 1.25rem; padding: .6rem 1rem; border-left: 4px solid var(--ok); background: var(--ok-soft); border-radius: 0 8px 8px 0; }
details.control.fail { border-color: var(--error); background: var(--error-soft); }
details.control summary { cursor: pointer; font-weight: 700; }
details.control ul { margin: .5rem 0 .2rem; padding-left: 1.1rem; list-style: none; }

/* ---- Tablas ---- */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: .94rem;
}
/* Compactas (las cuentas son un libro mayor: cada renglón de alto de más es un movimiento menos a la vista). */
th, td { padding: .42rem .7rem; text-align: left; border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
th {
  font: 600 .74rem/1.3 var(--display);
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  background: #f8fafc;
}
tbody tr:hover { background: var(--hover); }
td.cuit, td.nowrap { white-space: nowrap; }
td.name { min-width: 13rem; }
/* Texto largo que no hace falta leer entero en la lista (el proveedor habitual): se corta con «…», entero al pasar el mouse. */
td.clip { max-width: 9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
th.num { text-align: right; }
td.num { text-align: right; white-space: nowrap; }
tr.voided td { color: var(--muted); }
tr.legacy td { background: #fafbfc; color: #3d4b60; }
table + table { margin-top: 1rem; }
table.compact td { padding-top: .3rem; padding-bottom: .3rem; }
table.compact input { padding: .3rem .5rem; }
.form-stack input.apply-input { width: 9rem; text-align: right; }
.form-stack table.invoice-items input { width: 8.5rem; text-align: right; }
/* Estado de un comprobante: una etiqueta chica, con color sólo donde hay que actuar. */
.status { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; background: #eef2f8; color: var(--navy); }
.status-por-facturar, .status-facturado-en-parte, .status-a-revisar { background: var(--warn-soft); color: var(--warn); }
.status-facturado { background: var(--ok-soft); color: var(--ok); }
.status-anulado, .status-anulada, .status-inactivo, .status-revertido { background: #f1f3f6; color: var(--muted); }
.status-vigente, .status-activo, .status-registrado { background: var(--ok-soft); color: var(--ok); }
.status-vencida { background: var(--error-soft); color: var(--error); }
.pager { display: flex; gap: 1rem; justify-content: flex-end; margin-top: .75rem; }
tfoot td { background: #f8fafc; font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; }
/* Guardar siempre a la vista en listas largas. */
.sticky-actions { position: sticky; bottom: 0; z-index: 5; padding: .75rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 -6px 18px rgba(13, 45, 94, .08); }

/* ---- Ítems del remito (Astra): una fila por ítem, el producto ancho y lo demás angosto ---- */
.table-wrap { overflow-x: auto; }
table.items td { vertical-align: top; }
table.items tbody tr:hover { background: none; }
table.items .product-picker { min-width: 22rem; }
.form-stack table.items input { padding: .45rem .55rem; }
.volume-step { display: flex; gap: .25rem; align-items: center; }
.volume-step input { width: 7rem; text-align: right; }
.volume-step button { padding: .3rem .6rem; }
.form-stack table.items input[name$="unit_price"] { width: 8rem; text-align: right; }
.form-stack input.price-input { width: 8rem; text-align: right; }
.item-totals {
  display: flex; flex-wrap: wrap; gap: 2rem; justify-content: flex-end;
  padding: .75rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.item-totals strong { margin-left: .4rem; }
.item-totals span:last-child strong { color: var(--navy); box-shadow: inset 0 -3px var(--amber); }

/* Cliente del remito: buscador ancho con botón para desplegar la lista. */
.remito-header { grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr)); align-items: start; }
.client-field { min-width: 0; grid-column: span 2; }
.client-picker { position: relative; }
.form-stack .client-picker input { padding-right: 2.5rem; }
.client-picker-toggle {
  position: absolute; top: 1px; right: 1px; bottom: 1px; width: 2.2rem; padding: 0;
  color: var(--navy); background: var(--surface); border: 0; border-left: 1px solid var(--line); border-radius: 0 8px 8px 0;
}
.client-picker-toggle:hover { background: var(--hover); }

/* Sugerencias de los buscadores (productos y clientes): flotan sobre la página y se quedan dentro de la pantalla. */
.product-results, .picker-results {
  position: fixed; z-index: 200; overflow: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(13, 45, 94, .18);
  font-size: .93rem;
}
.product-results[hidden], .picker-results[hidden] { display: none; }
.product-count, .picker-count { padding: .35rem .75rem; color: var(--muted); background: #f8fafc; font-size: .78rem; border-bottom: 1px solid var(--line); }
.product-empty, .picker-empty { padding: .75rem; }
.product-option, .picker-option {
  display: flex; gap: .7rem; align-items: center; justify-content: space-between;
  padding: .5rem .75rem; border-bottom: 1px solid #edf1f6; cursor: pointer;
}
.product-option:last-child, .picker-option:last-child { border-bottom: 0; }
.product-option[aria-selected="true"], .product-option:hover,
.picker-option[aria-selected="true"], .picker-option:hover { background: var(--hover); box-shadow: inset 3px 0 var(--amber); }
.product-option[aria-disabled="true"] { color: var(--muted); cursor: default; background: #f8fafc; box-shadow: none; }
.option-code { font-weight: 700; color: var(--navy); }
.client-option { display: grid; grid-template-columns: 1fr; gap: 0; }
.option-cuit { color: var(--muted); font-size: .8rem; }
.option-state { white-space: nowrap; font-size: .8rem; color: var(--warn); }

form.inline-price { display: flex; flex-wrap: wrap; gap: .4rem; }
td.num form.inline-price { justify-content: flex-end; }
form.inline-price input { width: 8rem; padding: .35rem .5rem; font: inherit; border: 1px solid #c9d2df; border-radius: 8px; }
form.inline-price button { padding: .35rem .7rem; font-size: .88rem; }

/* ---- Pantallas angostas: el menú arriba; en el celular las tablas pasan a tarjetas (sólo consulta) ---- */
@media (max-width: 900px) {
  .sidebar { position: static; width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .75rem; padding: .75rem 1rem; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
  .nav-title { display: none; }
  .nav-group { display: flex; flex-wrap: wrap; }
  .nav-group a { padding: .35rem .6rem; border-left: 0; border-bottom: 3px solid transparent; }
  .nav-group a[aria-current="page"] { border-bottom-color: var(--amber); }
  .sidebar .who { margin: 0 0 0 auto; padding: 0; border: 0; }
  body.with-sidebar main, body.with-sidebar .test-base { margin-left: 0; }
  main { padding: 1.25rem 1rem 2rem; }
}
@media (max-width: 640px) {
  table.cards { border: 0; background: none; }
  table.cards thead { display: none; }
  table.cards tr { display: block; margin-bottom: .6rem; padding: .6rem .75rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
  table.cards td { display: flex; justify-content: space-between; gap: 1rem; padding: .15rem 0; border: 0; text-align: right; }
  table.cards td::before { content: attr(data-label); color: var(--muted); font-size: .85rem; text-align: left; }
  table.cards td.clip { max-width: none; white-space: normal; }
}

/* Facturar remitos: cada remito abre con una línea gruesa; los elegidos en la ficha, resaltados. */
@media (min-width: 641px) {
  .form-stack table.invoice-items tr.remito-start td { border-top: 3px solid var(--navy); }
  .form-stack table.invoice-items tr:first-child.remito-start td { border-top: 0; }
  table.invoice-items .remito-repeat { visibility: hidden; }
}
@media (max-width: 640px) { table.invoice-items tr.remito-start { border-top: 3px solid var(--navy); } }
table.invoice-items tr.remito-chosen td { background: var(--warn-soft); }
table.pending-remitos td div + div { margin-top: .15rem; }
table.pending-remitos .status { white-space: nowrap; }
table.pending-remitos + .actions { margin-top: .75rem; }

/* Una sola línea arriba: dónde estás (sección › pantalla) a la izquierda y el TC del BNA (divisa, cierre del día) a la
   derecha, en todas las pantallas. */
.topline { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem 1rem; margin: -.85rem 0 .9rem; font-size: .88rem; color: var(--muted); }
.topline .crumbs a { color: var(--muted); }
.bna-quote { margin: 0 0 0 auto; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.bna-quote strong { color: var(--navy); }

/* Cobro con varios medios: los medios en filas, los totales en dólares a la vista, la diferencia de cambio aparte. */
.collection .media-panel { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; background: var(--surface); }
.collection .panel-head { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; }
.collection .panel-head h2 { margin: 0; }
.add-media { display: flex; flex-wrap: wrap; gap: .4rem; }
.add-media button.small { margin-top: 0; }
.medium { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .75rem; margin: 0 0 .5rem; min-width: 0; }
.medium[hidden] { display: none; }
.medium.in-custody { background: var(--paper); border-style: dashed; }
.medium-fields { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: flex-end; }
.medium-fields > div { display: flex; flex-direction: column; gap: .2rem; flex: 0 1 10rem; min-width: 8rem; }
.medium-fields .f-usd { flex: 1 1 9rem; align-items: flex-end; font-variant-numeric: tabular-nums; color: var(--muted); }
.medium .for-transfer, .medium .for-card, .medium .for-cheque { display: none; }
.medium[data-kind="transferencia"] .for-transfer, .medium[data-kind="tarjeta"] .for-card,
.medium[data-kind="echeq"] .for-cheque, .medium[data-kind="cheque"] .for-cheque { display: flex; }
.medium .f-credit { flex: 0 1 16rem; min-width: 15rem; }
.medium .f-credit .label { font-weight: 600; }
.medium .f-credit > div { display: flex; flex-wrap: wrap; gap: .25rem .9rem; }
.medium .f-credit label { font-weight: 400; display: inline-flex; gap: .3rem; align-items: center; white-space: nowrap; }
.collection-totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; margin: .5rem 0; }
.collection-totals .tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; display: flex; flex-direction: column; gap: .15rem; }
.collection-totals .tile span, .collection-totals .tile small { color: var(--muted); font-size: .85rem; }
.collection-totals .tile strong { font-family: var(--display); font-size: 1.45rem; font-variant-numeric: tabular-nums; }
.collection-totals .tile.buy { background: var(--navy); border-color: var(--navy); color: #fff; }
.collection-totals .tile.buy span, .collection-totals .tile.buy small { color: #c9d6ea; }
.collection-totals .tile.applied strong { color: var(--ok); }
.collection-totals .tile.left { border: 2px solid var(--amber); background: var(--warn-soft); }
.collection-totals .tile.left strong { color: var(--warn); }
.collection-totals .tile.left.done { border-color: var(--ok); background: var(--ok-soft); }
.collection-totals .tile.left.done strong { color: var(--ok); }
.collection-totals .tile.custody { border-style: dashed; }
.apply-cell { display: flex; gap: .4rem; justify-content: flex-end; align-items: center; }
.row-diff.nd { color: var(--warn); font-weight: 600; }
.row-diff.nc { color: var(--navy); font-weight: 600; }
.exchange-preview { background: var(--warn-soft); border: 1px solid #f0d49b; border-radius: var(--radius); padding: .75rem 1rem; }
.exchange-preview h2 { margin-top: 0; color: var(--warn); }
.exchange-preview ul { margin: .25rem 0 .5rem; padding-left: 1.2rem; }
@media (max-width: 900px) { .collection-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.collection-totals .tile.left.over { border-color: var(--error); background: var(--error-soft); }
.collection-totals .tile.left.over strong { color: var(--error); }
p.warning.error { border-left-color: var(--error); background: var(--error-soft); color: var(--error); }

/* Lista de clientes filtrada en vivo: la fila elegida con el teclado se resalta; toda la fila abre el cliente. */
tr[data-url] { cursor: pointer; }
tr[data-url].active td, tr[data-url]:hover td { background: var(--hover); }
tr[data-url].active td:first-child { box-shadow: inset 3px 0 0 var(--amber); }


/* Cobro: lo obligatorio con *, lo que falta en rojo; más compacto y con los totales siempre a la vista. */
abbr.req { color: var(--error); text-decoration: none; font-weight: 700; }
.form-stack input.missing, .form-stack select.missing { border-color: var(--error); box-shadow: 0 0 0 3px rgba(180, 35, 24, .15); background: var(--error-soft); }
.collection .collection-head { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem .9rem; }
.collection .compact-note { margin: .2rem 0 .5rem; font-size: .85rem; }
.collection .media-panel { padding: .6rem .8rem; }
.collection .medium { padding: .45rem .6rem; margin-bottom: .4rem; }
.collection .medium-fields { gap: .35rem .6rem; }
.collection .medium-fields > div { flex: 0 1 8.5rem; min-width: 7rem; gap: .1rem; }
.collection .medium-fields label, .collection .medium-fields .label { font-size: .85rem; }
.collection .medium-fields input, .collection .medium-fields select { padding: .4rem .55rem; }
.collection .medium-fields .f-kind { flex-basis: 9.5rem; }
.collection .medium-fields .f-wide, .collection .medium .f-issuer { flex: 1 1 11rem; }
.collection .medium .f-issued_on, .collection .medium .f-due_on { flex-basis: 9.5rem; }
.collection .medium .f-credit { flex: 0 1 15rem; }
.collection .medium-fields .f-usd { flex: 1 1 10rem; flex-direction: row; justify-content: flex-end; align-items: center; gap: .75rem; }
.collection .collection-totals.sticky { position: sticky; bottom: .5rem; z-index: 5; }
.collection .collection-totals.sticky .tile { padding: .5rem .8rem; box-shadow: 0 6px 18px rgba(13, 45, 94, .12); }
.collection .collection-totals.sticky .tile strong { font-size: 1.25rem; }
.collection .collection-totals.sticky .tile small { font-size: .78rem; }
@media (max-width: 900px) { .collection .collection-head { grid-template-columns: repeat(2, minmax(0, 1fr)); } .collection .collection-totals.sticky { position: static; } }
/* Pasos después del cobro. */
.steps { list-style: none; margin: 1rem 0; padding: 0; display: grid; gap: .9rem; }
.steps .step { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--amber); border-radius: 0 var(--radius) var(--radius) 0; padding: .8rem 1rem; }
.steps .step.done { border-left-color: var(--ok); }
.steps .step h2 { margin: 0 0 .4rem; }
a.button { display: inline-block; padding: .6rem 1.15rem; font: 600 .95rem var(--body); color: #fff; background: var(--navy); border: 1px solid var(--navy); border-radius: 8px; text-decoration: none; }
a.button:hover { background: var(--navy-deep); }
a.button.secondary { color: var(--navy); background: var(--surface); }
a.button.secondary:hover { background: var(--hover); }
/* Fijos abajo, los totales son una franja fina para no tapar lo que se está cargando. */
.collection .collection-totals.sticky { background: var(--paper); padding: .35rem 0; margin: .25rem 0; }
.collection .collection-totals.sticky .tile { padding: .35rem .7rem; gap: 0; }
.collection .collection-totals.sticky .tile strong { font-size: 1.1rem; }
.collection .collection-totals.sticky .tile small { display: none; }


/* Ficha del cliente (Alvaro, 19/10): el estado de un vistazo arriba, los últimos movimientos y lo demás debajo. */
.client-line { margin: .2rem 0 .7rem; }
.summary-tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .65rem; margin: .75rem 0; }
.summary-tiles .tile { display: flex; flex-direction: column; gap: .05rem; padding: .55rem .85rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; transition: border-color .15s; }
.summary-tiles .tile:hover { border-color: var(--navy); }
.summary-tiles .tile span { color: var(--muted); font-size: .82rem; }
.summary-tiles .tile strong { font-family: var(--display); font-size: 1.2rem; font-variant-numeric: tabular-nums; color: var(--navy); }
.summary-tiles .tile small { color: var(--muted); font-size: .8rem; }
.summary-tiles .tile.debt { background: var(--navy); border-color: var(--navy); }
.summary-tiles .tile.debt span, .summary-tiles .tile.debt small { color: #c9d6ea; }
.summary-tiles .tile.debt strong { color: #fff; }
.summary-tiles .tile .overdue { color: #ffd59a; font-weight: 700; }
.summary-tiles .tile.attention { border: 2px solid var(--amber); background: var(--warn-soft); }
.section-head { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: baseline; justify-content: space-between; }
.section-head h2 { margin: 0; }
.recent { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1rem; }
.compact-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; margin-top: .5rem; }
.compact-table th { text-align: left; font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: .3rem .5rem; border-bottom: 1px solid var(--line); }
.compact-table td { padding: .35rem .5rem; border-bottom: 1px solid var(--line); }
.compact-table tr:last-child td { border-bottom: 0; }
.compact-table .num { text-align: right; }
/* El detalle largo se corta con «…»; entero, al pasar el mouse. */
.compact-table td.detail { color: var(--muted); max-width: 30rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compact-table tr.voided td { text-decoration: line-through; color: var(--muted); }
details.client-data { margin-bottom: 1rem; }
details.client-data .ficha { margin: .5rem 0 0; border: 0; padding: 0; }
@media (max-width: 1100px) { .summary-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .summary-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .compact-table td.detail { display: none; } }


/* Estado de cuenta: el saldo arriba; lo anterior a los últimos movimientos, plegado. */
.statement-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
tr.older-toggle td { text-align: center; background: var(--paper); }
tbody.older[hidden] { display: none; }

/* ---- Pulido general (Alvaro, 19/10: «falta un toque de gusto» en las planillas de carga) ---- */
/* Los datos de cada formulario, en una tarjeta: se distinguen del fondo y de las tablas de abajo. */
.form-stack > .form-grid { padding: 1rem 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.form-stack label { color: #33435c; font-size: .86rem; letter-spacing: .01em; }
.form-stack .helptext { font-size: .78rem; }
/* Cada sección con un acento de la marca. */
main h2 { display: flex; align-items: center; gap: .5rem; }
main h2::before { content: ""; flex: none; width: 4px; height: 1.05em; border-radius: 2px; background: var(--amber); }
.collection-totals h2::before, .steps h2::before, .exchange-preview h2::before { display: none; }
/* Tablas: los números alineados y la fila bajo el mouse marcada. */
td.num, .num { font-variant-numeric: tabular-nums; }
tbody tr:hover td { background: #f6f8fc; }
tr.legacy:hover td { background: #f3f5f8; }
/* La acción principal de cada pantalla se distingue de las demás. */
.form-stack .actions button[type="submit"]:not(.secondary):not(.link-button) { padding: .65rem 1.4rem; box-shadow: 0 2px 6px rgba(13, 45, 94, .18); }
/* Encabezados de las tablas, un poco más suaves. */
th { color: #66758c; }


/* Buscador del inicio: los clientes que coinciden, debajo del campo. */
.home-search { position: relative; }
.pick-results { position: absolute; z-index: 10; left: 0; right: 0; top: 100%; margin-top: .25rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 28px rgba(13, 45, 94, .14); overflow: hidden; }
.pick-results a { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem .9rem; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); }
.pick-results a:last-child { border-bottom: 0; }
.pick-results a span { color: var(--muted); font-variant-numeric: tabular-nums; }
.pick-results a.active, .pick-results a:hover { background: var(--hover); box-shadow: inset 3px 0 0 var(--amber); }
.home-search div.pick-results { display: block; }
.home-search div.pick-results[hidden] { display: none; }


/* ---- Pulido A (Alvaro, 21/10): una acción principal, lo destructivo en rojo y aparte, estados en etiqueta ---- */
/* Barra de acciones de una ficha: la principal llena, las frecuentes con borde, el resto dentro de «Más». */
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 0 0 1rem; }
/* Sin línea de datos entre el título y la barra (remito, factura), un poco de aire; en la ficha la da esa línea. */
.title-line + .toolbar { margin-top: .9rem; }
/* Botones de una barra de acciones: un poco más chicos que los de un formulario. */
.toolbar a.button, .statement-tools .actions a.button, .statement-tools .actions button { padding: .5rem 1rem; font-size: .92rem; }
.toolbar a.button:not(.secondary) { box-shadow: 0 2px 6px rgba(13, 45, 94, .2); }
.toolbar a.button.secondary { border-color: #c9d2df; }
details.more-menu { position: relative; }
details.more-menu > summary {
  display: inline-flex; align-items: center; gap: .45rem; padding: .5rem .8rem; border-radius: 8px;
  color: var(--navy); font: 600 .92rem var(--body); cursor: pointer; list-style: none;
}
details.more-menu > summary::-webkit-details-marker { display: none; }
details.more-menu > summary::after { content: ""; width: .4rem; height: .4rem; margin-top: -.25rem; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); }
details.more-menu > summary:hover, details.more-menu[open] > summary { background: var(--hover); }
details.more-menu > div {
  position: absolute; z-index: 30; top: calc(100% + .3rem); left: 0; display: grid; min-width: 15rem; padding: .3rem 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 28px rgba(13, 45, 94, .16);
}
details.more-menu > div a { padding: .45rem .9rem; color: var(--ink); text-decoration: none; }
details.more-menu > div a:hover { background: var(--hover); box-shadow: inset 3px 0 0 var(--amber); }

/* Lo que anula, revierte o rechaza: siempre en rojo, para que no se confunda con un link de consulta. */
a.danger, a.danger:hover { color: var(--error); }
a.button.secondary.danger { color: var(--error); border-color: #e7b4ae; }
a.button.secondary.danger:hover { background: var(--error-soft); }

/* Nombre con su estado al lado. */
.title-line { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .7rem; }
.title-line h1 { margin: 0; }
td .status + .status, td .status + a { margin-left: .3rem; }
/* Segunda línea de una celda (por ejemplo, «Anulada con la NC…»): chica y puede partirse, sin ensanchar la columna. */
td .sub { margin-top: .15rem; white-space: normal; font-size: .82rem; color: var(--muted); }

/* Título de sección con su subtotal a la derecha (en lugar de repetirlo en un renglón aparte). */
.section-head.account-head { margin: 1.5rem 0 .5rem; }
.section-head p.balance { margin: 0; padding: .3rem .7rem; font-size: .92rem; border-left-width: 3px; }
.section-head p.balance strong { font-size: 1rem; }

/* Columna de acciones de cada renglón: a la derecha, en una línea (en el celular, como tarjeta, puede partirse). */
td.row-actions { text-align: right; white-space: nowrap; }
@media (max-width: 640px) { table.cards td.row-actions { white-space: normal; } }

/* Estado de cuenta: filtros a la izquierda, imprimir y guardar a la derecha; la aclaración, al pie. */
.statement-tools { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: end; justify-content: space-between; margin-bottom: 1rem; }
.statement-tools .filters, .statement-tools .menu { margin: 0; }
p.footnote { margin: .6rem 0 0; font-size: .82rem; color: var(--muted); max-width: 60rem; }

/* ---- Cartel de confirmación (antes de pedir el CAE) ---- */
dialog.confirm-dialog {
  width: min(32rem, calc(100vw - 2rem));
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
dialog.confirm-dialog::backdrop { background: rgb(15 30 60 / .45); }
dialog.confirm-dialog h2 { margin-top: 0; }
.notices .button { margin-left: .5rem; }
