:root {
  --bg: #fdfcff;
  --bg-2: #efe5ff;

  --card: #fff;
  --text: #1f1f1f;
  --muted: #6a6a6a;
  --brand: #9d2ec5;
  --brand-600: #ae37da;
  --border: #e7ddff;
  --card: #ffffff;
  --ring: rgba(124, 58, 237, 0.25);
  --row-hover: #f5f6fa;
  --glow: rgba(124, 58, 237, 0.22);
  --white: #fff;
  --soft-lilac: #eee7ff;
  --soft-code: #f5efff;
  --purple-100: #efe8ff;
  --green-100: #e8fff1;
  --amber-100: #fff7e6;
  --pill-queued: #eadcff;
  --pill-pre: #dce7ff;
  --pill-train: #dceeff;
  --pill-opt: #d7fff4;
  --pill-pack: #fff2d8;
  --pill-done: #dcfbe7;
  --pill-fail: #ffe1e1;
  --row-hover: #ebecec;

  --shadow: 0 10px 30px rgba(124, 58, 237, 0.14);
  --shadow-deep: 0 12px 36px rgba(124, 58, 237, 0.22);
  --shadow-strong: 0 16px 40px rgba(124, 58, 237, 0.2);

  --gap: 16px;
}

header {
  background: var(--bg-2);
  min-height: 5%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #eee5ff;
  position: relative;
  z-index: 50;
}

.left-wrap {
  display: flex;
  align-items: center;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  font-size: 1.04rem;
  line-height: 1;
}

.brand-logo {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-logo-dark {
  display: none;
}

.nav {
  display: flex;
  gap: 12px;
}

.nav-link {
  color: #5c5c5c;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
}

.nav-link:hover {
  background: transparent;
  color: var(--brand);
  border-color: rgba(124, 58, 237, 0.14);
}

.nav-link.active {
  background: transparent;
  color: var(--brand);
  font-weight: 700;
  border-color: rgba(124, 58, 237, 0.18);
  box-shadow: inset 0 -2px 0 var(--brand);
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.notif-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
  color: var(--brand);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.08s ease, box-shadow 0.16s ease;
}

.notif-btn:hover {
  background: rgba(124, 58, 237, 0.08);
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.18);
  transform: translateY(-1px);
}

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ff4d6d;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
}

.notif-badge[hidden] {
  display: none !important;
}

.notif-menu {
  position: absolute;
  right: 56px;
  top: 60px;
  width: 320px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px;
  display: none;
  z-index: 1000;
}

.notif-menu.show {
  display: block;
}

.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 10px;
  font-weight: 700;
}

.notif-clear {
  border: none;
  background: none;
  color: var(--brand);
  font-weight: 600;
  cursor: pointer;
}

.notif-clear:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.notif-list {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
}

.notif-item {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #eee;
  background: #fff;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.08s ease, box-shadow 0.16s ease;
}

.notif-item:hover {
  background: #faf7ff;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
}

.notif-item.unread {
  border-color: #e5d6ff;
  background: #f8f4ff;
}

.notif-item-static {
  cursor: default;
}

.notif-item-static:hover {
  background: #fff;
  transform: none;
  box-shadow: none;
}

.notif-title {
  font-weight: 700;
  color: var(--text);
}

.notif-meta {
  font-size: 12px;
  color: var(--muted);
}

.header-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  cursor: pointer;
  font-weight: 700;
  border: 1px solid transparent;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.02);
  transition: background 0.16s ease, transform 0.08s ease, box-shadow 0.16s ease;
}

.header-btn:active {
  transform: translateY(1px);
}

.header-btn-solid {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.header-btn-solid:hover {
  background: var(--brand-600);
}

.header-btn-ghost {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.88);
  color: var(--brand);
  border: 1px solid var(--border);
}

.header-btn-ghost:hover {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(124, 58, 237, 0.18);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
  transition: box-shadow 0.16s ease, transform 0.08s ease;
}

.avatar:hover {
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.25);
  transform: translateY(-1px);
}

.avatar-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-photo.hidden {
  display: none;
}

.menu {
  position: absolute;
  right: 14px;
  top: 60px;
  width: 240px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px;
  display: none;
  z-index: 1000;
}

.menu.show {
  display: block;
}

.menu-header {
  padding: 6px 8px 10px;
}

.menu-header .muted {
  color: var(--muted);
  font-size: 12px;
}

.menu-item {
  width: 100%;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 10px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  transition: background 0.16s ease, transform 0.08s ease, box-shadow 0.16s ease;
}

.menu-item:hover {
  background: #faf7ff;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
}

.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  padding: 0;
  color: var(--brand);
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.1);
}

.mobile-menu-btn:hover {
  background: rgba(255, 255, 255, 0.96);
}

html[data-theme="dark"] header {
  background: var(--bg-2);
}

html[data-theme="dark"] .topbar {
  background: rgba(13, 20, 34, 0.92);
  border-bottom-color: #253347;
}

html[data-theme="dark"] .brand-logo-light {
  display: none;
}

html[data-theme="dark"] .brand-logo-dark {
  display: block;
}

html[data-theme="dark"] .nav-link {
  color: #c9d6e5;
}

html[data-theme="dark"] .nav-link:hover {
  background: transparent;
  border-color: rgba(161, 96, 235, 0.22);
}

html[data-theme="dark"] .nav-link.active {
  background: transparent;
  color: #f2e6ff;
  border-color: rgba(161, 96, 235, 0.28);
  box-shadow: inset 0 -2px 0 var(--brand);
}

html[data-theme="dark"] .notif-btn,
html[data-theme="dark"] .header-btn-ghost,
html[data-theme="dark"] .notif-menu,
html[data-theme="dark"] .menu,
html[data-theme="dark"] .menu-item {
  border-color: #253347;
  color: var(--text);
}

html[data-theme="dark"] .notif-btn {
  background: rgba(16, 24, 39, 0.94);
  color: #e8d6ff;
}

html[data-theme="dark"] .header-btn-ghost {
  background: rgba(16, 24, 39, 0.94);
}

html[data-theme="dark"] .notif-menu,
html[data-theme="dark"] .menu {
  background: #151f30;
}

html[data-theme="dark"] .menu-item {
  background: #101827;
}

html[data-theme="dark"] .notif-menu,
html[data-theme="dark"] .menu {
  background: #151f30;
}

html[data-theme="dark"] .menu-item {
  background: #101827;
}

html[data-theme="dark"] .notif-item,
html[data-theme="dark"] .notif-item-static {
  background: #101827;
  border-color: #253347;
}

html[data-theme="dark"] .notif-item:hover,
html[data-theme="dark"] .menu-item:hover {
  background: #1a2537;
}

html[data-theme="dark"] .notif-item.unread {
  border-color: #3b2b59;
  background: #1a1630;
}

html[data-theme="dark"] .nav {
  background: transparent;
}

html[data-theme="dark"] .menu-header .muted,
html[data-theme="dark"] .notif-meta {
  color: var(--muted);
}

html[data-theme="dark"] .header-btn-ghost:hover {
  background: rgba(26, 37, 55, 0.98);
  border-color: rgba(161, 96, 235, 0.28);
}

html[data-theme="dark"] .mobile-menu-btn {
  background: rgba(16, 24, 39, 0.94);
  border-color: #253347;
  color: #e8d6ff;
}

html[data-theme="dark"] .mobile-menu-btn:hover {
  background: rgba(26, 37, 55, 0.98);
}

@media (max-width: 1100px) {
  body header#header {
    padding: 14px 16px 22px;
  }

  body header#header .mobile-menu-btn {
    display: flex;
  }

  body header#header .topbar {
    padding: 12px 16px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.94);
  }

  body header#header .left-wrap {
    gap: 14px;
  }

  body header#header .brand {
    gap: 10px;
  }

  body header#header .brand span {
    font-size: 0.96rem;
  }

  body header#header .brand-logo {
    width: 48px;
    height: 48px;
  }

  body header#header .actions {
    gap: 8px;
  }

  body header#header .header-btn-ghost,
  body header#header .notif-btn,
  body header#header .mobile-menu-btn {
    background: rgba(255, 255, 255, 0.94);
  }

  body header#header .nav {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    left: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.97);
    flex-direction: column;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    z-index: 100;
  }

  body header#header .nav.show {
    display: flex;
  }

  body header#header .nav-link {
    display: block;
    width: 100%;
    padding: 12px;
    border-radius: 8px;
  }

  body header#header .banner-text {
    display: none;
  }

  body header#header .notif-menu {
    right: 14px;
    width: min(92vw, 320px);
  }
}

@media (max-width: 1100px) {
  html[data-theme="dark"] body header#header .topbar {
    background: rgba(13, 20, 34, 0.94);
  }

  html[data-theme="dark"] body header#header .header-btn-ghost,
  html[data-theme="dark"] body header#header .notif-btn,
  html[data-theme="dark"] body header#header .mobile-menu-btn {
    background: rgba(16, 24, 39, 0.96);
  }

  html[data-theme="dark"] body header#header .nav {
    background: rgba(21, 31, 48, 0.98);
    border-color: #253347;
  }
}
