.container-fluid:has(.app-shell) {
  padding: 0 !important;
  max-width: none !important;
}

:root {
  --sidebar-w: 264px;
  --sidebar-w-collapsed: 84px;
  --topbar-h: 68px;
}

.app-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  background: #f5f3f7;
  font-family: 'Inter', 'Poppins', sans-serif;
}

/* ---------- Sidebar ---------- */

.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(190deg, #3a0b30 0%, #7a1359 55%, #9b1b6e 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 40;
  transition: width .25s ease;
}

.app-sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 20px;
  padding-top: calc(22px + env(safe-area-inset-top, 0px));
  padding-left: calc(20px + env(safe-area-inset-left, 0px));
  min-height: var(--topbar-h);
}

.app-sidebar-logo {
  height: 26px;
  filter: brightness(0) invert(1);
  transition: opacity .2s ease;
}

.app-sidebar-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: 0;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .2s ease;
  flex-shrink: 0;
}

.app-sidebar-toggle i {
  transition: transform .2s ease;
}

.app-sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

.app-sidebar-nav {
  flex: 1;
  padding: 8px 14px;
  padding-left: calc(14px + env(safe-area-inset-left, 0px));
  overflow-y: auto;
  overscroll-behavior: contain;
  overflow-x: hidden;
}

.app-sidebar-section {
  display: block;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  padding: 14px 12px 8px;
  white-space: nowrap;
}

.app-nav-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 12px;
  margin-bottom: 4px;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  font-size: .92rem;
  font-weight: 500;
  white-space: nowrap;
  position: relative;
  transition: background .18s ease, color .18s ease;
}

.app-nav-link i {
  width: 18px;
  text-align: center;
  font-size: .95rem;
  flex-shrink: 0;
}

.app-nav-link:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.app-nav-link.active {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  box-shadow: inset 3px 0 0 #fff;
}

/* ---------- Grupos colapsables (ej. Administración) ---------- */

.app-nav-group-toggle {
  width: 100%;
  background: none;
  border: 0;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.app-nav-group-chevron {
  margin-left: auto;
  font-size: .72rem !important;
  width: auto !important;
  transition: transform .2s ease;
}

.app-nav-group.is-open .app-nav-group-chevron {
  transform: rotate(180deg);
}

.app-nav-group-children {
  max-height: 0;
  overflow: hidden;
  transition: max-height .2s ease;
}

.app-nav-group.is-open .app-nav-group-children {
  max-height: 400px;
}

.app-nav-sublink {
  padding-left: 30px;
  font-size: .86rem;
  gap: 12px;
  white-space: normal;   /* un nombre largo (p. ej. «Clientes no completados») baja a dos líneas para que quepa la bolita roja */
}

.app-nav-sublink .app-nav-label {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.2;
}

.app-shell.is-collapsed .app-nav-group-chevron,
.app-shell.is-collapsed .app-nav-group-children {
  display: none;
}

/* Bolita roja con el número de pendientes (p. ej. «Clientes no completados») */
.app-nav-badge {
  margin-left: auto;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ef3b3b;
  color: #fff;
  font-size: .7rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), 0 4px 10px -2px rgba(239, 59, 59, 0.7);
  flex-shrink: 0;
}

/* En el grupo: se ve solo con el grupo cerrado (abierto ya se ve en su opción); con el menú colapsado queda como punto sobre el ícono. */
.app-nav-badge-grupo { margin-right: 6px; }
.app-nav-group.is-open .app-nav-badge-grupo { display: none; }
/* Con el menú colapsado las opciones no se ven: la bolita del grupo se muestra siempre (aunque el grupo esté abierto), como punto sobre su ícono. */
.app-shell.is-collapsed .app-nav-group .app-nav-badge-grupo {
  display: inline-flex;
  position: absolute;
  top: 3px;
  right: 6px;
  margin: 0;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: .56rem;
}

.app-sidebar-footer {
  padding: 16px 14px 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  padding-left: calc(14px + env(safe-area-inset-left, 0px));
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-user {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.app-user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .82rem;
  flex-shrink: 0;
}

.app-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.app-user-name {
  font-size: .85rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-user-role {
  font-size: .72rem;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-logout {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-decoration: none;
  transition: background .18s ease;
}

.app-logout:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.app-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 5, 16, 0.5);
  z-index: 35;
}

/* Collapsed state (desktop) */

.app-shell.is-collapsed .app-sidebar {
  width: var(--sidebar-w-collapsed);
}

.app-shell.is-collapsed .app-sidebar-brand {
  justify-content: center;
  padding: 22px 10px;
}

.app-shell.is-collapsed .app-sidebar-logo {
  display: none;
}

.app-shell.is-collapsed .app-sidebar-toggle i {
  transform: rotate(180deg);
}

.app-shell.is-collapsed .app-nav-label,
.app-shell.is-collapsed .app-user-info,
.app-shell.is-collapsed .app-sidebar-section {
  display: none;
}

.app-shell.is-collapsed .app-nav-link {
  justify-content: center;
  padding: 12px;
}

.app-shell.is-collapsed .app-sidebar-footer {
  justify-content: center;
}

.app-shell.is-collapsed .app-user {
  flex: 0;
}

.app-shell.is-collapsed .app-logout {
  display: none;
}

/* ---------- Área principal ---------- */

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-content {
  flex: 1;
  padding: 28px;
}

.app-page-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.app-mobile-toggle {
  display: none;
  background: #fff;
  border: 1px solid #ece7ee;
  color: #4a3f4f;
  font-size: 1rem;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.app-page-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #201421;
  letter-spacing: -0.01em;
  margin: 0;
}

/* ---------- Barra de filtros (Año/Mes/Consultar, etc.) ---------- */

.filter-bar {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 4px 5px 0 rgba(0, 0, 0, 0.06), 0 1px 10px 0 rgba(0, 0, 0, 0.04);
  padding: 20px 22px;
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
}

.filter-field.filter-field-grow {
  flex: 1;
}

.filter-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #948d9c;
}

.filter-select {
  border: 1.5px solid #e9e3ec !important;
  border-radius: 12px !important;
  padding: 10px 14px !important;
  font-size: .9rem !important;
  font-weight: 600;
  color: #201421;
  background-color: #faf8fb !important;
  transition: border-color .15s ease, background-color .15s ease;
  min-width: 150px;
}

.filter-select:focus {
  border-color: var(--color-main) !important;
  background-color: #fff !important;
  box-shadow: 0 0 0 4px rgba(155, 27, 110, 0.08) !important;
}

.filter-submit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(120deg, var(--color-main), var(--color-secondary));
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 11px 22px;
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 20px -10px rgba(155, 27, 110, 0.5);
  transition: transform .15s ease, filter .15s ease;
  white-space: nowrap;
  height: 42px;
}

.filter-submit:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  color: #fff;
}

@media (max-width: 576px) {
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-field,
  .filter-submit {
    width: 100%;
  }
}

/* ---------- Tarjetas de módulo (desk) ---------- */

.app-welcome {
  margin-bottom: 28px;
}

.app-welcome h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #201421;
  margin-bottom: 4px;
}

.app-welcome p {
  color: #8a8494;
  font-size: .92rem;
  margin: 0;
}

/* Secciones de Inicio (mismas que el menú lateral). Cada sección tiene su acento (--tone) para no saturar de morado. */
.app-section {
  --tone: #9B1B6E;
  --tone-2: #C6389A;
  --tone-soft: rgba(155, 27, 110, 0.09);
  --tone-glow: rgba(155, 27, 110, 0.32);
  margin-bottom: 30px;
}

.app-section[data-tone="indigo"] { --tone: #4A46C8; --tone-2: #7C74F0; --tone-soft: rgba(74, 70, 200, 0.09); --tone-glow: rgba(74, 70, 200, 0.32); }
.app-section[data-tone="teal"]   { --tone: #0E8590; --tone-2: #2BC0B0; --tone-soft: rgba(14, 133, 144, 0.10); --tone-glow: rgba(14, 133, 144, 0.30); }
.app-section[data-tone="amber"]  { --tone: #C46A12; --tone-2: #F2A73B; --tone-soft: rgba(196, 106, 18, 0.10); --tone-glow: rgba(196, 106, 18, 0.30); }
.app-section[data-tone="slate"]  { --tone: #3F4A5F; --tone-2: #6B7A94; --tone-soft: rgba(63, 74, 95, 0.09); --tone-glow: rgba(63, 74, 95, 0.28); }

.app-section:last-child {
  margin-bottom: 8px;
}

.app-section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.app-section-icon {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: .68rem;
  color: var(--tone);
  background: var(--tone-soft);
}

.app-section-title {
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: #948d9c;
  white-space: nowrap;
}

.app-section-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, #e6dfe9, rgba(230, 223, 233, 0));
}

.app-module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}

.app-module-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #fff;
  border: 1px solid #ece7ee;
  border-radius: 18px;
  padding: 16px 18px;
  text-decoration: none;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.app-module-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 34px -16px var(--tone-glow);
  border-color: var(--tone-soft);
}

/* Icono suave (fondo tintado + glifo del acento); al pasar el mouse se llena con el degradado. */
.app-module-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--tone-soft);
  color: var(--tone);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .95rem;
  transition: background .2s ease, color .2s ease, transform .2s ease;
}

.app-module-card:hover .app-module-icon {
  background: linear-gradient(135deg, var(--tone), var(--tone-2));
  color: #fff;
  transform: scale(1.06);
}

/* generales.css fuerza h3 a 1.45rem con !important; aquí se necesita el tamaño de la navegación lateral */
.app-module-card h3 {
  font-size: .92rem !important;
  line-height: 1.3;
  font-weight: 600;
  color: #201421;
  margin: 0;
}

/* ---------- Responsive ---------- */

@media (max-width: 992px) {
  .app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    box-shadow: 20px 0 40px rgba(0, 0, 0, 0.25);
  }

  .app-shell.is-mobile-open .app-sidebar {
    transform: translateX(0);
  }

  .app-shell.is-mobile-open .app-sidebar-overlay {
    display: block;
  }

  .app-sidebar-toggle {
    display: none;
  }

  .app-mobile-toggle {
    display: flex;
  }

  .app-content {
    padding: 20px 16px;
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
  }
}


/* ---------- «Ver como» otro usuario (solo SUPERADMIN) ---------- */

.sup-bar {
  position: fixed;
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  z-index: 1040;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 18px;
  padding: 12px clamp(14px, 3vw, 28px);
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(120deg, #2b1226, #5b1a47);
  color: #fff;
  box-shadow: 0 -10px 30px -12px rgba(26, 10, 22, 0.55);
  border-top: 2px solid rgba(255, 255, 255, 0.18);
}

.app-shell.is-collapsed .sup-bar { left: var(--sidebar-w-collapsed); }
.sup-bar-info { display: flex; align-items: center; gap: 12px; min-width: 0; }

.sup-bar-ico {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.14);
  font-size: 1rem;
}

.sup-bar-texto { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.sup-bar-linea { font-size: .95rem; overflow-wrap: anywhere; }
.sup-bar-linea em { font-style: normal; font-size: .7rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; background: rgba(255, 255, 255, 0.18); padding: 2px 8px; border-radius: 999px; margin-left: 6px; white-space: nowrap; }
.sup-bar-texto small { font-size: .74rem; color: rgba(255, 255, 255, 0.7); overflow-wrap: anywhere; }

.sup-bar-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 12px;
  padding: 11px 18px;
  font-family: inherit;
  font-size: .86rem;
  font-weight: 800;
  color: var(--color-main);
  background: #fff;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}

.sup-bar-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 22px -10px rgba(0, 0, 0, 0.6); }

/* El contenido no queda tapado por la barra */
.is-suplantando .app-content { padding-bottom: 104px; }

@media (max-width: 992px) {
  .sup-bar { left: 0; }
}

@media (max-width: 576px) {
  .sup-bar { flex-direction: column; align-items: stretch; }
  .sup-bar-btn { justify-content: center; width: 100%; }
  .is-suplantando .app-content { padding-bottom: 150px; }
}

/* Ventana para elegir a quién ver */
.sup-modal { border: 0; border-radius: 22px; overflow: hidden; box-shadow: 0 30px 60px -20px rgba(122, 19, 89, 0.35); }

.sup-modal-header {
  background: linear-gradient(120deg, var(--color-main), var(--color-secondary));
  color: #fff;
  padding: 22px 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.sup-modal-titulo { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.01em; }
.sup-modal-sub { font-size: .82rem; color: rgba(255, 255, 255, 0.85); margin-top: 4px; }

.sup-modal-cerrar {
  background: rgba(255, 255, 255, 0.15);
  border: 0;
  color: #fff;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.sup-modal-body { padding: 18px 20px 22px; }

.sup-buscar {
  width: 100%;
  border: 1.5px solid #e9e3ec;
  border-radius: 12px;
  padding: 11px 14px;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  background: #faf8fb;
  margin-bottom: 14px;
}

.sup-buscar:focus { outline: 0; border-color: var(--color-main); background: #fff; box-shadow: 0 0 0 4px rgba(155, 27, 110, 0.08); }

.sup-grupo { margin-bottom: 14px; }
.sup-grupo-titulo { font-size: .7rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: #948d9c; margin: 0 0 8px 2px; }

.sup-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  border: 1.5px solid #ece7ee;
  background: #fff;
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-family: inherit;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}

.sup-item:hover { transform: translateY(-1px); border-color: var(--color-main); background: rgba(155, 27, 110, 0.04); }

.sup-item-avatar {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: .8rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--color-main), var(--color-secondary));
}

.sup-item-nombre { font-weight: 700; color: #201421; font-size: .9rem; overflow-wrap: anywhere; }
.sup-vacio { text-align: center; color: #948d9c; font-size: .86rem; padding: 18px 0; }
