.dashboard {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  width: var(--sidebar-width);
  height: 100vh;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid var(--color-border);
  background:
    radial-gradient(circle at -10% 12%, rgb(8 125 245 / 5%), transparent 30%),
    linear-gradient(180deg, #ffffff 0%, var(--color-sidebar) 52%, #f8fbff 100%);
}

.brand {
  position: relative;
  display: flex;
  min-height: var(--brand-height);
  align-items: center;
  padding: 0 clamp(2rem, 2.6vw, 2.65rem);
}

.brand::after {
  position: absolute;
  bottom: 0;
  left: clamp(2rem, 2.6vw, 2.65rem);
  width: 6.25rem;
  height: 1px;
  background: var(--color-border);
  content: "";
}

.brand-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.65rem;
}

.brand-copy small {
  color: var(--color-blue);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.brand-copy strong {
  overflow: hidden;
  color: var(--color-text);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary-navigation {
  display: flex;
  flex-direction: column;
  padding: 1.15rem clamp(1rem, 1.2vw, 1.25rem);
  gap: 0.7rem;
}

.nav-link {
  position: relative;
  display: flex;
  min-height: 4rem;
  align-items: center;
  padding: 0 1.3rem;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  color: var(--color-text-soft);
  font-size: 0.925rem;
  font-weight: 500;
  letter-spacing: -0.018em;
  gap: 1.05rem;
  transition:
    background-color var(--transition-fast),
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    color var(--transition-fast),
    transform var(--transition-fast);
}

.nav-link::before {
  position: absolute;
  top: 0.55rem;
  bottom: 0.55rem;
  left: -1px;
  width: 3px;
  border-radius: 0 999px 999px 0;
  background: var(--color-blue);
  box-shadow: 0 0 0.8rem rgb(8 125 245 / 20%);
  content: "";
  opacity: 0;
  transform: scaleY(0.45);
  transition:
    opacity var(--transition-fast),
    transform var(--transition-smooth);
}

.nav-icon {
  width: 1.5rem;
  height: 1.5rem;
  flex: 0 0 auto;
  color: var(--color-muted);
  transition:
    color var(--transition-fast),
    transform var(--transition-smooth);
}

.nav-link:hover {
  border-color: rgb(8 125 245 / 6%);
  background: var(--color-sidebar-hover);
  color: var(--color-blue-hover);
  transform: translateX(0.2rem);
}

.nav-link:hover .nav-icon {
  color: var(--color-blue);
  transform: scale(1.06);
}

.nav-link.is-active {
  border-color: rgb(8 125 245 / 5%);
  background: linear-gradient(90deg, #e8f3ff 0%, #eaf4ff 72%, #edf6ff 100%);
  box-shadow: 0 0.75rem 1.5rem -1.4rem rgb(8 125 245 / 42%);
  color: var(--color-blue);
  font-weight: 600;
}

.nav-link.is-active::before {
  opacity: 1;
  transform: scaleY(1);
}

.nav-link.is-active .nav-icon {
  color: var(--color-blue);
}

.application-area {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  padding: 0 clamp(2.5rem, 3vw, 3.15rem);
  border-bottom: 1px solid var(--color-border);
  background: rgb(255 255 255 / 90%);
  backdrop-filter: saturate(150%) blur(18px);
  gap: var(--space-4);
}

.page-identity {
  display: grid;
  min-width: 0;
  flex: 1;
  align-content: center;
  gap: 0.18rem;
}

.page-identity h1 {
  overflow: hidden;
  margin: 0;
  color: var(--color-text);
  font-size: clamp(1.7rem, 2.25vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-breadcrumbs {
  display: flex;
  overflow: hidden;
  min-width: 0;
  align-items: center;
  color: var(--color-muted);
  font-size: 0.7rem;
  font-weight: 620;
  gap: 0.42rem;
  white-space: nowrap;
}

.topbar-breadcrumbs[hidden] { display: none; }
.topbar-breadcrumbs span { overflow: hidden; text-overflow: ellipsis; }
.topbar-breadcrumbs span[aria-current="page"] { color: var(--color-blue); }
.topbar-breadcrumbs i { color: var(--color-border-strong); font-style: normal; }

.topbar-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.65rem;
}

.connection-status,
.topbar-icon-button,
.topbar-user-button {
  min-height: 3rem;
  border: 1px solid var(--color-border);
  border-radius: 0.8rem;
  background: rgb(255 255 255 / 74%);
  color: var(--color-text-soft);
  cursor: pointer;
}

.connection-status {
  display: flex;
  align-items: center;
  padding: 0 0.9rem;
  gap: 0.55rem;
}

.connection-status > span {
  width: 0.58rem;
  height: 0.58rem;
  border: 2px solid #d8f0e3;
  border-radius: 50%;
  background: #2b9f63;
  box-shadow: 0 0 0 2px rgb(43 159 99 / 10%);
}

.connection-status strong { font-size: 0.72rem; font-weight: 680; }
.connection-status.is-offline { border-color: #ead39f; background: #fffaf0; color: #94620d; }
.connection-status.is-offline > span { border-color: #f6dfb0; background: #d99a22; }

.topbar-popover-shell { position: relative; }

.topbar-icon-button {
  position: relative;
  display: grid;
  width: 3rem;
  place-items: center;
}

.topbar-icon-button svg { width: 1.2rem; height: 1.2rem; }

.topbar-notification-count {
  position: absolute;
  top: -0.3rem;
  right: -0.3rem;
  display: grid;
  min-width: 1.35rem;
  min-height: 1.35rem;
  place-items: center;
  padding: 0 0.2rem;
  border: 2px solid var(--color-surface);
  border-radius: 999px;
  background: #d45454;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 750;
}

.topbar-user-button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  padding: 0.38rem 0.7rem 0.38rem 0.42rem;
  gap: 0.65rem;
  text-align: left;
}

.topbar-user-avatar {
  display: grid;
  width: 2.2rem;
  height: 2.2rem;
  place-items: center;
  border-radius: 0.65rem;
  background: linear-gradient(145deg, var(--color-blue), #49a7ff);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 760;
}

.topbar-user-copy { display: grid; max-width: 10rem; gap: 0.08rem; }
.topbar-user-copy strong,
.topbar-user-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-user-copy strong { color: var(--color-text); font-size: 0.76rem; }
.topbar-user-copy small { color: var(--color-muted); font-size: 0.65rem; }
.topbar-user-button > svg { width: 0.95rem; color: var(--color-muted); }

.connection-status:hover,
.topbar-icon-button:hover,
.topbar-user-button:hover,
.topbar-icon-button[aria-expanded="true"],
.topbar-user-button[aria-expanded="true"] {
  border-color: #9bcafa;
  background: var(--color-surface);
  box-shadow: var(--shadow-tab);
}

.topbar-popover {
  position: absolute;
  z-index: 80;
  top: calc(100% + 0.7rem);
  right: 0;
  width: min(27rem, calc(100vw - 2rem));
  overflow: hidden;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-medium);
  background: var(--color-surface);
  box-shadow: 0 1.8rem 4rem -2rem rgb(17 49 80 / 48%);
}

.topbar-popover[hidden] { display: none; }
.topbar-popover > header { display: flex; min-height: 4.8rem; align-items: center; justify-content: space-between; padding: 0.85rem 1rem; border-bottom: 1px solid var(--color-border); gap: 1rem; }
.topbar-popover > header div { display: grid; gap: 0.18rem; }
.topbar-popover > header span { color: var(--color-blue); font-size: 0.62rem; font-weight: 720; letter-spacing: 0.08em; text-transform: uppercase; }
.topbar-popover > header h2 { margin: 0; color: var(--color-text); font-size: 1rem; }
.topbar-popover > header button { padding: 0.45rem; background: transparent; color: var(--color-blue); cursor: pointer; font-size: 0.7rem; font-weight: 650; }
.shell-notification-list { max-height: min(31rem, 68vh); overflow-y: auto; }
.shell-notification { display: grid; grid-template-columns: auto minmax(0, 1fr); min-height: 4.8rem; align-items: center; padding: 0.7rem 1rem; border-bottom: 1px solid var(--color-border); gap: 0.8rem; }
.shell-notification:hover { background: var(--color-blue-faint); }
.shell-notification > span:first-child { display: grid; width: 2.25rem; height: 2.25rem; place-items: center; border-radius: 0.65rem; background: var(--color-blue-faint); color: var(--color-blue); }
.shell-notification--warning > span:first-child { background: #fff7e8; color: #b47613; }
.shell-notification--danger > span:first-child { background: #fff0f0; color: #c44747; }
.shell-notification svg { width: 1.05rem; }
.shell-notification > span:last-child { display: grid; min-width: 0; gap: 0.25rem; }
.shell-notification strong { overflow: hidden; color: var(--color-text); font-size: 0.78rem; text-overflow: ellipsis; white-space: nowrap; }
.shell-notification small { color: var(--color-muted); font-size: 0.68rem; }
.shell-notification-panel > a:last-child { display: block; padding: 0.85rem; color: var(--color-blue); font-size: 0.74rem; font-weight: 680; text-align: center; }

.shell-user-panel { width: 19rem; padding-bottom: 0.45rem; }
.shell-user-panel > header { display: grid; min-height: 4.4rem; justify-content: stretch; }
.shell-user-panel > header strong { color: var(--color-text); font-size: 0.82rem; }
.shell-user-panel > header span { color: var(--color-muted); font-size: 0.68rem; font-weight: 500; letter-spacing: 0; text-transform: none; }
.shell-user-panel > a,
.shell-user-panel > button { display: flex; width: calc(100% - 0.9rem); min-height: 2.9rem; align-items: center; padding: 0 0.8rem; border-radius: 0.65rem; margin: 0.45rem 0.45rem 0; background: transparent; color: var(--color-text-soft); cursor: pointer; font-size: 0.76rem; gap: 0.75rem; }
.shell-user-panel > a:hover,
.shell-user-panel > button:hover { background: var(--color-blue-faint); color: var(--color-blue); }
.shell-user-panel svg { width: 1.05rem; }

.shell-session-warning {
  position: fixed;
  z-index: 120;
  right: 1.25rem;
  bottom: 1.25rem;
  left: max(calc(var(--sidebar-width) + 1.25rem), 1.25rem);
}

.shell-session-warning[hidden] { display: none; }
.shell-session-warning > div { display: grid; max-width: 65rem; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; padding: 0.85rem; border: 1px solid #e6c77f; border-radius: var(--radius-medium); margin: 0 auto; background: #fffaf0; box-shadow: 0 1.4rem 3rem -1.7rem rgb(67 49 15 / 45%); gap: 0.85rem; }
.shell-session-warning-icon { display: grid; width: 2.6rem; height: 2.6rem; place-items: center; border-radius: 0.72rem; background: #ffefc8; color: #a36d10; }
.shell-session-warning-icon svg { width: 1.25rem; }
.shell-session-warning strong { color: #563c0e; font-size: 0.83rem; }
.shell-session-warning p { margin: 0.22rem 0 0; color: #806328; font-size: 0.72rem; }

.shell-toast-region {
  position: fixed;
  z-index: 150;
  right: 1.25rem;
  bottom: 1.25rem;
  display: grid;
  width: min(28rem, calc(100vw - 2rem));
  gap: 0.65rem;
  pointer-events: none;
}

.shell-toast {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  padding: 0.85rem;
  border: 1px solid var(--color-border-strong);
  border-left: 3px solid var(--color-blue);
  border-radius: var(--radius-medium);
  background: var(--color-surface);
  box-shadow: 0 1.3rem 3rem -1.4rem rgb(16 49 82 / 55%);
  gap: 0.75rem;
  pointer-events: auto;
  animation: shell-toast-enter 220ms var(--ease-out) both;
}

.shell-toast.is-leaving { opacity: 0; transform: translateX(1rem); transition: opacity 180ms ease, transform 180ms ease; }
.shell-toast--success { border-left-color: #2b9f63; }
.shell-toast--warning { border-left-color: #d99a22; }
.shell-toast--danger { border-left-color: #d45454; }
.shell-toast-icon { display: grid; width: 2.2rem; height: 2.2rem; place-items: center; border-radius: 50%; background: var(--color-blue-faint); color: var(--color-blue); }
.shell-toast--success .shell-toast-icon { background: #eaf8f0; color: #258452; }
.shell-toast--warning .shell-toast-icon { background: #fff7e8; color: #a86f0f; }
.shell-toast--danger .shell-toast-icon { background: #fff0f0; color: #c44747; }
.shell-toast-icon svg { width: 1.1rem; }
.shell-toast > div { display: grid; gap: 0.22rem; }
.shell-toast strong { color: var(--color-text); font-size: 0.8rem; }
.shell-toast p { margin: 0; color: var(--color-muted); font-size: 0.7rem; line-height: 1.4; }
.shell-toast-action,
.shell-toast-close { background: transparent; color: var(--color-blue); cursor: pointer; font-size: 0.72rem; font-weight: 700; }
.shell-toast-close { display: grid; width: 2rem; height: 2rem; place-items: center; color: var(--color-muted); }
.shell-toast-close svg { width: 1rem; }

.shell-confirm-dialog {
  width: min(34rem, calc(100vw - 2rem));
  padding: 0;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-medium);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 2rem 6rem -2rem rgb(10 35 60 / 58%);
}

.shell-confirm-dialog::backdrop { background: rgb(14 35 56 / 46%); backdrop-filter: blur(3px); }
.shell-confirm-dialog form { padding: 1.35rem; }
.shell-confirm-dialog header { display: flex; align-items: center; gap: 0.9rem; }
.shell-confirm-icon { display: grid; width: 3rem; height: 3rem; flex: 0 0 auto; place-items: center; border-radius: 0.85rem; background: #fff7e8; color: #ad7616; }
.shell-confirm-icon svg { width: 1.35rem; }
.shell-confirm-dialog header p { margin: 0 0 0.2rem; color: var(--color-blue); font-size: 0.65rem; font-weight: 720; letter-spacing: 0.08em; text-transform: uppercase; }
.shell-confirm-dialog h2 { margin: 0; font-size: 1.2rem; }
.shell-confirm-dialog form > p { margin: 1.2rem 0; color: var(--color-muted); font-size: 0.82rem; line-height: 1.55; }
.shell-confirm-dialog footer { display: flex; justify-content: flex-end; gap: 0.7rem; }

@keyframes shell-toast-enter {
  from { opacity: 0; transform: translateY(0.7rem) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.page-content {
  min-height: calc(100vh - var(--topbar-height));
  padding: 2.65rem clamp(2.5rem, 3vw, 3.15rem) 3rem;
  background:
    radial-gradient(circle at 86% 8%, rgb(8 125 245 / 2.5%), transparent 24rem),
    var(--color-page);
}

.page-content.is-switching {
  opacity: 0.6;
  transform: translateY(0.16rem);
  transition:
    opacity var(--transition-fast),
    transform var(--transition-fast);
}

.menu-button {
  display: none;
  width: 2.6rem;
  height: 2.6rem;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 0;
  border: 1px solid var(--color-border-strong);
  border-radius: 0.7rem;
  background: var(--color-surface);
  cursor: pointer;
  gap: 0.25rem;
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    transform var(--transition-fast);
}

.menu-button:hover {
  border-color: rgb(8 125 245 / 34%);
  box-shadow: 0 0.4rem 1rem -0.7rem rgb(8 125 245 / 50%);
  transform: translateY(-1px);
}

.menu-button span {
  display: block;
  width: 1.05rem;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.sidebar-backdrop {
  position: fixed;
  z-index: 25;
  inset: 0;
  display: none;
  padding: 0;
  background: rgb(18 39 65 / 32%);
  backdrop-filter: blur(3px);
  cursor: pointer;
}

@media (max-width: 56rem) {
  :root {
    --topbar-height: 4.75rem;
  }

  .dashboard {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    width: min(20rem, 88vw);
    box-shadow: var(--shadow-sidebar);
    transform: translateX(-105%);
    transition: transform var(--transition-smooth);
  }

  .dashboard.sidebar-is-open .sidebar {
    transform: translateX(0);
  }

  .dashboard.sidebar-is-open .sidebar-backdrop {
    display: block;
  }

  .brand {
    min-height: 7rem;
  }

  .menu-button {
    display: flex;
  }

  .topbar {
    padding: 0 1.25rem;
  }

  .page-identity h1 {
    font-size: 1.35rem;
  }

  .topbar-breadcrumbs { display: none; }
  .connection-status { display: none; }
  .topbar-user-copy { display: none; }
  .topbar-user-button { grid-template-columns: auto auto; }
  .shell-session-warning { left: 1rem; right: 1rem; bottom: 1rem; }

  .page-content {
    padding: 1.5rem 1.25rem 2rem;
  }
}

@media (max-width: 30rem) {
  .topbar {
    padding: 0 var(--space-4);
  }

  .page-content {
    padding: var(--space-5) var(--space-4) var(--space-8);
  }

  .topbar { gap: 0.55rem; }
  .topbar-actions { gap: 0.45rem; }
  .topbar-icon-button,
  .topbar-user-button { min-height: 2.75rem; }
  .topbar-icon-button { width: 2.75rem; }
  .topbar-user-button {
    width: 2.75rem;
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 0.25rem;
    gap: 0;
  }
  .topbar-user-button > svg { display: none; }
  .topbar-user-avatar { width: 2.15rem; height: 2.15rem; }
  .page-identity h1 { font-size: 1.05rem; }

  .shell-notification-panel:not([hidden]) {
    position: fixed;
    z-index: 90;
    top: var(--topbar-height);
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    width: 100%;
    height: calc(100dvh - var(--topbar-height));
    max-height: none;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    border: 0;
    border-top: 1px solid var(--color-border);
    border-radius: 0;
    background: var(--color-surface);
    box-shadow: none;
  }

  .shell-notification-panel > header {
    min-height: 4.75rem;
    padding: 0.9rem var(--space-5);
    background: var(--color-surface);
  }

  .shell-notification-list {
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior-y: contain;
  }

  .shell-notification {
    min-height: 5.25rem;
    padding: 0.85rem var(--space-5);
  }

  .shell-notification strong {
    font-size: 0.82rem;
    white-space: normal;
  }

  .shell-notification-panel > a:last-child {
    min-height: 3.75rem;
    padding-bottom: max(0.85rem, env(safe-area-inset-bottom));
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
  }

  .shell-session-warning > div { grid-template-columns: auto minmax(0, 1fr); }
  .shell-session-warning button { width: 100%; }
  .shell-session-warning button:first-of-type { grid-column: 1 / -1; }
  .shell-session-warning button:last-of-type { grid-column: 1 / -1; }
  .shell-toast { grid-template-columns: auto minmax(0, 1fr) auto; }
  .shell-toast-action { grid-column: 2; justify-self: start; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
