/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Variables ── */
:root {
  --color-bg:        #f4f5f7;
  --color-surface:   #ffffff;
  --color-border:    #e2e4e9;
  --color-text:      #1a1d23;
  --color-muted:     #6b7280;
  --color-primary:   #4f46e5;
  --color-primary-h: #4338ca;
  --color-danger:    #dc2626;
  --color-danger-h:  #b91c1c;
  --color-success:   #16a34a;
  --color-warning:   #d97706;
  --radius:          8px;
  --shadow:          0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --nav-h:           56px;
}

/* ── Base ── */
body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow);
}

.nav-brand {
  font-weight: 700;
  font-size: 17px;
  color: var(--color-primary);
  margin-right: 8px;
}

.nav-links { display: flex; gap: 4px; flex: 1; }

.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius);
  color: var(--color-muted);
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--color-bg); color: var(--color-text); text-decoration: none; }
.nav-link.activo { background: #ede9fe; color: var(--color-primary); }

.nav-usuario {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.usuario-nombre { color: var(--color-muted); }

/* ── Badges de rol ── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.badge-admin   { background: #ede9fe; color: #4f46e5; }
.badge-compras { background: #d1fae5; color: #065f46; }
.badge-conta   { background: #fef3c7; color: #92400e; }
.badge-verde   { background: #d1fae5; color: #065f46; }
.badge-rojo    { background: #fee2e2; color: #991b1b; }

/* ── Contenido principal ── */
.contenido {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px;
}

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.page-header h2 { font-size: 20px; font-weight: 600; }

/* ── Botones ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, opacity .15s;
  text-decoration: none !important;
  line-height: 1;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-h); border-color: var(--color-primary-h); }
.btn-danger   { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.btn-danger:hover { background: var(--color-danger-h); }
.btn-outline  { background: transparent; color: var(--color-text); border-color: var(--color-border); }
.btn-outline:hover { background: var(--color-bg); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }

/* ── Alertas ── */
.alerta {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
  border-left: 4px solid;
}
.alerta.exito  { background: #f0fdf4; border-color: var(--color-success); color: #14532d; }
.alerta.error  { background: #fef2f2; border-color: var(--color-danger);  color: #7f1d1d; }

/* ── Toolbar buscador ── */
.toolbar { margin-bottom: 14px; }
.input-buscar {
  width: 280px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.input-buscar:focus { border-color: var(--color-primary); }

/* ── Tabla ── */
.tabla-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.tabla { width: 100%; border-collapse: collapse; }
.tabla th {
  background: var(--color-bg);
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--color-muted);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}
.tabla td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
}
.tabla tbody tr:last-child td { border-bottom: none; }
.tabla tbody tr:hover { background: #f9fafb; }
.tabla tfoot td {
  padding: 10px 14px;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  font-size: 14px;
}
.acciones { display: flex; gap: 6px; }

/* ── Form card ── */
.form-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 560px;
  box-shadow: var(--shadow);
}
.campo { display: flex; flex-direction: column; gap: 5px; margin-bottom: 18px; }
.campo label { font-size: 13px; font-weight: 500; color: var(--color-text); }
.campo input, .campo select, .campo textarea {
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
  background: var(--color-surface);
  color: var(--color-text);
}
.campo input:focus, .campo select:focus, .campo textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.campos-fila { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-acciones { display: flex; gap: 10px; margin-top: 8px; }

/* ── Stats reportes ── */
.stats-fila { display: flex; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.stat-card {
  flex: 1;
  min-width: 150px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; color: var(--color-muted); font-weight: 500; text-transform: uppercase; }
.stat-valor { font-size: 22px; font-weight: 700; color: var(--color-text); }

/* ── Filtros form ── */
.filtros-form {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.campo-inline { display: flex; flex-direction: column; gap: 4px; }
.campo-inline label { font-size: 12px; font-weight: 500; color: var(--color-muted); }
.campo-inline input {
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
}
.campo-inline input:focus { border-color: var(--color-primary); }

/* ── Login ── */
.pagina-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--color-bg);
}
.login-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
}
.login-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 24px; text-align: center; }

/* ── Errores ── */
.pagina-error {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.error-card { text-align: center; }
.error-code { font-size: 72px; font-weight: 800; color: var(--color-primary); line-height: 1; }
.error-card h1 { font-size: 22px; margin: 8px 0 12px; }
.error-card p { color: var(--color-muted); margin-bottom: 20px; }

/* ── Vacío ── */
.vacio {
  text-align: center;
  padding: 48px;
  color: var(--color-muted);
  font-size: 15px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  z-index: 9999;
  animation: fadeIn .2s ease;
}
.toast-exito { background: #16a34a; color: #fff; }
.toast-error { background: var(--color-danger); color: #fff; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Grid layouts ── */
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 700px) {
  .grid-2col, .grid-3col { grid-template-columns: 1fr; }
}

/* ── Cards ── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--color-muted);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}
.card-body { padding: 18px; }

/* ── Dato fila (ver detalle) ── */
.dato-fila {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
}
.dato-fila:last-child { border-bottom: none; }
.dato-label {
  min-width: 160px;
  font-weight: 500;
  color: var(--color-muted);
  flex-shrink: 0;
}
.doc-fila {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
}
.doc-fila:last-child { border-bottom: none; }

/* ── Badges extra ── */
.badge-azul   { background: #dbeafe; color: #1e40af; }
.badge-morado { background: #ede9fe; color: #4f46e5; }

/* ── Estatus importación ── */
.estatus-en_proceso { background: #fef3c7; color: #92400e; }
.estatus-aduana     { background: #dbeafe; color: #1e40af; }
.estatus-liberada   { background: #d1fae5; color: #065f46; }
.estatus-entregada  { background: #ede9fe; color: #4f46e5; }
.estatus-completada { background: #f0fdf4; color: #14532d; }

/* ── Doc upload helper ── */
.doc-actual { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.doc-hint   { font-size: 12px; color: var(--color-muted); }
.campo-hint { font-size: 12px; color: var(--color-muted); margin-top: 3px; display: block; }
.sin-doc    { font-size: 13px; color: var(--color-muted); }

/* ── Textarea ── */
.campo textarea {
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  resize: vertical;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color .15s;
}
.campo textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
