/* =========================================================================
   好物商城 · 新增组件样式
   承接 site.css 的设计语言（墨绿 + 金、衬线标题、圆角卡片），
   只补充原站没有的部分：顶栏账号区、表单卡、按钮组、后台面板、表格。
   ========================================================================= */

/* ---------------- 顶栏 ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 900;
  background: var(--nav-bg, rgba(246, 244, 238, .85));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .7rem 5%;
}
.topbar .brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; }
.topbar .brand-mark { width: 34px; height: 34px; flex-shrink: 0; transition: transform .3s var(--ease); }
.topbar .brand:hover .brand-mark { transform: rotate(-6deg) scale(1.05); }
.topbar .brand-text {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: .02em;
  color: var(--ink);
  white-space: nowrap;
}
.topbar .brand-text b { color: var(--brand); margin-left: .18em; }
.topbar .nav-links { display: flex; gap: .2rem; margin-left: .5rem; }
.topbar .nav-item {
  color: var(--ink-2);
  text-decoration: none;
  font-size: .94rem;
  font-weight: 500;
  padding: .45rem .9rem;
  border-radius: 999px;
  transition: all .2s var(--ease);
  cursor: pointer;
}
.topbar .nav-item:hover { color: var(--brand); background: var(--bg-soft); }
.topbar .nav-item.active { color: #fff; background: var(--brand); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.topbar .hamburger { display: none; }

/* ---------------- 账号区 ---------------- */

.account-area { position: relative; }
.account-area .account-link {
  color: var(--ink-2);
  text-decoration: none;
  font-size: .92rem;
  font-weight: 600;
  padding: .45rem .95rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  transition: all .2s var(--ease);
  margin-left: .35rem;
  display: inline-block;
}
.account-area .account-link:hover { color: var(--brand); border-color: var(--brand); }
.account-area .account-link.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: #fff;
  border-color: transparent;
}
.account-area .account-link.primary:hover { filter: brightness(1.08); }

.account-chip {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .3rem .75rem .3rem .35rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
  transition: all .2s var(--ease);
  outline: none;
}
.account-chip:hover, .account-chip:focus-visible { border-color: var(--brand); box-shadow: var(--shadow-sm); }
.account-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: .85rem;
  font-weight: 700;
  flex-shrink: 0;
}
.account-name { font-size: .9rem; font-weight: 600; color: var(--ink); max-width: 7em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-role {
  font-size: .7rem;
  color: var(--gold-deep);
  background: var(--gold-soft);
  padding: .1rem .45rem;
  border-radius: 999px;
  white-space: nowrap;
}
.account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + .5rem);
  min-width: 190px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: .4rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: all .18s var(--ease);
  z-index: 950;
}
.account-area.open .account-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.account-menu-head { padding: .5rem .7rem .6rem; border-bottom: 1px solid var(--line-soft); margin-bottom: .35rem; }
.account-menu-user { font-weight: 700; font-size: .92rem; color: var(--ink); }
.account-menu-sub { font-size: .78rem; color: var(--ink-3); margin-top: .15rem; }
.account-menu-item {
  display: block;
  padding: .5rem .7rem;
  border-radius: 8px;
  font-size: .9rem;
  color: var(--ink-2);
  text-decoration: none;
  transition: all .16s var(--ease);
}
.account-menu-item:hover { background: var(--bg-soft); color: var(--brand); }
.account-menu-item.danger { color: var(--danger); }
.account-menu-item.danger:hover { background: rgba(194, 64, 47, .1); color: var(--danger); }

/* ---------------- 页面骨架 ---------------- */

.page { max-width: 1280px; margin: 0 auto; padding: 2.5rem 5% 4rem; }
.page-head { margin-bottom: 1.8rem; }
.page-title {
  font-family: var(--serif);
  font-size: 1.9rem;
  letter-spacing: .04em;
  color: var(--ink);
  font-weight: 700;
}
.page-sub { color: var(--ink-3); font-size: .92rem; margin-top: .4rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.6rem;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 1.2rem; }
.card-title {
  font-family: var(--serif);
  font-size: 1.1rem;
  letter-spacing: .03em;
  margin-bottom: 1rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
}

/* ---------------- 表单 ---------------- */

.field { margin-bottom: 1.1rem; }
.field label {
  display: block;
  font-size: .86rem;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: .4rem;
  letter-spacing: .02em;
}
.field .hint { font-size: .78rem; color: var(--ink-3); margin-top: .35rem; }
.field .req { color: var(--danger); margin-left: .15em; }

.input, .textarea, .select {
  width: 100%;
  padding: .72rem .9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  font-size: .95rem;
  font-family: inherit;
  transition: all .2s var(--ease);
  outline: none;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(14, 124, 102, .12);
  background: var(--card);
}
.input:disabled, .select:disabled { opacity: .6; cursor: not-allowed; }
.textarea { min-height: 90px; resize: vertical; line-height: 1.6; }
.select { cursor: pointer; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ---------------- 按钮 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .72rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink);
  font-size: .94rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: all .22s var(--ease);
  white-space: nowrap;
}
.btn:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 16px rgba(14, 124, 102, .24);
}
.btn.primary:hover { filter: brightness(1.06); color: #fff; box-shadow: 0 10px 22px rgba(14, 124, 102, .3); }
.btn.gold { background: linear-gradient(135deg, var(--gold), var(--gold-deep)); color: #fff; border-color: transparent; }
.btn.danger { color: var(--danger); border-color: rgba(194, 64, 47, .4); }
.btn.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.small { padding: .4rem .85rem; font-size: .84rem; border-radius: 8px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: .7rem; flex-wrap: wrap; }

/* ---------------- 提示条 ---------------- */

.notice {
  padding: .8rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  line-height: 1.6;
  border: 1px solid transparent;
  margin-bottom: 1rem;
}
.notice.info { background: rgba(14, 124, 102, .08); border-color: rgba(14, 124, 102, .25); color: var(--brand-ink); }
.notice.warn { background: rgba(201, 138, 43, .1); border-color: rgba(201, 138, 43, .3); color: #8a5f14; }
.notice.error { background: rgba(194, 64, 47, .08); border-color: rgba(194, 64, 47, .28); color: var(--danger); }
.notice.success { background: rgba(46, 139, 87, .09); border-color: rgba(46, 139, 87, .28); color: #1f6b41; }

/* ---------------- 徽标 ---------------- */

.tag {
  display: inline-block;
  font-size: .74rem;
  padding: .16rem .6rem;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}
.tag.gray { background: var(--bg-soft); color: var(--ink-3); }
.tag.green { background: rgba(46, 139, 87, .13); color: #1f6b41; }
.tag.gold { background: var(--gold-soft); color: var(--gold-deep); }
.tag.red { background: rgba(194, 64, 47, .12); color: var(--danger); }
.tag.blue { background: rgba(14, 124, 102, .12); color: var(--brand); }

/* ---------------- 空状态 ---------------- */

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--ink-3); }
.empty-icon { font-size: 3rem; opacity: .55; margin-bottom: .9rem; }
.empty-state p { font-size: .95rem; }

/* ---------------- 数据表格（后台与商家台） ---------------- */

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; background: var(--card); }
table.data th {
  text-align: left;
  padding: .75rem .9rem;
  background: var(--bg-soft);
  color: var(--ink-2);
  font-weight: 700;
  font-size: .82rem;
  letter-spacing: .03em;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td { padding: .7rem .9rem; border-bottom: 1px solid var(--line-soft); color: var(--ink); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--bg); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .muted { color: var(--ink-3); font-size: .85rem; }
table.data .mono { font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace; font-size: .84rem; color: var(--ink-2); }

/* ---------------- 指标卡 ---------------- */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .9rem; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.stat-label { font-size: .78rem; color: var(--ink-3); letter-spacing: .04em; margin-bottom: .35rem; }
.stat-value { font-family: var(--serif); font-size: 1.7rem; font-weight: 700; color: var(--ink); line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-value.green { color: var(--brand); }
.stat-value.gold { color: var(--gold-deep); }
.stat-value.red { color: var(--danger); }
.stat-hint { font-size: .76rem; color: var(--ink-3); margin-top: .25rem; }

/* ---------------- 商品网格（前台） ---------------- */

.grid-products { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1.4rem; }
.product-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all .3s var(--ease);
  display: flex;
  flex-direction: column;
  cursor: pointer;
}
.product-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); border-color: transparent; }
.product-thumb {
  background: var(--img-bg, linear-gradient(135deg, #efece3 0%, #f0e4c8 100%));
  font-size: 3.2rem;
  text-align: center;
  padding: 1.6rem 0;
  position: relative;
}
.product-body { padding: 1rem 1.1rem 1.2rem; display: flex; flex-direction: column; flex: 1; }
.product-name { font-weight: 700; color: var(--ink); margin-bottom: .3rem; font-size: 1rem; }
.product-desc { font-size: .84rem; color: var(--ink-3); line-height: 1.5; margin-bottom: .7rem; flex: 1; }
.product-foot { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.price { font-family: var(--serif); color: var(--brand); font-weight: 700; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.price i { font-size: .8em; font-style: normal; margin-right: .1em; }
.shop-line { font-size: .76rem; color: var(--ink-3); margin-top: .5rem; display: flex; align-items: center; gap: .3rem; }

/* ---------------- 分页 ---------------- */

.pager { display: flex; justify-content: center; align-items: center; gap: .4rem; margin-top: 1.6rem; flex-wrap: wrap; }
.pager button {
  min-width: 36px;
  height: 36px;
  padding: 0 .6rem;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  border-radius: 8px;
  cursor: pointer;
  font-size: .88rem;
  font-family: inherit;
  transition: all .18s var(--ease);
}
.pager button:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.pager button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.pager button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------------- 侧栏布局（后台 / 商家台） ---------------- */

.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.side {
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 1.2rem .8rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.side-brand {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.05rem;
  padding: .4rem .7rem 1.1rem;
  color: var(--ink);
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: .7rem;
  display: flex;
  align-items: center;
  gap: .45rem;
}
.side-brand small { display: block; font-size: .68rem; color: var(--ink-3); font-family: inherit; font-weight: 400; letter-spacing: .04em; }
.side-link {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .62rem .7rem;
  border-radius: 9px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .18s var(--ease);
  margin-bottom: .15rem;
}
.side-link:hover { background: var(--bg-soft); color: var(--brand); }
.side-link.active { background: var(--brand); color: #fff; }
.side-link .badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: .7rem;
  padding: .05rem .4rem;
  border-radius: 999px;
  font-weight: 700;
}
.side-link.active .badge { background: rgba(255, 255, 255, .28); }

.main { padding: 1.6rem 2rem 3rem; max-width: 1200px; }
.main-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.main-title { font-family: var(--serif); font-size: 1.5rem; color: var(--ink); font-weight: 700; letter-spacing: .03em; }
.main-sub { font-size: .86rem; color: var(--ink-3); margin-top: .25rem; }

.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.1rem; }
.toolbar .input, .toolbar .select { width: auto; min-width: 150px; padding: .5rem .75rem; font-size: .88rem; }

/* ---------------- 登录 / 注册页 ---------------- */

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 2.5rem 1.2rem; background: var(--hero-bg, var(--bg)); }
.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-md);
}
.auth-brand { text-align: center; margin-bottom: 1.6rem; }
.auth-brand .brand-text { font-family: var(--serif); font-size: 1.6rem; font-weight: 700; color: var(--ink); }
.auth-brand .brand-text b { color: var(--brand); margin-left: .18em; }
.auth-brand p { color: var(--ink-3); font-size: .88rem; margin-top: .45rem; }
.auth-foot { text-align: center; margin-top: 1.3rem; font-size: .88rem; color: var(--ink-3); }
.auth-foot a { color: var(--brand); text-decoration: none; font-weight: 600; }
.auth-foot a:hover { text-decoration: underline; }

/* 身份选择卡 */
.role-pick { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-bottom: 1.2rem; }
.role-card {
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem .9rem;
  cursor: pointer;
  text-align: center;
  transition: all .2s var(--ease);
  background: var(--bg);
  position: relative;
}
.role-card:hover { border-color: var(--gold); }
.role-card.on { border-color: var(--brand); background: rgba(14, 124, 102, .06); }
.role-card .role-icon { font-size: 1.7rem; display: block; margin-bottom: .35rem; }
.role-card .role-name { font-weight: 700; font-size: .95rem; color: var(--ink); }
.role-card .role-desc { font-size: .76rem; color: var(--ink-3); margin-top: .3rem; line-height: 1.45; }
.role-card input { position: absolute; opacity: 0; pointer-events: none; }

/* ---------------- 详情弹窗 ---------------- */

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(3px);
  z-index: 1002;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
}
.modal-mask.active { display: flex; }
.modal-box {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 1.8rem;
  width: 100%;
  max-width: 480px;
  max-height: 86vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
  animation: slideUp .28s var(--ease);
}
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line); padding-bottom: .9rem; margin-bottom: 1.1rem; }
.modal-head h3 { font-family: var(--serif); font-size: 1.15rem; color: var(--ink); }
.modal-close { background: none; border: none; font-size: 1.3rem; color: var(--ink-3); cursor: pointer; width: 32px; height: 32px; border-radius: 50%; transition: all .2s; }
.modal-close:hover { background: var(--bg-soft); color: var(--ink); transform: rotate(90deg); }
.detail-icon { text-align: center; font-size: 4rem; padding: 1.4rem 0; background: var(--img-bg, var(--bg-soft)); border-radius: var(--radius); margin-bottom: 1.1rem; }
.detail-row { margin-bottom: .8rem; }
.detail-row .k { font-size: .78rem; color: var(--ink-3); letter-spacing: .05em; margin-bottom: .2rem; font-weight: 700; }
.detail-row .v { color: var(--ink); line-height: 1.65; }

/* ---------------- 帮助弹窗 ---------------- */

.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 1003;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
}
.help-overlay.active { display: flex; }
.help-box { background: var(--card); border-radius: var(--radius-lg); width: 100%; max-width: 540px; max-height: 82vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-md); }
.help-head { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--line); }
.help-head h3 { font-family: var(--serif); font-size: 1.1rem; color: var(--ink); }
.help-close { background: none; border: none; font-size: 1.2rem; color: var(--ink-3); cursor: pointer; width: 30px; height: 30px; border-radius: 50%; }
.help-close:hover { background: var(--bg-soft); color: var(--ink); }
.help-body { padding: 1.2rem 1.4rem; overflow-y: auto; color: var(--ink-2); font-size: .92rem; line-height: 1.75; }
.help-body p { margin-bottom: .7rem; }
.help-body b { color: var(--ink); }
.help-body p:last-child { margin-bottom: 0; }

/* ---------------- 页脚 ---------------- */

.site-footer { border-top: 1px solid var(--line); margin-top: 3rem; padding: 2rem 5%; background: var(--bg-soft); }
.footer-inner { max-width: 1280px; margin: 0 auto; }
.footer-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1.5rem; margin-bottom: 1.4rem; }
.footer-col h4 { font-size: .9rem; color: var(--ink); margin-bottom: .7rem; letter-spacing: .04em; }
.footer-col a { display: block; color: var(--ink-3); font-size: .86rem; text-decoration: none; padding: .2rem 0; cursor: pointer; }
.footer-col a:hover { color: var(--brand); }
.footer-bottom { text-align: center; color: var(--ink-3); font-size: .82rem; padding-top: 1rem; border-top: 1px solid var(--line); }

/* ---------------- 骨架屏 ---------------- */

.skeleton {
  background: linear-gradient(90deg, var(--bg-soft) 25%, var(--line-soft) 50%, var(--bg-soft) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-card { height: 280px; }

/* ---------------- 响应式 ---------------- */

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: .3rem;
    overflow-x: auto;
    padding: .7rem;
  }
  .side-brand { display: none; }
  .side-link { white-space: nowrap; margin-bottom: 0; }
  .side-link .badge { margin-left: .3rem; }
  .main { padding: 1.2rem 1rem 3rem; }
}

@media (max-width: 720px) {
  .topbar .hamburger { display: grid; place-items: center; }
  .topbar .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    padding: .6rem;
    gap: .2rem;
    display: none;
    box-shadow: var(--shadow-md);
  }
  .topbar .nav-links.open { display: flex; }
  .account-name { display: none; }
  .field-row { grid-template-columns: 1fr; }
  .role-pick { grid-template-columns: 1fr; }
  .grid-products { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
