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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f0f4f8;
  color: #1a202c;
  min-height: 100vh;
}

/* ── Navbar ───────────────────────────────────── */
nav {
  background: #1e40af;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 52px;
}
.nav-brand { font-weight: 700; font-size: 1.1rem; letter-spacing: .5px; }
.nav-links  { display: flex; align-items: center; gap: 1rem; }
.nav-links a { color: #bfdbfe; text-decoration: none; font-size: .9rem; }
.nav-links a:hover { color: #fff; }
.nav-user { color: #93c5fd; font-size: .9rem; }
.btn-logout {
  background: #dc2626;
  color: #fff !important;
  padding: .3rem .8rem;
  border-radius: 4px;
  font-size: .85rem !important;
}

/* ── Main ─────────────────────────────────────── */
main { padding: 1.5rem; max-width: 1100px; margin: 0 auto; }

/* ── Cards ────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  padding: 2rem;
  max-width: 560px;
  margin: 2rem auto;
}
.card.wide  { max-width: 100%; margin: 0; }
.card.center { text-align: center; }
.card h2 { font-size: 1.3rem; margin-bottom: .4rem; color: #1e40af; }
.card p  { color: #4b5563; margin-bottom: 1.2rem; }

/* ── Alertas ──────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: .9rem;
}
.alert-error   { background: #fee2e2; color: #991b1b; border-left: 4px solid #dc2626; }
.alert-success { background: #d1fae5; color: #065f46; border-left: 4px solid #059669; }

/* ── Login ────────────────────────────────────── */
.login-page { background: #1e40af; display: flex; align-items: center; justify-content: center; }
.login-box {
  background: #fff;
  padding: 2.5rem 2rem;
  border-radius: 12px;
  width: 360px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
}
.login-box h1 { text-align: center; font-size: 1.6rem; color: #1e40af; margin-bottom: .3rem; }
.login-sub { text-align: center; color: #6b7280; font-size: .9rem; margin-bottom: 1.5rem; }

/* ── Campos ───────────────────────────────────── */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .85rem; font-weight: 600; color: #374151; margin-bottom: .3rem; }
.field input, .field select {
  width: 100%;
  padding: .5rem .7rem;
  border: 1.5px solid #d1d5db;
  border-radius: 6px;
  font-size: .9rem;
  transition: border-color .2s;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: #3b82f6;
}

/* ── Botones ──────────────────────────────────── */
.btn-primary {
  background: #1e40af;
  color: #fff;
  border: none;
  padding: .65rem 1.4rem;
  border-radius: 7px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
  text-decoration: none;
  display: inline-block;
}
.btn-primary:hover { background: #1d3a9e; }
.btn-secondary {
  background: #e5e7eb;
  color: #374151;
  border: none;
  padding: .65rem 1.4rem;
  border-radius: 7px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn-secondary:hover { background: #d1d5db; }
.btn-full { width: 100%; text-align: center; margin-top: .5rem; }
.btn-download { background: #059669; }
.btn-download:hover { background: #047857; }

/* ── Drop zone ────────────────────────────────── */
.drop-zone {
  border: 2.5px dashed #93c5fd;
  border-radius: 10px;
  padding: 2.5rem 1rem;
  cursor: pointer;
  margin-bottom: 1rem;
  transition: background .2s, border-color .2s;
  position: relative;
}
.drop-zone:hover, .drop-zone.drag-over {
  background: #eff6ff;
  border-color: #3b82f6;
}
.drop-icon { font-size: 2.5rem; margin-bottom: .5rem; }
.drop-zone input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
#filename { display: block; margin-top: .5rem; font-weight: 600; color: #1e40af; font-size: .9rem; }

/* ── Spinner ──────────────────────────────────── */
.spinner { text-align: center; padding: 1.5rem; }
.spin {
  width: 40px; height: 40px;
  border: 4px solid #e5e7eb;
  border-top-color: #1e40af;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto .8rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Cabecera factura (grid) ──────────────────── */
.cabecera-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .8rem 1.2rem;
  margin-bottom: 1.5rem;
}
.span2 { grid-column: span 2; }

/* ── Tablas ───────────────────────────────────── */
.table-scroll { overflow-x: auto; margin-bottom: 1.2rem; }

.tabla-productos, .tabla-dist {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.tabla-productos th, .tabla-dist th {
  background: #1e40af;
  color: #fff;
  padding: .55rem .6rem;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}
.tabla-productos td, .tabla-dist td {
  padding: .4rem .5rem;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: middle;
}
.tabla-productos tr:hover td, .tabla-dist tr:hover td { background: #f8fafc; }
.num { text-align: center; color: #6b7280; width: 32px; }

/* Inputs dentro de tabla */
.input-cn   { width: 90px; }
.input-desc { width: 280px; }
.input-num  { width: 80px; text-align: right; }
.input-iva  { width: 70px; }

table input, table select {
  padding: .3rem .4rem;
  border: 1.5px solid #d1d5db;
  border-radius: 4px;
  font-size: .85rem;
}
table input:focus, table select:focus {
  outline: none; border-color: #3b82f6;
}

/* Distribución */
.col-total { text-align: center; font-weight: 600; width: 60px; }
.col-farm  { text-align: center; width: 100px; }
.input-dist { width: 75px; text-align: center; font-size: .9rem; padding: .3rem; }
.mt-val { font-weight: 700; font-size: 1rem; }
.mt-ok    { color: #059669; }
.mt-error { color: #dc2626; }

/* ── Resumen cabecera ─────────────────────────── */
.resumen-cabecera {
  display: flex;
  gap: 1.5rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 7px;
  padding: .7rem 1rem;
  font-size: .9rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

/* ── Acciones ─────────────────────────────────── */
.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.2rem;
  gap: 1rem;
}

h3 { color: #1e40af; margin: 1rem 0 .5rem; font-size: 1rem; }
