@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,500;9..40,600;9..40,700&family=JetBrains+Mono:wght@400;500;600&family=Noto+Sans+SC:wght@400;500;600;700&display=swap');

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --ink: #18181b;
  --muted: #71717a;
  --line: #e4e4e7;
  --line-soft: #f4f4f5;
  --accent: #18181b;
  --ok: #16a34a;
  --warn: #c2410c;
  --danger: #e11d48;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.02), 0 4px 12px rgba(0,0,0,.02);
  --shadow-float: 0 8px 30px rgba(0,0,0,.04);
  --font: 'DM Sans', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 40px;
}
a { color: var(--ink); text-decoration: none; }
button, select, input { font: inherit; }

.topnav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.topnav-inner {
  max-width: 1120px; margin: 0 auto; padding: 0 20px;
  height: 56px; display: flex; align-items: center; gap: 20px;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: .92rem; letter-spacing: -.01em; color: var(--ink);
}
.brand svg { flex-shrink: 0; }
.navs { display: flex; gap: 4px; flex: 1; }
.navs a {
  color: var(--muted); padding: 6px 10px; border-radius: 6px;
  font-size: .84rem; font-weight: 600;
}
.navs a:hover { color: var(--ink); }
.navs a.on { color: var(--ink); background: var(--line-soft); }
.nav-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.nav-link {
  font-size: .84rem; font-weight: 600; color: var(--muted);
  padding: 6px 8px; border-radius: 6px;
}
.nav-link:hover { color: var(--ink); }
.nav-link.on { color: var(--ink); background: var(--line-soft); }
.nav-cart {
  font-size: .84rem; font-weight: 600; color: var(--ink);
  display: inline-flex; align-items: center; gap: 4px;
}
.nav-cart.on { color: var(--ink); }
.cart-count {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 4px; background: var(--line-soft);
  color: var(--muted); font-size: .7rem; font-family: var(--mono);
}
.nav-cart.on .cart-count {
  background: var(--ink); color: #fff;
}

.shell { max-width: 1120px; margin: 0 auto; padding: 28px 20px 48px; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 28px;
}
.page-head h1 {
  margin: 0 0 6px; font-size: 1.75rem; font-weight: 700;
  letter-spacing: -.03em; line-height: 1.2;
}
.page-head p { margin: 0; color: var(--muted); font-size: .9rem; }
.sync-pill {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: .75rem; font-weight: 600;
  font-family: var(--mono); white-space: nowrap;
}
.sync-pill b {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 0 3px rgba(22,163,74,.15);
}

.cart-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 36px; align-items: start;
}

.block { margin: 0; }
.block-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin-bottom: 14px;
}
.block-head h2 {
  margin: 0; font-size: .88rem; font-weight: 700; letter-spacing: -.01em;
}

.btn {
  border: 0; cursor: pointer; border-radius: 8px; font-weight: 600;
  padding: 10px 14px; font-size: .84rem;
}
.btn-soft { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-soft:hover { background: var(--line-soft); }
.btn-ghost {
  background: transparent; color: var(--muted); border: 0; padding: 4px 8px; font-size: .75rem;
}
.btn-ghost:hover { color: var(--ink); }
.btn-buy { background: var(--ink); color: #fff; }
.btn-buy:hover { background: #000; }
.btn-buy:disabled, .btn-soft:disabled { opacity: .4; cursor: not-allowed; }
.btn-icon {
  width: 32px; height: 32px; padding: 0; border-radius: 6px;
  background: var(--line-soft); color: var(--ink); border: 0; cursor: pointer;
  display: inline-grid; place-items: center;
}
.btn-icon:hover { background: #e4e4e7; }
.btn-icon.danger:hover { background: #ffe4e6; color: var(--danger); }

.cart-list { display: grid; gap: 8px; }
.cart-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px; align-items: center;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; background: #fff; box-shadow: var(--shadow);
}
.cart-item:hover { border-color: #a1a1aa; }

.item-main { min-width: 0; }
.item-title {
  margin: 0 0 6px; font-size: .88rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item-meta {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px;
}
.chip {
  font-size: .65rem; font-weight: 700; padding: 2px 6px; border-radius: 4px;
  background: var(--line-soft); color: var(--muted); font-family: var(--mono);
}
.chip a { color: inherit; }
.chip.loc { background: #e0f2fe; color: #0369a1; }
.chip.line { background: #ffedd5; color: #c2410c; }
.chip.stock-ok { background: #dcfce7; color: #15803d; }
.chip.stock-out { background: #ffe4e6; color: #be123c; }
.specs {
  color: var(--muted); font-size: .75rem; line-height: 1.45;
  font-family: var(--mono);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.item-side {
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
  min-width: 120px;
}
.price {
  color: var(--ink); font-weight: 700; font-size: 1rem;
  font-family: var(--mono); white-space: nowrap;
}
.price small {
  display: inline; color: var(--muted); font-size: .7rem; font-weight: 500; margin-left: 2px;
}

.qty-row {
  display: inline-flex; align-items: center; gap: 0;
  border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff;
}
.qty-row .btn-icon {
  width: 30px; height: 30px; border-radius: 0; background: var(--line-soft);
}
.qty-row input {
  width: 40px; border: 0; text-align: center; font-weight: 600;
  font-family: var(--mono); font-size: .85rem; padding: 4px 0; outline: none;
}

.item-actions { display: flex; gap: 8px; align-items: center; }
.link-buy {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 6px; padding: 6px 10px; font-weight: 600; cursor: pointer; font-size: .75rem;
}
.link-buy:hover { background: var(--ink); color: #fff; border-color: var(--ink); }

.empty {
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 48px 24px; text-align: center; background: #fff;
}
.empty h3 { margin: 0 0 8px; font-size: 1rem; font-weight: 700; }
.empty p { margin: 0 0 18px; color: var(--muted); font-size: .88rem; line-height: 1.6; }

.order-panel { position: sticky; top: 80px; }
.order-card {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); overflow: hidden;
}
.order-top { padding: 20px 20px 16px; border-bottom: 1px solid var(--line-soft); }
.order-kicker {
  font-size: .68rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px;
}
.order-top h3 {
  margin: 0 0 8px; font-size: 1rem; font-weight: 700; letter-spacing: -.02em;
}
.order-stock {
  margin: 0; color: var(--muted); font-size: .78rem;
  display: flex; align-items: center; gap: 8px;
}
.order-stock::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%; background: #d4d4d8;
  flex-shrink: 0;
}
.order-stock.ok::before { background: var(--ok); }

.order-lines {
  list-style: none; margin: 0; padding: 14px 20px;
}
.order-lines li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 0; font-size: .82rem; color: var(--muted);
  border-bottom: 1px dashed rgba(228,228,231,.9);
}
.order-lines li:last-child { margin-bottom: 0; padding-bottom: 0; border: 0; }
.order-lines strong {
  color: var(--ink); font-weight: 600; text-align: right; font-family: var(--mono);
}

.order-pay { padding: 18px 20px 20px; }
.buy-price { text-align: left; margin-bottom: 14px; }
.buy-price .label { color: var(--muted); font-size: .75rem; font-weight: 600; }
.buy-price .num {
  font-size: 1.65rem; font-weight: 700; letter-spacing: -.03em;
  font-family: var(--mono); margin-top: 2px;
}
.buy-price .sub { color: var(--muted); font-size: .72rem; margin-top: 4px; line-height: 1.4; }
.buy-actions { display: grid; gap: 8px; }
.buy-actions.stack { grid-template-columns: 1fr; }
.order-note {
  margin: 12px 0 0; color: var(--muted); font-size: .72rem; line-height: 1.5;
}

.toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 50;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 16px; max-width: 360px; box-shadow: var(--shadow-float);
  display: none; font-weight: 600; font-size: .85rem;
}
.toast.show { display: block; }
.toast.ok { border-color: #86efac; }
.toast.err { border-color: #fda4af; color: #be123c; }

.auth-slot { display: inline-flex; align-items: center; gap: 8px; }
.auth-slot .auth-user { font-size: .8rem; font-weight: 600; color: var(--muted); }
.auth-slot .ghost, .auth-slot .auth-btn {
  border: 0; background: transparent; color: var(--ink); font-weight: 600; cursor: pointer; padding: 6px 8px; font-size: .8rem;
}
.auth-slot .btn-soft-mini {
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer;
  background: #fff; color: var(--ink); font-weight: 600; font-size: .8rem;
}
.auth-modal {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.35);
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.auth-modal.show { display: flex; }
.auth-card {
  position: relative; width: min(400px, 100%); background: #fff; border-radius: 12px;
  padding: 22px; box-shadow: var(--shadow-float); border: 1px solid var(--line);
}
.auth-close {
  position: absolute; right: 12px; top: 10px; border: 0; background: transparent;
  font-size: 1.4rem; cursor: pointer; color: var(--muted);
}
.auth-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.auth-tabs button {
  flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 10px; cursor: pointer;
  background: #fff; font-weight: 700; color: var(--muted);
}
.auth-tabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.auth-form label {
  display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px;
  font-size: .75rem; font-weight: 700; color: var(--muted);
}
.auth-form input {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
.auth-form .btn { width: 100%; margin-top: 4px; background: var(--ink); color: #fff; }
.auth-tip { text-align: center; color: var(--muted); font-size: .75rem; margin: 12px 0 0; }

@media (max-width: 900px) {
  .cart-grid { grid-template-columns: 1fr; }
  .order-panel { position: static; }
}
@media (max-width: 640px) {
  .cart-item {
    grid-template-columns: 1fr;
  }
  .item-side {
    flex-direction: row; justify-content: space-between; align-items: center;
    min-width: 0; flex-wrap: wrap;
  }
}
