.cn-shell,
.cn-shell * {
  box-sizing: border-box;
}

.cn-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  grid-template-areas: "main sidebar";
  direction: ltr;
}

.cn-main {
  grid-area: main;
  min-width: 0;
  direction: rtl;
  display: flex;
  flex-direction: column;
}

.cn-sidebar {
  grid-area: sidebar;
  direction: rtl;
  width: 220px;
  min-height: 100vh;
  position: sticky;
  top: 0;
  align-self: start;
  padding: 1rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-inline-end: 1px solid rgba(220, 229, 238, 0.85);
}

.cn-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.15rem 0.1rem 0.4rem;
}

.cn-sidebar-brand-mark {
  width: 2.25rem;
  height: 2.25rem;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 0.8rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  box-shadow: none;
}

.cn-sidebar-brand-text {
  display: grid;
  gap: 0.08rem;
}

.cn-sidebar-brand-title {
  font-size: 0.96rem;
  font-weight: 800;
  line-height: 1.2;
}

.cn-sidebar-brand-subtitle {
  font-size: 0.76rem;
  line-height: 1.2;
  color: var(--muted);
}

.cn-sidebar-primary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.8rem;
  border-radius: 0.85rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  color: #fff;
  font-weight: 800;
  font-size: 0.92rem;
  text-decoration: none;
  box-shadow: none;
}

.cn-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.cn-sidebar-link,
.cn-sidebar-logout {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.62rem 0.72rem;
  border-radius: 0.8rem;
  border: 1px solid transparent;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  line-height: 1.35;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.cn-sidebar-link:hover,
.cn-sidebar-link.is-active {
  background: var(--primary-soft);
  color: var(--primary-deep);
  border-color: rgba(23, 107, 135, 0.12);
}

.cn-sidebar-link--disabled,
.cn-sidebar-link--disabled:hover,
.cn-sidebar-link--disabled.is-active {
  color: #8a96a5;
  background: #f3f5f7;
  border-color: rgba(220, 229, 238, 0.85);
  cursor: not-allowed;
  opacity: 0.78;
}

.cn-sidebar-link-badge {
  margin-inline-start: auto;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: #e6eaf0;
  color: #6a7482;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.4;
}

.cn-sidebar-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.cn-sidebar-icon .ui-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.cn-sidebar-user {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(220, 229, 238, 0.9);
  display: grid;
  gap: 0.65rem;
}

.cn-sidebar-user-meta {
  display: grid;
  gap: 0.1rem;
}

.cn-sidebar-user-name {
  font-size: 0.96rem;
  font-weight: 800;
  line-height: 1.35;
}

.cn-sidebar-user-role {
  font-size: 0.8rem;
  color: var(--muted);
}

.cn-sidebar-logout-form {
  margin: 0;
}

.cn-sidebar-logout {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
}

.cn-mobile-header {
  display: none;
}

.cn-mobile-button {
  display: inline-grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 0.7rem;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--primary-deep);
  cursor: pointer;
  flex: 0 0 auto;
}

.cn-mobile-button .ui-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.cn-mobile-brand {
  display: grid;
  gap: 0.05rem;
  min-width: 0;
  flex: 1 1 auto;
}

.cn-mobile-brand-title {
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.2;
}

.cn-mobile-brand-subtitle {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cn-content {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 20px 32px 24px;
  min-width: 0;
}

.cn-shell-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.cn-mobile-overlay {
  display: none;
}

@media (max-width: 899px) {
  .cn-shell {
    display: block;
    min-height: 100vh;
  }

  .cn-main {
    min-height: 100vh;
  }

  .cn-sidebar {
    position: fixed;
    top: 0;
    inset-inline-end: 0;
    z-index: 30;
    width: min(82vw, 280px);
    height: 100vh;
    transform: translateX(110%);
    transition: transform 0.2s ease;
    box-shadow: 0 20px 48px rgba(22, 32, 44, 0.18);
    border-inline-end: 0;
    border-inline-start: 1px solid rgba(220, 229, 238, 0.85);
  }

  .cn-shell-toggle:checked ~ .cn-shell .cn-sidebar {
    transform: translateX(0);
  }

  .cn-mobile-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.75rem 0.75rem 0;
    padding: 0.75rem 0.85rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow);
  }

  .cn-content {
    width: 100%;
    padding: 1rem;
  }

  .cn-mobile-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(10, 18, 28, 0.32);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .cn-shell-toggle:checked ~ .cn-mobile-overlay {
    opacity: 1;
    pointer-events: auto;
  }
}
