:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #172033;
  --muted: #697386;
  --border: #dfe4ea;
  --accent: #1f6feb;
  --accent-strong: #175ac1;
  --accent-soft: #eaf2ff;
  --success: #147d45;
  --warning: #9a6700;
  --danger: #b42318;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101318;
    --card: #171b22;
    --text: #f2f5f8;
    --muted: #a8b0bd;
    --border: #2b313b;
    --accent: #6ea8ff;
    --accent-strong: #8bb8ff;
    --accent-soft: #16243b;
    --success: #69c98d;
    --warning: #e6b450;
    --danger: #ff8a80;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(760px, 100%);
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 76px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 16px 10px;
}
.eyebrow { color: var(--muted); font-size: 13px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 28px; }
h2 { font-size: 21px; margin-bottom: 14px; }
h3 { font-size: 17px; margin-bottom: 6px; }

.demo-badge,
.status-badge,
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.demo-badge {
  padding: 6px 10px;
  background: var(--accent-soft);
  color: var(--accent);
}
.count-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--accent-soft);
  color: var(--accent);
}
.status-badge { padding: 4px 8px; }
.status-in { background: rgba(20, 125, 69, .12); color: var(--success); }
.status-order { background: rgba(154, 103, 0, .12); color: var(--warning); }

main { padding: 0 16px 20px; }
.view { display: none; }
.view.active { display: block; }

.notice {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 14px;
}
.search-block,
.contact-card,
.cart-summary {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
}
.search-block { margin-bottom: 18px; }
.search-block > label:first-child { display: block; margin-bottom: 8px; font-weight: 600; }
.search-row { display: flex; gap: 8px; }
input[type="search"] {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
}
input[type="search"]:focus { border-color: var(--accent); }
.check-row { display: flex; align-items: center; gap: 9px; margin-top: 12px; color: var(--muted); }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.section-head h2 { margin-bottom: 10px; }
.muted { color: var(--muted); font-size: 14px; }
.center { text-align: center; }

.product-list,
.cart-list { display: grid; gap: 10px; }
.product-card,
.cart-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
}
.product-top,
.cart-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.article { font-weight: 800; letter-spacing: .2px; }
.product-name { color: var(--muted); margin: 4px 0 12px; }
.product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 12px;
}
.price { font-size: 19px; font-weight: 800; }
.stock { color: var(--muted); }

.primary,
.secondary,
.text-button,
.qty-button {
  border-radius: 11px;
  padding: 10px 13px;
  border: 1px solid transparent;
}
.primary { background: var(--accent); color: white; }
.primary:hover { background: var(--accent-strong); }
.secondary { background: var(--card); color: var(--text); border-color: var(--border); }
.small { padding: 9px 11px; }
.full { width: 100%; margin-top: 14px; }
.text-button { background: transparent; color: var(--accent); padding: 6px; }
.primary:disabled { opacity: .45; cursor: default; }

.qty-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qty-button {
  min-width: 38px;
  padding: 8px 10px;
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
}
.qty-input {
  width: 76px;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  text-align: center;
  font-weight: 700;
  outline: none;
}
.qty-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.cart-item .price { font-size: 16px; }
.cart-summary { margin-top: 12px; }
.summary-row { display: flex; justify-content: space-between; gap: 12px; }
.summary-row + .summary-row { margin-top: 8px; }
.summary-total { font-weight: 800; font-size: 18px; }
.empty-state {
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 28px 18px;
  text-align: center;
  color: var(--muted);
}

.contact-card { display: grid; gap: 4px; }
.contact-label { color: var(--muted); font-size: 13px; margin-top: 10px; }
.contact-label:first-child { margin-top: 0; }
.contact-value { font-size: 17px; font-weight: 650; }

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(760px, 100%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--border);
}
.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 6px;
  border-radius: 10px;
  font-weight: 650;
}
.tab.active { color: var(--accent); background: var(--accent-soft); }

#checkoutDialog {
  width: min(520px, calc(100% - 28px));
  max-height: min(760px, calc(100vh - 28px));
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 0;
  background: var(--card);
  color: var(--text);
}
#checkoutDialog::backdrop { background: rgba(0,0,0,.48); }
.dialog-body { padding: 18px; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.preview-item { padding: 8px 0; border-bottom: 1px solid var(--border); }

.checkout-fields {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.field-label {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 700;
}
.form-input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
}
.form-input:focus { border-color: var(--accent); }
.field-hint {
  margin-top: -3px;
  color: var(--muted);
  font-size: 12px;
}
.form-error {
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(180, 35, 24, .09);
  color: var(--danger);
  font-size: 14px;
  font-weight: 650;
}
.consent-note {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.4;
}
.success-note {
  border: 1px solid var(--border);
  background: var(--accent-soft);
  color: var(--text);
  border-radius: 14px;
  padding: 13px 14px;
  line-height: 1.45;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 86px;
  transform: translateX(-50%) translateY(20px);
  width: min(520px, calc(100% - 32px));
  background: var(--text);
  color: var(--card);
  padding: 11px 14px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
  text-align: center;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 520px) {
  .search-row { flex-direction: column; }
  .dialog-actions { grid-template-columns: 1fr; }
  .product-top { align-items: center; }
  .qty-input { width: 70px; }
}
