:root {
  --azul: #1a6fff;
  --verde: #00b86b;
  --rojo: #e0433d;
  --morado: #7b4fd6;
  --gris-100: #f4f6f9;
  --gris-200: #e6e9ee;
  --gris-500: #8a94a3;
  --gris-800: #2b2f38;
  --radio: 10px;
}

* { box-sizing: border-box; }

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

/* ---- LOGIN ---- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-box {
  background: #fff; padding: 32px 28px; border-radius: var(--radio);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08); width: 100%; max-width: 380px; text-align: center;
}
.login-box h1 { margin: 0 0 4px; font-size: 24px; }
.subtitle { color: var(--gris-500); margin: 0 0 24px; font-size: 14px; }
.login-box form { text-align: left; }

/* ---- LAYOUT ---- */
.topbar {
  background: #fff; border-bottom: 1px solid var(--gris-200); padding: 14px 20px;
  display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-weight: 700; font-size: 18px; }
.topbar-user { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--gris-500); }

.container { max-width: 960px; margin: 0 auto; padding: 20px; }
.container-narrow { max-width: 480px; }

.card { background: #fff; border-radius: var(--radio); padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.card h2 { margin-top: 0; font-size: 17px; }

.actions-row { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }

.highlight-card {
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(135deg, #fff, var(--gris-100));
  border: 1px solid var(--gris-200);
}

/* ---- BOTONES ---- */
.btn {
  display: inline-block; padding: 10px 16px; border-radius: 8px; text-decoration: none;
  font-size: 14px; font-weight: 600; border: none; cursor: pointer; text-align: center;
}
.btn-primary { background: var(--azul); color: #fff; }
.btn-secondary { background: var(--gris-200); color: var(--gris-800); }
.btn-small { background: transparent; color: var(--gris-500); padding: 6px 10px; font-weight: 500; }
.btn-block { display: block; width: 100%; margin-top: 8px; }
.btn-grande { padding: 16px; font-size: 17px; }

/* ---- FORMULARIOS ---- */
label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: var(--gris-800); }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--gris-200); border-radius: 8px;
  font-size: 15px; background: #fff;
}
textarea { resize: vertical; font-family: inherit; }
.fila-doble { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 12px; color: var(--gris-500); margin: 6px 0 0; }

.tipo-selector { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tipo-opcion { border: 2px solid var(--gris-200); border-radius: 8px; padding: 14px; text-align: center; cursor: pointer; font-weight: 600; margin: 0; font-size: 15px; }
.tipo-opcion input { display: none; }
.tipo-entrada:has(input:checked) { border-color: var(--verde); background: #eafff4; color: #067a44; }
.tipo-salida:has(input:checked) { border-color: var(--rojo); background: #fff0ef; color: #a52a24; }

.foto-input-wrap { display: flex; flex-direction: column; gap: 10px; }
.preview-foto { max-width: 100%; max-height: 240px; border-radius: 8px; object-fit: contain; background: var(--gris-100); }

/* ---- ALERTAS ---- */
.alert { padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.alert-error { background: #fdecea; color: #a52a24; }
.alert-info { background: #eaf2ff; color: #14509e; }
.alert-success { background: #e6f8ee; color: #067a44; }

/* ---- STOCK ---- */
.stock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.stock-item { border: 1px solid var(--gris-200); border-radius: 8px; padding: 14px; position: relative; }
.stock-item.stock-bajo { border-color: #f5c6a5; background: #fff8f0; }
.stock-foto-thumb {
  width: 56px; height: 56px; border-radius: 8px; overflow: hidden; margin-bottom: 8px;
  cursor: pointer; background: var(--gris-100);
}
.stock-foto-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.foto-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85);
  display: none; align-items: center; justify-content: center;
  z-index: 9999; padding: 20px; cursor: pointer;
}
.foto-modal-overlay.open { display: flex; }
.foto-modal-overlay img {
  max-width: 92vw; max-height: 92vh; object-fit: contain; border-radius: 8px; cursor: default;
}
.stock-nombre { font-size: 13px; color: var(--gris-500); margin-bottom: 4px; }
.stock-cantidad { font-size: 22px; font-weight: 700; }
.stock-cantidad .unidad { font-size: 13px; font-weight: 500; color: var(--gris-500); }
.badge { display: inline-block; font-size: 11px; padding: 3px 8px; border-radius: 20px; font-weight: 600; }
.badge-warning { background: #ffedd5; color: #9a5b0f; margin-top: 6px; }
.badge-entrada { background: #d6f5e5; color: #067a44; }
.badge-salida { background: #fbdedc; color: #a52a24; }

.categoria-tag {
  position: absolute; top: 10px; right: 10px; font-size: 10px; background: var(--gris-100);
  color: var(--gris-500); padding: 2px 7px; border-radius: 10px; font-weight: 600;
}
.categoria-tag-inline {
  font-size: 11px; background: var(--gris-100); color: var(--gris-500);
  padding: 2px 8px; border-radius: 10px; font-weight: 600; margin-left: 4px;
}

/* ---- FILTROS ---- */
.filtros { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; align-items: center; }
.filtros select, .filtros input { width: auto; margin: 0; padding: 8px 10px; font-size: 13px; }

/* ---- TABLA MOVIMIENTOS ---- */
.movimiento-row { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--gris-200); }
.movimiento-row:last-child { border-bottom: none; }
.mov-foto img, .mov-foto-vacia {
  width: 64px; height: 64px; border-radius: 8px; object-fit: cover; background: var(--gris-100);
  display: flex; align-items: center; justify-content: center; font-size: 24px;
}
.mov-info { flex: 1; }
.mov-linea1 { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; flex-wrap: wrap; }
.mov-linea2 { font-size: 13px; color: var(--gris-500); }
.mov-nota { font-size: 13px; color: var(--gris-800); margin-top: 4px; font-style: italic; }

.link-back { display: inline-block; margin-bottom: 14px; color: var(--gris-500); text-decoration: none; font-size: 14px; }
.muted { color: var(--gris-500); font-size: 14px; }

/* ---- PRECIOS ---- */
.precio-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--gris-200);
}
.precio-row:last-of-type { border-bottom: none; }
.precio-input { display: flex; align-items: center; gap: 4px; width: 130px; }
.precio-input .prefijo { color: var(--gris-500); font-weight: 600; }
.precio-input input { width: 100%; text-align: right; }

/* ---- REPORTE ---- */
.totales-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.total-box { text-align: center; }
.total-entrada .stock-cantidad { color: var(--verde); }
.total-salida .stock-cantidad { color: var(--rojo); }
.tabla-scroll { overflow-x: auto; }
.tabla-reporte { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabla-reporte th {
  text-align: left; padding: 8px 10px; background: var(--gris-100); color: var(--gris-500);
  font-weight: 600; white-space: nowrap;
}
.tabla-reporte td { padding: 8px 10px; border-bottom: 1px solid var(--gris-200); white-space: nowrap; }

.receta-card { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; cursor: pointer; transition: box-shadow .15s; }
.receta-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }

@media (max-width: 700px) {
  .totales-row { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .fila-doble { grid-template-columns: 1fr; }
  .container { padding: 14px; }
}
