/* Citadel 05B-1: independent, full-width administrative purchase-order view. */
.workspace-section.po-dashboard-section {
  max-width: none;
  min-width: 0;
}
.po-dashboard {
  --db-border: rgba(171, 191, 217, 0.19);
  --db-surface: rgba(18, 27, 39, 0.88);
  color: var(--text);
  width: 100%;
  min-width: 0;
}
.po-dashboard button,
.po-dashboard input,
.po-dashboard select {
  font: inherit;
}
.po-db-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.po-db-head h2 {
  font-size: clamp(20px, 2.3vw, 27px);
  letter-spacing: -0.025em;
  margin: 4px 0 7px;
}
.po-db-head p {
  color: var(--muted-light);
  font-size: 13px;
  margin: 0;
  line-height: 1.6;
}
.po-db-eyebrow {
  font-size: 10px;
  letter-spacing: 0.13em;
  color: #9ab4cf;
  font-weight: 800;
}
.po-db-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.po-dashboard button {
  border: 1px solid var(--db-border);
  color: var(--text);
  background: #1a2635;
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 650;
}
.po-dashboard button:hover:not(:disabled) {
  border-color: #819dbb;
  background: #26394d;
}
.po-dashboard button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.po-dashboard button:focus-visible,
.po-dashboard input:focus-visible,
.po-dashboard select:focus-visible,
.po-dashboard summary:focus-visible {
  outline: 2px solid #9fd0ff;
  outline-offset: 2px;
}
.po-dashboard .po-db-primary {
  background: #dce9f7;
  border-color: #dce9f7;
  color: #101d2d;
}
.po-dashboard .po-db-primary:hover:not(:disabled) {
  background: #f0f6ff;
}
.po-db-filters {
  border: 1px solid var(--db-border);
  background: var(--db-surface);
  border-radius: 13px;
  padding: 16px;
  margin-bottom: 16px;
}
.po-db-filter-grid {
  display: grid;
  grid-template-columns: minmax(200px, 2fr) repeat(4, minmax(130px, 1fr));
  gap: 12px;
}
.po-db-filter-grid--secondary {
  grid-template-columns: repeat(4, minmax(115px, 1fr)) minmax(175px, 1.4fr);
  margin-top: 10px;
}
.po-db-filter-grid label,
.po-db-pagination label {
  font-size: 11px;
  font-weight: 700;
  color: #c3cedb;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.po-db-filter-grid input,
.po-db-filter-grid select,
.po-db-pagination select {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid var(--db-border);
  border-radius: 7px;
  color: var(--text);
  color-scheme: dark;
  background: #0d1622;
  font-size: 12px;
}
.po-db-filter-grid input::placeholder {
  color: #7f90a2;
}
.po-db-filter-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 13px;
}
.po-db-filter-actions small {
  color: var(--muted);
  font-size: 11px;
  margin-left: auto;
}
.po-db-column-wrap {
  position: relative;
}
.po-db-columns {
  position: absolute;
  z-index: 20;
  right: 0;
  top: calc(100% + 9px);
  background: #121e2d;
  padding: 14px;
  border: 1px solid #48617d;
  border-radius: 12px;
  width: min(300px, 85vw);
  box-shadow: 0 16px 35px rgba(0, 0, 0, 0.38);
  max-height: 60vh;
  overflow: auto;
}
.po-db-columns[hidden] {
  display: none;
}
.po-db-columns h3 {
  font-size: 13px;
  margin: 0 0 11px;
}
.po-db-column-choice {
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 6px 0;
  color: #d6e1ed;
  font-size: 12px;
}
.po-db-column-choice input {
  accent-color: #a8c6e9;
}
.po-db-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
  flex-wrap: wrap;
}
.po-db-meta {
  font-size: 12px;
  color: #b5c5d6;
}
.po-db-status {
  font-size: 12px;
  color: #a9c0d7;
  margin: 0 0 9px;
  min-height: 18px;
}
.po-db-status[data-error='true'] {
  color: #ffb0b0;
}
.po-db-grid-shell {
  border: 1px solid var(--db-border);
  border-radius: 13px;
  background: var(--db-surface);
  overflow: hidden;
}
.po-db-table-scroll {
  overflow: auto;
  max-width: 100%;
}
.po-db-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  white-space: nowrap;
  text-align: left;
  font-size: 12px;
}
.po-db-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #1a2a3c;
  font-size: 10px;
  letter-spacing: 0.045em;
  text-transform: uppercase;
  color: #b6c9dd;
  font-weight: 750;
  padding: 13px 12px;
  border-bottom: 1px solid #354b63;
}
.po-db-table td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--db-border);
  vertical-align: middle;
  color: #e4edf7;
}
.po-db-table tbody tr:last-child td {
  border-bottom: 0;
}
.po-db-table tbody tr:hover {
  background: rgba(116, 154, 199, 0.095);
}
.po-db-table td small {
  display: block;
  color: #8fa2b6;
  margin-top: 3px;
  font-size: 10px;
}
.po-db-table th[data-column='documentNo'],
.po-db-table td[data-column='documentNo'] {
  position: sticky;
  left: 0;
  z-index: 3;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.2);
}
.po-db-table th[data-column='documentNo'] {
  background: #1a2a3c;
}
.po-db-table td[data-column='documentNo'] {
  background: #152333;
}
.po-db-table tbody tr:hover td[data-column='documentNo'] {
  background: #203449;
}
.po-db-table .po-db-num {
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}
.po-db-table .po-db-money {
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.po-db-table .po-db-action-cell {
  position: sticky;
  right: 0;
  z-index: 3;
  background: #152333;
  box-shadow: -2px 0 5px rgba(0, 0, 0, 0.2);
}
.po-db-table th.po-db-action-cell {
  z-index: 4;
  background: #1a2a3c;
}
.po-db-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 7px;
  background: #283647;
  color: #d6e1eb;
  font-size: 11px;
  font-weight: 650;
}
.po-db-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.po-db-pill[data-tone='ok'] {
  background: rgba(49, 130, 93, 0.2);
  color: #8bdfb3;
}
.po-db-pill[data-tone='warn'] {
  background: rgba(182, 129, 36, 0.2);
  color: #ffd38b;
}
.po-db-pill[data-tone='bad'] {
  background: rgba(172, 66, 77, 0.22);
  color: #ffafb5;
}
.po-db-pill[data-tone='muted'] {
  background: rgba(140, 155, 176, 0.14);
  color: #b1c0cf;
}
.po-db-empty {
  text-align: center;
  padding: 38px 15px !important;
  color: #c5d2de !important;
  white-space: normal;
}
.po-db-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  flex-wrap: wrap;
  border-top: 1px solid var(--db-border);
  font-size: 12px;
  color: #b8c8d8;
}
.po-db-pagination .po-db-pages {
  display: flex;
  align-items: center;
  gap: 10px;
}
.po-db-pagination select {
  width: 85px;
  min-height: 31px;
}
.po-db-footnote {
  font-size: 11px;
  color: #9aacc0;
  line-height: 1.6;
  margin-top: 13px;
}
.po-db-overlay[hidden] {
  display: none;
}
.po-db-overlay {
  position: fixed;
  inset: 0;
  z-index: 1300;
  background: rgba(4, 8, 13, 0.75);
  display: grid;
  place-items: center;
  padding: 20px;
}
.po-db-detail {
  position: relative;
  background: #101b29;
  color: var(--text);
  border: 1px solid #405875;
  border-radius: 16px;
  width: min(920px, 96vw);
  max-height: 89vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.55);
}
.po-db-detail-head {
  padding: 21px 23px;
  border-bottom: 1px solid var(--db-border);
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}
.po-db-detail-head h3 {
  margin: 4px 0 0;
  font-size: 19px;
}
.po-db-detail-body {
  overflow: auto;
  padding: 23px;
}
.po-db-detail-body h4 {
  font-size: 14px;
  margin: 18px 0 9px;
}
.po-db-detail-body p {
  color: #b5c6d7;
  font-size: 12px;
  line-height: 1.6;
}
.po-db-detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.po-db-detail-table td,
.po-db-detail-table th {
  padding: 10px 9px;
  border-bottom: 1px solid var(--db-border);
  text-align: left;
}
.po-db-detail-table th {
  color: #aac1db;
  font-size: 11px;
}
.po-db-detail-pre {
  white-space: pre-wrap;
  word-break: break-word;
  color: #bcd0e5;
  font:
    11px/1.5 ui-monospace,
    SFMono-Regular,
    monospace;
  max-height: 300px;
  overflow: auto;
  background: #09111a;
  padding: 12px;
  border-radius: 9px;
}
.po-db-detail-body details {
  margin-top: 15px;
}
.po-db-detail-body summary {
  cursor: pointer;
  font-size: 12px;
  color: #b4c8dc;
}
@media (max-width: 1300px) {
  .po-db-filter-grid,
  .po-db-filter-grid--secondary {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }
}
@media (max-width: 720px) {
  .po-db-filter-grid,
  .po-db-filter-grid--secondary {
    grid-template-columns: repeat(2, minmax(135px, 1fr));
  }
  .po-db-head {
    gap: 12px;
  }
}
@media (max-width: 430px) {
  .po-db-filter-grid,
  .po-db-filter-grid--secondary {
    grid-template-columns: 1fr;
  }
  .po-db-detail-head {
    padding: 15px;
  }
  .po-db-detail-body {
    padding: 15px;
  }
}

/* Acciones compactas del Panel Administrativo de Compras */
.po-db-table td.po-db-action-cell {
  white-space: nowrap;
}

.po-db-table .po-db-action-cell button.po-db-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  box-sizing: border-box;
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  margin: 0 4px 0 0;
  border: 1px solid #49617b;
  border-radius: 7px;
  background: #24364a;
  color: #e5edf7;
  line-height: 1;
  cursor: pointer;
}

.po-db-table .po-db-action-cell button.po-db-icon-button:hover {
  background: #36516e;
}

.po-db-table .po-db-action-cell button.po-db-icon-button:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.po-db-table .po-db-action-cell button.po-db-icon-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.po-db-table .po-db-action-cell button.po-db-icon-button svg {
  display: block;
  width: 17px;
  height: 17px;
  flex: none;
}

/* Etapa 07.5-C: documentos adjuntos */
.po-db-document-button {
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  font: inherit;
}

.po-db-document-button:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
  border-radius: 4px;
}

.po-db-documents-section {
  margin-bottom: 18px;
}

.po-db-document-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.po-db-document-name {
  overflow-wrap: anywhere;
}

.po-db-document-actions {
  display: inline-flex;
  gap: 14px;
}

.po-db-document-actions a {
  color: #93c5fd;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Etapa 07.5-C: alerta de documentos faltantes */
.po-db-pill.po-db-no-documents {
  background: rgba(220, 38, 38, 0.17);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.45);
  font-weight: 600;
}

.po-db-pill.po-db-no-documents::before {
  content: '●';
  color: #f87171;
  margin-right: 5px;
}

/* Etapa 07.5-C: indicadores compactos por tipo */
.po-db-doc-missing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  color: #fca5a5;
  background: rgba(220, 38, 38, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 5px;
  padding: 4px 6px;
  font-size: 11px;
  font-weight: 700;
}

.po-db-doc-missing::before {
  content: '!';
  display: inline-grid;
  place-items: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  color: white;
  background: #dc2626;
  font-size: 10px;
}

.po-db-file-icons {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.po-db-file-type-icon {
  position: relative;
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  box-sizing: border-box;
  min-width: 29px;
  height: 27px;
  padding: 0 3px 5px;
  border: 1px solid;
  border-radius: 3px;
  font-size: 8px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.2px;
}

.po-db-file-type-icon::after {
  content: '';
  position: absolute;
  right: -1px;
  top: -1px;
  border-style: solid;
  border-width: 0 8px 8px 0;
  border-color: transparent #0f1b2a transparent transparent;
}

.po-db-file-type-icon[data-type='PDF'] {
  color: #bbf7d0;
  background: rgba(22, 163, 74, 0.22);
  border-color: #22c55e;
}

.po-db-file-type-icon[data-type='XML'] {
  color: #a5f3fc;
  background: rgba(8, 145, 178, 0.22);
  border-color: #22d3ee;
}

.po-db-file-type-icon[data-type='DOC'] {
  color: #bfdbfe;
  background: rgba(37, 99, 235, 0.2);
  border-color: #60a5fa;
}

.po-db-file-extra {
  font-size: 11px;
  font-weight: 700;
  color: #cbd5e1;
  padding-left: 2px;
}

.po-db-document-button:hover .po-db-file-type-icon {
  filter: brightness(1.3);
}

/* Etapa 07.6: acciones documentales visuales */
.po-db-doc-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: 10px 0 14px;
}

.po-db-doc-upload-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border: 1px solid #3b82f6;
  border-radius: 7px;
  background: #1d4ed8;
  color: white;
  font-weight: 650;
  cursor: pointer;
}

.po-db-doc-upload-button:hover:not(:disabled) {
  background: #2563eb;
}

.po-db-doc-upload-button svg,
.po-db-doc-action-icon svg,
.po-db-doc-file-icon svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.po-db-document-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 6px;
}

.po-db-document-name {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.po-db-document-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.po-db-doc-action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 6px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 7px;
  background: rgba(148, 163, 184, 0.09);
  color: #cbd5e1;
  cursor: pointer;
  text-decoration: none;
}

.po-db-doc-action-icon:hover:not(:disabled) {
  color: white;
  background: rgba(59, 130, 246, 0.2);
}

.po-db-doc-delete {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}

.po-db-doc-delete:hover:not(:disabled) {
  color: #fecaca;
  background: rgba(220, 38, 38, 0.2);
}

.po-db-doc-file-icon {
  display: inline-flex;
  padding: 7px;
  border-radius: 7px;
}

.po-db-doc-file-icon.pdf {
  background: rgba(34, 197, 94, 0.14);
  color: #4ade80;
}

.po-db-doc-file-icon.xml {
  background: rgba(34, 211, 238, 0.14);
  color: #67e8f9;
}

.po-db-doc-operation-status {
  margin: 7px 0 12px;
  color: #86efac;
  font-size: 12px;
}

.po-db-doc-operation-status[data-error='true'] {
  color: #fca5a5;
}

.po-db-doc-empty {
  color: #94a3b8;
  padding: 12px 0;
}

.po-db-doc-missing {
  cursor: pointer;
}

.po-db-doc-missing:hover {
  filter: brightness(1.2);
}

.po-db-doc-action-icon:disabled,
.po-db-doc-upload-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Etapa 07.6: destacar la acción principal de documentos */
.po-db-documents-section button.po-db-doc-upload-button {
  background: #1d4ed8;
  border-color: #3b82f6;
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(29, 78, 216, 0.2);
}

.po-db-documents-section button.po-db-doc-upload-button:hover:not(:disabled) {
  background: #2563eb;
  border-color: #60a5fa;
}

.po-db-documents-section .po-db-doc-toolbar {
  margin: 6px 0 12px;
}

/* Etapa 07.7: órdenes relacionadas por trabajo */
.po-db-job-document-group {
  margin-top: 22px;
  padding: 16px;
  border: 1px solid rgba(59, 130, 246, 0.28);
  border-radius: 9px;
  background: rgba(30, 64, 175, 0.08);
}

.po-db-job-document-group h4 {
  margin: 0 0 10px;
  color: #bfdbfe;
  font-size: 14px;
}

.po-db-job-document-message {
  margin: 0 0 10px;
  color: #94a3b8;
  font-size: 12px;
}

.po-db-job-document-message[data-error='true'] {
  color: #fca5a5;
}

.po-db-job-document-orders {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.po-db-job-document-order {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid rgba(59, 130, 246, 0.32);
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.38);
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 600;
}

.po-db-job-document-check {
  color: #4ade80;
  font-weight: 800;
}

/* Etapa 07.7: carga conjunta por trabajo */
.po-db-job-document-group .po-db-doc-upload-button {
  margin-top: 14px;
  background: #1d4ed8;
  border-color: #3b82f6;
  color: #fff;
}

.po-db-job-document-results {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}

.po-db-job-document-result {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  font-size: 12px;
}

.po-db-job-document-result[data-status='completed'] {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.35);
}

.po-db-job-document-result[data-status='failed'] {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}

.po-db-job-document-result[data-status='requiresVerification'] {
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.35);
}

/* Etapa 07.7: resultados de eliminación conjunta */
.po-db-job-document-result[data-status='deleted'] {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.35);
}

.po-db-job-document-result[data-status='not_present'],
.po-db-job-document-result[data-status='not_attempted'] {
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.3);
}

.po-db-job-document-result[data-status='requires_verification'] {
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.35);
}

/* Semáforo de cantidades en Seguimiento de OC */
.po-db-quantity-legend {
  margin: 4px 0 12px;
  color: #94a3b8;
  font-size: 0.8rem;
  line-height: 1.5;
}

.po-db-detail-table td.po-db-qty--complete {
  color: #6ee7b7;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.po-db-detail-table td.po-db-qty--partial {
  color: #fbbf24;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.po-db-detail-table td.po-db-qty--overdue {
  color: #fca5a5;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* 09C-3F: búsqueda específica por SKU junto a las acciones del Panel. */
.po-db-filter-actions .po-db-sku-field {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  min-width: 220px;
  max-width: 280px;
  margin-left: 18px;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
}
.po-db-filter-actions .po-db-sku-field input {
  box-sizing: border-box;
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid #394e68;
  border-radius: 7px;
  background: #101b2a;
  color: #eff5ff;
  font: inherit;
}
.po-db-filter-actions .po-db-sku-field input::placeholder {
  color: #8da4bb;
}
.po-db-filter-actions .po-db-sku-field input:focus-visible {
  outline: 2px solid #8fc6ff;
  outline-offset: 2px;
}
@media (max-width: 980px) {
  .po-db-filter-actions .po-db-sku-field {
    margin-left: 0;
    flex-basis: 100%;
    max-width: 320px;
  }
}
