/* ===== Header (clean version) ===== */
.topbar {
  min-height: 72px;
  background: linear-gradient(135deg, #ffebf5, #ece6fb);
  border: 1px solid #d9dae6;
  border-bottom: 1px solid rgba(236, 72, 153, 0.2);
  border-radius: 0 0 14px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap; /* 改：桌面端不换行，防偏移 */
  padding: 10px 16px;
  margin: -18px auto 16px; /* 改：水平居中 */
  max-width: 1380px;       /* 改：与主容器一致 */
  /*width: calc(100% - 28px);/* 改：保留两侧呼吸感 */
  position: relative;
  z-index: 300;
  overflow: visible;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 0 0 auto; /* 改：品牌区不被压缩 */
}
.brand h1 {
  margin: 0;
  color: #d65adf;
  line-height: 1.05;
}
.brand p {
  margin: 0;
  font-size: 12px;
  color: #5c6077;
  line-height: 1.2;
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1 1 auto;   /* 改：中间区域弹性占位 */
  min-width: 240px; /* 改：避免被压到错位 */
  overflow: visible;
}

.nav-item {
  position: relative;
  overflow: visible;
}

.top-nav .nav-link,
.top-nav .nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid #d6d9e3;
  background: #f2f3f7;
  color: #303546;
  font-size: 14px;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.top-nav .nav-btn {
  appearance: none;
  -webkit-appearance: none;
}
.top-nav .nav-link:hover,
.top-nav .nav-btn:hover {
  background: #e9ecf5;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 190px;
  padding: 8px;
  margin-top: 0;
  border: 1px solid #dcdfea;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 26px rgba(34, 42, 73, 0.14);
  display: none;
  z-index: 300;
}
.dropdown-menu a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: #2f3445;
  text-decoration: none;
  font-size: 14px;
}
.dropdown-menu a:hover {
  background: #f2f5ff;
  color: #4f46e5;
}

.has-dropdown:hover .dropdown-menu,
.has-dropdown:focus-within .dropdown-menu,
.has-dropdown.open .dropdown-menu {
  display: block;
}

.nav-item.has-dropdown::after {
  content: "";
  position: absolute;
  left: 0;
  top: 100%;
  width: 100%;
  height: 10px;
}

.top-actions {
  margin-left: 0;     /* 改：去掉 auto 挤压中间区 */
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  white-space: nowrap;
}

@media (max-width: 1024px) {
  .topbar {
    align-items: flex-start;
    flex-wrap: wrap; /* 保留你原来的移动逻辑 */
  }

  .brand { flex: 1 1 100%; }
  .top-nav {
    order: 3;
    flex: 1 1 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .top-actions {
    order: 2;
    margin-left: auto; /* 保留 */
  }
}

@media (max-width: 768px) {
  .topbar {
    padding: 10px 12px;
    gap: 10px;
    margin: -18px auto 12px;   /* 改：保持居中 */
    width: calc(100% - 12px);  /* 改：小屏边距 */
    border-radius: 0 0 12px 12px;
  }

  .brand { flex: 1 1 auto; }

  .brand h1 { font-size: clamp(24px, 6vw, 32px); }

  .top-actions { margin-left: auto; }

  .top-nav {
    order: 3;
    flex: 1 1 100%;
    width: 100%;
    gap: 8px;
  }

  .has-dropdown,
  .top-nav .nav-link {
    width: 100%;
  }

  .has-dropdown .nav-btn {
    width: 100%;
    justify-content: flex-start;
  }

  .top-nav .nav-link {
    height: 34px;
    justify-content: flex-start;
    padding: 0 12px;
    font-size: 13px;
  }

  .dropdown-menu {
    position: static;
    width: 100%;
    min-width: 0;
    margin-top: 6px;
    box-shadow: none;
    border-radius: 10px;
    z-index: 1;
  }
/* ===== 移动端菜单按钮 ===== */
.nav-toggle{
  display:none;
  width:40px;height:40px;
  border:1px solid #d6d9e3;
  background:#f2f3f7;
  border-radius:10px;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  gap:5px;
  cursor:pointer;
}
.nav-toggle span{
  width:18px;height:2px;background:#303546;border-radius:2px;
}

/* 桌面端保持你原样 */
@media (min-width: 769px){
  .top-nav{ display:flex !important; }
}

/* ===== H5：折叠菜单 ===== */
@media (max-width: 768px){
  .topbar{
    align-items:center;
  }

  .brand{
    flex:1 1 auto;
    min-width:0;
  }

  .brand h1{
    font-size:28px; /* 你原来很大，手机稍微收一点 */
    line-height:1.1;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }

  .nav-toggle{
    display:inline-flex;
    flex:0 0 auto;
  }

  /* 默认隐藏导航，点击按钮后再显示 */
  .top-nav{
    display:none;
    order: 99;
    width:100%;
    flex: 1 1 100%;
    margin-top:10px;
    padding-top:8px;
    border-top:1px solid #e3e6f2;
    gap:8px;
  }

  .topbar.nav-open .top-nav{
    display:flex;
    flex-direction:column;
    align-items:stretch;
  }

  .top-nav .nav-link,
  .top-nav .nav-btn{
    width:100%;
    justify-content:flex-start;
    height:38px;
    padding:0 12px;
    border-radius:10px;
    font-size:14px;
  }

  .has-dropdown{
    width:100%;
  }

  .has-dropdown .nav-btn{
    position:relative;
  }

  .has-dropdown .nav-btn::after{
    content:"▾";
    margin-left:auto;
    font-size:12px;
    color:#666;
  }

  .dropdown-menu{
    position:static;
    display:none;
    width:100%;
    min-width:0;
    margin-top:6px;
    box-shadow:none;
    border-radius:10px;
    border:1px solid #e1e5f2;
    background:#fff;
  }

  .has-dropdown.open .dropdown-menu{
    display:block;
  }

  .dropdown-menu a{
    padding:10px 12px;
    font-size:13px;
  }
}