/* 海外代购代充 — 样式。无构建步骤，无 CDN 依赖。
 *
 * 配色：Anthropic 式暖米白底 + 陶土色点缀，叠加莫兰迪的低饱和灰调。
 * 标题用衬线体，正文用无衬线体 —— 这是这套视觉语言的主要辨识点。
 *
 * 固定浅色，不随系统切换暗色：同一张页面在不同用户那里长得不一样，
 * 对商品图与价格的呈现不利。日后若要做暗色，建议改为显式主题开关。 */

:root {
  color-scheme: light;

  /* 底色：暖米白，取 Anthropic 的 cream 基调 */
  --bg: #f0eee6;
  --surface: #fbfaf7;
  --surface-2: #e9e6dd;
  --surface-sunk: #e4e0d5;

  /* 文字：暖调近黑，不用纯黑 */
  --text: #191919;
  --text-2: #6b665e;
  --text-3: #948d82;

  --border: #ded8cc;
  --border-strong: #cdc5b6;

  /* 主色：陶土/clay。饱和度压低一档以贴合莫兰迪调性 */
  --accent: #c96442;
  --accent-hover: #b0553a;
  --accent-soft: rgba(201, 100, 66, .09);
  --accent-ring: rgba(201, 100, 66, .22);

  /* 状态色：全部走莫兰迪灰调，避免刺眼 */
  --success: #5e7358;
  --success-soft: rgba(94, 115, 88, .12);
  --warn: #9a7b4f;
  --warn-soft: rgba(154, 123, 79, .13);
  --danger: #a04b3c;
  --danger-soft: rgba(160, 75, 60, .11);
  --neutral: #8a8279;
  --neutral-soft: rgba(138, 130, 121, .13);

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;

  /* 阴影带暖调，避免灰扑扑 */
  --shadow-sm: 0 1px 2px rgba(60, 48, 34, .05);
  --shadow: 0 2px 4px rgba(60, 48, 34, .05), 0 10px 26px rgba(60, 48, 34, .06);
  --shadow-lg: 0 8px 20px rgba(60, 48, 34, .09), 0 28px 60px rgba(60, 48, 34, .12);

  --font-serif: Georgia, "Times New Roman", "Songti SC", "Source Han Serif SC", "Noto Serif SC", serif;
  --font-sans: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;

  --ease: cubic-bezier(.32, .72, 0, 1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 极淡的暖色渐晕，让大片米白不至于发闷。
 *
 * 用 z-index: -1 沉到最底层。若用 0，它会与 .wrap 等同层元素一起参与层叠，
 * 并且在某些布局下被判定为覆盖在交互元素之上，导致点击被拦截。 */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 420px;
  background: radial-gradient(120% 100% at 50% 0%, rgba(201, 100, 66, .055), transparent 62%);
  pointer-events: none;
  z-index: -1;
}

h1, h2, h3 { font-family: var(--font-serif); font-weight: 600; letter-spacing: -.015em; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

::selection { background: var(--accent-ring); }

/* ------------------------------- 布局 ------------------------------- */

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.wrap-narrow { max-width: 660px; margin: 0 auto; padding: 0 24px; }

header.site {
  padding: 22px 0 18px;
  position: relative;
  z-index: 1;
}

/* 标题与副标题同排一行，整体压低高度 */
.brand {
  display: flex;
  align-items: baseline;
  gap: 9px;
  flex-wrap: wrap;
  row-gap: 2px;
}

header.site h1 {
  margin: 0;
  font-size: 1.42rem;
  line-height: 1.3;
  white-space: nowrap;
}

header.site .sep {
  color: var(--text-3);
  font-size: 1.1rem;
  line-height: 1;
}

header.site .tagline {
  color: var(--text-2);
  font-size: 1rem;
  letter-spacing: .01em;
  line-height: 1.3;
}

/* 页头下的细分隔线，长度与内容错开，显得透气 */
header.site::after {
  content: "";
  display: block;
  height: 1px;
  margin-top: 18px;
  background: linear-gradient(90deg, var(--border-strong), var(--border) 42%, transparent);
}

main { padding: 34px 0 80px; position: relative; z-index: 1; }

/* 返回类链接（订单页） */
.nav-link {
  display: inline-block;
  font-size: .85rem;
  color: var(--text-2);
  margin-bottom: 18px;
}
.nav-link:hover { color: var(--accent); text-decoration: none; }

/* ------------------------------- 商品 ------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 22px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform .32s var(--ease), box-shadow .32s var(--ease), border-color .32s var(--ease);
  box-shadow: var(--shadow-sm);
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}

.card .thumb {
  aspect-ratio: 16 / 10;
  background: linear-gradient(150deg, var(--surface-2), var(--surface-sunk));
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  position: relative;
}
.card .thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .5s var(--ease);
}
.card:hover .thumb img { transform: scale(1.035); }

/* 无图时的占位：一个小图形，比干巴巴的文字好看 */
.card .thumb .ph {
  width: 42px; height: 42px;
  color: var(--text-3);
  opacity: .5;
}

.card .body { padding: 17px 19px 19px; display: flex; flex-direction: column; flex: 1; }

/* 卡片缩略图与标题都是链接，点进详情页。
   用 <a> 而非 JS 跳转，保留中键新开标签等原生行为。 */
.card .card-link { display: block; text-decoration: none; }
.card .card-link:hover { text-decoration: none; }

.card .card-name-link { text-decoration: none; color: inherit; }
.card .card-name-link:hover { text-decoration: none; }
.card .card-name-link:hover h3 { color: var(--accent); }

.card h3 {
  margin: 0 0 8px;
  font-size: 1.06rem;
  line-height: 1.4;
  transition: color .18s var(--ease);
}

.card .desc {
  color: var(--text-2);
  font-size: .85rem;
  line-height: 1.62;
  margin: 0 0 18px;
  flex: 1;
  white-space: pre-wrap;
  word-break: break-word;
}

.card .price-row {
  display: flex; align-items: baseline; gap: 3px;
  margin-bottom: 15px;
}

.card .price {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

/* 售罄标 */
.card .soldout {
  position: absolute; inset: 0;
  background: rgba(240, 238, 230, .74);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif);
  font-size: .95rem;
  color: var(--text-2);
  letter-spacing: .08em;
}

.empty {
  text-align: center;
  padding: 88px 24px;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 1.05rem;
}
.empty p { margin: 0 0 8px; }
.empty .sub { font-size: .87rem; color: var(--text-3); }

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

button, .btn {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 9px 18px;
  transition: background .18s var(--ease), border-color .18s var(--ease),
              transform .12s var(--ease), box-shadow .18s var(--ease);
  text-decoration: none;
  display: inline-block;
}
button:active:not(:disabled) { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(120, 50, 28, .18);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  text-decoration: none;
  box-shadow: 0 3px 10px rgba(120, 50, 28, .2);
}
.btn-primary:disabled { opacity: .42; cursor: not-allowed; box-shadow: none; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); text-decoration: none; }

.btn-danger { background: transparent; color: var(--danger); border-color: var(--border-strong); }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); text-decoration: none; }

.btn-sm { padding: 5px 12px; font-size: .82rem; border-radius: 7px; }
.btn-block { width: 100%; text-align: center; padding: 11px 18px; }

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

.field { margin-bottom: 18px; }
.field label {
  display: block; font-size: .84rem; font-weight: 500;
  margin-bottom: 7px; color: var(--text);
}
.field .hint { font-size: .78rem; color: var(--text-3); margin-top: 6px; line-height: 1.55; }
.field .req { color: var(--accent); }

input[type=text], input[type=number], input[type=email], textarea, select {
  width: 100%; font: inherit; padding: 10px 13px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
input[readonly] {
  background: var(--surface-2);
  color: var(--text-2);
  border-color: var(--border);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
textarea { resize: vertical; min-height: 84px; line-height: 1.6; }

.checkbox { display: flex; align-items: center; gap: 9px; }
.checkbox input { width: auto; accent-color: var(--accent); }
.checkbox label { margin: 0; font-weight: 400; }

/* 文件选择 */
input[type=file] {
  width: 100%; font: inherit; font-size: .85rem; color: var(--text-2);
  padding: 9px 12px; background: var(--surface);
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
}
input[type=file]::file-selector-button {
  font: inherit; font-size: .83rem; margin-right: 11px;
  padding: 5px 13px; border: 1px solid var(--border-strong);
  border-radius: 7px; background: var(--surface-2); color: var(--text);
  cursor: pointer;
}
input[type=file]::file-selector-button:hover { background: var(--surface-sunk); }

/* ------------------------------- 弹层 ------------------------------- */

.overlay {
  position: fixed; inset: 0;
  background: rgba(48, 40, 30, .38);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; z-index: 50;
  animation: fade .22s var(--ease);
}
.overlay[hidden] { display: none; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise {
  from { opacity: 0; transform: translateY(12px) scale(.99); }
  to   { opacity: 1; transform: none; }
}

/* 三段式：头部与底部固定，只有中间内容区滚动。
 *
 * 早先的做法是整块 .modal 加 overflow-y:auto —— 那会让标题和按钮
 * 跟着内容一起滚走，滚动条还占掉右侧内边距，比例显得又高又窄。
 * 用 flex 三段结构才能让固定部分真正固定。 */
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 420px;
  max-height: min(86vh, 680px);
  display: flex;
  flex-direction: column;
  overflow: hidden;          /* 圆角不被子元素方角顶破 */
  box-shadow: var(--shadow-lg);
  animation: rise .28s var(--ease);
}

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 15px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.modal-head h2 { margin: 0; font-size: 1.14rem; }

.modal-x {
  background: none; border: none; padding: 0;
  width: 30px; height: 30px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  font-size: 1.35rem; line-height: 1;
  color: var(--text-3);
  transition: background .15s var(--ease), color .15s var(--ease);
}
.modal-x:hover { background: var(--surface-2); color: var(--text); }

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;             /* flex 子项可收缩，滚动才会生效 */
  overscroll-behavior: contain;
}

.modal-foot {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 15px 22px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex: 0 0 auto;
}

/* 弹窗内的商品摘要：把商品与金额收进一块浅底区域，
   比两个只读输入框更省高度也更易读 */
.summary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  margin-bottom: 20px;
}
.summary-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 14px;
  font-size: .89rem;
}
.summary-row + .summary-row { margin-top: 7px; }
.summary-row .k { color: var(--text-2); flex: 0 0 auto; }
.summary-row .v {
  text-align: right; word-break: break-word; font-weight: 500;
}
.summary-row .v.price {
  font-family: var(--font-serif);
  font-size: 1.16rem; font-weight: 600;
  color: var(--accent); letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------- 表格 ------------------------------- */

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: 12px 15px; border-bottom: 1px solid var(--border); }
th {
  font-weight: 600; font-size: .74rem; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .06em; white-space: nowrap;
  background: var(--surface-2);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .14s var(--ease); }
tbody tr:hover { background: var(--surface-2); }
td.mono { font-variant-numeric: tabular-nums; }

/* ------------------------------- 状态标签 ---------------------------- */

.badge {
  display: inline-block; padding: 3px 11px; border-radius: 20px;
  font-size: .75rem; font-weight: 500; white-space: nowrap;
  border: 1px solid transparent;
}
.badge-pending_payment { background: var(--warn-soft); color: var(--warn); border-color: rgba(154,123,79,.2); }
.badge-paid            { background: var(--success-soft); color: var(--success); border-color: rgba(94,115,88,.2); }
.badge-fulfilled       { background: var(--accent-soft); color: var(--accent); border-color: rgba(201,100,66,.2); }
.badge-cancelled       { background: var(--neutral-soft); color: var(--neutral); border-color: rgba(138,130,121,.2); }
.badge-refunded        { background: var(--neutral-soft); color: var(--neutral); border-color: rgba(138,130,121,.2); }
.badge-payment_failed  { background: var(--danger-soft); color: var(--danger); border-color: rgba(160,75,60,.2); }

/* ------------------------------- 统计卡 ------------------------------ */

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 16px; margin-bottom: 34px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.stat .k {
  font-size: .76rem; color: var(--text-2);
  margin-bottom: 8px; letter-spacing: .02em;
}
.stat .v {
  font-family: var(--font-serif);
  font-size: 1.75rem; font-weight: 600;
  letter-spacing: -.02em; font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

/* ------------------------------- 分区切换 ---------------------------- */

.tabs {
  display: flex; gap: 2px; margin-bottom: 30px;
  border-bottom: 1px solid var(--border); overflow-x: auto;
}
.tab {
  background: none; border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-2); padding: 11px 17px;
  font-size: .9rem; border-radius: 0;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 500;
}

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin-bottom: 20px; flex-wrap: wrap;
}
.section-head h2 { margin: 0; font-size: 1.24rem; }

/* ------------------------------- 杂项 ------------------------------- */

.toolbar { display: flex; gap: 11px; align-items: center; flex-wrap: wrap; }

.msg {
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: .88rem; margin-bottom: 20px;
  border: 1px solid transparent;
}
.msg-err { background: var(--danger-soft); color: var(--danger); border-color: rgba(160,75,60,.2); }
.msg-ok  { background: var(--success-soft); color: var(--success); border-color: rgba(94,115,88,.2); }
.msg[hidden] { display: none; }

.muted { color: var(--text-2); }
.small { font-size: .84rem; }
.center { text-align: center; }
.mt { margin-top: 18px; }
.mb { margin-bottom: 18px; }

.spinner {
  color: var(--text-3); padding: 64px 20px; text-align: center;
  font-size: .9rem;
}

/* ------------------------------- 订单页 ------------------------------ */

.order-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 38px 34px;
  text-align: center;
  box-shadow: var(--shadow);
}
.order-hero .no {
  font-family: var(--font-serif);
  font-size: 1.6rem; font-weight: 600;
  letter-spacing: .01em;
  font-variant-numeric: tabular-nums;
  margin: 9px 0 18px;
  word-break: break-all;
}

dl.kv {
  margin: 26px 0 0; padding-top: 22px;
  border-top: 1px solid var(--border);
  text-align: left;
}
dl.kv div {
  display: flex; justify-content: space-between; gap: 18px;
  padding: 8px 0; font-size: .88rem;
}
dl.kv dt { color: var(--text-2); flex-shrink: 0; }
dl.kv dd { margin: 0; text-align: right; word-break: break-word; }

footer.site {
  text-align: center;
  padding: 38px 24px 46px;
  color: var(--text-3);
  font-size: .82rem;
  position: relative;
  z-index: 1;
}
footer.site::before {
  content: "";
  display: block;
  height: 1px;
  margin: 0 auto 30px;
  max-width: 1120px;
  background: linear-gradient(90deg, transparent, var(--border-strong) 50%, transparent);
}
footer.site .contact {
  color: var(--text-2);
  margin-bottom: 10px;
  font-size: .87rem;
}
footer.site .contact span { white-space: nowrap; }

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

@media (max-width: 640px) {
  .wrap, .wrap-narrow { padding: 0 18px; }
  header.site { padding: 18px 0 15px; }
  header.site h1 { font-size: 1.18rem; white-space: normal; }
  header.site .tagline { font-size: .85rem; }
  header.site .sep { font-size: .95rem; }
  main { padding: 22px 0 52px; }
  .grid { grid-template-columns: 1fr; gap: 16px; }
  .modal { padding: 22px; border-radius: var(--radius); }
  .order-hero { padding: 28px 22px; }
  .order-hero .no { font-size: 1.3rem; }
  .stat { padding: 15px 17px; }
  .stat .v { font-size: 1.5rem; }
}
