:root {
  --sidebar-bg: #dde4eb;
  --sidebar-text: #0f172a;
}

.admin-only {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  font-size: 13px;
  background: #EFF4F9;
}

.sidebar {
  width: 280px;
  flex: 0 0 280px;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 10009;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 12px 14px 10px;
  color: #0f172a;
  overflow: visible;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 32px;
}

.sidebar-brand {
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: 0;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand-logo {
  width: 45px;
  height: 45px;
  border-radius: 0;
  border: none;
  flex: 0 0 55px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.sidebar-brand-logo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center;
  transform: none;
}

.sidebar-brand-text {
  line-height: 1;
}

.sidebar-toggle {
  width: 22px;
  height: 22px;
  border-radius: 0;
  border: none;
  background: transparent;
  color: rgba(15, 23, 42, 0.7);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: none;
}

.sidebar-toggle img {
  width: 23px;
  height: 23px;
  display: block;
  object-fit: contain;
}

.sidebar-primary {
  width: 100%;
  height: 34px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(180deg, #16275a 0%, #0e1c4b 100%);
  color: rgba(255, 255, 255, 0.94);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(11, 22, 54, 0.16);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.sidebar-primary-icon {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-primary-plus {
  display: inline-block;
  color: rgba(255, 255, 255, 0.98);
  font-size: 16px;
  line-height: 1;
  font-weight: 700;
}

.sidebar-primary-image {
  display: none;
  width: 18px;
  height: 18px;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  transform: translateZ(0);
}

.sidebar-primary-text {
  display: inline-block;
}

.sidebar-primary:hover {
  filter: brightness(1.03);
}

.sidebar-nav {
  display: grid;
  gap: 12px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 7px 12px;
  border-radius: 8px;
  color: rgba(1, 8, 47, 0.9);
  text-decoration: none;
  border: 1px solid transparent;
  background: transparent;
  position: relative;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.44);
  border-color: transparent;
  transform: translateY(-1px);
}

.sidebar-link.active {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.9) 0%, rgba(227, 226, 255, 0.72) 100%);
  border-color: transparent;
  color: #01082f;
  transform: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.sidebar-link.active::before {
  display: none;
}

.sidebar-link-icon {
  width: 22px;
  text-align: center;
  font-size: 12px;
  line-height: 1;
  color: rgba(1, 8, 47, 0.72);
  flex: 0 0 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-link-icon svg {
  width: 20px;
  height: 20px;
}

.sidebar-link-icon img {
  width: 22px;
  height: 22px;
  display: block;
  object-fit: contain;
}

.sidebar-link.active .sidebar-link-icon {
  color: #01082f;
}

.sidebar-link-text {
  font-size: 13px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-divider {
  height: 1px;
  margin: 6px 0 2px;
  background: rgba(1, 8, 47, 0.06);
}

.sidebar-section {
  padding: 2px 0 0;
  font-size: 10.5px;
  line-height: 1.4;
  color: rgba(1, 8, 47, 0.28);
  letter-spacing: 0.4px;
}

.sidebar-recent {
  display: grid;
  gap: 8px;
  padding: 0 4px 2px;
}

.sidebar-recent-empty {
  padding: 4px 0;
  border-radius: 0;
  font-size: 13px;
  line-height: 1.35;
  color: rgba(1, 8, 47, 0.28);
  background: transparent;
  border: none;
}

.sidebar-recent-list {
  display: grid;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
}

.sidebar-recent-list::-webkit-scrollbar {
  width: 6px;
}

.sidebar-recent-list::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-recent-list::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.55);
  border-radius: 999px;
}

.sidebar-recent-list::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.55);
}

.sidebar-recent-item {
  display: block;
  padding: 2px 0;
  border-radius: 0;
  color: rgba(15, 23, 42, 0.78);
  text-decoration: none;
  background: transparent;
  border: none;
  width: 100%;
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-recent-item:hover {
  color: #6a73f2;
  background: transparent;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 8px;
  border-top: none;
}

.user-area {
  width: 100%;
}

.sidebar-footer .settings-dropdown {
  display: inline-flex;
}

.sidebar-footer .user-area {
  width: 100%;
}

.sidebar-user {
  width: 100%;
  display: flex;
  align-items: center;
  min-height: 36px;
  gap: 10px;
  position: relative;
}

.sidebar-user-meta {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #1f3fb8;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 700;
  flex: 0 0 26px;
}

.sidebar-user-name {
  min-width: 0;
  font-size: 11.5px;
  font-weight: 500;
  color: rgba(1, 8, 47, 0.72);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-settings-dropdown {
  position: relative;
  display: inline-flex;
  margin-left: auto;
}

.sidebar-settings-btn {
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: rgba(1, 8, 47, 0.56);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 20px;
}

.sidebar-settings-btn:hover {
  background: transparent;
  color: #6a73f2;
}

.sidebar-settings-btn svg {
  width: 14px;
  height: 14px;
}

.sidebar-settings-dropdown .settings-menu {
  top: auto;
  bottom: 0;
  right: auto;
  left: calc(100% + 8px);
  max-width: 216px;
  width: max-content;
}

.app-main {
  flex: 1;
  min-width: 0;
  overflow: auto;
  padding: 0;
}

.app-main .page {
  max-width: none;
  margin: 0;
  padding: 10px 4px 24px;
}

.page-content {
  width: 100%;
  max-width: none;
  margin: 0;
}

body.sidebar-collapsed .sidebar {
  width: 56px;
  flex-basis: 56px;
  padding: 14px 6px 18px;
}

body.sidebar-collapsed .sidebar-brand,
body.sidebar-collapsed .sidebar-link-text,
body.sidebar-collapsed .sidebar-section,
body.sidebar-collapsed .sidebar-user-name {
  display: none;
}

body.sidebar-collapsed .sidebar-primary {
  display: inline-flex;
  width: 100%;
  min-height: 44px;
  align-self: stretch;
  justify-content: center;
  padding: 10px 6px;
  gap: 0;
  border-radius: 14px;
  background: transparent;
  box-shadow: none;
  filter: none;
  color: #64748b;
}

body.sidebar-collapsed .sidebar-primary:hover {
  filter: none;
  transform: none;
  background: rgba(59, 130, 246, 0.05);
}

body.sidebar-collapsed .sidebar-primary-text {
  display: none;
}

body.sidebar-collapsed .sidebar-primary-icon {
  width: 22px;
  height: 22px;
  background: transparent;
  box-shadow: none;
}

body.sidebar-collapsed .sidebar-primary-plus {
  display: none;
}

body.sidebar-collapsed .sidebar-primary-image {
  display: block;
  width: 20px;
  height: 20px;
}

body.sidebar-collapsed .sidebar-header {
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

body.sidebar-collapsed .sidebar-brand {
  flex: 0 0 auto;
  gap: 0;
}

body.sidebar-collapsed .sidebar-brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 10px;
}

body.sidebar-collapsed .sidebar-toggle {
  width: 32px;
  height: 32px;
  margin-left: auto;
  margin-right: auto;
}

body.sidebar-collapsed .sidebar-toggle svg {
  width: 23px;
  height: 23px;
}

body.sidebar-collapsed .sidebar-toggle img {
  width: 23px;
  height: 23px;
}

body.sidebar-collapsed .sidebar-nav {
  gap: 14px;
  padding-top: 10px;
}

body.sidebar-collapsed .sidebar-link {
  justify-content: center;
  width: 100%;
  min-height: 44px;
  padding: 10px 6px;
  border-radius: 14px;
  background: transparent;
  box-shadow: none;
}

body.sidebar-collapsed .sidebar-link:hover {
  transform: none;
  background: rgba(59, 130, 246, 0.05);
  border-color: rgba(147, 197, 253, 0.45);
}

body.sidebar-collapsed .sidebar-link.active {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(147, 197, 253, 0.7);
  box-shadow: inset 0 0 0 1px rgba(191, 219, 254, 0.22);
}

body.sidebar-collapsed .sidebar-link.active::before {
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 4px;
  background: #3b82f6;
}

body.sidebar-collapsed .sidebar-link-icon {
  width: 22px;
  flex-basis: 22px;
  color: #64748b;
}

body.sidebar-collapsed .sidebar-link-icon svg {
  width: 20px;
  height: 20px;
}

body.sidebar-collapsed .sidebar-link-icon img {
  width: 22px;
  height: 22px;
}

body.sidebar-collapsed .sidebar-divider {
  margin: 4px 4px 0;
}

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

body.sidebar-collapsed .sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
}

body.sidebar-collapsed .sidebar-user {
  min-height: 0;
  padding: 8px 0;
  border-radius: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  gap: 14px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

body.sidebar-collapsed .sidebar-user-meta {
  flex: 0 0 auto;
  order: 2;
  justify-content: center;
}

body.sidebar-collapsed .sidebar-user-avatar {
  width: 32px;
  height: 32px;
  font-size: 14px;
  flex: 0 0 32px;
}

body.sidebar-collapsed .sidebar-settings-dropdown {
  margin-left: 0;
  order: 1;
  align-self: center;
}

body.sidebar-collapsed .sidebar-settings-btn {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: transparent;
  border: none;
  box-shadow: none;
}

body.sidebar-collapsed .sidebar-settings-btn svg {
  width: 16px;
  height: 16px;
}

body.sidebar-collapsed .sidebar-settings-dropdown .settings-menu {
  left: calc(100% + 8px);
  right: auto;
}

@media (max-width: 980px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: relative;
    width: 100%;
    min-height: auto;
    flex-basis: auto;
    z-index: 10009;
    overflow: visible;
  }

  body.sidebar-collapsed .sidebar {
    width: 100%;
    flex-basis: auto;
  }

  body.sidebar-collapsed .sidebar-brand,
  body.sidebar-collapsed .sidebar-primary,
  body.sidebar-collapsed .sidebar-link-text,
  body.sidebar-collapsed .sidebar-section,
  body.sidebar-collapsed .sidebar-user-name {
    display: initial;
  }

  body.sidebar-collapsed .sidebar-brand {
    display: inline-flex;
  }

  body.sidebar-collapsed .sidebar-primary {
    display: inline-flex;
  }

  body.sidebar-collapsed .sidebar-link {
    justify-content: flex-start;
  }

  body.sidebar-collapsed .sidebar-recent {
    display: grid;
  }

  .app-main .page {
    padding: 12px 12px 28px;
  }
}
