:root{
  --bg:     #f1f5f9;
  --panel:  #ffffff;
  --panel-2:#f8fafc;
  --text:   #1e293b;
  --muted:  #64748b;
  --border: rgba(0,0,0,.10);
  --accent: #7c3aed;
  --danger: #ef4444;
  --success: #16a34a;
  --warn: #d97706;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page{ min-height:100%; display:flex; flex-direction:column; }

.topbar{
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.brand{ display:flex; align-items:center; gap:10px; }
.brand__dot{
  width:10px; height:10px; border-radius:999px;
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(124,58,237,.12);
}
.brand__name{ font-weight:700; letter-spacing:.2px; }

.content{
  flex:1;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 26px;
}

.card{
  width: 100%;
  max-width: 420px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 4px 20px rgba(0,0,0,.07);
}

.card__title{ margin:0; font-size: 24px; }
.card__subtitle{ margin:5px 0 0px; color: var(--muted); font-size: 20px; }

.form{ display:flex; flex-direction:column; gap: 12px; }
.field{ display:flex; flex-direction:column; gap: 6px; margin-bottom: 5px;}
.field__label{ font-size: 12px; color: var(--muted); display:flex; align-items:center; gap:6px; }
.btn-inline-na{ font-size:10px; padding:1px 6px; border-radius:4px; border:1px solid var(--border); background:transparent; color:var(--muted); cursor:pointer; line-height:1.4; }
.btn-inline-na:hover{ color:var(--text); border-color:var(--text); }

.input{
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  outline: none;
  width: 100%;
}
input[type="date"]::-webkit-calendar-picker-indicator{
  cursor: pointer;
  opacity: .6;
}
.input:focus{
  border-color: rgba(124,58,237,.5);
  box-shadow: 0 0 0 3px rgba(124,58,237,.12);
}
.input[readonly]{
  background: #f0f0f0;
  color: var(--muted);
  cursor: not-allowed;
}

.btn{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    line-height: 1.2;
    height: 32px;
    padding: 0 14px;
    border: none;
    border-radius: 10px;
    background: var(--accent);
    text-decoration: none;
    color: white;
    font-weight: 700;
    font-size: inherit;
    white-space: nowrap;
    cursor: pointer;
    margin-bottom: 5px;
}

.btn:hover{ filter: brightness(1.08); }
.btn:active{ transform: translateY(1px); }

.hint{
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.flash-stack{
  position: fixed;
  top: 16px;
  right: 16px;
  display:flex;
  flex-direction:column;
  gap: 10px;
  z-index: 9999;
}

.flash{
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  max-width: 360px;
  box-shadow: 0 6px 24px rgba(0,0,0,.10);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.flash__close{
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  opacity: .6;
}
.flash__close:hover{ opacity: 1; }

.flash--error{ border-color: rgba(239,68,68,.35); background: #fff5f5; }
.flash--success{ border-color: rgba(22,163,74,.35); background: #f0fdf4; }
.flash--warning{ border-color: rgba(217,119,6,.35); background: #fffbeb; }

.actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top: 10px;
}

.btn--ghost{
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn--ghost:hover{
  border-color: rgba(0,0,0,.22);
  background: rgba(0,0,0,.03);
}

.btn--soft-purple{ background:rgba(124,58,237,0.12); color:#7c3aed; border:1px solid #7c3aed; box-shadow:0 1px 4px rgba(124,58,237,0.25); }
.btn--soft-purple:hover{ background:rgba(124,58,237,0.20); }
.btn--soft-red   { background:rgba(220,38,38,0.10);  color:#dc2626; border:1px solid #dc2626; box-shadow:0 1px 4px rgba(220,38,38,0.20); }
.btn--soft-red:hover{ background:rgba(220,38,38,0.18); }
.btn--soft-orange{ background:rgba(234,88,12,0.10);  color:#ea580c; border:1px solid #ea580c; box-shadow:0 1px 4px rgba(234,88,12,0.20); }
.btn--soft-orange:hover{ background:rgba(234,88,12,0.18); }
.btn--soft-yellow{ background:rgba(202,138,4,0.10);  color:#b45309; border:1px solid #ca8a04; box-shadow:0 1px 4px rgba(202,138,4,0.20); }
.btn--soft-yellow:hover{ background:rgba(202,138,4,0.18); }
.btn--soft-green { background:rgba(22,163,74,0.10);  color:#16a34a; border:1px solid #16a34a; box-shadow:0 1px 4px rgba(22,163,74,0.20); }
.btn--soft-green:hover{ background:rgba(22,163,74,0.18); }
.btn--soft-blue  { background:rgba(37,99,235,0.10);  color:#2563eb; border:1px solid #2563eb; box-shadow:0 1px 4px rgba(37,99,235,0.20); }
.btn--soft-blue:hover{ background:rgba(37,99,235,0.18); }

.btn--email{
  background: #671E75;
  color: #fff;
  border: 1px solid #671E75;
  box-sizing: border-box;
  line-height: normal;
  font-size: inherit;
  font-family: inherit;
}

.btn--email:hover{
  background: #4e1659;
  border-color: #4e1659;
}

.btn--email:disabled{
  opacity: .65;
  cursor: not-allowed;
}

.container{
  width: min(1400px, calc(100% - 40px));
  margin: 0 auto;
}

.card{
  width: 100%;
}

.card--wide{
  max-width: none;
}

.split{
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 16px;
  align-items: start;
  margin-top: 12px;
}

@media (max-width: 1100px){
  .split{
    grid-template-columns: 1fr;
  }
}

.grid-2{
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 12px;
}

@media (max-width: 720px){
  .grid-2{
    grid-template-columns: 1fr;
  }
}

.pdf-frame{
  height: calc(100vh - 280px);
  min-height: 260px;
  max-height: 920px;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: #f8fafc;
}

@media (max-width: 1100px){
  .pdf-frame{
    height: 70vh;
    min-height: 420px;
  }
}

.pdf-frame iframe{
  width: 100%;
  height: 100%;
  border: 0;
}

.table-wrap{
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px;
  background: #ffffff;
}

.table{
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.input--cell{
  width: 100%;
  padding: 5px 10px;
  border-radius: 8px;
  margin-bottom: 5px;
}

.split__right{
  position: sticky;
  top: 16px;
}
@media (max-width: 1100px){
  .split__right{ position: static; }
}

.card__head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
}

.card__head-right{
  margin-left:auto;
  display:flex;
  align-items:flex-start;
  gap: 8px;
}

.section-title--center{
  text-align:center;
  margin-bottom: 8px;
  width:100%;
}

.split__left .section-title,
.split__right .section-title{
  margin-top: 0;
}

/* 3 columnas para Customer / Delivery / Other */
.tri-cols{
  display: grid;
  grid-template-columns: repeat(3, minmax(260px, 1fr));
  gap: 10px;
}

@media (max-width: 1200px){
  .tri-cols{ grid-template-columns: 1fr; }
}

/* Panel estilo "caja" interna */
.panel{
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px;
  background: #f8fafc;
}

/* textarea */
.input--textarea{
  min-height: 86px;
  resize: vertical;
}

/* Comments + Totals: 2 columnas */
.bottom-grid{
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 10px;
}

@media (max-width: 980px){
  .bottom-grid{ grid-template-columns: 1fr; }
}

.sep{
  margin: 10px 0;
  opacity: 0.18;
}

/* Country + TaxID en la misma línea (solo donde lo uses) */
.field-row{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 5px;
}
.field-row .field{ margin-bottom: 0; }

@media (max-width: 720px){
  .field-row{ grid-template-columns: 1fr; }
}

/* Products header + acciones */
.lines-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.lines-actions{ display:flex; gap:8px; }

.debug-box{
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: #f8fafc;
  margin: 10px 0 12px;
}

.debug-box summary{
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
}

.debug-pre{
  margin: 10px 0 0;
  padding: 10px;
  border-radius: 8px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  color: var(--text);
}

.dropdown{
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 8px 28px rgba(0,0,0,.10);
}
/* Dropdown absoluto para productos */
.dropdown--product{
  margin-top: 0;
  max-height: 300px;
  overflow-y: auto;
}
.dropdown__item{
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
}
.dropdown__item:hover{
  background: rgba(124,58,237,.07);
}
.dropdown__item:last-child{ border-bottom: 0; }
.dropdown__item--action{
  color: var(--accent);
  font-weight: 600;
  border-top: 1px solid var(--border);
}
.dropdown__item--action:hover{
  background: rgba(124,58,237,.10);
}

/* ── Modal ── */
.modal-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.40);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay[hidden]{ display: none; }
.modal{
  background: var(--panel);
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  padding: 28px 32px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  position: relative;
}
.modal__head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal__title{
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.modal__close{
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  padding: 0 4px;
}
.modal__close:hover{ color: var(--text); }
.modal--new-customer{ max-width: 520px; }

/* New customer sections */
.nc-section{
  margin-bottom: 20px;
}
.nc-section__label{
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 10px;
}
.nc-name-input{
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .9rem;
  color: var(--text);
  background: var(--surface);
  box-sizing: border-box;
}
.nc-name-input:focus{
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,58,237,.12);
}
.nc-download{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

/* Dropzone */
.nc-dropzone{
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.nc-dropzone:hover,
.nc-dropzone--over{
  border-color: var(--accent);
  background: rgba(124,58,237,.04);
}
.nc-dropzone__icon{ font-size: 2rem; display: block; margin-bottom: 8px; }
.nc-dropzone__text{ margin: 0; color: var(--text); font-size: .9rem; }
.nc-dropzone__hint{ margin: 4px 0 0; color: var(--muted); font-size: .78rem; }
.btn-link{
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-size: inherit;
}
.btn-link:hover{ text-decoration: underline; }

/* File list */
.nc-file-list{
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.nc-file-item{
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 12px;
  font-size: .85rem;
}
.nc-file-item__name{
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.nc-file-item__remove{
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 1.1rem;
  padding: 0 0 0 10px;
  flex-shrink: 0;
}
.nc-file-item__remove:hover{ color: var(--danger); }

/* Success modal */
.modal--success{
  max-width: 400px;
  text-align: center;
  padding: 36px 32px;
}
.nc-success-icon{
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  font-size: 1.8rem;
  line-height: 56px;
  margin: 0 auto 16px;
}
.nc-success-title{
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 10px;
}
.nc-success-msg{
  font-size: .9rem;
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}

/* Card específico para confirmación (más estrecho) */
.card--confirmation {
  max-width: 1000px;
  margin: 0 auto;
}

/* Contenedor principal */
.confirmation-content {
  margin-top: 16px;
}

/* Header con SO Number y Status */
.so-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(124, 58, 237, 0.06);
  border-radius: 12px;
  margin-bottom: 20px;
  border: 1px solid rgba(124, 58, 237, 0.18);
}

.so-grid {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 0 75px;
}

.so-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.so-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 600;
}

.so-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
}

.so-status {
  display: flex;
  align-items: center;
}

/* Grid de 3 columnas para las secciones */
.confirmation-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 1100px) {
  .confirmation-grid {
    grid-template-columns: 1fr;
  }
}

/* Secciones */
.conf-section {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.conf-section-title {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

/* Campos dentro de cada sección */
.conf-fields {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.conf-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.conf-field--full {
  grid-column: 1 / -1;
}

.conf-label {
  font-size: 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: bold;
}

.conf-value {
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
}

/* Badge de status */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  width: fit-content;
}

.badge--new {
  background: rgba(22, 163, 74, 0.10);
  color: #15803d;
  border: 1px solid rgba(22, 163, 74, 0.25);
}

.badge--sent {
  background: rgba(26, 111, 181, 0.10);
  color: #1a6fb5;
  border: 1px solid rgba(26, 111, 181, 0.25);
}

.badge--adjust {
  background: rgba(217, 119, 6, 0.10);
  color: #b45309;
  border: 1px solid rgba(217, 119, 6, 0.25);
}

/* Sección de líneas */
.lines-section {
  margin-bottom: 20px;
}

.lines-section .conf-section-title {
  margin-bottom: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px 12px 0 0;
  padding: 12px 14px;
  margin-bottom: 0;
}

.lines-section .table-wrap {
  border-radius: 0 0 12px 12px;
  border-top: none;
}

/* Tabla de confirmación */
.table--confirmation {
  font-size: 13px;
}

.table--confirmation thead th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 12px;
  font-weight: 700;
  color: var(--accent);
}

.table--confirmation tbody td {
  padding: 10px 12px;
  text-align: center;
}

.table--confirmation tbody tr:hover {
  background: rgba(124, 58, 237, 0.04);
  transition: background 0.15s ease;
}

.table--confirmation .sku-code {
  background: rgba(124, 58, 237, 0.08);
  padding: 3px 7px;
  border-radius: 4px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 12px;
  color: var(--accent);
  border: 1px solid rgba(124, 58, 237, 0.18);
  display: inline-block;
}

.text-right {
  text-align: right;
}

/* Filas de totales */
.subtotal-row {
  border-top: 1px solid var(--border);
  font-weight: 600;
}

.subtotal-row td,
.tax-row td {
  padding: 8px 12px;
  font-size: 13px;
  white-space: nowrap;
}

.grand-total-row {
  border-top: 2px solid var(--border);
  font-weight: 700;
  background: rgba(22, 163, 74, 0.04);
}

.grand-total-row td {
  padding: 10px 12px;
  white-space: nowrap;
}

.grand-total-label {
  text-align: right;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 13px;
}

.grand-total-value {
  font-size: 16px;
  color: var(--success);
  font-weight: 700;
}

/* Botones de acciones */
.confirmation-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 16px 0;
}

/* Sólo visible en impresión */
.print-only     { display: none; }
.print-proforma { display: none; }

/* ══ @media print — DISEÑO PROFORMA ══════════════════════════════════════ */
@media print {
  /* ── Reset & ocultar chrome ─────────────────────────────────────────── */
  /* margin:0 elimina el área donde el browser renderiza URL y nro de página */
  @page { margin: 0; size: A4 portrait; }
  body, html { background: #fff !important; margin: 0; padding: 0; }
  .page    { display: block; min-height: unset; }
  .content { display: block !important; padding: 0 !important; }
  .topbar,
  .flash-stack,
  .container,
  div[style*="position:fixed"] { display: none !important; }

  /* ── Mostrar proforma ───────────────────────────────────────────────── */
  .print-proforma {
    display: block !important;
    font-family: 'Century Gothic', CenturyGothic, AppleGothic, Calibri, sans-serif;
    font-size: 8pt;
    color: #000;
    width: 100%;
    /* Los márgenes de página se manejan aquí porque @page margin:0 */
    padding: 14mm 12mm 18mm;
    box-sizing: border-box;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* ── Pie de página personalizado (repetido en cada hoja) ─────────────── */
  .pp-page-footer {
    position: fixed;
    bottom: 5mm;
    left: 12mm;
    right: 12mm;
    text-align: center;
    font-size: 6.5pt;
    font-family: 'Century Gothic', CenturyGothic, AppleGothic, Calibri, sans-serif;
    color: rgba(0, 0, 0, 0.22);
    letter-spacing: 0.8pt;
  }

  /* ── 1. Header ──────────────────────────────────────────────────────── */
  .pp-header {
    display: flex;
    align-items: center;
    gap: 10pt;
    padding-bottom: 7pt;
    margin-bottom: 7pt;
    border-bottom: 2px solid #01788e;
  }
  .pp-logo-col { flex: 0 0 auto; }
  .pp-logo     { height: 25pt; width: auto; }
  .pp-company-col { flex: 1; text-align: center; line-height: 1.5; }
  .pp-company-name   { font-size: 10pt; font-weight: 700; letter-spacing: 0.1pt; margin-bottom: 1pt; color: #000; }
  .pp-company-detail { font-size: 7.5pt; }
  .pp-company-rfc    { font-size: 9pt; font-weight: 700; margin-top: 3pt; color: #000; }
  .pp-folio-col { flex: 0 0 auto; text-align: right; min-width: 95pt; }
  .pp-folio-row { display: flex; justify-content: flex-end; align-items: baseline; gap: 5pt; margin-bottom: 3pt; }
  .pp-folio-label { font-size: 7.5pt; font-weight: 700; color: #01788e; }
  .pp-folio-num   { font-size: 14pt; font-weight: 700; color: #ff0000; }
  .pp-folio-date  { font-size: 8pt; }

  /* ── 2. Addresses ───────────────────────────────────────────────────── */
  .pp-addresses {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border: 1px solid #bbb;
    margin-bottom: 4pt;
    overflow: hidden; /* garantiza grosor uniforme en todos los lados */
  }
  .pp-addr-block      { padding: 5pt 7pt; }
  .pp-addr-block--ship { border-left: 1px solid #bbb; }
  .pp-addr-table { width: 100%; border-collapse: collapse; }
  .pp-ak {
    font-size: 7pt; font-weight: 700; vertical-align: top; color: #01788e;
    padding: 1.5pt 6pt 1.5pt 0; width: 68pt; white-space: nowrap; line-height: 1.4;
  }
  .pp-av {
    font-size: 7.5pt; vertical-align: top;
    padding: 1.5pt 0; line-height: 1.4; word-break: break-word;
  }

  /* ── 3. Meta table ──────────────────────────────────────────────────── */
  .pp-meta-table { width: 100%; border-collapse: collapse; margin-bottom: 3pt; }
  .pp-meta-table thead th {
    background: #01788e; color: #fff;
    font-size: 6.5pt; font-weight: 700;
    padding: 4pt 5pt; border: 1px solid #01788e;
    text-align: left; line-height: 1.3;
  }
  .pp-meta-table tbody td {
    font-size: 8pt; padding: 4pt 5pt;
    border: 1px solid #ccc; vertical-align: top;
  }

  /* ── 4. Lines table ─────────────────────────────────────────────────── */
  .pp-lines-table { width: 100%; border-collapse: collapse; margin-bottom: 5pt; }
  .pp-lines-table thead th {
    background: #01788e; color: #fff;
    font-size: 6.5pt; font-weight: 700;
    padding: 4pt 5pt; border: 1px solid #01788e;
    text-align: center; line-height: 1.3;
  }
  .pp-lines-table tbody td {
    font-size: 8pt; padding: 4pt 5pt;
    border: 1px solid #ddd; text-align: center; vertical-align: middle;
  }
  .pp-lines-table .pp-desc { text-align: left; }
  .pp-lines-table .pp-num  { text-align: right; }
  .pp-lines-table th:nth-child(1),
  .pp-lines-table td:nth-child(1) { width: 7%;  text-align: center; }
  .pp-lines-table th:nth-child(2),
  .pp-lines-table td:nth-child(2) { width: 11%; text-align: center; }
  .pp-lines-table th:nth-child(3),
  .pp-lines-table td:nth-child(3) { width: 13%; text-align: center; }
  .pp-lines-table th:nth-child(4),
  .pp-lines-table td:nth-child(4) { width: auto; }
  .pp-lines-table th:nth-child(5),
  .pp-lines-table td:nth-child(5) { width: 13%; text-align: right; }
  .pp-lines-table th:nth-child(6),
  .pp-lines-table td:nth-child(6) { width: 11%; text-align: right; }

  /* ── 5. Remarks ─────────────────────────────────────────────────────── */
  .pp-remarks { border: 1px solid #ddd; padding: 5pt 7pt; margin-bottom: 5pt; }
  .pp-remarks-body { font-size: 7.5pt; line-height: 1.5; white-space: pre-wrap; }

  /* ── Section label (shared) ─────────────────────────────────────────── */
  .pp-section-label { font-size: 7.5pt; font-weight: 700; color: #01788e; margin-bottom: 2pt; }
  .pp-mt { margin-top: 6pt; }

  /* ── 6. Bottom (amount + totals) ────────────────────────────────────── */
  .pp-bottom {
    display: flex; align-items: flex-start;
    border: 1px solid #ddd; margin-bottom: 5pt;
  }
  .pp-bottom-left  { flex: 1; padding: 5pt 7pt; }
  .pp-bottom-right { flex: 0 0 155pt; padding: 5pt 7pt; }
  .pp-amount-words  { font-size: 8pt; font-weight: 400; line-height: 1.4; margin-bottom: 3pt; }
  .pp-payment-detail { font-size: 7.5pt; line-height: 1.4; }

  .pp-totals-table { width: 100%; border-collapse: collapse; }
  .pp-totals-table td { font-size: 8pt; padding: 2pt 3pt; line-height: 1.5; }
  .pp-total-lbl { text-align: right; font-weight: 600; padding-right: 8pt; white-space: nowrap; color: #01788e; }
  .pp-total-amt { text-align: right; white-space: nowrap; min-width: 55pt; }
  .pp-total-final-row td {
    border-top: 2px solid #01788e; font-weight: 700;
    font-size: 9.5pt; padding-top: 4pt;
  }
  .pp-total-final-amt { font-size: 10pt; }

  /* ── 7. Bank info ───────────────────────────────────────────────────── */
  .pp-bank { border-top: 1px solid #ccc; padding-top: 4pt; }
  .pp-bank-detail { font-size: 7pt; line-height: 1.6; }
}

/* Responsive para móvil */
@media (max-width: 768px) {
  .conf-fields {
    grid-template-columns: 1fr;
  }

  .so-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}

.form-container {
  margin-top: 12px;
}
.form-full {
  max-width: 1200px;
  margin: 0 auto;
}

.form-full .tri-cols {
  grid-template-columns: repeat(3, minmax(260px, 1fr));
}

@media (max-width: 1200px) {
  .form-full .tri-cols {
    grid-template-columns: 1fr;
  }
}

.form-full .form {
  width: 100%;
}

/* ── Topbar right (user + logout) ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand__name {
  text-decoration: none;
  color: inherit;
  font-weight: 700;
  letter-spacing: .2px;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar__user {
  font-size: 13px;
  color: var(--muted);
}

.topbar__logout {
  font-size: inherit;
  padding: 6px 14px;
  font-weight: 700;
}

/* ── Small button variant ── */
.btn--sm {
  padding: 4px 12px;
  font-size: 12px;
  border-radius: 8px;
  font-weight: 600;
}

/* ── Orders Portal ── */
.portal-container {
  padding-top: 20px;
  padding-bottom: 40px;
  align-self: flex-start;
  width: 100%;
}

.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}

.portal-title {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
}

.portal-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.portal-table-wrap {
  border-radius: 14px;
}

.table--portal {
  font-size: 13px;
  min-width: 900px;
}

.table--portal thead th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  text-align: left;
  background: #f8fafc;
}

.table--portal tbody td {
  padding: 11px 14px;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

.table--portal tbody tr:nth-child(odd) {
  background: #fafbfc;
}

.table--portal tbody tr:hover {
  background: rgba(124, 58, 237, 0.05);
}

.portal-so-number {
  font-weight: 700;
  color: var(--accent);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 14px;
}
.portal-proform {
  font-weight: 700;
  color: #4f1fb8;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 15px;
}

.portal-total {
  font-weight: 600;
  white-space: nowrap;
}

.portal-actions-cell {
  white-space: nowrap;
  display: flex;
  gap: 6px;
  align-items: center;
}

.portal-empty {
  text-align: center;
  color: var(--muted);
  padding: 40px;
  font-size: 14px;
}

/* Content alignment for full-width pages */
.content:has(.portal-container) {
  align-items: flex-start;
  justify-content: flex-start;
}

/* ── Portal Toolbar (per-page selector) ── */
.portal-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.portal-perpage-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.portal-perpage-select {
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
}

/* ── Filter row ── */
.filter-row th {
  padding: 6px 8px;
  background: #f1f5f9;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.filter-input {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  outline: none;
  font-family: inherit;
}

.filter-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(124,58,237,.10);
}

.filter-input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

/* ── Pagination ── */
.portal-pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 34px;
  text-align: center;
}

.page-btn--active {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 30px;
  padding: 4px 10px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
}

.page-ellipsis {
  color: var(--muted);
  padding: 0 4px;
  font-size: 13px;
}

.btn:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

/* ── Calculator ──────────────────────────────────────────────────────────── */
.calc-panel { display: flex; flex-direction: column; align-items: center; text-align: center; }
.calc { display: flex; flex-direction: column; gap: 4px; max-width: 160px; }
.calc__display {
  text-align: right;
  font-size: 14px;
  font-weight: 600;
  padding: 4px 8px;
  letter-spacing: 0.5px;
  pointer-events: none;
}
.calc__keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
}
.calc__key {
  padding: 5px 0;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #faf7fb;
  cursor: pointer;
  transition: background 0.1s;
}
.calc__key:hover  { background: #f0e8f5; }
.calc__key:active { background: #e0d0ec; }
.calc__key--fn  { background: #ede6f2; color: #671E75; }
.calc__key--op  { background: #671E75; color: #fff; border-color: #671E75; }
.calc__key--op:hover  { background: #8D5698; }
.calc__key--eq  { background: #8D5698; color: #fff; border-color: #8D5698; }
.calc__key--eq:hover  { background: #671E75; }
.calc__key--zero { grid-column: span 2; text-align: left; padding-left: 8px; }
