:root {
  --bg: #ffffff;
  --bg-soft: #f7f7f5;
  --card: #ffffff;
  --card-soft: #fcfbf9;
  --text: #2b2b2b;
  --muted: #6b6b6b;
  --accent: #b94128;
  --accent-dark: #a33a23;
  --accent-soft: #c96a52;
  --border: #e5e2de;
  --success: #b94128;
  --error: #a33a23;
  --shadow-soft: 0 12px 30px rgba(43, 43, 43, 0.06);
  --shadow-subtle: 0 4px 14px rgba(43, 43, 43, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  background: linear-gradient(180deg, #ffffff 0%, #f7f7f5 100%);
  color: var(--text);
}

.landing-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(185, 65, 40, 0.12), transparent 30%),
    radial-gradient(circle at bottom right, rgba(201, 106, 82, 0.14), transparent 32%),
    linear-gradient(180deg, #fffdfa 0%, #f4f0eb 100%);
}

.landing-hero {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 420px);
  gap: 28px;
  padding: 40px;
  border: 1px solid rgba(185, 65, 40, 0.12);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 24px 60px rgba(43, 43, 43, 0.08);
  backdrop-filter: blur(6px);
}

.landing-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}

.landing-eyebrow {
  display: inline-flex;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(185, 65, 40, 0.08);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.landing-copy h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 4rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
}

.landing-text {
  margin: 0;
  max-width: 34rem;
  color: #585551;
  font-size: 1rem;
  line-height: 1.7;
}

.landing-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
  justify-content: center;
}

.landing-button,
.landing-button-link {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  padding: 22px 24px;
  border-radius: 20px;
  text-align: left;
  text-decoration: none;
}

.landing-button {
  position: relative;
  overflow: hidden;
  align-items: flex-start;
  border: 1px solid rgba(185, 65, 40, 0.18);
  background: linear-gradient(180deg, #fff 0%, #f9f4ef 100%);
  color: var(--text);
  box-shadow: 0 12px 24px rgba(43, 43, 43, 0.06);
}

.landing-button::before {
  content: "";
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-position: right 18px center;
  background-size: 118px auto;
  opacity: 0.13;
  pointer-events: none;
}

.landing-button > * {
  position: relative;
  z-index: 1;
}

.landing-button-industrial::before {
  background-image: url("/logo-dimap-industrial.png");
}

.landing-button-salas::before {
  background-image: url("/logo-salas-dimap..png");
}

.landing-button-link {
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.landing-button-link:hover {
  transform: translateY(-2px);
  border-color: var(--accent-soft);
  box-shadow: 0 18px 28px rgba(185, 65, 40, 0.14);
}

.landing-button.is-disabled {
  cursor: not-allowed;
  color: #8b8177;
  background: linear-gradient(180deg, #f2efea 0%, #ebe6e0 100%);
  border-color: rgba(107, 107, 107, 0.18);
  box-shadow: none;
}

.landing-button.is-disabled::before {
  opacity: 0.08;
}

.landing-button-title {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.landing-button-meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.page {
  max-width: 960px;
  margin: 32px auto;
  padding: 0 16px 48px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 14px 0 18px;
  border-bottom: 1px solid var(--border);
}

h1, h2 {
  margin: 0 0 8px 0;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-soft);
}

.doc-id {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

input, select, button {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
}

textarea {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
  resize: vertical;
  min-height: 90px;
}

input,
select,
textarea {
  background: #fff;
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(185, 65, 40, 0.12);
}

button {
  background: var(--accent);
  color: white;
  border: 1px solid var(--accent);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.message {
  font-size: 14px;
  min-height: 18px;
}

.message.success {
  color: var(--success);
}

.message.warning {
  color: var(--warning);
}

.message.error {
  color: var(--error);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: #fff;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.btn.secondary {
  background: #fff;
}

.admin-password-submit {
  width: auto;
  min-width: 140px;
  justify-self: start;
  align-self: end;
}

.btn:hover,
.btn.secondary:hover {
  background: var(--bg-soft);
  border-color: var(--accent-dark);
  color: var(--accent-dark);
}

.hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.menu {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  text-decoration: none;
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-subtle);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.menu-item:hover {
  background: var(--bg-soft);
  border-color: var(--accent-soft);
  transform: translateY(-1px);
}

#adminMenuItem {
  display: none;
}

#adminInvoicesMenuItem {
  display: none;
}

#adminDocumentValidationMenuItem,
#adminDocumentValidationPromptsMenuItem {
  display: none;
}

.list-item {
  display: grid;
  grid-template-columns: 1.2fr 0.6fr 0.8fr 0.8fr 0.6fr;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-soft);
}

.list-header {
  font-weight: 600;
  background: var(--bg-soft);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 12px;
}

.list-item.admin {
  display: block;
  padding: 12px;
}

.list-item.admin.selectable {
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.list-item.admin.selectable:hover {
  background: var(--bg-soft);
  border-color: var(--accent-soft);
}

.admin-row-top {
  display: grid;
  grid-template-columns: 120px 130px 1fr 160px 60px 170px 110px;
  gap: 10px;
  align-items: center;
}

.admin-row-top > div {
  min-width: 0;
}

.cell-email {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-row-bottom {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(43, 43, 43, 0.34);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
}

.modal.active {
  display: flex;
}

.modal-card {
  background: var(--card);
  border-radius: 12px;
  width: min(1100px, 95vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  box-shadow: 0 18px 44px rgba(43, 43, 43, 0.12);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.modal-body {
  padding: 14px 18px 18px;
  overflow: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--border);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.modal-tab {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
}

.modal-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.modal-content {
  min-height: 420px;
}

.modal-pane {
  display: none;
}

.modal-pane.active {
  display: block;
}

.modal-viewer {
  width: 100%;
  height: 70vh;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.modal-xml {
  white-space: pre-wrap;
  background: #2b2b2b;
  color: #f7f7f5;
  padding: 14px;
  border-radius: 8px;
  height: 70vh;
  overflow: auto;
  border: 1px solid #000000;
  font-size: 12px;
}

  .admin-invoices-header,
  .admin-invoice-row {
    grid-template-columns: 90px 140px 140px 1fr 140px 140px 160px;
  }

  .admin-delivery-invoices-header,
  .admin-delivery-invoice-row {
    display: block;
  }

  .supplier-delivery-invoices-header,
  .supplier-delivery-invoice-row {
    display: block;
  }

  .admin-delivery-row-top {
    display: grid;
    grid-template-columns: 190px 80px 160px 170px 140px 150px 120px;
    gap: 10px;
    align-items: center;
  }

  .admin-delivery-row-bottom {
    margin-top: 8px;
  }

  .supplier-delivery-row-top {
    display: grid;
    grid-template-columns: 120px 80px 110px 140px 140px 120px;
    gap: 10px;
    align-items: center;
  }

  .supplier-delivery-row-bottom {
    margin-top: 8px;
  }

  .supplier-delivery-row-bottom-inner {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .admin-delivery-row-bottom-inner {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .supplier-delivery-actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
  }

  .admin-delivery-supplier-name {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .admin-invoice-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-start;
  }

.badge {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.badge.success {
  background: rgba(185, 65, 40, 0.12);
  color: var(--accent-dark);
}

.badge.validated {
  background: rgba(32, 122, 58, 0.14);
  color: #207a3a;
}

.badge.invalid {
  background: rgba(163, 58, 35, 0.14);
  color: var(--error);
}

.badge.pending {
  background: rgba(201, 106, 82, 0.16);
  color: var(--accent-dark);
}

.badge.na {
  background: var(--bg-soft);
  color: var(--muted);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.icon-btn:hover {
  background: var(--bg-soft);
  border-color: var(--accent-soft);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.admin-delivery-invoice-lines {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: var(--card-soft);
}

.admin-delivery-invoice-lines.hidden {
  display: none;
}

.admin-delivery-lines-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-delivery-lines-table th,
.admin-delivery-lines-table td {
  text-align: left;
  padding: 8px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.admin-delivery-lines-table th {
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
}

.admin-delivery-lines-table tr:last-child td {
  border-bottom: 0;
}

.admin-delivery-lines-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.admin-delivery-lines-title strong {
  font-size: 13px;
}

.admin-delivery-lines-title .badge {
  transform: translateY(-1px);
}

.icon-btn.small {
  width: 56px;
  height: 48px;
  border-radius: 8px;
}

.icon-btn.small svg {
  width: 24px;
  height: 24px;
}

.link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.link:hover {
  text-decoration: underline;
}

.po-row {
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.po-row:hover {
  background: var(--bg-soft);
  border-color: var(--accent-soft);
}

  .po-list-header,
  .po-row {
    grid-template-columns: 90px 140px 1.4fr 120px 148px;
  }

  .delivery-list {
    overflow-x: auto;
    padding-bottom: 8px;
  }

  .delivery-lines-header,
  .delivery-line-row {
    width: max-content;
    min-width: 100%;
    grid-template-columns: 44px 84px 96px 120px minmax(240px, 1.4fr) 108px 116px;
  }

  .delivery-lines-header.delivery-lines-basic,
  .delivery-line-row.delivery-lines-basic {
    grid-template-columns: 44px 84px 96px 120px minmax(240px, 1.4fr) 108px 116px;
  }

  .delivery-qty-cell {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .delivery-qty-input {
    width: 100%;
    min-width: 110px;
  }

  .delivery-qty-input:disabled {
    opacity: 0.65;
    background: var(--bg-soft);
    cursor: not-allowed;
  }

  .delivery-qty-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12px;
    color: var(--muted);
  }

  .po-cell-muted {
    color: var(--muted);
    font-size: 12px;
  }

  .delivery-line-wrap {
    margin-top: 10px;
    min-width: fit-content;
  }

  .delivery-line-title {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--bg-soft);
    font-weight: 700;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: max-content;
    min-width: 100%;
  }

  .delivery-retencion-cell {
    min-width: 0;
  }

  .delivery-retencion-select {
    width: 100%;
    min-width: 0;
    font-size: 12px;
    padding: 8px 10px;
  }

  .delivery-total-cell {
    font-weight: 700;
  }

  .delivery-retenciones-panel {
    margin-top: 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-soft);
  }

  .delivery-retenciones-title {
    margin-bottom: 10px;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .delivery-retenciones-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(240px, 1fr));
    gap: 12px;
  }

  .delivery-retencion-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .delivery-retencion-field span {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
  }

  .delivery-retencion-empty {
    font-size: 12px;
    color: var(--error);
  }

  .selected-summary-retentions {
    grid-column: 1 / -1;
    font-size: 12px;
    color: var(--muted);
    border-top: 1px solid var(--border);
    padding-top: 8px;
  }

.po-details {
  margin-top: 8px;
  margin-bottom: 12px;
  border-left: 3px solid var(--border);
  padding-left: 12px;
}

  .po-detail-header,
  .po-detail-row {
    display: grid;
    grid-template-columns: 60px 140px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-soft);
  margin-bottom: 8px;
}

.po-detail-group {
  margin-bottom: 10px;
}

.po-detail-top {
  margin-bottom: 6px;
}

.po-detail-bottom {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  background: var(--bg-soft);
  font-size: 13px;
}

.po-delivery-breakdown {
  margin: 6px 0 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
}

.po-delivery-breakdown.hidden {
  display: none;
}

.po-delivery-title {
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 600;
}

.po-delivery-row {
  display: grid;
  grid-template-columns: 140px 140px 1fr;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
}

.po-delivery-row:first-of-type {
  border-top: 0;
}

.po-invoice-cell {
  display: flex;
  justify-content: flex-end;
}

.invoice-check {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(185, 65, 40, 0.12);
  color: var(--accent-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border: 1px solid rgba(185, 65, 40, 0.22);
}

.po-invoice-btn {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

.po-invoice-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.po-invoice-panel {
  margin: 8px 0 16px;
  padding: 12px;
  border: 1px dashed var(--accent-soft);
  border-radius: 10px;
  background: var(--bg-soft);
}

.po-invoice-title {
  font-weight: 600;
  margin-bottom: 8px;
}

.po-invoice-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 6px;
}

.po-invoice-fields label {
  font-size: 13px;
  color: var(--muted);
}

.delivery-support-docs {
  display: grid;
  gap: 12px;
}

.support-doc-list {
  display: grid;
  gap: 10px;
}

.support-doc-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.po-invoice-upload {
  align-self: end;
}

  .po-detail-header {
    font-weight: 600;
    background: var(--bg-soft);
  }

  /* Deliveries: show checkbox + line number as separate columns. */
  .delivery-detail-header,
  .delivery-detail-row {
    grid-template-columns: 44px 70px 140px 1fr;
  }

.qty-positive {
  color: var(--success);
  font-weight: 600;
}

.qty-negative {
  color: var(--error);
  font-weight: 600;
}

.po-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
}

.po-toggle,
.po-print {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.po-toggle.is-open {
  background: rgba(185, 65, 40, 0.12);
  border-color: var(--accent-soft);
}

.po-toggle.is-open svg .eye-open {
  display: none;
}

.po-toggle:not(.is-open) svg .eye-closed {
  display: none;
}

  .filter-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
  }

  .filter-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
    max-width: 260px;
  }

  .filter-grow {
    flex: 1;
    max-width: none;
    min-width: 260px;
  }

  .selected-summary {
    margin-left: auto;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    border-radius: 10px;
    padding: 10px 12px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
  }

  .delivery-invoice-actions {
    display: flex;
    align-items: flex-end;
    gap: 10px;
  }

  .delivery-upload-modal {
    width: min(560px, 95vw);
  }

  .delivery-upload-fields {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .delivery-upload-fields input[type="file"] {
    padding: 10px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
  }

  .delivery-file-btn.is-ready {
    background: rgba(185, 65, 40, 0.12);
    border-color: rgba(185, 65, 40, 0.22);
    color: var(--accent-dark);
  }

  #deliveryInvoiceUpload.is-ready {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
  }

  #deliveryUploadModalSubmit.is-ready {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 12px 24px rgba(185, 65, 40, 0.24);
  }

  #deliveryUploadModalSubmit:disabled {
    background: linear-gradient(180deg, #ece7e2 0%, #ddd5cd 100%);
    color: #8e8479;
    border-color: #d1c7bd;
    box-shadow: none;
  }

  #deliveryUploadModalSubmit.is-ready:hover {
    transform: translateY(-1px);
  }

.full {
  grid-column: 1 / -1;
}

.request-docs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.request-doc-row {
  display: grid;
  grid-template-columns: 1.6fr 0.7fr 60px 1fr 120px;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-soft);
}

.request-doc-row.admin-view {
  grid-template-columns: 1.6fr 0.7fr 60px;
}

.request-doc-row .status-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.status-chip.pending {
  background: rgba(201, 106, 82, 0.18);
  color: var(--accent-dark);
}

.status-chip.success {
  background: rgba(185, 65, 40, 0.12);
  color: var(--accent-dark);
}

.status-chip.na {
  background: var(--bg-soft);
  color: var(--muted);
}

.request-doc-row input[type="file"] {
  padding: 6px;
  background: #fff;
}

.request-doc-row .link {
  justify-self: start;
}

.prompt-card {
  padding: 20px;
}

.prompt-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.validation-doc-card {
  padding: 20px;
}

.doc-validation-loading {
  color: var(--muted);
  background: var(--bg-soft);
  font-weight: 600;
}

.validation-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 14px;
}

.validation-meta-grid strong {
  color: var(--text);
}

.validation-details {
  margin-top: 14px;
}

.validation-details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}

.validation-json-view {
  height: auto;
  max-height: 360px;
  margin-top: 10px;
}

@media (max-width: 820px) {
  .landing-hero {
    grid-template-columns: 1fr;
    padding: 28px;
  }

  .landing-copy h1 {
    font-size: clamp(2rem, 12vw, 3rem);
  }
}

@media (max-width: 720px) {
  .list-item {
    grid-template-columns: 1fr;
  }
  .delivery-lines-header,
  .delivery-line-row,
  .delivery-lines-header.delivery-lines-basic,
  .delivery-line-row.delivery-lines-basic {
    width: auto;
    min-width: 0;
    grid-template-columns: 1fr;
  }
  .delivery-line-wrap {
    min-width: 0;
  }
  .delivery-line-title {
    width: auto;
    min-width: 0;
    white-space: normal;
  }
  .delivery-retenciones-grid {
    grid-template-columns: 1fr;
  }
  .admin-invoices-header,
  .admin-invoice-row {
    grid-template-columns: 1fr;
  }
  .admin-delivery-row-top {
    grid-template-columns: 1fr;
  }
  .supplier-delivery-row-top {
    grid-template-columns: 1fr;
  }
  .po-list-header,
  .po-row {
    grid-template-columns: 1fr;
  }
  .po-detail-header,
  .po-detail-row {
    grid-template-columns: 1fr;
  }
  .request-doc-row {
    grid-template-columns: 1fr;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

/* Unified system overrides */
:root {
  --bg: #f4f1ec;
  --bg-soft: #f8f5f1;
  --card: #ffffff;
  --card-soft: #fbf8f4;
  --text: #221f1b;
  --muted: #70675d;
  --accent: #b94128;
  --accent-dark: #94311d;
  --accent-soft: #d98672;
  --accent-ghost: rgba(185, 65, 40, 0.08);
  --border: #ddd5cb;
  --border-strong: #cdbfb0;
  --success: #207a3a;
  --warning: #9a5b14;
  --error: #a33a23;
  --shadow-soft: 0 18px 42px rgba(43, 43, 43, 0.08);
  --shadow-subtle: 0 8px 24px rgba(43, 43, 43, 0.06);
}

body {
  min-height: 100vh;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(185, 65, 40, 0.08), transparent 25%),
    linear-gradient(180deg, #faf7f3 0%, #f0ebe4 100%);
  color: var(--text);
  line-height: 1.45;
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 56px;
  padding: 0;
}

.auth-body .page {
  max-width: 560px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 24px;
  padding: 24px 28px;
  border: 1px solid rgba(185, 65, 40, 0.12);
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 244, 239, 0.96) 100%);
  box-shadow: var(--shadow-soft);
}

.topbar > div:first-child {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.85rem, 2.3vw, 2.4rem);
  line-height: 1.04;
  letter-spacing: -0.025em;
  color: var(--accent);
}

h2 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.2;
  color: var(--accent);
}

.subtitle {
  margin: 0;
  max-width: 72ch;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px 14px;
  min-height: 40px;
}

.actions span {
  color: var(--border-strong);
}

.card {
  position: relative;
  margin-bottom: 18px;
  padding: 24px 24px 22px;
  border: 1px solid rgba(185, 65, 40, 0.11);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(252, 249, 245, 0.98) 100%);
  box-shadow: var(--shadow-subtle);
}

.card > h2 + .form,
.card > h2 + .filter-row,
.card > h2 + .request-docs,
.card > h2 + .list,
.card > h2 + .menu {
  margin-top: 16px;
}

.doc-id {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.form {
  gap: 16px;
}

.form.grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px 18px;
}

label,
.filter-label {
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #4f463d;
}

input,
select,
textarea,
button,
.btn,
.po-invoice-btn {
  min-height: 44px;
  border-radius: 12px;
  font-size: 0.94rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  background: #fff;
}

textarea {
  min-height: 112px;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--border-strong);
}

button,
.btn,
.po-invoice-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

button:disabled,
.btn:disabled,
.po-invoice-btn:disabled {
  cursor: not-allowed;
  transform: none;
  background: linear-gradient(180deg, #ece7e2 0%, #ddd5cd 100%);
  color: #8e8479;
  border-color: #d1c7bd;
  box-shadow: none;
  opacity: 1;
}

button:not(.secondary):not(.danger):not(.link):not(.icon-btn):not(.modal-tab),
.btn:not(.secondary):not(.danger),
.po-invoice-btn:not(.secondary):not(.danger) {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  border-color: var(--accent-dark);
  box-shadow: 0 10px 18px rgba(185, 65, 40, 0.16);
}

button:not(.secondary):not(.danger):not(.link):not(.icon-btn):not(.modal-tab):hover,
.btn:not(.secondary):not(.danger):hover,
.po-invoice-btn:not(.secondary):not(.danger):hover {
  transform: translateY(-1px);
  background: linear-gradient(180deg, #c84f35 0%, var(--accent-dark) 100%);
}

.btn.secondary,
.po-invoice-btn.secondary,
.modal-close,
.link.btn-secondary {
  background: #fff;
  color: var(--accent);
  border-color: var(--border-strong);
  box-shadow: none;
}

.btn.secondary:hover,
.po-invoice-btn.secondary:hover,
.modal-close:hover {
  background: var(--bg-soft);
  border-color: var(--accent-soft);
  color: var(--accent-dark);
}

.btn.danger,
.po-invoice-btn.danger {
  background: rgba(163, 58, 35, 0.08);
  color: var(--error);
  border-color: rgba(163, 58, 35, 0.18);
  box-shadow: none;
}

.btn.danger:hover,
.po-invoice-btn.danger:hover {
  background: rgba(163, 58, 35, 0.14);
  border-color: rgba(163, 58, 35, 0.28);
}

.admin-password-submit {
  min-width: 160px;
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.link:hover {
  color: var(--accent-dark);
  text-decoration: none;
}

.message {
  min-height: 22px;
  margin-top: 4px;
  font-size: 0.9rem;
  font-weight: 600;
}

.message.success {
  color: var(--success);
}

.message.warning {
  color: var(--warning);
}

.message.error {
  color: var(--error);
}

.hint {
  margin-top: 2px;
  font-size: 0.79rem;
  line-height: 1.5;
  color: var(--muted);
}

.filter-row {
  display: flex;
  align-items: end;
  gap: 14px 16px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(248, 245, 241, 0.92) 0%, rgba(255, 255, 255, 0.95) 100%);
}

.filter-label {
  max-width: 300px;
}

.filter-grow {
  min-width: min(100%, 280px);
}

.selected-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 6px 14px;
  min-width: min(100%, 290px);
  margin-left: auto;
  padding: 12px 14px;
  border: 1px solid rgba(185, 65, 40, 0.14);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(185, 65, 40, 0.05) 0%, rgba(255, 255, 255, 0.94) 100%);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
  white-space: normal;
}

.process-summary {
  margin: 0 0 16px 0;
}

.selection-cell {
  display: flex;
  justify-content: center;
}

.delivery-invoice-actions,
.prompt-actions,
.admin-invoice-actions,
.supplier-delivery-actions,
.po-actions,
.modal-actions,
.modal-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.supplier-delivery-actions {
  flex-wrap: nowrap;
}

.list {
  gap: 12px;
}

.list-item {
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 245, 241, 0.98) 100%);
  box-shadow: 0 6px 16px rgba(43, 43, 43, 0.04);
}

.list-header {
  border-color: rgba(185, 65, 40, 0.12);
  background: linear-gradient(180deg, rgba(185, 65, 40, 0.08) 0%, rgba(255, 255, 255, 0.98) 100%);
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.po-row,
.list-item.admin.selectable,
.admin-delivery-invoice-row,
.supplier-delivery-invoice-row {
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.po-row:hover,
.list-item.admin.selectable:hover,
.admin-delivery-invoice-row:hover,
.supplier-delivery-invoice-row:hover {
  transform: translateY(-1px);
  border-color: rgba(185, 65, 40, 0.22);
  box-shadow: 0 12px 22px rgba(43, 43, 43, 0.06);
}

.menu {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.menu-item {
  min-height: 84px;
  justify-content: flex-start;
  padding: 18px 20px;
  border-radius: 18px;
  border: 1px solid rgba(185, 65, 40, 0.12);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(249, 245, 240, 0.98) 100%);
  color: var(--accent);
  font-size: 0.98rem;
  line-height: 1.35;
}

.menu-item:hover {
  transform: translateY(-2px);
  border-color: rgba(185, 65, 40, 0.24);
  box-shadow: 0 14px 22px rgba(185, 65, 40, 0.12);
}

.badge,
.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.02em;
}

.badge.success,
.status-chip.success {
  background: #dff3e4;
  border-color: #b8dfc2;
  color: #2f6b3f;
}

.badge.validated {
  background: #dff3e4;
  border-color: #b8dfc2;
  color: #2f6b3f;
}

.badge.pending,
.status-chip.pending {
  background: #fff1bf;
  border-color: #f3dd8d;
  color: #8a6a12;
}

.badge.invalid {
  background: #f8d7da;
  border-color: #efb5bb;
  color: #9f3748;
}

.badge.info {
  background: #dcecff;
  border-color: #b7d4fb;
  color: #2d64a8;
}

.badge.na,
.status-chip.na {
  background: rgba(112, 103, 93, 0.10);
  border-color: rgba(112, 103, 93, 0.14);
  color: var(--muted);
}

.request-doc-row,
.request-doc-row.admin-view {
  align-items: center;
  padding: 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(249, 246, 242, 0.98) 100%);
}

.request-doc-row input[type="file"],
.delivery-upload-fields input[type="file"] {
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px dashed var(--border-strong);
  background: #fff;
}

.modal {
  padding: 28px;
  background: rgba(32, 27, 23, 0.56);
  backdrop-filter: blur(6px);
}

.modal-card {
  width: min(1180px, 100%);
  max-height: min(92vh, 980px);
  border-radius: 22px;
  border: 1px solid rgba(185, 65, 40, 0.12);
  overflow: hidden;
}

.modal-header {
  padding: 18px 22px;
  background: linear-gradient(180deg, rgba(248, 245, 241, 0.96) 0%, rgba(255, 255, 255, 0.98) 100%);
}

.modal-body {
  padding: 20px 22px 22px;
}

.modal-footer {
  justify-content: flex-end;
  padding: 16px 22px 22px;
  background: rgba(248, 245, 241, 0.76);
}

.modal-tab {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--accent);
  font-weight: 700;
}

.modal-tab.active {
  box-shadow: 0 8px 16px rgba(185, 65, 40, 0.14);
}

.modal-viewer,
.modal-xml {
  border-radius: 16px;
}

.admin-delivery-invoice-lines,
.po-details,
.po-invoice-panel,
.po-delivery-breakdown {
  margin-top: 14px;
  border-radius: 16px;
  border-color: var(--border);
  background: linear-gradient(180deg, rgba(248, 245, 241, 0.86) 0%, rgba(255, 255, 255, 0.98) 100%);
}

.admin-delivery-lines-table {
  font-size: 0.86rem;
}

.admin-delivery-lines-table th,
.admin-delivery-lines-table td {
  padding: 10px 10px;
}

.admin-delivery-lines-table th {
  color: var(--accent);
  background: rgba(185, 65, 40, 0.04);
}

.validation-meta-grid,
.po-invoice-fields,
.delivery-upload-fields,
.support-doc-list {
  gap: 12px;
}

.support-doc-row {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 245, 241, 0.96) 100%);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: #fff;
  box-shadow: none;
}

.icon-btn:hover,
.po-toggle.is-open {
  background: var(--accent-ghost);
  border-color: var(--accent-soft);
}

.icon-btn.small {
  width: 48px;
  height: 48px;
}

.icon-btn.small svg {
  width: 24px;
  height: 24px;
}

.validation-link svg {
  stroke: var(--success);
}

.validation-link:hover {
  background: rgba(32, 122, 58, 0.08);
  border-color: rgba(32, 122, 58, 0.24);
}

.admin-delivery-row-top {
  grid-template-columns: minmax(150px, 1.6fr) 72px minmax(120px, 1fr) 120px minmax(110px, 0.9fr) minmax(150px, 1fr);
}

.admin-status-cell {
  min-width: 0;
}

.admin-status-cell .badge {
  max-width: 100%;
  white-space: normal;
  text-align: center;
  line-height: 1.25;
}

.delivery-line-title {
  margin-bottom: 8px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(248, 245, 241, 0.92);
}

.delivery-qty-meta,
.po-cell-muted,
.admin-delivery-supplier-name,
.admin-row-bottom {
  color: var(--muted);
}

.permission-block {
  grid-column: 1 / -1;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card-soft);
}

.permission-block-title {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 10px;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 14px;
}

.permission-item,
.permission-toggle-inline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.internal-users-header-row,
.internal-users-row-top {
  display: grid;
  grid-template-columns: 1.1fr 1.2fr 150px 180px 90px 240px;
  gap: 10px;
  align-items: center;
}

.internal-users-row-bottom {
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

.internal-users-row-bottom .permission-block {
  margin-top: 0;
}

.validation-doc-card,
.prompt-card {
  padding: 22px;
}

#documentValidationGeneratedLabel {
  margin-left: 4px;
}

@media (max-width: 960px) {
  .page {
    width: min(100% - 24px, 100%);
    margin-top: 16px;
  }

  .topbar,
  .card {
    padding-left: 18px;
    padding-right: 18px;
  }

  .filter-row {
    padding: 14px;
  }

  .selected-summary {
    width: 100%;
    margin-left: 0;
  }
}

@media (max-width: 720px) {
  .page {
    width: calc(100% - 16px);
  }

  .topbar {
    padding: 18px;
    border-radius: 18px;
  }

  .actions {
    justify-content: flex-start;
  }

  .card {
    padding: 18px 16px;
    border-radius: 18px;
  }

  .filter-row,
  .delivery-invoice-actions,
  .prompt-actions,
  .admin-invoice-actions,
  .supplier-delivery-actions,
  .po-actions,
  .modal-actions,
  .modal-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-label,
  .filter-grow {
    max-width: none;
    min-width: 0;
    width: 100%;
  }

  .btn,
  .po-invoice-btn,
  button:not(.icon-btn),
  .modal-tab {
    width: 100%;
  }

  .selected-summary {
    grid-template-columns: 1fr;
  }

  .modal {
    padding: 12px;
  }

  .modal-card {
    border-radius: 18px;
  }

  .doc-id {
    flex-direction: column;
    align-items: flex-start;
  }
}
