:root {
  --azul: #2f5d8c;
  --azul-osc: #1f3f5f;
  --rojo: #c0392b;
  --naranja: #d97706;
  --verde: #2e7d32;
  --gris-bg: #f4f6f8;
  --gris-borde: #dfe3e8;
  --texto: #22303f;
}

* { box-sizing: border-box; }

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

.topbar {
  background: var(--azul-osc);
  color: white;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.topbar h1 { font-size: 20px; margin: 0; }

.operador-box { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.operador-box input {
  padding: 6px 10px;
  border-radius: 6px;
  border: none;
  width: 160px;
}

.tabs {
  display: flex;
  background: white;
  border-bottom: 1px solid var(--gris-borde);
  padding: 0 24px;
}

.tab-btn {
  padding: 12px 18px;
  border: none;
  background: none;
  font-size: 15px;
  cursor: pointer;
  color: #5a6b7b;
  border-bottom: 3px solid transparent;
}

.tab-btn.active {
  color: var(--azul);
  border-bottom-color: var(--azul);
  font-weight: 600;
}

main { padding: 20px 24px 60px; max-width: 1100px; margin: 0 auto; }

.tab-content { display: none; }
.tab-content.active { display: block; }

.alerta-banner {
  background: #fff3e0;
  border: 1px solid var(--naranja);
  color: #7a4a00;
  padding: 10px 16px;
  border-radius: 8px;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

#buscador, #buscador-admin {
  flex: 1;
  min-width: 220px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--gris-borde);
  font-size: 15px;
}

.contador { color: #728093; font-size: 14px; white-space: nowrap; }

.tabla-wrap { background: white; border-radius: 10px; overflow: auto; border: 1px solid var(--gris-borde); max-height: 60vh; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th {
  text-align: left;
  padding: 10px 12px;
  background: #eef2f6;
  position: sticky;
  top: 0;
  color: #45566a;
  font-weight: 600;
  border-bottom: 1px solid var(--gris-borde);
}

td { padding: 8px 12px; border-bottom: 1px solid #eef1f4; vertical-align: middle; }

tr.bajo-minimo td { background: #fdecea; }
tr.bajo-minimo .stock-valor { color: var(--rojo); font-weight: 700; }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--rojo);
  color: white;
  margin-left: 6px;
}

input[type=number].cant-input {
  width: 70px;
  padding: 6px 8px;
  border: 1px solid var(--gris-borde);
  border-radius: 6px;
}

button.primario, a.primario {
  background: var(--azul);
  color: white;
  border: none;
  padding: 9px 16px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  display: inline-block;
}
button.primario:hover, a.primario:hover { background: var(--azul-osc); }

button.secundario {
  background: white;
  border: 1px solid var(--gris-borde);
  padding: 8px 14px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
}

button.descontar-btn {
  background: var(--azul);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
button.descontar-btn:hover { background: var(--azul-osc); }

button.editar-btn, button.eliminar-btn {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 5px;
}
button.editar-btn { color: var(--azul); }
button.eliminar-btn { color: var(--rojo); }
button.editar-btn:hover, button.eliminar-btn:hover { background: #f0f2f5; }

.link-btn {
  background: none;
  border: none;
  color: var(--azul);
  text-decoration: underline;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
}

.oculto { display: none !important; }

.grid-admin {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.card {
  background: white;
  border: 1px solid var(--gris-borde);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 20px;
}

.card h2 { font-size: 16px; margin-top: 0; margin-bottom: 10px; }

.ayuda { font-size: 13px; color: #667586; margin-bottom: 10px; }

.campo { margin-bottom: 10px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.campo label { font-weight: 500; color: #45566a; }
.campo input[type=text], .campo input[type=number], .campo input[type=password],
.campo input[type=time], .campo select {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--gris-borde);
  font-family: inherit;
  font-size: 14px;
}

.card .campo:has(input[type=radio]) { flex-direction: row; align-items: center; font-weight: 400; }

input[type=file] { display: block; margin: 10px 0; }

.mensaje { font-size: 13px; margin-top: 8px; }
.mensaje.ok { color: var(--verde); }
.mensaje.error { color: var(--rojo); }

.boton-link { margin-top: 6px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--azul-osc);
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
  z-index: 999;
}
.toast.error { background: var(--rojo); }

@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: flex-start; }
}
