:root {
  --primary: #7C1D24;
  --primary-hover: #63141a;
  --secondary: #475569;
  --success: #15803D;
  --success-hover: #166534;
  --bg: #F1F5F9;
  --card-bg: #FFFFFF;
  --border: #E2E8F0;
  --text-main: #0F172A;
  --text-muted: #64748B;
  --radius: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
}

/* NAVBAR */
.navbar {
  background-color: var(--primary);
  color: white;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-box {
  background-color: white;
  color: var(--primary);
  font-weight: 900;
  font-size: 1.2rem;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.brand-title {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0.5px;
  display: block;
  line-height: 1.1;
}

.brand-sub {
  font-size: 0.72rem;
  opacity: 0.85;
}

.nav-info {
  display: flex;
  gap: 10px;
}

.badge-user {
  background-color: rgba(255,255,255,0.15);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
}

.nav-actions {
  display: flex;
  gap: 8px;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: #E2E8F0; color: #1E293B; }
.btn-secondary:hover { background: #CBD5E1; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: var(--success-hover); }

.btn-outline { background: transparent; color: white; border: 1px solid rgba(255,255,255,0.6); }
.btn-outline:hover { background: rgba(255,255,255,0.15); }

.btn-sm { padding: 5px 10px; font-size: 0.78rem; }

/* CONTAINER & VIEWS */
.main-container {
  max-width: 1200px;
  margin: 20px auto;
  padding: 0 16px 40px;
}

.view { display: none; }
.view.active { display: block; animation: fadeIn 0.2s ease; }

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

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-header h2 {
  font-size: 1.4rem;
  font-weight: 800;
  color: #1E293B;
}

.subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.search-box {
  display: flex;
  gap: 8px;
}

.search-box input {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  width: 260px;
  background: white;
}

/* GRID DECAS */
.grid-decas {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.deca-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.deca-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(0,0,0,0.08);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.card-qr-box {
  width: 75px;
  height: 75px;
  background: #FFF;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.card-qr-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card-header-info {
  flex: 1;
  margin-left: 12px;
}

.deca-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary);
}

.deca-id-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.status-pill {
  display: inline-block;
  background: #DCFCE7;
  color: var(--success);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  margin-top: 4px;
}

.card-meta-list {
  font-size: 0.8rem;
  border-top: 1px solid #F1F5F9;
  padding-top: 10px;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta-item {
  display: flex;
  justify-content: space-between;
}

.meta-item strong {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.meta-item span {
  font-weight: 600;
  text-align: right;
  max-width: 190px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  border-top: 1px solid #F1F5F9;
  padding-top: 12px;
}

.card-actions .btn {
  flex: 1;
}

/* WIZARD (ALTA RÁPIDA) */
.wizard-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  max-width: 800px;
  margin: 0 auto;
  overflow: hidden;
}

.wizard-header {
  background: #F8FAFC;
  border-bottom: 1px solid var(--border);
  padding: 20px 24px;
}

.wizard-header h2 {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
}

.stepper {
  display: flex;
  background: white;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.step-item {
  flex: 1;
  min-width: 120px;
  padding: 12px 10px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}

.step-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: #FFF9F9;
}

.step-item.completed {
  color: var(--success);
  border-bottom-color: var(--success);
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #E2E8F0;
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

.step-item.active .step-num {
  background: var(--primary);
  color: white;
}

.step-item.completed .step-num {
  background: var(--success);
  color: white;
}

.wizard-body {
  padding: 24px;
}

.wizard-step {
  display: none;
}

.wizard-step.active {
  display: block;
}

.card-inner {
  background: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.card-inner-title {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: 4px;
}

.input-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #CBD5E1;
  border-radius: 6px;
  font-size: 0.88rem;
  background: white;
  transition: border-color 0.15s ease;
}

.input-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124,29,36,0.12);
}

.form-row {
  display: flex;
  gap: 12px;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }

.help-text {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 3px;
  display: block;
}

.info-pill {
  background: #EEF2F6;
  border: 1px solid #CBD5E1;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  line-height: 1.4;
}

/* TABLA MERCANCÍAS */
.mercancias-box {
  margin-top: 10px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
}

.mercancia-linea {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.mercancia-linea:last-child {
  margin-bottom: 0;
}

.btn-remove {
  background: #FEE2E2;
  color: #DC2626;
  border: 1px solid #FCA5A5;
  border-radius: 4px;
  width: 32px;
  height: 36px;
  font-weight: 700;
  cursor: pointer;
}

/* RESUMEN PASO 5 */
.summary-table {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid #F1F5F9;
  font-size: 0.82rem;
}

.summary-row:last-child { border-bottom: none; }
.summary-label { font-weight: 700; color: #475569; }
.summary-val { font-weight: 600; text-align: right; }

.wizard-footer {
  display: flex;
  justify-content: space-between;
  padding: 16px 24px;
  background: #F8FAFC;
  border-top: 1px solid var(--border);
}

/* MODALES */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: white;
  border-radius: 12px;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

.modal-header {
  padding: 16px 20px;
  background: #F8FAFC;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.6rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 20px;
}

.qr-preview-box {
  text-align: center;
  margin-bottom: 16px;
}

.qr-preview-box img {
  width: 160px;
  height: 160px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
}

.qr-caption {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.action-group-title {
  font-size: 0.7rem;
  font-weight: 800;
  color: #64748B;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.btn-action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: none;
  color: white;
  margin-bottom: 8px;
  cursor: pointer;
  text-align: left;
  transition: opacity 0.15s ease;
}

.btn-action strong { font-size: 0.88rem; }
.btn-action span { font-size: 0.72rem; opacity: 0.9; }

.btn-purple { background: #6D28D9; }
.btn-blue { background: #2563EB; }
.btn-green { background: #16A34A; }
.btn-teal { background: #0D9488; }

.btn-action:hover { opacity: 0.9; }

/* CANVAS FIRMA */
.canvas-container {
  border: 2px dashed #94A3B8;
  border-radius: 8px;
  background: #FAFAFA;
  margin-top: 8px;
  touch-action: none;
}

canvas {
  width: 100%;
  height: 180px;
  display: block;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.text-center { text-align: center; }

/* RESPONSIVE */
@media (max-width: 640px) {
  .navbar { padding: 10px 14px; }
  .nav-info { display: none; }
  .grid-decas { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; gap: 8px; }
  .stepper { justify-content: flex-start; }
}

/* LOGIN OVERLAY & CARD */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}

.login-overlay.hidden {
  display: none !important;
}

.login-card {
  background: white;
  width: 100%;
  max-width: 420px;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  padding: 28px 24px;
  animation: fadeInModal 0.2s ease-out;
}

.login-header {
  text-align: center;
  margin-bottom: 20px;
}

.logo-box-lg {
  background-color: var(--primary);
  color: white;
  font-weight: 900;
  font-size: 1.8rem;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  box-shadow: 0 4px 10px rgba(124, 29, 36, 0.25);
}

.alert-error {
  background-color: #FEE2E2;
  border: 1px solid #FCA5A5;
  color: #B91C1C;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 16px;
  font-weight: 500;
}

.demo-access-box {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px dashed var(--border);
  text-align: center;
}

.demo-access-title {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.demo-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-demo {
  background: #F8FAFC;
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  padding: 8px 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
}

.btn-demo:hover {
  background: #EFF6FF;
  border-color: #93C5FD;
}

.btn-demo strong {
  font-size: 0.78rem;
  color: #1E293B;
}

.btn-demo small {
  font-size: 0.70rem;
  color: var(--primary);
  font-weight: 600;
}

