:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #15171d;
  --muted: #667085;
  --line: #dde3ea;
  --soft: #eef2f5;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --accent-soft: #dff4ef;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
  font-family: Arial, "Microsoft YaHei", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--ink);
  margin: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  padding: 14px 14px 88px;
}

.topbar {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin: 0 auto 10px;
  max-width: 1440px;
  padding: 12px 14px;
}

.brand {
  align-items: center;
  display: flex;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  align-items: center;
  background: #15171d;
  border-radius: 8px;
  color: #fff;
  display: flex;
  flex: 0 0 40px;
  font-size: 21px;
  font-weight: 800;
  height: 40px;
  justify-content: center;
  width: 40px;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1 {
  font-size: 21px;
  line-height: 1.15;
}

.brand p,
.muted,
.product-meta,
.form-message,
.totals p {
  color: var(--muted);
}

.brand p {
  font-size: 13px;
  margin-top: 3px;
}

.language-toggle,
.chip,
.text-button,
.back-button,
.quantity-button,
.remove-item,
.modal-close {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #344054;
  font-weight: 800;
}

.language-toggle {
  flex: 0 0 auto;
  padding: 8px 10px;
}

main {
  margin: 0 auto;
  max-width: 1440px;
}

.catalog-toolbar {
  background: rgba(245, 247, 248, 0.94);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
  margin: 0 -2px 12px;
  padding: 8px 2px 10px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.search-box {
  display: grid;
  gap: 5px;
}

.search-box span,
.form-grid span {
  color: #344054;
  font-size: 12px;
  font-weight: 800;
}

.search-box input,
.form-grid input,
.form-grid textarea,
.item-note {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  outline: none;
  padding: 10px 11px;
  resize: vertical;
  width: 100%;
}

.search-box input:focus,
.form-grid input:focus,
.form-grid textarea:focus,
.item-note:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.toolbar-bottom {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.filter-row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filter-row::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 7px 11px;
}

.chip.active {
  background: #15171d;
  border-color: #15171d;
  color: #fff;
}

.result-count {
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 800;
}

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

.product-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
  overflow: hidden;
  padding: 10px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.product-card.has-quantity {
  border-color: rgba(15, 118, 110, 0.45);
}

.product-card.is-confirmed {
  animation: confirm-card 360ms ease;
}

.image-slot {
  aspect-ratio: 4 / 5;
  background: linear-gradient(135deg, #edf1f7, #f9fafb);
  border: 1px dashed #c9d2df;
  border-radius: 8px;
  cursor: zoom-in;
  display: block;
  overflow: hidden;
  padding: 0;
  position: relative;
  width: 100%;
}

.image-slot img {
  display: block;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.16s ease;
  width: 100%;
}

.image-slot.has-image img {
  opacity: 1;
}

.image-slot.has-image .image-placeholder {
  display: none;
}

.image-placeholder {
  align-items: center;
  color: #475467;
  display: flex;
  flex-direction: column;
  gap: 7px;
  height: 100%;
  inset: 0;
  justify-content: center;
  position: absolute;
  text-align: center;
}

.placeholder-code {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #15171d;
  font-weight: 800;
  padding: 7px 10px;
}

.product-info {
  align-items: start;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.product-info h3,
.checkout-item h4 {
  font-size: 16px;
  line-height: 1.2;
}

.product-meta {
  font-size: 12px;
  margin-top: 3px;
}

.selected-badge {
  background: var(--accent-soft);
  border-radius: 999px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  min-height: 24px;
  padding: 5px 9px;
  white-space: nowrap;
}

.selected-badge:empty {
  display: none;
}

.quantity-stepper {
  align-items: center;
  display: grid;
  gap: 7px;
  grid-template-columns: 42px repeat(4, minmax(0, 1fr));
}

.quantity-stepper.compact {
  grid-template-columns: 42px repeat(4, 52px);
  justify-content: start;
}

.quantity-value {
  align-items: center;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  font-weight: 900;
  height: 38px;
  justify-content: center;
}

.is-confirmed .quantity-value {
  animation: pulse-quantity 360ms ease;
}

.quantity-button {
  min-height: 38px;
  padding: 7px 8px;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}

.quantity-button.boost {
  background: var(--accent-soft);
  border-color: rgba(15, 118, 110, 0.32);
  color: var(--accent-dark);
}

.quantity-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.quantity-button:active,
.quantity-button.is-tapping {
  transform: scale(0.93);
}

.checkout-dock {
  align-items: center;
  background: #15171d;
  border: 0;
  border-radius: 999px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  box-shadow: 0 14px 36px rgba(16, 24, 40, 0.24);
  color: #fff;
  display: flex;
  gap: 10px;
  left: 50%;
  min-height: 48px;
  padding: 8px 14px;
  position: fixed;
  transform: translateX(-50%);
  z-index: 16;
}

.dock-icon {
  border: 2px solid #fff;
  border-radius: 5px;
  height: 18px;
  position: relative;
  width: 18px;
}

.dock-icon::before {
  border: 2px solid #fff;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  content: "";
  height: 8px;
  left: 3px;
  position: absolute;
  top: -8px;
  width: 8px;
}

.checkout-dock span {
  font-size: 13px;
  font-weight: 800;
}

.checkout-dock strong {
  font-size: 14px;
}

.checkout-head {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px;
}

.back-button {
  font-size: 24px;
  height: 40px;
  line-height: 1;
  width: 40px;
}

.checkout-layout {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
}

.checkout-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.checkout-panel:first-child {
  grid-row: span 2;
}

.section-title {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.text-button,
.remove-item {
  padding: 7px 10px;
}

.selected-items {
  display: grid;
  gap: 11px;
}

.empty-selection {
  background: var(--soft);
  border-radius: 8px;
  color: var(--muted);
  padding: 16px;
  text-align: center;
}

.checkout-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 106px minmax(0, 1fr);
  padding: 10px;
}

.checkout-item img {
  aspect-ratio: 4 / 5;
  background: var(--soft);
  border-radius: 8px;
  height: auto;
  object-fit: cover;
  width: 100%;
}

.checkout-item-body {
  display: grid;
  gap: 9px;
  min-width: 0;
}

.checkout-item-head {
  align-items: start;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.remove-item {
  color: var(--danger);
  flex: 0 0 auto;
}

.form-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
  margin-top: 12px;
}

.form-grid label {
  display: grid;
  gap: 6px;
}

.span-2 {
  grid-column: 1 / -1;
}

.totals {
  display: grid;
  gap: 10px;
}

.totals > div {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.totals strong {
  text-align: right;
}

.grand-total {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.grand-total strong {
  color: var(--accent-dark);
}

.totals p,
.form-message {
  font-size: 12px;
  line-height: 1.5;
}

.primary-button {
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  color: #fff;
  font-weight: 900;
  min-height: 44px;
  padding: 11px 14px;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.form-message {
  color: var(--danger);
  min-height: 18px;
  text-align: center;
}

.image-modal {
  align-items: center;
  display: none;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 30;
}

.image-modal.is-open {
  display: flex;
}

.image-modal-backdrop {
  background: rgba(10, 15, 25, 0.78);
  inset: 0;
  position: absolute;
}

.image-modal-content {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  display: grid;
  gap: 10px;
  max-height: 94vh;
  max-width: min(900px, 96vw);
  padding: 12px;
  position: relative;
  width: 100%;
}

.image-modal-content img {
  background: var(--soft);
  border-radius: 8px;
  max-height: 78vh;
  object-fit: contain;
  width: 100%;
}

.modal-close {
  justify-self: end;
  padding: 8px 12px;
}

.modal-caption {
  color: #344054;
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}

@keyframes confirm-card {
  0% {
    box-shadow: var(--shadow);
    transform: translateY(0);
  }
  45% {
    box-shadow: 0 12px 34px rgba(15, 118, 110, 0.2);
    transform: translateY(-1px);
  }
  100% {
    box-shadow: var(--shadow);
    transform: translateY(0);
  }
}

@keyframes pulse-quantity {
  0% {
    background: var(--soft);
  }
  45% {
    background: var(--accent-soft);
    color: var(--accent-dark);
  }
  100% {
    background: var(--soft);
  }
}

@media (max-width: 1040px) {
  .checkout-layout {
    grid-template-columns: 1fr;
  }

  .checkout-panel:first-child {
    grid-row: auto;
  }
}

@media (max-width: 700px) {
  .app-shell {
    padding: 10px 10px 84px;
  }

  .topbar {
    align-items: flex-start;
  }

  .brand p {
    display: none;
  }

  h1 {
    font-size: 18px;
  }

  .catalog-grid {
    grid-template-columns: 1fr;
  }

  .product-card {
    padding: 8px;
  }

  .toolbar-bottom {
    align-items: stretch;
    flex-direction: column;
  }

  .result-count {
    padding-left: 2px;
  }

  .checkout-item {
    grid-template-columns: 86px minmax(0, 1fr);
  }

  .quantity-stepper.compact {
    grid-template-columns: 38px repeat(4, minmax(42px, 1fr));
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }
}
