:root {
  --global-topbar-blur: 16px;
}

.global-topbar {
  position: sticky;
  top: 0;
  width: 100%;
  background: rgba(15, 23, 42, 0.94);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.2);
  backdrop-filter: blur(var(--global-topbar-blur));
  color: #fff;
  z-index: 160;
}

.topbar-inner {
  width: 100%;
  margin: 0;
  padding: 14px clamp(18px, 4vw, 36px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  min-width: 200px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.12);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  box-shadow: 0 10px 25px rgba(129, 140, 248, 0.25);
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
}

.brand-subtitle {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.75);
}

.topbar-spacer {
  flex: 1;
  min-width: 40px;
}

.topbar-user {
  position: relative;
  margin-left: auto;
}

.topbar-changelog {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.topbar-changelog:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.35);
  transform: translateY(-1px);
}

.topbar-changelog .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f97316;
  box-shadow: 0 0 6px rgba(249, 115, 22, 0.7);
}

.topbar-alerts {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.topbar-alerts .bell-icon {
  font-size: 16px;
}

.topbar-alerts .alerts-badge {
  display: none;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #f97316;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.5);
}

.topbar-alerts .alerts-badge.show {
  display: inline-flex;
}

.topbar-alerts.is-active,
.topbar-alerts:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}

.user-pill {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 6px 12px 6px 6px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  min-width: 190px;
  color: inherit;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
}

.user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  align-items: flex-start;
}

.user-badge {
  display: none;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: linear-gradient(120deg, #fbbf24, #f97316);
  color: #0f172a;
  text-transform: uppercase;
}

.user-badge.show {
  display: inline-flex;
}

.user-name {
  font-weight: 700;
  font-size: 13px;
}

.user-role {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
}

.user-pill .chevron {
  font-size: 11px;
  opacity: 0.7;
  margin-left: auto;
}

.user-dropdown {
  position: absolute;
  right: 0;
  top: 58px;
  background: #fff;
  color: #0f172a;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 25px 50px rgba(15, 23, 42, 0.25);
  padding: 8px;
  display: none;
  min-width: 190px;
  z-index: 200;
}

.user-dropdown.show {
  display: block;
}

.user-dropdown button {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
}

.user-dropdown button:hover {
  background: rgba(99, 102, 241, 0.08);
  color: #4338ca;
}

.user-dropdown button.danger {
  color: #dc2626;
}

.alerts-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.05);
  backdrop-filter: blur(0px);
  z-index: 3990;
  display: none;
}

.alerts-overlay.show {
  display: block;
}

.alerts-panel {
  position: fixed;
  top: calc(var(--global-topbar-height, 64px) + 10px);
  right: clamp(12px, 4vw, 42px);
  width: min(360px, calc(100% - 24px));
  background: #fff;
  color: #0f172a;
  border-radius: 18px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 25px 60px rgba(15, 23, 42, 0.25);
  padding: 16px;
  z-index: 4000;
  display: none;
  flex-direction: column;
}

.alerts-panel.show {
  display: flex;
}

.alerts-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.alerts-headings {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.alerts-title {
  font-size: 15px;
  font-weight: 700;
}

.alerts-subtitle {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
}

.alerts-mark-all {
  border: 1px solid #cbd5f5;
  background: #eef2ff;
  color: #4338ca;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.alerts-mark-all:hover {
  background: #e0e7ff;
}

.alerts-delete-all {
  border: 1px solid #fecdd3;
  background: #fff1f2;
  color: #be123c;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.alerts-delete-all:hover {
  background: #ffe4e6;
}

.alerts-body {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.alerts-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 36px 12px;
  background: #f8fafc;
  border-radius: 12px;
  font-size: 13px;
  color: #94a3b8;
  text-align: center;
}

.alerts-list {
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.alerts-loading {
  padding: 28px 0;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
}

.alert-item {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px;
  background: #f8fafc;
  display: flex;
  gap: 12px;
}

.alert-item.unread {
  border-color: #c7d2fe;
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.2);
  background: #eef2ff;
}

.alert-item-thumb {
  width: 72px;
  min-width: 72px;
  height: 72px;
  border-radius: 10px;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #475569;
  overflow: hidden;
}

.alert-item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.alert-item-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.alert-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-item-meta-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.alert-item-time {
  font-size: 11px;
  color: #94a3b8;
}

.alert-item-category {
  background: rgba(99, 102, 241, 0.12);
  color: #4338ca;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.alert-item-delete {
  margin-left: auto;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s ease;
}

.alert-item-delete:hover {
  color: #dc2626;
}

.alert-item-title {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
}

.alert-item-content {
  font-size: 13px;
  color: #475569;
  line-height: 1.5;
}

.alert-item-media {
  margin-top: 8px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}

.alert-item-media img {
  width: 100%;
  height: auto;
  display: block;
}

.alert-item-link {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #4f46e5;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.alert-item-link::after {
  content: '↗';
  font-size: 11px;
}

.alerts-footer {
  margin-top: 14px;
}

.alerts-load-more {
  width: 100%;
  border: 1px dashed #cbd5f5;
  background: #eef2ff;
  color: #4338ca;
  padding: 8px 0;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}

.alerts-load-more:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.user-dropdown button.danger:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

.topbar-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 999;
}

.topbar-modal-overlay.show {
  display: flex;
}

.topbar-modal {
  width: min(420px, 100%);
  background: #fff;
  color: #0f172a;
  border-radius: 18px;
  padding: 20px 24px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.25);
}

.topbar-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.topbar-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.topbar-modal-close {
  border: none;
  background: rgba(148, 163, 184, 0.2);
  width: 32px;
  height: 32px;
  border-radius: 10px;
  cursor: pointer;
}

.topbar-modal-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topbar-modal-form label {
  font-size: 13px;
  color: #475569;
  font-weight: 600;
}

.topbar-modal-form input {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.topbar-modal-form input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.topbar-modal-submit {
  margin-top: 6px;
  border: none;
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(135deg, #7c3aed, #6366f1);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 12px 25px rgba(99, 102, 241, 0.3);
  transition: transform 0.15s ease;
}

.topbar-modal-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  box-shadow: none;
}

.topbar-modal-submit:not(:disabled):hover {
  transform: translateY(-1px);
}

.topbar-toast {
  position: fixed;
  left: 50%;
  top: 100px;
  transform: translateX(-50%) translateY(-10px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  color: #fff;
  font-size: 13px;
  box-shadow: 0 15px 30px rgba(15, 23, 42, 0.35);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1200;
}

.topbar-toast.show {
  opacity: 1;
  transform: translateX(-50%);
}

.topbar-toast.error {
  background: rgba(239, 68, 68, 0.92);
}

.topbar-toast.success {
  background: rgba(34, 197, 94, 0.92);
}

body.has-global-topbar {
  --global-topbar-height: var(--global-topbar-height, 76px);
}

.topbar-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 16px;
}

.topbar-modal-overlay.show {
  display: flex;
}

.topbar-modal {
  width: min(420px, 100%);
  background: #fff;
  color: #0f172a;
  border-radius: 18px;
  padding: 20px 24px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.25);
}

.topbar-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.topbar-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.topbar-modal-close {
  border: none;
  background: rgba(148, 163, 184, 0.2);
  width: 32px;
  height: 32px;
  border-radius: 10px;
  cursor: pointer;
}

.topbar-modal-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topbar-modal-form label {
  font-size: 13px;
  color: #475569;
  font-weight: 600;
}

.topbar-modal-form input {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.topbar-modal-form input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.topbar-modal-submit {
  margin-top: 6px;
  border: none;
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(135deg, #7c3aed, #6366f1);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 12px 25px rgba(99, 102, 241, 0.3);
  transition: transform 0.15s ease;
}

.topbar-modal-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  box-shadow: none;
}

.topbar-modal-submit:not(:disabled):hover {
  transform: translateY(-1px);
}

.topbar-toast {
  position: fixed;
  left: 50%;
  top: 100px;
  transform: translateX(-50%) translateY(-10px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  color: #fff;
  font-size: 13px;
  box-shadow: 0 15px 30px rgba(15, 23, 42, 0.35);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1200;
}

.topbar-toast.show {
  opacity: 1;
  transform: translateX(-50%);
}

.topbar-toast.error {
  background: rgba(239, 68, 68, 0.92);
}

.topbar-toast.success {
  background: rgba(34, 197, 94, 0.92);
}

@media (max-width: 900px) {
  .topbar-inner {
    padding: 12px 20px;
    gap: 14px;
  }
  .topbar-brand {
    min-width: 0;
  }
  .topbar-changelog {
    width: 100%;
    justify-content: center;
  }
  .topbar-user {
    width: 100%;
    display: flex;
    justify-content: flex-end;
  }
  .user-pill {
    width: 100%;
    justify-content: space-between;
  }
  .user-dropdown {
    width: 100%;
  }
}
