/* ═══════════════════════════════════════════════════════════════════
   POS-SAAS-0D.5 · Compras (proveedores, órdenes de compra, recepciones)
   ═══════════════════════════════════════════════════════════════════ */

.purchases { display: grid; gap: var(--s-5); min-width: 0; }
.purchases > * { min-width: 0; }
.purchases .card__head { flex-wrap: wrap; }
.purchases .card__head > :first-child { flex: 1 1 220px; min-width: 0; }

.btn-link { border: 0; background: none; padding: var(--s-1) 0; min-height: 32px; color: var(--c-interact-ink, var(--c-ink)); font: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.btn-link:hover { text-decoration-thickness: 2px; }
.btn-link:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-sm, 4px); }

/* Sugerencias de compra */
.po-suggest__list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-3); }
.po-suggest__item { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; padding: var(--s-3) var(--s-4); border: 1px solid var(--c-accent); border-radius: var(--r-lg); background: var(--c-accent-soft); }
.po-suggest__text { display: grid; gap: 2px; min-width: 0; flex: 1 1 260px; }

.po-table .col-folio, .po-table .col-date, .receipt-table .col-date, .receipt-table .col-po { white-space: nowrap; }
@container (min-width: 981px) { .po-table td.col-status { white-space: nowrap; } }
.po-lines tbody th[scope="row"] { background: transparent; }

/* Detalle de orden */
.po-kv { display: grid; gap: var(--s-1); margin: 0; }
.po-kv__row { display: grid; grid-template-columns: minmax(120px, 160px) 1fr; gap: var(--s-3); align-items: center; }
.po-kv dt { color: var(--c-ink-2); font-size: var(--fs-sm); }
.po-kv dd { margin: 0; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.po-notes { display: flex; gap: var(--s-2); align-items: flex-start; margin: 0; padding: var(--s-3); border-radius: var(--r-md); background: var(--c-surface-2); }
.po-notes .icon { flex: none; width: 18px; height: 18px; margin-top: 2px; }
.po-lines th[scope="row"] { font-weight: 600; }
.po-totals { margin-top: var(--s-2); }
.po-receipts__list { margin: 0; padding-left: var(--s-5); display: grid; gap: var(--s-1); }
@media (max-width: 600px) { .po-kv__row { grid-template-columns: 1fr; gap: 0; } }

/* Recibir mercancía */
.rcv { display: grid; gap: var(--s-4); }
.rcv-line { border: 1px solid var(--c-line); border-radius: var(--r-lg); padding: var(--s-3) var(--s-4); margin: 0; display: grid; gap: var(--s-2); }
.rcv-line__name { padding: 0 var(--s-1); }
.rcv-line__fields { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.rcv-line .field__error:empty, .rcv .form-error:empty { display: none; }
.rcv-line .field__error { color: var(--c-danger); font-weight: 600; font-size: var(--fs-sm); margin: 0; }
.rcv [aria-invalid="true"] { border-color: var(--c-danger); box-shadow: 0 0 0 1px var(--c-danger); }
.rcv .rcv__policy { display: flex; gap: var(--s-2); align-items: flex-start; margin: 0; }
.rcv .rcv__policy .icon { flex: none; width: 18px; height: 18px; margin-top: 2px; }

/* Nueva orden / editar borrador */
.poform { display: grid; gap: var(--s-3); }
.poform__title { font-size: var(--fs-xl); font-weight: 800; }
.poform__h { font-size: var(--fs-md); font-weight: 700; margin-top: var(--s-2); }
.poform__grid { display: grid; gap: var(--s-5); align-items: start; }
@media (min-width: 1000px) {
  .poform__grid { grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); }
  .poform__side { position: sticky; top: calc(var(--topbar-h) + var(--s-4)); }
}
.poform__main { display: grid; gap: var(--s-3); min-width: 0; }
.poform__fields { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.poform .field__error:empty { display: none; }
.poform .field__error { color: var(--c-danger); font-weight: 600; font-size: var(--fs-sm); margin: 0; }
.poform [aria-invalid="true"] { border-color: var(--c-danger); box-shadow: 0 0 0 1px var(--c-danger); }
.poform__side { display: grid; gap: var(--s-3); padding: var(--s-4); background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-xl); box-shadow: var(--shadow-1); }
.poform__side .btn { width: 100%; justify-content: center; }
.poform__sum { display: grid; gap: var(--s-1); }
.polines__list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-3); }
.polines__row { display: grid; gap: var(--s-3); align-items: end; padding: var(--s-3); border: 1px solid var(--c-line); border-radius: var(--r-lg); background: var(--c-surface);
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) minmax(0, 1.2fr) auto; }
.polines__row > .field__error { grid-column: 1 / -1; }
.polines__end { display: flex; align-items: center; gap: var(--s-2); min-height: var(--touch); }
.polines__total { font-weight: 700; min-width: 88px; text-align: right; }
@media (max-width: 760px) {
  .polines__row { grid-template-columns: 1fr 1fr; }
  .polines__supply { grid-column: 1 / -1; }
  .polines__end { grid-column: 1 / -1; justify-content: space-between; }
}

/* Proveedor · panel lateral */
.spl-d { display: grid; gap: var(--s-4); }
.spl-d__block { display: grid; gap: var(--s-2); }
.spl-d__list { margin: 0; padding-left: var(--s-5); display: grid; gap: var(--s-1); }

/* Inventario · editar insumo (proveedores) */
.sup-edit__list { border: 0; padding: 0; margin: 0; display: grid; gap: var(--s-2); }
.poform .btn[data-pol-add] { justify-self: start; }
.rcv-line__fields { align-items: start; }
.inv-table .btn-link { text-align: left; }
