@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

/* === Design Tokens — Light === */
:root {
  --bg: #f8fafc;
  --bg-raised: #ffffff;
  --bg-elevated: #f1f5f9;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --accent: #0d9488;
  --accent-dim: rgba(13, 148, 136, 0.08);
  --accent-glow: rgba(13, 148, 136, 0.15);
  --warm: #d97706;
  --warm-dim: rgba(217, 119, 6, 0.08);
  --success: #059669;
  --success-dim: rgba(5, 150, 105, 0.08);
  --danger: #dc2626;
  --danger-dim: rgba(220, 38, 38, 0.08);
  --text: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Reset & Base === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 24px 40px;
}

/* === Header === */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 0;
  margin-bottom: 40px;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
}

.nav {
  display: flex;
  gap: 4px;
}

.nav a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
}

.nav a:hover { color: var(--accent); background: var(--accent-dim); }

/* === Section Layout === */
.section {
  display: none;
  animation: fadeSlideIn 0.35s ease;
}

.section.active { display: block; }

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.section h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 28px;
}

/* === Product Grid === */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

/* === Product Card === */
.product-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px 24px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.product-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--transition);
}

.product-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.product-card:hover::before { opacity: 1; }

.product-card .badge {
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.73rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  font-family: var(--font-mono);
}

.product-name {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.product-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 20px;
  min-height: 24px;
}

.product-price {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.product-price .original {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: line-through;
  margin-left: 8px;
  font-weight: 400;
}

.product-stock {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  padding: 4px 12px;
  background: var(--bg-elevated);
  border-radius: 20px;
  display: inline-block;
}

.product-stock.low {
  background: var(--warm-dim);
  color: var(--warm);
}

/* === Purchase Card === */
.purchase-card,
.payment-card,
.result-card,
.query-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  max-width: 540px;
  margin: 0 auto;
  box-shadow: var(--shadow);
}

/* === Forms === */
.form-group { margin-bottom: 20px; }

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group .hint { font-weight: 400; opacity: 0.6; }

.form-group input,
.form-group select {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font-sans);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-group input::placeholder { color: var(--text-muted); }

.form-group select {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.info-text {
  font-size: 0.95rem;
  color: var(--text);
  padding: 6px 0;
}

/* Quantity Control */
.quantity-control {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.quantity-control button {
  width: 42px;
  height: 40px;
  background: var(--bg-elevated);
  border: none;
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  transition: background var(--transition);
  font-family: var(--font-mono);
}

.quantity-control button:hover { background: var(--border-hover); }

.quantity-control span {
  width: 52px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
}

/* Total */
.total {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin: 22px 0;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.total span {
  font-size: 1.4rem;
  color: var(--accent);
  font-weight: 700;
}

/* Buttons */
.btn-primary {
  display: block;
  width: 100%;
  padding: 13px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-sans);
}

.btn-primary:hover {
  background: #0f766e;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-primary:active { transform: scale(0.98); }

.btn-back {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.btn-back:hover {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border-hover);
}

/* Payment */
.payment-card { text-align: center; }

.order-info {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 18px;
  margin: 16px 0;
  text-align: left;
  border: 1px solid var(--border);
}

.order-info p {
  padding: 4px 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.order-info strong { color: var(--text); }

.qrcode-wrap {
  background: var(--bg-elevated);
  padding: 24px;
  border-radius: var(--radius);
  display: inline-block;
  margin: 16px 0;
  border: 1px solid var(--border);
}

.qrcode-wrap img {
  max-width: 200px;
  max-height: 200px;
  display: block;
}

.payment-tips {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.6;
}

.payment-tips .hint {
  font-size: 0.8rem;
  opacity: 0.6;
  margin-top: 4px;
}

.payment-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Result */
.result-card { text-align: center; }

.success-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--success-dim);
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 20px;
  border: 2px solid var(--success);
}

.result-card h2 {
  color: var(--success);
  margin-bottom: 8px;
}

.result-card > p {
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.card-list { text-align: left; margin: 16px 0; }

.card-item {
  background: var(--accent-dim);
  border-left: 3px solid var(--accent);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  word-break: break-all;
}

.card-item:last-child { margin-bottom: 0; }

.order-detail {
  margin-top: 16px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.8;
}

/* Query */
.query-result { margin-top: 16px; }

/* Footer */
.footer {
  text-align: center;
  padding: 40px 20px 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* === Responsive === */
@media (max-width: 768px) {
  .container { padding: 12px 16px 30px; }
  
  .header { flex-direction: column; gap: 14px; padding: 16px 0; margin-bottom: 28px; }
  
  .nav { width: 100%; }
  .nav a { flex: 1; text-align: center; }

  .product-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .section h2 { font-size: 1.25rem; }

  .purchase-card,
  .payment-card,
  .result-card,
  .query-card {
    padding: 24px 18px;
  }

  .order-info p { font-size: 0.85rem; }

  .qrcode-wrap { padding: 16px; }
  .qrcode-wrap img { max-width: 160px; max-height: 160px; }

  .footer { padding: 28px 16px; margin-top: 32px; }
}

@media (max-width: 400px) {
  .product-price { font-size: 1.4rem; }
}
