/* Topbar: ⋮ trigger + anchored popover (all breakpoints) */

.topbar {
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
}
.tb-head {
  flex: 1 1 auto;
  min-width: 0;
}
.tb-sub {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tb-sub.tb-sub--module,
.tb-sub.tb-sub--players {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}
.tb-end {
  width: auto;
  margin-left: auto;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 0;
}
.tb-end .tb-edit-profile-btn,
.tb-end .tb-user-tools,
.tb-end #tb-actions {
  display: none !important;
}

.tb-user-first {
  display: none;
}

/* Notification bell — left of profile chip */
.tb-notif-btn {
  display: inline-flex;
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  margin-right: 6px;
  border: 0.5px solid rgba(30, 58, 138, 0.12);
  border-radius: 12px;
  cursor: pointer;
  color: var(--pn);
  background: rgba(255, 255, 255, 0.95);
  box-shadow:
    0 1px 4px rgba(30, 58, 138, 0.08),
    0 0 0 1px rgba(255, 255, 255, 0.85) inset;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease, color 0.2s ease;
}
.tb-notif-btn .tb-notif-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  transition: transform 0.2s ease;
}
.tb-notif-btn:hover {
  background: #f7f9fc;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(30, 58, 138, 0.12);
}
.tb-notif-btn:hover .tb-notif-icon {
  transform: scale(1.06);
}
.tb-notif-btn.is-open {
  background: #eef2ff;
  color: var(--pg);
  border-color: rgba(57, 73, 171, 0.25);
}
.tb-notif-btn.has-unread {
  color: var(--pg);
  border-color: rgba(57, 73, 171, 0.2);
}
.tb-notif-btn.has-unread .tb-notif-icon {
  animation: tb-notif-ring 2.4s ease-in-out infinite;
}
@keyframes tb-notif-ring {
  0%, 100% { transform: rotate(0deg); }
  8% { transform: rotate(14deg); }
  16% { transform: rotate(-12deg); }
  24% { transform: rotate(8deg); }
  32% { transform: rotate(0deg); }
}
.tb-notif-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  color: #fff;
  background: linear-gradient(145deg, #ef5350 0%, #c62828 100%);
  box-shadow: 0 0 0 2px #fff;
  pointer-events: none;
  z-index: 1;
}
.tb-notif-inbox {
  visibility: hidden;
  pointer-events: none;
  position: fixed;
  z-index: var(--z-modal-panel);
  width: min(320px, calc(100vw - 24px));
  max-height: min(420px, 70dvh);
  margin: 0;
  padding: 0;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  border: 1px solid rgba(30, 58, 138, 0.1);
  box-shadow: 0 12px 32px rgba(30, 58, 138, 0.14);
  font-family: 'Outfit', sans-serif;
  opacity: 0;
  transform: scale(0.92) translateY(-8px);
  transition: opacity 0.22s ease, transform 0.28s ease, visibility 0s linear 0.28s;
}
.tb-notif-inbox.open {
  visibility: visible;
  pointer-events: auto;
  opacity: 1;
  transform: scale(1) translateY(0);
  transition: opacity 0.22s ease, transform 0.28s ease, visibility 0s;
}
.tb-notif-inbox-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 8px;
  border-bottom: 1px solid #ECEFF1;
}
.tb-notif-inbox-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--pn);
}
.tb-notif-inbox-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.tb-notif-mark-all {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--pg);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  white-space: nowrap;
}
.tb-notif-mark-all:hover:not(:disabled) { background: #EEF2FF; }
.tb-notif-mark-all:disabled {
  opacity: 0.45;
  cursor: default;
}
.tb-notif-settings-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--pg);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
}
.tb-notif-settings-link:hover { background: #EEF2FF; }
.tb-notif-inbox-list {
  overflow-y: auto;
  max-height: min(360px, calc(70dvh - 52px));
  padding: 6px;
}
.tb-notif-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.tb-notif-row:hover { background: #F0F4FF; }
.tb-notif-row--unread { background: #EEF2FF; }
.tb-notif-row-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #E8EAF6;
  color: var(--pg);
  flex-shrink: 0;
  font-size: 17px;
}
.tb-notif-row-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.tb-notif-row-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--pn);
}
.tb-notif-row-summary {
  font-size: 12px;
  color: #546E7A;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.tb-notif-row-when {
  font-size: 10px;
  color: #90A4AE;
  margin-top: 2px;
}
.tb-notif-empty {
  margin: 16px 12px;
  font-size: 12px;
  color: #78909C;
  line-height: 1.45;
  text-align: center;
}

.notif-settings-section { margin-bottom: 16px; }
.notif-settings-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #78909C;
  margin-bottom: 8px;
}
.notif-cat-group { margin-bottom: 14px; }
.notif-cat-group:last-child { margin-bottom: 0; }
.notif-cat-group-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #90A4AE;
  margin: 0 0 4px;
  padding-top: 4px;
}
.notif-cat-group:first-child .notif-cat-group-title { padding-top: 0; }
.notif-cat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #ECEFF1;
}
.notif-cat-row:last-child { border-bottom: none; }
.notif-cat-row-text { min-width: 0; }
.notif-cat-row-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--pn);
}
.notif-cat-row-hint {
  display: block;
  font-size: 11px;
  color: #90A4AE;
  margin-top: 2px;
  line-height: 1.35;
}
.notif-prefs--settings { margin-top: 4px; }

@media (max-width: 1023px) {
  .tb-notif-btn {
    width: 40px;
    height: 40px;
    margin-right: 4px;
    font-size: 19px;
  }
}

/* Desktop: profile chip with avatar + full name left of ⋮ menu */
@media (min-width: 1024px) {
  .tb-end {
    gap: 10px;
  }
  .tb-end .tb-user-chip {
    display: inline-flex !important;
    align-items: center;
    max-width: min(240px, 28vw);
  }
  .tb-end .tb-user-av {
    overflow: hidden;
    padding: 0;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85);
  }
  .tb-end .tb-user-text {
    display: flex !important;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
  }
  .tb-end .tb-user-name,
  .tb-end .tb-user-role {
    display: block !important;
  }
  .tb-end .tb-user-first {
    display: none !important;
  }
}

/* Mobile / tablet: compact profile chip left of ⋮ menu */
@media (max-width: 1023px) {
  .tb-end {
    gap: 6px;
  }
  .tb-end .tb-user-chip {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    padding: 3px 8px 3px 3px;
    max-width: min(118px, 32vw);
    border: 0.5px solid rgba(30, 58, 138, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 1px 4px rgba(30, 58, 138, 0.08);
    margin-right: 2px;
  }
  .tb-end .tb-user-chip:hover {
    background: #f7f9fc;
  }
  .tb-end .tb-user-av {
    width: 36px;
    height: 36px;
    font-size: 12px;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85);
    overflow: hidden;
    padding: 0;
  }
  .tb-end .tb-user-text {
    display: flex !important;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
  }
  .tb-end .tb-user-name,
  .tb-end .tb-user-role {
    display: none !important;
  }
  .tb-end .tb-user-first {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--pn);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 68px;
    line-height: 1.2;
  }
}

@media (max-width: 360px) {
  .tb-end .tb-user-chip {
    padding: 2px;
    max-width: none;
  }
  .tb-end .tb-user-first {
    display: none !important;
  }
}

#ev-summary-stats {
  display: none;
}

.tb-more-btn {
  display: inline-flex;
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 22px;
  color: #fff;
  background: linear-gradient(145deg, var(--pn) 0%, #2a4fad 100%);
  box-shadow:
    0 2px 8px rgba(30, 58, 138, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.12) inset;
  transition:
    transform 0.2s cubic-bezier(0.34, 1.2, 0.64, 1),
    box-shadow 0.2s ease,
    background 0.2s ease;
}
.tb-more-btn i { transition: transform 0.25s ease; }
.tb-more-btn:hover {
  transform: translateY(-1px);
  box-shadow:
    0 6px 18px rgba(30, 58, 138, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.18) inset;
}
.tb-more-btn:active { transform: translateY(0) scale(0.97); }
.tb-more-btn:focus-visible {
  outline: 2px solid var(--py);
  outline-offset: 3px;
}
.tb-more-btn.is-open {
  background: linear-gradient(145deg, var(--py) 0%, #f5c842 100%);
  color: var(--pn);
  box-shadow:
    0 4px 20px rgba(245, 200, 66, 0.45),
    0 0 0 2px rgba(30, 58, 138, 0.12);
}
.tb-more-btn.is-open i { transform: rotate(90deg); }

.tb-menu-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: var(--z-modal-overlay);
  background: rgba(15, 23, 42, 0.32);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.22s ease;
}
.tb-menu-backdrop.open {
  display: block;
  opacity: 1;
}

.tb-menu-popover,
.tb-menu-sheet {
  visibility: hidden;
  pointer-events: none;
  position: fixed;
  z-index: var(--z-modal-panel);
  width: min(288px, calc(100vw - 24px));
  max-height: min(70dvh, 420px);
  margin: 0;
  padding: 8px;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 16px;
  border: 1px solid rgba(30, 58, 138, 0.1);
  box-shadow:
    0 2px 4px rgba(30, 58, 138, 0.04),
    0 12px 32px rgba(30, 58, 138, 0.14),
    0 0 0 1px rgba(255, 255, 255, 0.85) inset;
  font-family: 'Outfit', sans-serif;
  transform-origin: top right;
  opacity: 0;
  transform: scale(0.92) translateY(-8px);
  overflow: hidden;
  transition:
    opacity 0.24s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.3s cubic-bezier(0.34, 1.35, 0.64, 1),
    visibility 0s linear 0.3s;
}
.tb-menu-popover::before,
.tb-menu-sheet::before {
  content: '';
  position: absolute;
  top: -6px;
  right: var(--tb-menu-caret-right, 14px);
  width: 12px;
  height: 12px;
  background: rgba(255, 255, 255, 0.97);
  border-left: 1px solid rgba(30, 58, 138, 0.1);
  border-top: 1px solid rgba(30, 58, 138, 0.1);
  transform: rotate(45deg);
  box-shadow: -2px -2px 8px rgba(30, 58, 138, 0.05);
}
.tb-menu-popover.open,
.tb-menu-sheet.open {
  visibility: visible;
  pointer-events: auto;
  opacity: 1;
  transform: scale(1) translateY(0);
  transition:
    opacity 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.28s cubic-bezier(0.34, 1.35, 0.64, 1),
    visibility 0s;
}
.tb-menu-popover--above::before,
.tb-menu-sheet.tb-menu-popover--above::before {
  top: auto;
  bottom: -5px;
  border-left: none;
  border-top: none;
  border-right: 1px solid rgba(30, 58, 138, 0.08);
  border-bottom: 1px solid rgba(30, 58, 138, 0.08);
  box-shadow: 2px 2px 6px rgba(30, 58, 138, 0.06);
}

.tb-menu-list {
  list-style: none;
  margin: 0;
  padding: 2px 0;
  overflow-y: auto;
  max-height: min(68dvh, 400px);
}

@media (min-width: 1024px) {
  .tb-menu-popover,
  .tb-menu-sheet {
    max-height: calc(100dvh - 24px);
  }
  .tb-menu-list {
    max-height: none;
    overflow-y: visible;
  }
  .tb-menu-popover.tb-menu--scroll .tb-menu-list,
  .tb-menu-sheet.tb-menu--scroll .tb-menu-list {
    overflow-y: auto;
  }
}

.tb-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: none;
  border-radius: 11px;
  background: transparent;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--pn);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}
.tb-menu-item i {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 18px;
  background: #EEF2FF;
  color: var(--pg);
  flex-shrink: 0;
  transition: transform 0.15s ease;
}
.tb-menu-item--primary {
  font-weight: 600;
}
.tb-menu-item--primary i {
  background: linear-gradient(145deg, var(--py) 0%, #ffe082 100%);
  color: var(--pn);
}
.tb-menu-item--danger { color: #C62828; }
.tb-menu-item--danger i {
  background: #FFEBEE;
  color: #C62828;
}
.tb-menu-item:hover,
.tb-menu-item:focus-visible {
  background: #F0F4FF;
  outline: none;
}
.tb-menu-item:hover i { transform: scale(1.04); }
.tb-menu-item:active { transform: scale(0.98); }
.tb-menu-item:focus-visible {
  box-shadow: inset 0 0 0 2px var(--pg);
}

.tb-menu-sep {
  height: 1px;
  margin: 4px 10px;
  background: linear-gradient(90deg, transparent, #E2E8F0 20%, #E2E8F0 80%, transparent);
  list-style: none;
}

@media (prefers-reduced-motion: reduce) {
  .tb-notif-btn.has-unread .tb-notif-icon {
    animation: none;
  }
  .tb-menu-popover,
  .tb-menu-sheet,
  .tb-menu-backdrop,
  .tb-more-btn,
  .tb-more-btn i,
  .signout-confirm,
  .signout-confirm-sheet {
    transition: none;
  }
}

/* Sign-out confirmation (replaces native confirm dialog) */
.signout-confirm {
  display: none;
  position: fixed;
  inset: 0;
  z-index: var(--z-modal-stack-panel);
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.22s ease;
}
.signout-confirm[hidden] { display: none; }
.signout-confirm.open {
  display: flex;
  opacity: 1;
}
.signout-confirm.open[hidden] { display: flex; }

.signout-confirm-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.signout-confirm-sheet {
  position: relative;
  z-index: 1;
  width: min(340px, 100%);
  padding: 28px 24px 22px;
  background: #fff;
  border-radius: 20px;
  border: 1px solid rgba(30, 58, 138, 0.08);
  box-shadow:
    0 8px 32px rgba(30, 58, 138, 0.18),
    0 0 0 1px rgba(255, 255, 255, 0.9) inset;
  text-align: center;
  font-family: 'Outfit', sans-serif;
  transform: scale(0.94) translateY(12px);
  transition: transform 0.28s cubic-bezier(0.34, 1.35, 0.64, 1);
}
.signout-confirm.open .signout-confirm-sheet {
  transform: scale(1) translateY(0);
}

.signout-confirm-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 14px;
  font-size: 26px;
  color: #C62828;
  background: linear-gradient(145deg, #FFEBEE 0%, #FFCDD2 100%);
}

.signout-confirm-title {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
  color: var(--pn);
  letter-spacing: -0.02em;
}

.signout-confirm-lead {
  margin: 0 0 22px;
  font-size: 14px;
  line-height: 1.45;
  color: #64748B;
}

.signout-confirm-actions {
  display: flex;
  gap: 10px;
}
.signout-confirm-actions .btn {
  flex: 1;
  min-height: 44px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 12px;
}
.signout-confirm-proceed {
  font-weight: 700;
}
