:root {
  --brand: #0b4f8a;
  --brand-2: #0e7490;
  --brand-soft: #e8f1fa;
  --accent: #0ea5a4;
  --success: #16a34a;
  --success-soft: #e8f8ee;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --warn: #d97706;
  --warn-soft: #fef4e6;
  --bg: #f2f5f9;
  --card: #ffffff;
  --border: #e4e8ef;
  --text: #16202e;
  --muted: #6b7280;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 10px 26px -16px rgba(16, 24, 40, .3);
  --tabbar-h: 58px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

img { display: block; }

input, select, textarea, button { font-family: inherit; }

input[type="text"], input[type="number"], input[type="search"], select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 11px;
  padding: 10px 13px;
  font-size: 15px;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(11, 79, 138, .12);
}

textarea { resize: vertical; min-height: 68px; }

/* ---------------- 登录 ---------------- */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(165deg, #0b4f8a 0%, #0e7490 52%, #f2f5f9 52.1%, #f2f5f9 100%);
}

.login-hero {
  padding: 64px 26px 40px;
  color: #fff;
  text-align: center;
}

.hero-logo {
  display: inline-block;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 6px;
  padding: 9px 24px;
  border: 1.5px solid rgba(255, 255, 255, .55);
  border-radius: 16px;
  margin-bottom: 18px;
}

.login-hero h1 { font-size: 22px; margin: 0 0 10px; font-weight: 700; letter-spacing: 1px; }

.login-hero p {
  margin: 0 auto;
  max-width: 320px;
  font-size: 13px;
  line-height: 1.75;
  color: rgba(255, 255, 255, .82);
}

.login-panel {
  margin: 0 18px 32px;
  background: var(--card);
  border-radius: 18px;
  padding: 24px 20px 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 440px;
  width: calc(100% - 36px);
  align-self: center;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #9aa4b2;
  font-size: 12px;
  margin: 2px 0;
}
.login-divider::before, .login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.login-tip { margin: 2px 0 0; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.6; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 9px 16px;
  border-radius: 11px;
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover { border-color: #c9d3e0; background: #f8fafc; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.07); background: linear-gradient(135deg, var(--brand), var(--brand-2)); }

.btn-wechat {
  background: #07c160;
  border-color: #07c160;
  color: #fff;
  font-weight: 600;
  padding: 12px;
  font-size: 15px;
}
.btn-wechat:hover { background: #06ad56; border-color: #06ad56; }

.btn-ghost { border-color: transparent; background: transparent; color: var(--brand); }
.btn-ghost:hover { background: var(--brand-soft); }

.btn-danger { color: var(--danger); border-color: #f3c6c6; background: var(--danger-soft); }
.btn-danger:hover { background: #fbdbdb; }

.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }

.wx-ico { font-size: 17px; }

/* ---------------- 布局 ---------------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  box-shadow: 0 2px 14px -6px rgba(11, 79, 138, .6);
}

.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand { font-size: 18px; font-weight: 800; letter-spacing: 4px; }

.header-actions { display: flex; align-items: center; gap: 10px; }

.user-chip {
  font-size: 12.5px;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .28);
  padding: 4px 12px;
  border-radius: 999px;
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view {
  flex: 1;
  padding: 14px 14px calc(var(--tabbar-h) + 26px);
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
}

/* ---------------- 筛选 ---------------- */
.filters {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
  margin-bottom: 14px;
}

.search-row { display: flex; gap: 8px; margin-bottom: 12px; }

.search-row input { flex: 1; }

.filter-group { margin-top: 11px; }

.filter-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 7px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 3px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  color: #48566a;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.chip:hover { border-color: #b9c6d8; }

.chip.on {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}

.chip.on.tag { background: var(--accent); border-color: var(--accent); }

/* ---------------- 商品卡片 ---------------- */
.result-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 2px 12px;
  font-size: 12.5px;
  color: var(--muted);
  flex-wrap: wrap;
}

.result-bar strong { color: var(--text); }

.result-bar select {
  width: auto;
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 9px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 12px;
}

.pcard {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
  display: flex;
  flex-direction: column;
  transition: box-shadow .18s, transform .18s;
}

.pcard:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

.pcard-img {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #eef2f7;
  overflow: hidden;
}

.pcard-img img { width: 100%; height: 100%; object-fit: cover; }

.pcard-img .noimg {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: #a8b3c2;
  font-size: 12px;
  background: linear-gradient(135deg, #eef2f7, #e2e8f0);
}

.pcard-badge {
  position: absolute;
  left: 8px;
  top: 8px;
  background: rgba(11, 79, 138, .92);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.pcard-body { padding: 10px 11px 12px; display: flex; flex-direction: column; gap: 7px; flex: 1; }

.pcard-title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 39px;
}

.pcard-meta { display: flex; flex-wrap: wrap; gap: 5px; }

.meta-pill {
  font-size: 11.5px;
  background: var(--brand-soft);
  color: var(--brand);
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
}

.meta-pill.size { background: #f1f5f9; color: #52607a; font-weight: 500; }

.pcard-tags { display: flex; flex-wrap: wrap; gap: 4px; }

.tag-mini {
  font-size: 11px;
  color: #0f766e;
  background: #e2f7f6;
  padding: 1px 7px;
  border-radius: 5px;
}

.pcard-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  gap: 8px;
}

.price { color: #e5484d; font-weight: 800; font-size: 15px; }
.price small { font-size: 11px; font-weight: 600; }

.adder { font-size: 11px; color: #9aa4b2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 90px; }

.pcard-actions { display: flex; gap: 6px; margin-top: 9px; }

.act {
  flex: 1;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 9px;
  padding: 7px 4px;
  font-size: 12.5px;
  cursor: pointer;
  transition: all .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #48566a;
}

.act:hover { border-color: #b9c6d8; background: #f8fafc; }
.act.buy { background: linear-gradient(135deg, #ff6b3d, #ef4444); border-color: transparent; color: #fff; font-weight: 600; }
.act.buy:hover { filter: brightness(1.07); }
.act.done { background: var(--success-soft); border-color: #b6e3c6; color: var(--success); font-weight: 600; }

/* ---------------- 通用卡片 ---------------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
  overflow: hidden;
}

.card + .card { margin-top: 12px; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 15px;
  border-bottom: 1px solid #f0f3f8;
  flex-wrap: wrap;
}

.card-head h2 { font-size: 15px; margin: 0; font-weight: 700; }
.card-body { padding: 15px; }

.muted { color: var(--muted); font-size: 12.5px; }

/* ---------------- 我的清单 ---------------- */
.seg {
  display: flex;
  background: #e8ecf3;
  border-radius: 12px;
  padding: 3px;
  margin-bottom: 14px;
}

.seg button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #5b6a80;
  cursor: pointer;
  transition: all .15s;
}

.seg button.on { background: #fff; color: var(--brand); box-shadow: 0 1px 4px rgba(16, 24, 40, .1); }

.summary-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.summary-item {
  flex: 1;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  border-radius: var(--radius);
  padding: 14px 15px;
}

.summary-item .k { font-size: 12px; opacity: .85; }
.summary-item .v { font-size: 20px; font-weight: 800; margin-top: 2px; }
.summary-item .v small { font-size: 12px; font-weight: 600; opacity: .85; }

.list-block { margin-bottom: 12px; }

.list-block-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 15px;
  cursor: pointer;
}

.list-block-head .name { font-weight: 700; font-size: 14.5px; }

.list-block-head .arrow { color: #9aa4b2; transition: transform .2s; font-size: 12px; }
.list-block-head .arrow.open { transform: rotate(90deg); }

.list-block-head .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #eef2f7;
  color: #48566a;
  white-space: nowrap;
}

.badge-brand { background: var(--brand-soft); color: var(--brand); }
.badge-accent { background: #e2f7f6; color: #0f766e; }
.badge-success { background: var(--success-soft); color: var(--success); }

.item-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 15px;
  border-top: 1px solid #f4f7fb;
}

.item-row img, .item-row .noimg {
  width: 50px;
  height: 50px;
  border-radius: 10px;
  object-fit: cover;
  background: #eef2f7;
  flex: 0 0 50px;
}

.item-row .noimg { display: grid; place-items: center; color: #a8b3c2; font-size: 10px; }

.item-info { flex: 1; min-width: 0; }
.item-info .t { font-size: 13.5px; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-info .m { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------------- 表单 ---------------- */
.form-grid { display: grid; gap: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: #48566a; font-weight: 600; }
.field .req { color: var(--danger); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.parse-row { display: flex; gap: 8px; }
.parse-row input { flex: 1; }

.parse-result {
  margin-top: 9px;
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 13px;
  border: 1px dashed var(--border);
  background: #f8fafc;
  color: #48566a;
  line-height: 1.6;
}

.parse-result.ok { border-color: #b6e3c6; background: var(--success-soft); color: #166534; }
.parse-result.dup { border-color: #f3c98b; background: var(--warn-soft); color: #92400e; }
.parse-result.err { border-color: #f2b8b8; background: var(--danger-soft); color: #991b1b; }

.hint { font-size: 12px; color: var(--muted); line-height: 1.6; }

/* ---------------- 底部导航 ---------------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 40;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  color: #93a0b0;
  text-decoration: none;
  transition: color .15s;
}

.tab-ico { font-size: 19px; filter: grayscale(1) opacity(.55); transition: filter .15s; }

.tab.active { color: var(--brand); font-weight: 700; }
.tab.active .tab-ico { filter: none; }

/* ---------------- 弹窗 / Toast ---------------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  animation: fade .16s ease;
}

@media (min-width: 620px) {
  .modal-mask { align-items: center; }
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: #fff;
  width: 100%;
  max-width: 480px;
  max-height: 86vh;
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  animation: slideUp .22s cubic-bezier(.22, 1, .36, 1);
  overflow: hidden;
}

@media (min-width: 620px) {
  .modal { border-radius: 18px; max-height: 84vh; }
}

@keyframes slideUp { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; }

.modal-close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: #9aa4b2;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 8px;
}
.modal-close:hover { background: #f1f5f9; color: var(--text); }

.modal-body { padding: 18px; overflow-y: auto; }

.modal-foot {
  display: flex;
  gap: 10px;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
}

.modal-foot .btn { flex: 1; }

.toast-root {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: 90vw;
}

.toast {
  background: #1f2937;
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13.5px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .5);
  animation: drop .2s ease;
  text-align: center;
}

@keyframes drop { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }

.toast.success { background: #15803d; }
.toast.error { background: #b91c1c; }
.toast.warn { background: #b45309; }

/* ---------------- 状态 ---------------- */
.empty {
  padding: 56px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

.empty .big { font-size: 36px; display: block; margin-bottom: 10px; opacity: .5; }

.loading { padding: 48px; text-align: center; color: var(--muted); }

.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid #dbe3ee;
  border-top-color: var(--brand);
  border-radius: 50%;
  margin: 0 auto 10px;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, #eef2f7 25%, #e4e9f0 37%, #eef2f7 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
  border-radius: var(--radius);
  height: 240px;
}

@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }

@media (min-width: 900px) {
  .view { padding: 20px 20px 40px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
}
