.compact-navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: grid;
  grid-template-columns: auto minmax(280px, 650px) auto;
  align-items: center;
  gap: 24px;
  min-height: 82px;
  padding: 12px clamp(20px, 6vw, 105px);
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid #dbe7f7;
  backdrop-filter: blur(14px)
}

.compact-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
  text-decoration: none
}

.compact-logo img {
  width: 48px;
  height: 48px
}

.compact-logo span {
  font-size: clamp(22px, 2vw, 30px);
  font-weight: 800;
  color: #10203a
}

.compact-search {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border: 1px solid #cfe0f5;
  border-radius: 999px;
  background: #f8fbff;
  box-shadow: 0 4px 16px rgba(30, 90, 180, .06)
}

.compact-search:focus-within {
  border-color: #2e68ec;
  box-shadow: 0 0 0 4px rgba(46, 104, 236, .12)
}

.compact-search-icon {
  font-size: 25px;
  color: #10203a;
  transform: rotate(-20deg)
}

.compact-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 16px;
  color: #17233b
}

.compact-search kbd {
  border: 1px solid #c8d7eb;
  border-radius: 8px;
  padding: 4px 8px;
  background: #fff;
  color: #52627a;
  font: 600 12px/1 system-ui
}

.compact-navbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-self: end
}

.compact-navbar [data-user-area] {
  display: flex;
  align-items: center
}

.compact-navbar .user-mini {
  display: flex;
  align-items: center;
  gap: 12px
}

.compact-navbar .user-mini>button[data-logout] {
  display: none !important
}

.compact-navbar .header-action-link {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  text-decoration: none;
  background: #f3f7fd;
  border: 1px solid #d8e5f6;
  font-size: 20px;
  position: relative
}

.compact-navbar .profile-link {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: #14213a;
  font-weight: 600
}

.compact-navbar .profile-link img {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #2e68ec
}

.compact-navbar .notification-count {
  position: absolute;
  right: -3px;
  top: -5px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 99px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  display: grid;
  place-items: center
}

.compact-menu-toggle {
  width: 52px;
  height: 52px;
  border: 2px solid #2e68ec;
  border-radius: 18px;
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  cursor: pointer
}

.compact-menu-toggle span {
  width: 21px;
  height: 2px;
  border-radius: 2px;
  background: #14213a
}

.compact-menu-toggle:hover {
  background: #eef4ff
}

.compact-menu {
  position: absolute;
  right: clamp(20px, 3vw, 55px);
  top: 72px;
  width: min(320px, calc(100vw - 28px));
  max-height: calc(100vh - 92px);
  overflow: auto;
  background: #fff;
  border: 1px solid #dbe6f5;
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(25, 52, 90, .18);
  padding: 14px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(.98);
  transform-origin: top right;
  transition: .2s ease;
  z-index: 1002
}

.compact-menu.is-open {
  opacity: 1;
  visibility: visible;
  transform: none
}

.compact-menu-head {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 14px;
  border-bottom: 1px solid #e5edf8
}

.compact-menu-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #10203a
}

.compact-menu-brand img {
  width: 36px;
  height: 36px
}

.compact-menu-close {
  border: 0;
  background: transparent;
  font-size: 30px;
  cursor: pointer
}

.compact-menu-list {
  display: flex;
  flex-direction: column;
  gap: 3px
}

.compact-menu-list a,
.compact-menu-logout {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #24344f;
  text-decoration: none;
  font: 600 15px/1.3 system-ui;
  text-align: left;
  cursor: pointer
}

.compact-menu-list a:hover,
.compact-menu-list a.is-active,
.compact-menu-logout:hover {
  background: #eaf1ff;
  color: #1f5fe0
}

.compact-menu-list a>span,
.compact-menu-logout>span {
  flex: 1
}

.compact-menu-divider {
  height: 1px;
  background: #e4ebf5;
  margin: 8px 4px
}

.compact-menu-backdrop {
  display: none
}

body.compact-menu-lock {
  overflow: hidden
}

@media(max-width:1100px) {
  .compact-navbar {
    grid-template-columns: auto 1fr auto;
    padding-inline: 22px;
    gap: 16px
  }

  .compact-navbar .profile-link span {
    display: none
  }

  .compact-search {
    max-width: none
  }
}

@media(max-width:760px) {
  .compact-navbar {
    min-height: 68px;
    padding: 9px 14px;
    grid-template-columns: auto 1fr auto
  }

  .compact-logo img {
    width: 42px;
    height: 42px
  }

  .compact-logo span {
    font-size: 22px
  }

  .compact-search {
    display: none
  }

  /* Trên điện thoại chỉ giữ hai thao tác quan trọng ở thanh trên cùng. */
  .compact-navbar .header-action-link {
    display: none;
  }

  /* Ghi đè chắc chắn quy tắc ẩn trong style.css. */
  .compact-navbar [data-user-area] .header-action-link[href="chat.html"],
  .compact-navbar [data-user-area] .header-action-link[href="notifications.html"] {
    width: 40px;
    height: 40px;
    display: grid !important;
    place-items: center;
    flex: 0 0 40px;
    font-size: 18px;
  }

  .compact-navbar [data-user-area],
  .compact-navbar .user-mini {
    width: auto;
    min-width: 0;
    flex-wrap: nowrap;
  }

  .compact-navbar .user-mini {
    gap: 7px;
  }

  .compact-navbar .profile-link {
    display: flex;
    flex: 0 0 auto;
  }

  .compact-navbar .profile-link .user-mini-copy {
    display: none;
  }

  .compact-navbar .profile-link img {
    width: 40px;
    height: 40px
  }

  .compact-menu-toggle {
    width: 44px;
    height: 44px;
    border-radius: 14px
  }

  .compact-menu {
    position: fixed;
    right: 0;
    top: 0;
    height: 100dvh;
    max-height: none;
    width: min(340px, 88vw);
    border-radius: 24px 0 0 24px;
    transform: translateX(105%);
    opacity: 1;
    visibility: hidden;
    padding: 16px
  }

  .compact-menu.is-open {
    transform: none;
    visibility: visible
  }

  .compact-menu-head {
    display: flex
  }

  .compact-menu-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 25, 45, .38);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    display: block;
    transition: .2s
  }

  .compact-menu-backdrop.is-open {
    opacity: 1;
    visibility: visible
  }
}

@media(max-width:380px){
  .compact-navbar {
    padding-inline: 10px;
    gap: 7px;
  }

  .compact-navbar-right,
  .compact-navbar .user-mini {
    gap: 5px;
  }

  .compact-navbar [data-user-area] .header-action-link[href="chat.html"],
  .compact-navbar [data-user-area] .header-action-link[href="notifications.html"],
  .compact-navbar .profile-link img {
    width: 38px;
    height: 38px;
  }

  .compact-menu-toggle {
    width: 42px;
    height: 42px;
  }
}

@media(max-width:430px){
  .compact-logo span{
    display:none;
  }

  .compact-navbar-right{
    gap:7px;
  }

  .compact-navbar .profile-link{
    display:flex;
  }

  .compact-navbar .profile-link span{
    display:none;
  }

  .compact-navbar .profile-link img{
    display:block;
    width:40px;
    height:40px;
    border-radius:50%;
    object-fit:cover;
    border:2px solid #2e68ec;
  }
}