* { box-sizing: border-box; }

/* ── Themed scrollbars ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(10, 20, 36, 0.6); }
::-webkit-scrollbar-thumb { background: rgba(56, 189, 248, 0.28); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(56, 189, 248, 0.5); }
* { scrollbar-width: thin; scrollbar-color: rgba(56, 189, 248, 0.28) rgba(10, 20, 36, 0.6); }

:root {
  --shell-bg: #111d31;
  --shell-card: rgba(20, 34, 53, 0.9);
  --shell-border: rgba(56, 189, 248, 0.24);
  --shell-text: #eaf2ff;
  --shell-muted: rgba(223, 234, 250, 0.62);
  --shell-accent: #14b8a6;
  --shell-radius: 14px;
  --shell-sidebar-w: 250px;
  --shell-sidebar-w-collapsed: 74px;
  --shell-topbar-h: 64px;
  --shell-font-body: 'Manrope', system-ui, sans-serif;
  --shell-font-head: 'Fraunces', Georgia, serif;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at 0% 0%, #122946, #0e1a2c 55%, #0c1524 100%);
  color: var(--shell-text);
  font-family: var(--shell-font-body);
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }

.shell {
  min-height: 100vh;
  display: flex;
}

.shell-sidebar {
  width: var(--shell-sidebar-w);
  border-right: 1px solid var(--shell-border);
  background: rgba(15, 28, 45, 0.95);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 30;
  transition: width 0.25s ease, transform 0.25s ease;
}

.shell-sidebar.collapsed {
  width: var(--shell-sidebar-w-collapsed);
}

.shell-sidebar.collapsed .shell-brand-text,
.shell-sidebar.collapsed .shell-link span,
.shell-sidebar.collapsed .shell-user-info {
  display: none;
}

.shell-sidebar.collapsed .shell-link {
  justify-content: center;
}

.shell-sidebar.collapsed .shell-brand {
  justify-content: center;
  padding: 14px 10px;
}

.shell-brand {
  padding: 16px;
  display: flex;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid rgba(56, 189, 248, 0.14);
}

.shell-brand img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

.shell-brand-text {
  overflow: hidden;
}

.shell-brand-title {
  display: block;
  font-family: var(--shell-font-head);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.shell-brand-sub {
  display: block;
  margin-top: 1px;
  color: var(--shell-muted);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.shell-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 7px 14px;
  width: 100%;
  border: none;
  border-bottom: 1px solid rgba(56, 189, 248, 0.1);
  background: transparent;
  color: rgba(223, 234, 250, 0.42);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.shell-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--shell-text);
}

.shell-toggle svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.shell-sidebar.collapsed .shell-toggle {
  justify-content: center;
  padding: 7px;
}

.shell-nav {
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  flex: 1;
}

.shell-link {
  padding: 10px 12px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(223, 234, 250, 0.72);
  font-size: 0.86rem;
}

.shell-link:hover {
  background: rgba(255, 255, 255, 0.09);
  color: var(--shell-text);
}

.shell-link.is-active {
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.26);
  color: var(--shell-text);
}

.shell-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  font-style: normal;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.shell-badge:not(:empty) {
  display: inline-flex;
}

.shell-sidebar.collapsed .shell-badge {
  display: none !important;
}

.shell-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.shell-nav-label {
  display: block;
  padding: 10px 12px 4px;
  font-size: 0.63rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(223, 234, 250, 0.35);
}

.shell-sidebar.collapsed .shell-nav-label {
  display: none;
}

.shell-quick-actions {
  border-top: 1px solid rgba(56, 189, 248, 0.1);
  padding: 6px 10px;
}

.shell-qa-toggle {
  width: 100%;
  border: none;
  background: transparent;
  color: rgba(223, 234, 250, 0.62);
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.86rem;
  font-family: var(--shell-font-body);
  transition: background 0.15s, color 0.15s;
}

.shell-qa-toggle:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--shell-text);
}

.shell-qa-toggle svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.shell-qa-items {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0 2px;
}

.shell-qa-items.is-open {
  display: flex;
}

.shell-qa-item {
  display: block;
  padding: 7px 12px 7px 38px;
  border-radius: 8px;
  color: rgba(223, 234, 250, 0.72);
  font-size: 0.82rem;
  font-family: var(--shell-font-body);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
  text-decoration: none;
}

.shell-qa-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--shell-text);
}

.shell-sidebar.collapsed .shell-quick-actions {
  display: none;
}

.shell-footer {
  border-top: 1px solid rgba(56, 189, 248, 0.14);
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.shell-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0;
  min-width: 0;
  flex: 1;
}

.shell-user-info {
  min-width: 0;
}

.shell-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0f172a, #14b8a6);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.77rem;
  font-weight: 700;
  color: #fff;
}

.shell-user-name {
  font-size: 0.82rem;
  font-weight: 600;
}

.shell-user-role {
  font-size: 0.7rem;
  color: var(--shell-muted);
}

.shell-logout {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(56, 189, 248, 0.24);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--shell-text);
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.shell-logout:hover {
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.35);
  transform: translateY(-1px);
}

.shell-logout svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.shell-main {
  margin-left: var(--shell-sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s ease;
}

.shell-sidebar.collapsed + .shell-main,
.shell.sb-mini .shell-main {
  margin-left: var(--shell-sidebar-w-collapsed);
}

.shell-topbar {
  min-height: var(--shell-topbar-h);
  border-bottom: 1px solid rgba(56, 189, 248, 0.14);
  background: rgba(18, 34, 54, 0.78);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.shell-topbar-title {
  font-family: var(--shell-font-head);
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shell-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shell-btn,
.dark-toggle {
  border: 1px solid rgba(56, 189, 248, 0.24);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--shell-text);
  font-size: 0.8rem;
  padding: 7px 11px;
  cursor: pointer;
}

.dark-toggle {
  width: 36px;
  height: 36px;
  padding: 0;
}

.dark-toggle__icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  border-radius: 999px;
  background: linear-gradient(135deg, #7dd3fc 0%, #14b8a6 100%);
}

.shell-mobile-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(56, 189, 248, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--shell-text);
  align-items: center;
  justify-content: center;
}

.shell-mobile-toggle svg {
  width: 18px;
  height: 18px;
}

.shell-content {
  padding: 18px;
}

.shell-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
  z-index: 25;
}

.shell-overlay.visible {
  display: block;
}

@media (max-width: 900px) {
  .shell-sidebar {
    transform: translateX(-100%);
    width: var(--shell-sidebar-w);
  }

  .shell-sidebar.is-open {
    transform: translateX(0);
  }

  .shell-main,
  .shell-sidebar.collapsed + .shell-main {
    margin-left: 0;
  }

  .shell-mobile-toggle {
    display: inline-flex;
  }

  .shell-toggle {
    display: inline-flex;
  }
}

@media (max-width: 600px) {
  .shell-topbar {
    align-items: center;
  }

  .shell-topbar-actions {
    flex-shrink: 0;
    flex-wrap: wrap;
  }

  .shell-content {
    padding: 14px;
  }
}

/* Light mode overrides for internal workspace pages */
:root:not(.dark-mode) {
  --shell-bg: #eef4fb;
  --shell-card: rgba(255, 255, 255, 0.9);
  --shell-border: rgba(37, 99, 235, 0.2);
  --shell-text: #13223a;
  --shell-muted: rgba(19, 34, 58, 0.6);
}

:root:not(.dark-mode) body {
  background: radial-gradient(circle at 0% 0%, #f7fbff, #edf3fb 55%, #e6edf8 100%);
  color: var(--shell-text);
}

:root:not(.dark-mode) .shell-sidebar {
  background: rgba(248, 252, 255, 0.96);
  border-right-color: rgba(37, 99, 235, 0.18);
}

:root:not(.dark-mode) .shell-brand,
:root:not(.dark-mode) .shell-topbar,
:root:not(.dark-mode) .shell-footer,
:root:not(.dark-mode) .shell-toggle {
  border-color: rgba(37, 99, 235, 0.16);
}

:root:not(.dark-mode) .shell-toggle {
  color: rgba(19, 34, 58, 0.5);
}

:root:not(.dark-mode) .shell-toggle:hover,
:root:not(.dark-mode) .shell-link:hover {
  background: rgba(37, 99, 235, 0.08);
}

:root:not(.dark-mode) .shell-link {
  color: rgba(19, 34, 58, 0.75);
}

:root:not(.dark-mode) .shell-link.is-active {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.24);
}

:root:not(.dark-mode) .shell-topbar {
  background: rgba(250, 253, 255, 0.88);
}

:root:not(.dark-mode) .shell-btn,
:root:not(.dark-mode) .dark-toggle,
:root:not(.dark-mode) .shell-mobile-toggle,
:root:not(.dark-mode) .shell-logout {
  background: rgba(37, 99, 235, 0.06);
  border-color: rgba(37, 99, 235, 0.22);
  color: var(--shell-text);
}
