:root {
  --sidebar-width: 240px;
  --sidebar-blue-top: #1769dc;
  --sidebar-blue-mid: #2e86e7;
  --sidebar-blue-bottom: #77b7ef;
  --sidebar-text: rgba(255, 255, 255, .94);
  --sidebar-muted: rgba(232, 246, 255, .72);
  --sidebar-line: rgba(255, 255, 255, .18);
}

.app-shell { grid-template-columns: var(--sidebar-width) 1fr; }
.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 25px 15px 18px;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 255, 255, .16), transparent 24%),
    linear-gradient(165deg, var(--sidebar-blue-top) 0%, var(--sidebar-blue-mid) 46%, var(--sidebar-blue-bottom) 100%);
  box-shadow: 10px 0 35px rgba(22, 92, 177, .12);
}
.sidebar::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .025) 1px, transparent 1px);
  background-size: 30px 30px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .8), transparent 78%);
}
.sidebar-backdrop { display: none; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 66px;
  margin: 0 5px 28px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 14px;
  background: rgba(255, 255, 255, .09);
  box-shadow: inset 0 1px rgba(255, 255, 255, .16);
}
.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  place-items: center;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, .76);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(14, 74, 157, .22);
}
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: cover; }
.brand strong { display: block; color: #fff; font-size: 17px; letter-spacing: .3px; }
.brand span { display: block; margin-top: 3px; color: var(--sidebar-muted); font-size: 11px; line-height: 1.45; }

.sidebar nav {
  display: block;
  min-height: 0;
  overflow-y: auto;
  padding: 0 3px 10px 0;
  scrollbar-color: rgba(255, 255, 255, .25) transparent;
  scrollbar-width: thin;
}
.nav-primary-list { display: grid; gap: 6px; }
.nav-button {
  display: flex;
  align-items: center;
  gap: 11px;
  border: 0;
  border-radius: 10px;
  color: var(--sidebar-muted);
  background: transparent;
  text-align: left;
  transition: color .16s ease, background .16s ease, transform .16s ease, box-shadow .16s ease;
}
.nav-button:hover {
  color: #fff;
  background: rgba(255, 255, 255, .11);
  transform: translateX(2px);
}
.nav-button.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, .13));
  box-shadow: inset 3px 0 rgba(255, 255, 255, .92), 0 8px 20px rgba(15, 78, 165, .12);
}
.nav-icon { width: 23px; color: rgba(240, 250, 255, .82); font-size: 16px; text-align: center; }
.nav-primary {
  min-height: 48px;
  padding: 9px 10px;
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 700;
}
.nav-primary .nav-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 9px;
  color: #fff;
  background: rgba(255, 255, 255, .12);
  box-shadow: inset 0 1px rgba(255, 255, 255, .12);
  font-size: 18px;
}
.nav-primary.active .nav-icon {
  color: #1266cf;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 7px 17px rgba(15, 79, 167, .2);
}
.nav-divider { height: 1px; margin: 14px 6px 10px; background: var(--sidebar-line); }
.nav-group { margin-bottom: 4px; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.nav-group:last-child { border-bottom: 0; }
.nav-group-title {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 9px 8px 7px;
  border: 0;
  color: rgba(233, 246, 255, .7);
  background: transparent;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .7px;
  text-align: left;
}
.nav-group-title:hover { color: #fff; }
.nav-group-title i { color: rgba(255, 255, 255, .72); font-size: 14px; font-style: normal; transition: transform .18s ease; }
.nav-group.collapsed .nav-group-title i { transform: rotate(-90deg); }
.nav-group-items { display: grid; gap: 2px; padding-bottom: 5px; }
.nav-group.collapsed .nav-group-items { display: none; }
.nav-group-items .nav-button { width: 100%; min-height: 38px; padding: 7px 10px; font-size: 13px; }
.nav-group-items .nav-icon {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 8px;
  color: rgba(241, 250, 255, .84);
  background: rgba(255, 255, 255, .08);
  font-size: 13px;
}

.sidebar-footer {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 9px;
  margin-top: auto;
  padding: 12px 13px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 12px;
  color: var(--sidebar-muted);
  background: rgba(255, 255, 255, .12);
  box-shadow: inset 0 1px rgba(255, 255, 255, .13), 0 12px 28px rgba(24, 94, 177, .12);
  font-size: 11px;
  backdrop-filter: blur(8px);
}
.sidebar-footer strong { color: #fff; font-size: 11px; font-weight: 700; }
.sidebar-footer small { grid-column: 2; overflow: hidden; color: rgba(236, 248, 255, .68); text-overflow: ellipsis; white-space: nowrap; }
.save-dot {
  width: 7px;
  height: 7px;
  margin-top: 4px;
  border-radius: 50%;
  background: #54e3a4;
  box-shadow: 0 0 0 4px rgba(84, 227, 164, .15);
}
.sidebar-footer.sync-warning .save-dot { background: #ffd166; box-shadow: 0 0 0 4px rgba(255, 209, 102, .15); }
.sidebar-footer.sync-error .save-dot { background: #ff7d78; box-shadow: 0 0 0 4px rgba(255, 125, 120, .15); }

@media (prefers-reduced-motion: reduce) {
  .nav-button, .nav-group-title i { transition: none; }
}

@media (max-width: 800px) {
  .sidebar {
    position: fixed;
    left: calc(-1 * var(--sidebar-width) - 20px);
    width: var(--sidebar-width);
    z-index: 31;
    box-shadow: 20px 0 60px rgba(7, 53, 119, .3);
    transition: left .25s ease;
  }
  .sidebar.open { left: 0; }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: block;
    opacity: 0;
    pointer-events: none;
    background: rgba(7, 34, 73, .38);
    transition: opacity .2s ease;
    backdrop-filter: blur(2px);
  }
  .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }
  body.sidebar-open { overflow: hidden; touch-action: none; }
}
