:root {
  --brand: #0d1b8e;
  --brand-dk: #0a1570;
  --brand-lt: #eef0fb;
  --green: #16a34a;
  --red: #dc2626;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,.09), 0 1px 4px rgba(0,0,0,.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f1f5f9;
  color: var(--gray-800);
  min-height: 100vh;
}

/* ── Header ── */
header {
  background: linear-gradient(135deg, #0d1b8e 0%, #0a1270 100%);
  border-bottom: none;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(13, 27, 142, 0.22);
}
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-logo {
  height: 38px;
  width: auto;
  display: block;
  filter: brightness(0) invert(1);
}
.header-logo-divider {
  width: 1px;
  height: 22px;
  background: rgba(255,255,255,0.2);
  flex-shrink: 0;
}
.header-logo-subtitle {
  font-weight: 600;
  font-size: 14px;
  color: rgba(255,255,255,0.75);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: rgba(255,255,255,0.82);
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.3);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}
.btn-sm {
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.1);
  cursor: pointer;
  color: rgba(255,255,255,0.85);
  transition: all 0.15s;
}
.btn-sm:hover { border-color: rgba(255,255,255,0.5); background: rgba(255,255,255,0.18); color: #fff; }

/* ── Layout app (con sidebar) ── */
main:not(#view-login) {
  padding: 32px 36px;
}
#view-login { padding: 0; margin: 0; max-width: 100%; }

/* App shell */
#app-shell {
  display: flex;
  min-height: calc(100vh - 56px);
}
.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #0d1b8e 0%, #0a1270 100%);
  border-right: none;
  box-shadow: 2px 0 16px rgba(13,27,142,0.18);
  padding: 20px 0 16px;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 10px;
}
.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.28);
  padding: 12px 14px 5px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255,255,255,0.62);
  text-align: left;
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.nav-item svg { stroke: rgba(255,255,255,0.55); transition: stroke 0.15s; }
.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.92);
}
.nav-item:hover svg { stroke: rgba(255,255,255,0.85); }
.nav-item.active {
  background: rgba(255,255,255,0.13);
  color: #fff;
  font-weight: 700;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: rgba(255,255,255,0.7);
  border-radius: 0 3px 3px 0;
}
.nav-item.active svg { stroke: #fff; }
.app-content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
}

/* ── Steps ── */
.steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 24px;
  user-select: none;
  max-width: 560px;
}
.step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-400);
  white-space: nowrap;
}
.step.active { color: var(--brand); font-weight: 700; }
.step.done   { color: var(--green); }
.step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: #fff;
  flex-shrink: 0;
  transition: all 0.2s;
}
.step.active .step-dot {
  border-color: var(--brand);
  color: #fff;
  background: var(--brand);
  box-shadow: 0 0 0 4px rgba(13,27,142,0.12);
}
.step.done .step-dot { border-color: var(--green); color: #fff; background: var(--green); }
.step-line { flex: 1; height: 2px; background: var(--gray-200); min-width: 20px; margin: 0 8px; }

/* ── Cards ── */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ── Login ── */
@keyframes slideInLeft  { from { opacity:0; transform:translateX(-24px); } to { opacity:1; transform:translateX(0); } }
@keyframes slideInRight { from { opacity:0; transform:translateX( 24px); } to { opacity:1; transform:translateX(0); } }
@keyframes fadeUp       { from { opacity:0; transform:translateY(12px);  } to { opacity:1; transform:translateY(0);  } }

#view-login {
  min-height: 100vh;
  display: flex;
  overflow: hidden;
  padding: 0;
  background: none;
  align-items: stretch;
  justify-content: unset;
}

/* ── Panel izquierdo: branding ── */
.login-branding {
  display: none;
  flex: 0 0 55%;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #0d1b8e 0%, #0a1270 60%, #060d52 100%);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: slideInLeft 0.45s ease-out both;
}
@media (min-width: 900px) { .login-branding { display: flex; } }

.login-deco-1 {
  position: absolute; top: -96px; right: -96px;
  width: 384px; height: 384px; border-radius: 50%;
  background: rgba(255,255,255,0.04);
}
.login-deco-2 {
  position: absolute; bottom: -128px; left: -64px;
  width: 480px; height: 480px; border-radius: 50%;
  background: rgba(255,255,255,0.04);
}
.login-deco-3 {
  position: absolute; top: 33%; right: -48px;
  width: 224px; height: 224px; border-radius: 50%;
  background: rgba(255,255,255,0.04);
}

.login-brand-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.login-brand-logo {
  width: 320px;
  height: auto;
  user-select: none;
  animation: fadeUp 0.5s 0.15s ease-out both;
}
.login-brand-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0 16px;
  animation: fadeUp 0.5s 0.28s ease-out both;
}
.login-sep-line   { width: 48px; height: 1px; background: rgba(255,255,255,0.2); }
.login-sep-accent { width: 32px; height: 2px; background: #ef4444; border-radius: 2px; }
.login-brand-title {
  font-size: 18px; font-weight: 300; letter-spacing: 0.06em;
  color: #fff; margin: 0 0 6px;
  animation: fadeUp 0.5s 0.36s ease-out both;
}
.login-brand-sub {
  font-size: 13px; font-weight: 400;
  color: rgba(255,255,255,0.4); margin: 0;
  animation: fadeUp 0.5s 0.44s ease-out both;
}
.login-copy {
  position: absolute; bottom: 20px;
  font-size: 11px; color: rgba(255,255,255,0.22);
}

/* ── Panel derecho: formulario ── */
.login-form-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  padding: 40px 32px;
  animation: slideInRight 0.45s ease-out both;
}
.login-mobile-logo {
  display: block;
  margin-bottom: 28px;
  text-align: center;
}
.login-mobile-logo img { width: 180px; height: auto; }
@media (min-width: 900px) { .login-mobile-logo { display: none; } }

.login-form-wrap {
  width: 100%;
  max-width: 360px;
}
.login-form-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  animation: fadeUp 0.5s 0.2s ease-out both;
}
.login-form-accent-bar {
  width: 4px; height: 28px;
  background: #0d1b8e;
  border-radius: 2px;
  flex-shrink: 0;
}
.login-form-header h1 {
  font-size: 24px; font-weight: 800; color: var(--gray-800);
}
.login-subtitle {
  font-size: 13px; color: var(--gray-400);
  margin-bottom: 28px; padding-left: 16px;
  animation: fadeUp 0.5s 0.28s ease-out both;
}
.login-form-wrap .field:nth-child(1) { animation: fadeUp 0.5s 0.30s ease-out both; }
.login-form-wrap .field:nth-child(2) { animation: fadeUp 0.5s 0.37s ease-out both; }
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 7px;
}
.field input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  background: #fff;
  transition: border 0.15s, box-shadow 0.15s;
  color: var(--gray-800);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.field input:focus {
  border-color: #0d1b8e;
  box-shadow: 0 0 0 3px rgba(13, 27, 142, 0.1);
  background: #fff;
}
.field-pass { position: relative; }
.field-pass input { padding-right: 44px; }
.btn-toggle-pass {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  display: flex;
  align-items: center;
  padding: 4px;
}
.btn-toggle-pass:hover { color: var(--gray-600); }
.btn-primary {
  width: 100%;
  padding: 13px;
  background: #0d1b8e;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 4px;
  letter-spacing: 0.01em;
  animation: fadeUp 0.5s 0.44s ease-out both;
  box-shadow: 0 4px 16px rgba(13, 27, 142, 0.25);
}
.btn-primary:hover {
  background: #0a1570;
  box-shadow: 0 6px 20px rgba(13, 27, 142, 0.38);
  transform: translateY(-1px);
}
.btn-primary:active  { transform: none; box-shadow: none; }
.btn-primary:disabled { opacity: 0.55; cursor: default; transform: none; box-shadow: none; }
.err { color: var(--red); font-size: 13px; margin-top: 12px; text-align: center; }

/* ── Upload zone ── */
.upload-zone {
  border: 2px dashed #c7d2fe;
  border-radius: var(--radius);
  padding: 64px 40px;
  text-align: center;
  transition: all 0.25s;
  background: linear-gradient(145deg, #fff 0%, #f5f7ff 100%);
  outline: none;
  cursor: default;
  max-width: 600px;
  margin: 0 auto;
}
.upload-zone:focus, .upload-zone.drag-over {
  border-color: var(--brand);
  background: linear-gradient(145deg, #eef0fb, #e8ecff);
  box-shadow: 0 0 0 4px rgba(13,27,142,.1);
}
.upload-icon {
  margin-bottom: 20px;
  color: var(--brand);
  opacity: 0.45;
  display: flex;
  justify-content: center;
}
.upload-zone h3 { font-size: 19px; font-weight: 700; margin-bottom: 8px; color: var(--gray-800); }
.upload-zone p  { color: var(--gray-500); font-size: 14px; }
.upload-hint { font-size: 12px !important; color: var(--gray-400) !important; margin-top: 8px; }
.upload-zone kbd {
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 13px;
  color: var(--gray-800);
  font-family: inherit;
  font-weight: 700;
  box-shadow: 0 1px 0 var(--gray-200);
}

/* ── Spinner ── */
.spinner-wrap {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px;
  gap: 16px;
  color: var(--gray-600);
  font-size: 15px;
}
.spinner-wrap.show { display: flex; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Review ── */
.review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: stretch; }
@media (max-width: 760px) { .review-grid { grid-template-columns: 1fr; } }
.file-preview { padding: 20px; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 84px; }
.file-thumb {
  background: var(--gray-50);
  border-radius: 10px;
  flex: 1;
  min-height: 420px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--gray-200);
  transition: box-shadow .2s;
}
.file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: top;
  cursor: zoom-in;
  transition: opacity .15s;
}
.file-thumb img:hover { opacity: .92; }
.file-thumb .pdf-icon { font-size: 64px; margin-top: 40px; }
.file-info h4 { font-size: 13px; font-weight: 600; word-break: break-all; color: var(--gray-800); }
.file-info p  { font-size: 12px; color: var(--gray-400); margin-top: 3px; }
.ai-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #6d28d9;
  background: #f5f3ff;
  border: 1px solid #ede9fe;
  padding: 5px 12px;
  border-radius: 20px;
  font-weight: 700;
  letter-spacing: .01em;
}

/* ── Form ── */
.form-section { padding: 22px 28px; }
.form-section h3 {
  font-size: 11px;
  font-weight: 800;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--brand-lt);
  display: flex;
  align-items: center;
  gap: 6px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-row.cols-quot { grid-template-columns: 2fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-1 { grid-template-columns: 1fr; }
.f-label { font-size: 11.5px; font-weight: 700; color: var(--gray-600); margin-bottom: 5px; letter-spacing: .01em; }
.f-input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  background: #fff;
  color: var(--gray-800);
}
.f-input[type="date"] { color-scheme: light; }
.f-input:hover { border-color: #c0cfe0; }
.f-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* ── Items table ── */
.items-table-wrap { overflow-x: auto; margin-bottom: 14px; border-radius: 8px; border: 1px solid var(--gray-200); }
.items-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.items-table th {
  background: var(--gray-50);
  text-align: left;
  padding: 9px 10px;
  font-size: 11px;
  font-weight: 800;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.items-table td { padding: 4px 4px; border-bottom: 1px solid var(--gray-100); }
.items-table tr:last-child td { border-bottom: none; }
.items-table tr:hover td { background: #f8fafc; }
.items-table td input {
  width: 100%;
  padding: 7px 9px;
  border: 1.5px solid transparent;
  border-radius: 6px;
  font-size: 13px;
  background: transparent;
  transition: all 0.15s;
  outline: none;
  min-height: 34px;
}
.items-table td input:hover { border-color: var(--gray-200); background: #fff; }
.items-table td input:focus {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.items-table .td-num input { text-align: right; }
/* Ocultar flechas de cantidad */
.item-qty::-webkit-inner-spin-button,
.item-qty::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.item-qty { -moz-appearance: textfield; }
.btn-del-row {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  font-size: 16px;
  padding: 4px 6px;
  border-radius: 4px;
  transition: all 0.15s;
}
.btn-del-row:hover { color: var(--red); background: #fee2e2; }
.btn-add-row {
  background: none;
  border: 1.5px dashed var(--gray-200);
  cursor: pointer;
  color: var(--brand);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  margin-top: 6px;
  transition: all 0.15s;
  width: 100%;
}
.btn-add-row:hover { background: var(--brand-lt); border-color: var(--brand); }

/* ── Totales del formulario ── */
.form-totals {
  margin-top: 12px;
  border-top: 2px solid var(--gray-200);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.form-tot-row {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  font-size: 13px;
  color: var(--gray-600);
  min-width: 220px;
}
.form-tot-lbl { font-weight: 600; }
.form-tot-val { font-variant-numeric: tabular-nums; text-align: right; min-width: 90px; }
.form-tot-main {
  font-size: 15px;
  font-weight: 800;
  color: var(--gray-800);
  border-top: 2px solid var(--brand);
  margin-top: 4px;
  padding-top: 6px;
}

/* ── Totales ── */
/* ── Lightbox ── */
.img-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.88);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.img-lightbox.show { display: flex; }
.img-lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.img-lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  font-size: 22px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.img-lightbox-close:hover { background: rgba(255,255,255,.3); }

/* ── Barra de acción ── */
.generate-bar {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.btn-generate {
  padding: 11px 28px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(22,163,74,.25);
}
.btn-generate:hover {
  background: #15803d;
  box-shadow: 0 4px 16px rgba(22,163,74,.35);
  transform: translateY(-1px);
}
.btn-generate:active { transform: none; box-shadow: none; }
.btn-generate:disabled { opacity: .55; cursor: default; transform: none; box-shadow: none; }
.btn-reset {
  background: none;
  border: 1.5px solid var(--gray-200);
  color: var(--gray-600);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all .15s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-reset:hover { border-color: var(--gray-400); color: var(--gray-800); background: var(--gray-50); }

/* ── OC generada ── */
.oc-success {
  padding: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--gray-100);
}
.oc-badge {
  background: #f0fdf4;
  color: var(--green);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin-bottom: 4px;
}
.oc-number { font-size: 28px; font-weight: 800; color: var(--gray-800); }
.oc-sub    { font-size: 15px; color: var(--gray-600); }
.oc-detail { padding: 24px; }
.oc-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.oc-box h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-400);
  margin-bottom: 8px;
}
.oc-box p   { font-size: 14px; margin-bottom: 4px; }
.oc-box .val { font-weight: 600; }
.oc-items-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 16px; }
.oc-items-table th {
  background: var(--gray-50);
  text-align: left;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
}
.oc-items-table td { padding: 9px 12px; border-bottom: 1px solid var(--gray-100); }
.oc-items-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.oc-totals { text-align: right; }
.oc-totals .total-line { font-size: 20px; font-weight: 800; margin-top: 8px; }
.oc-actions {
  display: flex;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
  border-radius: 0 0 var(--radius) var(--radius);
  flex-wrap: wrap;
}
.btn-action {
  padding: 9px 20px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid var(--gray-200);
  background: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-action.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-action.primary:hover { background: var(--brand-dk); }
.btn-action:hover { border-color: var(--gray-400); }

/* ── No AI notice ── */
.no-ai-notice {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: #92400e;
  margin-bottom: 16px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

/* ── Toasts ── */
.toast-wrap {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}
.toast {
  background: #1f2937;
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 14px;
  animation: fadeIn 0.2s;
  max-width: 320px;
  line-height: 1.4;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.toast.error   { background: var(--red); }
.toast.success { background: var(--green); }
.toast.info    { background: var(--brand); }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ── Print doc (visible en pantalla como preview A4) ── */
.print-doc {
  background: #fff;
  max-width: 860px;
  margin: 0 auto;
  padding: 40pt 48pt;
  box-shadow: 0 2px 8px rgba(0,0,0,.08), 0 8px 32px rgba(0,0,0,.12);
  border: 1px solid var(--gray-200);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: 10pt;
  color: #1e293b;
  line-height: 1.6;
}

/* ── Encabezado ── */
.pd-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 3px solid #000065;
  padding-bottom: 10pt;
  margin-bottom: 12pt;
}
.pd-company-logo {
  height: 44pt;
  width: auto;
  display: block;
  margin-bottom: 6pt;
}
.pd-company-meta { font-size: 8pt; color: #475569; line-height: 1.7; }
.pd-oc-id { text-align: right; }
.pd-oc-label {
  font-size: 7.5pt;
  font-weight: 800;
  color: #64748b;
  letter-spacing: 2pt;
  text-transform: uppercase;
  margin-bottom: 3pt;
}
.pd-oc-num  { font-size: 22pt; font-weight: 900; color: #1e293b; line-height: 1.1; }
.pd-oc-date { font-size: 9pt; color: #475569; margin-top: 4pt; }

/* ── Partes (Proveedor / Referencia) ── */
.pd-parties { display: flex; gap: 10pt; margin-bottom: 12pt; }
.pd-party {
  flex: 1;
  border: 1pt solid #cbd5e1;
  border-radius: 4pt;
  overflow: hidden;
}
.pd-party-hd {
  background: #000065;
  color: #fff;
  font-size: 7pt;
  font-weight: 800;
  letter-spacing: 1.5pt;
  text-transform: uppercase;
  padding: 4pt 8pt;
}
.pd-pt { width: 100%; border-collapse: collapse; font-size: 8.5pt; }
.pd-pt tr { border-bottom: 0.5pt solid #f1f5f9; }
.pd-pt tr:last-child { border-bottom: none; }
.pd-pt td { padding: 3.5pt 8pt; }
.pd-lbl { color: #64748b; font-weight: 700; white-space: nowrap; width: 38%; }

/* ── Tabla de ítems ── */
.pd-items {
  width: 100%;
  border-collapse: collapse;
  font-size: 8.5pt;
  margin-bottom: 10pt;
  border: 1pt solid #e2e8f0;
}
.pd-items thead tr { background: #000065; color: #fff; }
.pd-items th {
  padding: 5pt 8pt;
  text-align: left;
  font-weight: 800;
  font-size: 7.5pt;
  letter-spacing: 0.5pt;
  text-transform: uppercase;
}
.pd-items td {
  padding: 5pt 8pt;
  border-bottom: 0.5pt solid #e2e8f0;
  color: #1e293b;
  vertical-align: top;
}
.pd-items tbody tr:nth-child(even) td { background: #f8fafc; }
.pd-items tbody tr:last-child td { border-bottom: none; }
.pdi-num   { width:  5%; text-align: center; }
.pdi-desc  { width: 43%; }
.pdi-qty   { width:  9%; text-align: center; }
.pdi-unit  { width:  8%; text-align: center; }
.pdi-price { width: 17%; text-align: right; }
.pdi-sub   { width: 18%; text-align: right; }
.pd-items td.pdi-num   { text-align: center; color: #64748b; }
.pd-items td.pdi-qty   { text-align: center; }
.pd-items td.pdi-unit  { text-align: center; }
.pd-items td.pdi-price,
.pd-items td.pdi-sub   { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Observaciones + Totales ── */
.pd-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14pt;
  padding: 8pt 0;
  border-top: 1pt solid #e2e8f0;
  margin-bottom: 10pt;
}
.pd-obs { flex: 1; }
.pd-obs-lbl {
  font-size: 7.5pt;
  font-weight: 800;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5pt;
  margin-bottom: 4pt;
}
.pd-obs-txt { font-size: 8.5pt; color: #1e293b; min-height: 16pt; }
.pd-totals  { min-width: 145pt; }
.pd-tot-row {
  display: flex;
  justify-content: space-between;
  font-size: 8.5pt;
  padding: 2.5pt 0;
  color: #475569;
  border-bottom: 0.5pt solid #f1f5f9;
}
.pd-tot-lbl  { color: #64748b; }
.pd-tot-val  { font-variant-numeric: tabular-nums; min-width: 65pt; text-align: right; }
.pd-tot-main {
  margin-top: 3pt;
  padding-top: 4pt;
  border-top: 2pt solid #000065;
  border-bottom: none;
  font-weight: 900;
  font-size: 12pt;
  color: #1e293b;
}

/* ── Pie de página ── */
.pd-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12pt;
  background: #f1f5f9;
  border: 1pt solid #e2e8f0;
  border-radius: 4pt;
  padding: 6pt 10pt;
  font-size: 8pt;
  color: #1e293b;
  margin-bottom: 14pt;
}
.pd-footer strong { color: #000065; }

/* ── Firmas ── */
.pd-sigs {
  display: flex;
  gap: 40pt;
  margin-top: 110pt;
}
.pd-sig { flex: 1; }
.pd-sig.pd-sig-center { text-align: center; }
.pd-sig.pd-sig-left   { text-align: left; }
.pd-sig-line  { border-top: 1pt solid #94a3b8; margin-bottom: 1pt; }
.pd-sig-lbl   { font-size: 7.5pt; color: #64748b; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5pt; margin-top: 1pt; }
.pd-sig-name  { font-size: 8pt; color: #1e293b; margin-top: 1pt; font-weight: 700; }
.pd-sig-line-wrap { position: relative; }
.pd-sig-date  { font-size: 8.5pt; font-weight: 700; color: #000065; text-align: right; margin-top: 1pt; margin-bottom: 0; letter-spacing: 0.2pt; }
.pd-sig-img   { max-height: 45pt; max-width: 160pt; object-fit: contain; display: block; margin: 0 auto 4pt; }

/* ── Acciones pantalla OC (se ocultan al imprimir) ── */
.oc-generated-head {
  /* El ancho lo define .oc-detail-right (flex: 1) */
}
.oc-steps-row {
  margin-bottom: 12px;
}
.oc-generate-bar {
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid var(--gray-200);
  border-bottom: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
}
.oc-bar-history-layout {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0;
}
.oc-bar-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
}
.oc-bar-top .btn-reset { margin-right: auto; }
.oc-bar-actions-right {
  display: flex;
  gap: 8px;
  align-items: center;
}
.oc-bar-bottom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 20px;
  background: #f8fafc;
  border-top: 1px solid var(--gray-200);
}
.oc-bar-bottom .btn-action {
  height: 36px;
  padding: 0 18px;
  font-size: 13px;
  border-radius: 8px;
}
.oc-generate-right {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.oc-generate-right button {
  height: 42px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  font-size: 14px;
}
.oc-generate-right .btn-generate {
  padding: 0 24px;
}

/* ── Layout detalle OC: historial (izq) + columna derecha ── */
.oc-detail-layout {
  display: flex;
  gap: 0;
  align-items: flex-start;
}
.oc-detail-right {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ── Historial / Timeline (panel izquierdo) ── */
.oc-history-section {
  flex: 0 0 280px;
  position: sticky;
  top: 16px;
  padding: 20px 16px 20px 4px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
.oc-history-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 18px;
  letter-spacing: -0.01em;
}
.oc-timeline {
  position: relative;
  padding-left: 20px;
}
.oc-timeline::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--gray-200);
  border-radius: 1px;
}
.oc-tl-item {
  position: relative;
  padding-bottom: 20px;
}
.oc-tl-item:last-child { padding-bottom: 0; }
.oc-tl-dot {
  position: absolute;
  left: -18px;
  top: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gray-400);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--gray-200);
}
.oc-tl-dot.dot-created  { background: var(--brand); box-shadow: 0 0 0 2px #dbeafe; }
.oc-tl-dot.dot-approved { background: var(--green); box-shadow: 0 0 0 2px #dcfce7; }
.oc-tl-dot.dot-rejected { background: var(--red);   box-shadow: 0 0 0 2px #fee2e2; }
.oc-tl-dot.dot-sent     { background: #7c3aed;      box-shadow: 0 0 0 2px #ede9fe; }
.oc-tl-dot.dot-reactivated { background: #f59e0b;   box-shadow: 0 0 0 2px #fef3c7; }
.oc-tl-time {
  font-size: 11px;
  color: var(--gray-400);
  font-variant-numeric: tabular-nums;
  margin-bottom: 2px;
}
.oc-tl-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
  line-height: 1.3;
}
.oc-tl-who {
  font-size: 12px;
  color: var(--gray-600);
  margin-top: 1px;
}
.oc-tl-detail {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 2px;
}
.oc-tl-comment {
  margin-top: 4px;
  font-size: 11px;
  color: var(--gray-400);
  font-style: italic;
  padding-left: 8px;
  border-left: 2px solid var(--gray-200);
}

/* Dentro de la columna derecha el doc ocupa todo el ancho disponible */
.oc-detail-right .print-doc {
  max-width: none;
  margin: 0;
}

/* ── Print ── */
@media print {
  header, .sidebar, .toast-wrap, .img-lightbox,
  .page-header, #view-upload, #view-login,
  #view-oc-list, .oc-generated-head, .oc-steps-row,
  .oc-history-section { display: none !important; }

  #app-shell   { display: block !important; }
  .app-content { overflow: visible; }
  #view-oc     { display: block !important; margin: 0; padding: 0; }
  main:not(#view-login) { padding: 0 !important; }
  body { background: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { size: letter; margin: 10mm 16mm; }

  .print-doc {
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding: 0;
    max-width: none;
    margin: 0;
  }
  .oc-detail-layout, .oc-detail-right { display: block; }
}

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}
.page-header h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--gray-800);
  margin-bottom: 2px;
}
.page-sub {
  font-size: 13px;
  color: var(--gray-400);
}

/* ── Tabla de lista ── */
.list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.list-table th {
  background: var(--gray-50);
  text-align: left;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
.list-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-800);
}
.list-table tr:last-child td { border-bottom: none; }
.list-table tr:hover td { background: var(--gray-50); }
.list-empty {
  text-align: center;
  padding: 48px 16px !important;
  color: var(--gray-400);
}
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--gray-100);
  color: var(--gray-600);
  white-space: nowrap;
}
.status-badge::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.75;
  flex-shrink: 0;
}
.status-badge.pendiente_aprobacion { background: #fef3c7; color: #92400e; }
.status-badge.aprobada             { background: #d1fae5; color: #065f46; }
.status-badge.anulada              { background: #fee2e2; color: #991b1b; }
.status-badge.enviada              { background: #ede9fe; color: #5b21b6; }

/* ── Info secundaria en fila de lista ── */
.oc-row-meta {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 2px;
}
.oc-row-meta strong {
  font-weight: 600;
  color: var(--gray-500);
}

/* ── Filtro de lista ── */

/* ── Modal aprobación/rechazo ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  animation: fadeIn 0.15s ease;
}
.modal-box {
  background: #fff;
  border-radius: 14px;
  width: 420px;
  max-width: 92vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  animation: slideUp 0.2s ease;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--gray-100);
}
.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-800);
}
.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--gray-400);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: 6px;
  transition: background 0.15s;
}
.modal-close:hover { background: var(--gray-100); }
.modal-body {
  padding: 16px 22px;
}
.modal-body p {
  margin: 0 0 10px;
  font-size: 13.5px;
  color: var(--gray-500);
}
.modal-body textarea {
  width: 100%;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}
.modal-body textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(13, 27, 142, 0.1);
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--gray-100);
}
.modal-box.reject .modal-header h3 { color: #b91c1c; }
.modal-box.reject #modal-confirm-btn {
  background: #dc2626;
  color: #fff;
}
.modal-box.reject #modal-confirm-btn:hover { background: #b91c1c; }

/* Firma upload */
.sig-upload-label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  border: 1.5px dashed var(--gray-300);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--gray-50);
  padding: 10px;
}
.sig-upload-label:hover { border-color: var(--brand); background: var(--brand-lt); }
.sig-upload-label.has-img { border-style: solid; border-color: #22c55e; background: #f0fdf4; }
#modal-sig-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--gray-400);
  font-size: 13px;
}

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px) } to { opacity: 1; transform: translateY(0) } }

.list-filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.list-filter-bar input[type="search"],
.list-filter-bar select {
  height: 38px;
  padding: 0 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: 13px;
  color: var(--gray-700);
  background: #fff;
  outline: none;
  transition: border-color .15s;
}
.list-filter-bar input[type="search"] { flex: 1; min-width: 180px; }
.list-filter-bar input[type="search"]:focus,
.list-filter-bar select:focus { border-color: var(--brand); }

/* ── Fila de tabla clicable ── */
.list-table tbody tr.clickable { cursor: pointer; }
.list-table tbody tr.clickable:hover td { background: #f0f4ff; }

.oc-approval-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.btn-approve {
  background: var(--green) !important;
  color: #fff !important;
  border-color: var(--green) !important;
  font-weight: 700 !important;
}
.btn-approve:hover { background: #15803d !important; }
.btn-reject {
  background: #fff !important;
  color: var(--red) !important;
  border-color: var(--red) !important;
  font-weight: 700 !important;
}
.btn-reject:hover { background: #fee2e2 !important; }

/* ── Badge de estado y botones de acción ── */
.status-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
}
.oc-status-badge {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.oc-status-badge.pendiente_aprobacion { background: #fef3c7; color: #92400e; }
.oc-status-badge.aprobada { background: #dcfce7; color: #166534; }
.oc-status-badge.enviada { background: #dbeafe; color: #1e40af; }
.oc-status-badge.anulada, .oc-status-badge.rechazada { background: #fee2e2; color: #991b1b; }
.btn-send {
  background: var(--brand) !important;
  color: #fff !important;
  border-color: var(--brand) !important;
  font-weight: 700 !important;
}
.btn-send:hover { background: var(--brand-dk) !important; }
.status-select-wrap select {
  height: 38px;
  padding: 0 10px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: #fff;
}

/* ── Administración de usuarios ── */
.users-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.users-header p {
  color: var(--gray-500);
  margin-top: 4px;
  font-size: 13px;
}
.btn-inline { width: auto; padding: 10px 16px; }
.users-card { padding: 0; overflow: hidden; }
.table-wrap { width: 100%; overflow-x: auto; }
.users-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}
.users-table th,
.users-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--gray-100);
  text-align: left;
  font-size: 13px;
}
.users-table th {
  background: var(--gray-50);
  color: var(--gray-500);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.users-table tbody tr:hover { background: #fafbff; }
.user-role,
.user-status {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.role-admin { background: #dbeafe; color: #1e40af; }
.role-compras { background: #dcfce7; color: #166534; }
.role-gerencia { background: #f3e8ff; color: #6b21a8; }
.role-consulta { background: #f1f5f9; color: #475569; }
.user-status.active { background: #dcfce7; color: #166534; }
.user-status.inactive { background: #fee2e2; color: #991b1b; }
.user-actions { display: flex; gap: 6px; }
.btn-danger-soft { color: #b91c1c; border-color: #fecaca; }
.empty-cell { text-align: center !important; color: var(--gray-400); padding: 28px !important; }
.error-text { color: #b91c1c; }

.user-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, .48);
  backdrop-filter: blur(3px);
  animation: fadeIn .18s ease-out;
}
.user-modal-card {
  width: min(440px, 100%);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .24);
  animation: slideUp .22s ease-out;
}
.user-modal-header,
.user-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 20px;
  border-bottom: 1px solid var(--gray-100);
}
.user-modal-header h3 { margin: 0; font-size: 17px; }
.user-modal-close {
  border: 0;
  background: transparent;
  color: var(--gray-400);
  font-size: 26px;
  cursor: pointer;
}
.user-modal-body { padding: 20px; }
.user-modal-body .field { margin-bottom: 14px; }
.user-modal-body select {
  width: 100%;
  height: 42px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  padding: 0 11px;
  background: #fff;
}
.user-modal-footer {
  justify-content: flex-end;
  gap: 9px;
  border-top: 1px solid var(--gray-100);
  border-bottom: 0;
}
.user-active-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--gray-700);
  margin-top: 5px;
}
