:root {
  --sidebar-width: 258px;
  --sidebar-collapsed: 82px;
  --page-bg: #f4f8fc;
  --surface: rgba(255, 255, 255, 0.98);
  --surface-soft: rgba(248, 252, 255, 0.96);
  --border: rgba(184, 199, 217, 0.68);
  --text: #16263d;
  --muted: #52657a;
  --primary: #008fef;
  --primary-soft: #ddf2ff;
  --danger: #d92d20;
  --shadow: 0 10px 24px rgba(40, 62, 92, 0.08),
    0 3px 8px rgba(40, 62, 92, 0.04);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 6%, rgba(214, 233, 246, 0.85) 0, transparent 27%),
    radial-gradient(circle at 92% 10%, rgba(230, 239, 247, 0.94) 0, transparent 29%),
    radial-gradient(circle at 70% 90%, rgba(217, 228, 238, 0.72) 0, transparent 34%),
    linear-gradient(135deg, #eaf6fc 0%, #f4f8fc 48%, #ffffff 100%);
  background-attachment: fixed;
  font-family: "Segoe UI", Inter, Arial, sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(84, 110, 139, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(84, 110, 139, 0.018) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.42), transparent 78%);
}

button,
input {
  font: inherit;
}

#particles-js {
  display: none;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 16px auto 16px 16px;
  z-index: 100;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  padding: 18px 16px;
  overflow: hidden;
  background: linear-gradient(
    165deg,
    rgba(255, 255, 255, 0.99),
    rgba(248, 252, 255, 0.97)
  );
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 16px 36px rgba(36, 60, 94, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  transition: width 0.28s ease, padding 0.28s ease, box-shadow 0.28s ease;
}

.sidebar-toggle {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  padding: 10px 13px;
  color: #1e67a8;
  background: linear-gradient(135deg, rgba(0, 143, 239, 0.11), rgba(22, 183, 245, 0.1));
  border: 1px solid rgba(124, 203, 255, 0.52);
  border-radius: 12px;
  cursor: pointer;
}

.sidebar-toggle:hover {
  color: var(--primary);
  background: linear-gradient(135deg, rgba(0, 143, 239, 0.16), rgba(22, 183, 245, 0.14));
}

.sidebar-toggle-icon {
  display: inline-flex;
  width: 22px;
  height: 18px;
  flex: 0 0 22px;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.25s ease;
}

.sidebar-toggle-icon span {
  display: block;
  width: 100%;
  height: 2px;
  background: currentColor;
  border-radius: 999px;
  transition: width 0.2s ease, transform 0.2s ease;
}

.sidebar-toggle-icon span:nth-child(2) {
  width: 72%;
}

.sidebar-brand {
  display: flex;
  min-height: 92px;
  align-items: center;
  gap: 13px;
  padding: 7px 5px 17px;
}

.sidebar-brand img {
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  object-fit: contain;
  padding: 5px;
  background: linear-gradient(145deg, #f6fbff, #ebf4fb);
  border: 1px solid rgba(199, 214, 229, 0.9);
  border-radius: 16px;
  box-shadow: 0 8px 18px rgba(40, 120, 227, 0.07);
  transition: width 0.28s ease, height 0.28s ease, flex-basis 0.28s ease,
    padding 0.28s ease, border-radius 0.28s ease;
}

.sidebar-brand-copy {
  min-width: 0;
}

.sidebar-brand-copy strong,
.sidebar-brand-copy span {
  display: block;
  white-space: nowrap;
}

.sidebar-brand-copy strong {
  font-size: 1.1rem;
}

.sidebar-brand-copy span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

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

.sidebar-divider-menu {
  margin: 14px 0 18px;
}

.sidebar-nav {
  flex: 1;
  min-height: 0;
  padding-right: 3px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-color: #c8ddf5 transparent;
  scrollbar-width: thin;
}

.sidebar-nav::-webkit-scrollbar {
  width: 5px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: #c8ddf5;
  border-radius: 999px;
}

.sidebar-nav-title {
  margin: 0 10px 9px;
  color: #98a2b3;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.sidebar-nav-title-secondary {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 50px;
  padding: 10px 12px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 12px;
  font-weight: 600;
  transition: color 0.2s ease, background-color 0.2s ease,
    padding 0.28s ease, transform 0.2s ease;
}

.sidebar-nav-item.active,
.sidebar-nav-item:hover {
  color: var(--primary);
  background: linear-gradient(90deg, rgba(221, 242, 255, 0.98), rgba(236, 248, 255, 0.9));
  box-shadow: inset 0 0 0 1px rgba(124, 203, 255, 0.72);
}

.sidebar-nav-item:hover {
  transform: translateX(2px);
}

.sidebar-nav-item .sidebar-label {
  min-width: 0;
  overflow: hidden;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-nav-icon {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  place-items: center;
  background: linear-gradient(135deg, rgba(0, 143, 239, 0.1), rgba(22, 183, 245, 0.1));
  border: 1px solid rgba(199, 214, 229, 0.92);
  border-radius: 10px;
  transition: width 0.28s ease, height 0.28s ease, flex-basis 0.28s ease,
    background-color 0.2s ease, border-color 0.2s ease;
}

.sidebar-nav-icon img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 15px 10px 3px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  white-space: nowrap;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  background: #12b76a;
  border-radius: 50%;
  box-shadow: 0 0 0 4px #e6f8ef;
}

.app-content {
  min-height: 100vh;
  margin-left: calc(var(--sidebar-width) + 32px);
  transition: margin-left 0.25s ease;
}

.topbar {
  display: flex;
  min-height: 108px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: 16px 20px 0;
  padding: 20px 26px;
  background: linear-gradient(
    120deg,
    rgba(255, 255, 255, 0.99),
    rgba(248, 252, 255, 0.96)
  );
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 12px 28px rgba(39, 67, 101, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

.topbar h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(1.35rem, 2vw, 1.8rem);
  line-height: 1.25;
}

.subtext {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.date-time {
  min-width: 150px;
  padding: 10px 16px;
  text-align: center;
  background: rgba(248, 252, 255, 0.98);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.date-time span,
.date-time strong {
  display: block;
}

.date-time span {
  color: var(--muted);
  font-size: 0.76rem;
}

.date-time strong {
  margin-top: 2px;
  font-size: 1rem;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 184px;
  padding: 8px 11px;
  background: rgba(248, 252, 255, 0.98);
  border: 1px solid var(--border);
  border-radius: 13px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.user-avatar {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #4f9cf9, #246bce);
  border-radius: 12px;
  font-weight: 700;
}

.user-copy {
  min-width: 0;
}

.user-copy strong,
.user-copy small {
  display: block;
}

.user-copy strong {
  max-width: 190px;
  overflow: hidden;
  font-size: 0.88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: capitalize;
}

.logout-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  gap: 7px;
  padding: 9px 13px;
  color: var(--danger);
  background: #fff;
  border: 1px solid #f2c6c2;
  border-radius: 12px;
  cursor: pointer;
}

.logout-button:hover {
  background: #fff2f1;
}

.logout-button .bi {
  display: none;
}

.logout-button::before {
  content: "\21AA";
  font-size: 1rem;
}

.dashboard-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  max-width: 1500px;
  margin: 0 auto;
  padding: 34px 32px 8px;
}

.dashboard-kicker {
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.dashboard-intro h2 {
  margin: 7px 0 5px;
  color: var(--text);
  font-size: clamp(1.45rem, 2.4vw, 2rem);
}

.dashboard-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.dashboard-badge {
  padding: 8px 12px;
  color: #1e67a8;
  background: rgba(221, 242, 255, 0.95);
  border: 1px solid rgba(124, 203, 255, 0.58);
  border-radius: 999px;
  box-shadow: 0 5px 12px rgba(40, 120, 227, 0.06);
  font-size: 0.76rem;
  font-weight: 700;
}

main.menu {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 15px;
  width: 100%;
  max-width: 1500px;
  height: auto;
  max-height: none;
  margin: 0 auto;
  padding: 18px 32px 36px;
  overflow: visible;
  transition: grid-template-columns 0.28s ease, gap 0.28s ease,
    padding 0.28s ease;
}

.card {
  position: relative;
  display: flex;
  min-width: 0;
  width: 100%;
  max-width: none;
  height: 150px;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 17px 16px 14px;
  overflow: hidden;
  color: var(--text);
  text-align: center;
  text-decoration: none;
  background: linear-gradient(
    155deg,
    rgba(255, 255, 255, 0.99),
    rgba(248, 252, 255, 0.97)
  );
  border: 1px solid rgba(184, 199, 217, 0.9);
  border-radius: 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease,
    border-color 0.2s ease, width 0.28s ease;
}

.card::before {
  position: absolute;
  inset: 0 16px auto;
  height: 4px;
  content: "";
  background: linear-gradient(
    90deg,
    rgba(124, 203, 255, 0.78),
    rgba(50, 181, 244, 0.98),
    rgba(124, 203, 255, 0.78)
  );
  border-radius: 0 0 8px 8px;
}

.card::after {
  position: absolute;
  top: -45px;
  right: -45px;
  width: 105px;
  height: 105px;
  pointer-events: none;
  content: "";
  background: radial-gradient(circle, rgba(105, 164, 230, 0.1), transparent 70%);
}

.card:hover {
  z-index: 1;
  transform: translateY(-4px);
  border-color: rgba(124, 203, 255, 0.86);
  box-shadow: 0 18px 34px rgba(30, 64, 105, 0.11),
    0 5px 12px rgba(30, 64, 105, 0.06);
}

.card img {
  width: 48px;
  height: 48px;
  margin: 2px 0 9px;
  padding: 10px;
  object-fit: contain;
  background: rgba(221, 242, 255, 0.24);
  border: 1px solid rgba(124, 203, 255, 0.24);
  border-radius: 14px;
  box-shadow: 0 6px 14px rgba(40, 120, 227, 0.06);
}

.card:nth-child(4n + 2) img {
  background: rgba(222, 248, 232, 0.32);
  border-color: rgba(145, 214, 170, 0.3);
}

.card:nth-child(4n + 3) img {
  background: rgba(255, 241, 222, 0.34);
  border-color: rgba(241, 191, 123, 0.3);
}

.card:nth-child(4n + 4) img {
  background: rgba(240, 233, 255, 0.34);
  border-color: rgba(188, 167, 232, 0.28);
}

.card h2 {
  margin: 0 0 4px;
  color: var(--text);
  font-size: 0.99rem;
  line-height: 1.25;
}

.card p {
  display: -webkit-box;
  margin: 0;
  padding: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.admin-only {
  /* La visibilidad se conserva bajo control del JavaScript existente. */
}

.loading {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: #fff;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  font-weight: 700;
}

.loading.oculto,
.oculto {
  display: none !important;
}

#loginContainer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(236, 242, 248, 0.96);
  backdrop-filter: blur(7px);
}

#loginContainer.oculto {
  display: none !important;
}

.login-box {
  width: 100%;
  max-width: 410px;
  padding: 34px;
  color: var(--text);
  text-align: center;
  background: rgba(255, 255, 255, 0.99);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 18px 40px rgba(16, 24, 40, 0.1);
  backdrop-filter: blur(10px);
}

.login-box h2 {
  margin: 0 0 20px;
  color: var(--text);
}

.login-box input {
  width: 100%;
  margin: 7px 0;
  padding: 12px 14px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
}

.login-box input:focus {
  border-color: #84b7f4;
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.login-box button {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  color: #fff;
  background: var(--primary);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
}

.login-box button:hover {
  background: #1e67c4;
}

.text-danger {
  color: var(--danger);
}

body.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed);
  padding-right: 10px;
  padding-left: 10px;
}

body.sidebar-collapsed .app-content {
  margin-left: calc(var(--sidebar-collapsed) + 32px);
}

body.sidebar-collapsed .sidebar-label {
  display: none;
}

body.sidebar-collapsed .sidebar-brand {
  min-height: 68px;
  padding: 5px 0 12px;
}

body.sidebar-collapsed .sidebar-brand img {
  width: 42px;
  height: 42px;
  flex-basis: 42px;
  padding: 5px;
  border-radius: 12px;
}

body.sidebar-collapsed .sidebar-nav {
  padding-right: 0;
}

body.sidebar-collapsed .sidebar-nav-item {
  width: 100%;
  min-height: 46px;
  padding: 7px 5px;
}

body.sidebar-collapsed .sidebar-nav-icon {
  width: 32px;
  height: 32px;
  flex-basis: 32px;
}

body.sidebar-collapsed .sidebar-nav-item:hover {
  transform: translateY(-1px);
}

body.sidebar-collapsed .sidebar-divider {
  margin-right: 0;
  margin-left: 0;
}

body.sidebar-collapsed .sidebar-footer {
  min-height: 46px;
  padding-right: 0;
  padding-left: 0;
}

body.sidebar-collapsed .sidebar-brand,
body.sidebar-collapsed .sidebar-footer,
body.sidebar-collapsed .sidebar-nav-item,
body.sidebar-collapsed .sidebar-toggle {
  justify-content: center;
}

body.sidebar-collapsed .sidebar-toggle-icon {
  transform: none;
}

body.sidebar-collapsed .sidebar-toggle-icon span,
body.sidebar-collapsed .sidebar-toggle-icon span:nth-child(2) {
  width: 100%;
}

@media (min-width: 1051px) {
  body.sidebar-collapsed main.menu {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

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

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .date-time {
    margin-left: auto;
  }

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

@media (max-width: 760px) {
  :root {
    --sidebar-collapsed: 72px;
  }

  .sidebar {
    inset: 8px auto 8px 8px;
    width: var(--sidebar-collapsed);
    padding: 12px 8px;
  }

  .sidebar-label {
    display: none;
  }

  .sidebar-brand,
  .sidebar-footer,
  .sidebar-nav-item {
    justify-content: center;
  }

  .app-content {
    margin-left: calc(var(--sidebar-collapsed) + 16px);
  }

  .topbar {
    margin: 8px 10px 0;
    padding: 18px 20px;
  }

  .date-time {
    display: none;
  }

  .user-chip {
    min-width: 0;
    flex: 1;
  }

  .logout-button {
    font-size: 0.78rem;
  }

  main.menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 18px 20px 30px;
  }

  .sidebar-brand {
    min-height: 62px;
    padding: 3px 0 10px;
  }

  .sidebar-brand img,
  body.sidebar-collapsed .sidebar-brand img {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
    padding: 4px;
    border-radius: 11px;
  }

  .sidebar-toggle {
    min-height: 40px;
    justify-content: center;
    padding: 8px 6px;
  }

  .sidebar-toggle-icon {
    width: 20px;
    height: 16px;
    flex-basis: 20px;
  }

  .sidebar-nav-item,
  body.sidebar-collapsed .sidebar-nav-item {
    min-height: 42px;
    padding: 6px 4px;
  }

  .sidebar-nav-icon,
  body.sidebar-collapsed .sidebar-nav-icon {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
    border-radius: 9px;
  }

  .sidebar-nav-icon img {
    width: 16px;
    height: 16px;
  }

  .dashboard-intro {
    padding: 28px 20px 7px;
  }
}

@media (max-width: 520px) {
  .topbar-actions {
    align-items: stretch;
  }

  .user-copy strong {
    max-width: 130px;
  }

  main.menu {
    grid-template-columns: 1fr;
  }

  .dashboard-badge {
    display: none;
  }

  .card {
    height: 150px;
  }
}
