:root {
  --fondo: #f3f5f9;
  --tarjeta: #ffffff;
  --texto: #1e2430;
  --texto-suave: #667085;
  --primario: #2f5bea;
  --primario-oscuro: #2347bd;
  --borde: #dfe3ec;
  --error: #c0392b;
  --error-fondo: #fdecea;
  --sombra: 0 6px 24px rgba(30, 36, 48, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fondo);
  color: var(--texto);
  line-height: 1.4;
}

/* ---------- Login ---------- */
.pagina-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-caja {
  width: 100%;
  max-width: 380px;
  background: var(--tarjeta);
  border-radius: 14px;
  box-shadow: var(--sombra);
  padding: 32px 28px;
}

.login-marca { text-align: center; margin-bottom: 22px; }
.login-marca .logo { font-size: 44px; }
.login-marca h1 { margin: 6px 0 4px; font-size: 22px; }
.login-marca p { margin: 0; color: var(--texto-suave); font-size: 14px; }

form label { display: block; font-size: 14px; font-weight: 600; margin: 14px 0 6px; }

form input {
  width: 100%;
  padding: 11px 12px;
  font-size: 16px;
  border: 1px solid var(--borde);
  border-radius: 8px;
  background: #fff;
}
form input:focus {
  outline: none;
  border-color: var(--primario);
  box-shadow: 0 0 0 3px rgba(47, 91, 234, 0.15);
}

button {
  font: inherit;
  cursor: pointer;
}

#btn-entrar {
  width: 100%;
  margin-top: 20px;
  padding: 12px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: var(--primario);
  border: 0;
  border-radius: 8px;
}
#btn-entrar:hover { background: var(--primario-oscuro); }
#btn-entrar:disabled { opacity: 0.6; cursor: wait; }

.mensaje-error {
  margin: 14px 0 0;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--error);
  background: var(--error-fondo);
  border-radius: 8px;
}

/* ---------- Menu ---------- */
.barra {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #ffffff;
  padding: 0.75rem 2rem;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
  position: sticky;
  top: 0;
  z-index: 100;
}
.barra-marca {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.barra-marca .enlace-volver {
  color: #4f46e5;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: color 0.2s;
}
.barra-marca .enlace-volver:hover {
  color: #4338ca;
}

.barra-marca span {
  font-size: 1.15rem;
  font-weight: 600;
  color: #1e293b;
}
.barra-usuario {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.usuario-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background-color: #f8fafc;
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  border: 1px solid #e2e8f0;
}
.usuario-avatar {
  width: 28px;
  height: 28px;
  background-color: #4f46e5;
  color: #ffffff;
  font-weight: 600;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.usuario-detalles {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
#usuario-nombre {
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.etiqueta-rol {
  font-size: 0.7rem;
  font-weight: 500;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}
.boton-salir {
  background-color: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  padding: 0.4rem 0.85rem;
  border-radius: 0.375rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.boton-salir:hover {
  background-color: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}

.boton-secundario {
  padding: 7px 12px;
  font-size: 14px;
  color: var(--texto);
  background: #fff;
  border: 1px solid var(--borde);
  border-radius: 8px;
}
.boton-secundario:hover { background: var(--fondo); }

.contenedor { max-width: 1000px; margin: 0 auto; padding: 28px 20px 48px; }
.contenedor h2 { margin: 0; font-size: 26px; }
.subtitulo { margin: 4px 0 22px; color: var(--texto-suave); }

.rejilla-menu {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}

.tarjeta {
  position: relative;
  display: block;
  padding: 20px 18px;
  color: inherit;
  text-decoration: none;
  background: var(--tarjeta);
  border: 1px solid var(--borde);
  border-radius: 12px;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
a.tarjeta:hover {
  transform: translateY(-2px);
  border-color: var(--primario);
  box-shadow: var(--sombra);
}
.tarjeta-icono { font-size: 30px; }
.tarjeta h3 { margin: 10px 0 4px; font-size: 17px; }
.tarjeta p { margin: 0; font-size: 13px; color: var(--texto-suave); }

.tarjeta-pendiente { opacity: 0.6; cursor: default; }
.insignia {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--texto-suave);
  background: var(--fondo);
  border-radius: 999px;
}