:root {
  --navy: #1f3a5f;
  --blue: #2f6fed;
  --gray: #5b6b7c;
  --light: #eef2f7;
  --border: #c7d1dd;
  --bg: #f5f7fa;
  --text: #1a2430;
  --green: #2f9e6b;
  --red: #d64545;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--navy);
  color: white;
  padding: 14px 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .logo { width: 32px; height: 32px; border-radius: 8px; }
.topbar-brand { flex: 1; }
.brand { font-weight: 700; font-size: 18px; line-height: 1.1; }
.brand-sub { font-size: 12px; opacity: 0.8; }
.topbar-user { text-align: right; font-size: 12.5px; }
.user-nombre { font-weight: 600; margin-bottom: 2px; }
.user-links a {
  color: #cfe0ff;
  text-decoration: none;
  margin-left: 10px;
  font-weight: 600;
}
.user-links a:hover { text-decoration: underline; }

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}
.container-wide { max-width: 920px; }

.login-card { max-width: 380px; margin: 40px auto; }
.demo-hint { margin-top: 14px; text-align: center; }
.demo-hint code { background: var(--light); padding: 1px 5px; border-radius: 4px; }

/* ---- Admin: tabs ---- */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.tab-btn {
  background: white;
  border: 1.5px solid var(--border);
  color: var(--gray);
  padding: 9px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
}
.tab-btn.active { background: var(--navy); border-color: var(--navy); color: white; }

.admin-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  align-items: center;
}
.admin-form input, .admin-form select {
  padding: 9px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  flex: 1;
  min-width: 130px;
}
.admin-form-5 input { min-width: 110px; }
.btn-inline { width: auto; padding: 9px 16px; }
.buscador-admin {
  width: 100%;
  padding: 9px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 10px;
}
.filtro-stock {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.filtro-stock select {
  padding: 9px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
}
.filtro-stock input { flex: 1; margin-bottom: 0; }

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table th, table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table th { color: var(--gray); font-size: 12px; text-transform: uppercase; letter-spacing: 0.3px; }
.btn-mini {
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.input-clave {
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
  width: 120px;
}

.plantilla-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 16px;
}
.plantilla-box h3 { margin: 0 0 10px; color: var(--navy); font-size: 15px; }
.plantilla-box textarea {
  width: 100%;
  padding: 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
}

.card {
  background: white;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 1px 3px rgba(20, 30, 50, 0.08);
}

h1 { font-size: 20px; margin: 0 0 14px; color: var(--navy); }
h2 { font-size: 15px; margin: 0 0 10px; color: var(--navy); }

.field {
  display: block;
  margin-bottom: 14px;
}
.field span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray);
  margin-bottom: 4px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
  background: white;
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--blue);
}
.field input:disabled { background: var(--light); color: var(--gray); }

.field-inline { flex: 1; margin-bottom: 0; }

.hint {
  font-size: 12.5px;
  color: var(--gray);
  margin: -8px 0 14px;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 18px 0;
}

.resultados {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 6px;
}
.resultado-item {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.resultado-item:hover, .resultado-item:active { border-color: var(--blue); background: #f7faff; }
.resultado-item .ri-top { display: flex; justify-content: space-between; font-size: 14.5px; font-weight: 600; }
.resultado-item .ri-nombre { font-size: 13.5px; color: var(--gray); margin-top: 2px; }
.resultado-item .ri-stock { font-size: 12.5px; margin-top: 4px; }
.stock-ok { color: var(--green); font-weight: 600; }
.stock-bajo { color: #b8860b; font-weight: 600; }
.stock-cero { color: var(--red); font-weight: 600; }

.linea-seleccion {
  border: 1.5px solid var(--blue);
  background: #f7faff;
  border-radius: 12px;
  padding: 14px;
  margin: 10px 0 6px;
}
.linea-seleccion.hidden { display: none; }
.producto-elegido { margin-bottom: 10px; }
.pe-codigo { font-size: 12.5px; color: var(--gray); font-weight: 700; letter-spacing: 0.3px; }
.pe-nombre { font-size: 15px; font-weight: 600; margin: 2px 0; }
.pe-stock { font-size: 13px; }
.pe-bodega { font-size: 12px; color: var(--gray); margin-top: 2px; }
.linea-inputs { display: flex; gap: 10px; margin-bottom: 10px; }

.badge {
  display: inline-block;
  background: var(--light);
  color: var(--navy);
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 9px;
  margin-left: 4px;
}

.tabla-lineas { margin-bottom: 16px; }
.vacio { color: var(--gray); font-size: 13.5px; font-style: italic; }
.linea-fila {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.linea-fila .lf-info { flex: 1; }
.linea-fila .lf-codigo { font-size: 11.5px; color: var(--gray); font-weight: 700; }
.linea-fila .lf-nombre { font-size: 14px; font-weight: 600; }
.linea-fila .lf-meta { font-size: 12.5px; color: var(--gray); margin-top: 2px; }
.linea-fila .lf-quitar {
  background: none;
  border: none;
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 8px;
}

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: none;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}
.btn-primary { background: var(--blue); color: white; }
.btn-primary:disabled { background: #a9bde0; cursor: not-allowed; }
.btn-secondary { background: var(--navy); color: white; margin-top: 2px; }

.error {
  color: var(--red);
  font-size: 13.5px;
  margin-top: 10px;
  text-align: center;
}

.hidden { display: none !important; }

.check {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--green);
  color: white;
  font-size: 28px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}
#vista-confirmacion h1 { text-align: center; }
.correlativo {
  text-align: center;
  font-size: 20px;
  font-weight: 800;
  color: var(--navy);
  background: var(--light);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 16px;
  letter-spacing: 0.5px;
}
.notif-list { margin-bottom: 18px; }
.notif-item {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.notif-ok { color: var(--green); font-weight: 700; }
.notif-error { color: var(--red); font-weight: 700; }
