: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;
  overflow-x: hidden;
}

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: var(--accent-dark);
  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,
.add-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;
}

.add-button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  min-height: 40px;
  padding: 9px 12px;
}

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 0 12px;
  overflow: hidden;
  padding: 8px 0 10px;
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.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,
.size-color-input {
  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,
.size-color-input: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;
  min-width: 0;
}

.filter-row {
  display: flex;
  flex: 1 1 auto;
  gap: 7px;
  min-width: 0;
  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: var(--accent-dark);
  border-color: var(--accent-dark);
  color: #fff;
}

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

.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 {
  background: #fff;
  display: block;
  height: 100%;
  object-fit: contain;
  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(2, 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;
}

.size-line.is-confirmed .quantity-value,
.generic-quantity-row.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: var(--accent-dark);
  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 {
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(190px, 260px) minmax(0, 1fr);
  padding: 10px;
}

.checkout-image-button {
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.75);
  cursor: zoom-in;
  overflow: hidden;
  padding: 6px;
  width: 100%;
}

.checkout-image-button img {
  aspect-ratio: 4 / 5;
  background: #fff;
  border-radius: 6px;
  display: block;
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.checkout-item-body {
  display: grid;
  gap: 10px;
  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;
}

.item-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.size-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.size-chip,
.remove-size {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #344054;
  font-weight: 800;
}

.size-chip {
  min-height: 34px;
  min-width: 44px;
  padding: 6px 9px;
}

.size-chip.active {
  background: #eef8f6;
  border-color: rgba(15, 118, 110, 0.55);
  color: var(--accent-dark);
}

.size-lines {
  display: grid;
  gap: 8px;
}

.size-line {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: 44px 122px minmax(120px, 1fr) 32px;
  padding: 8px;
}

.size-line.is-confirmed {
  border-color: rgba(15, 118, 110, 0.55);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.08);
}

.size-line-label,
.generic-label {
  color: #344054;
  font-size: 13px;
  font-weight: 900;
}

.mini-stepper {
  align-items: center;
  display: grid;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  gap: 0;
  grid-template-columns: 36px 42px 36px;
  overflow: hidden;
}

.mini-stepper .quantity-value,
.mini-stepper .quantity-button {
  font-size: 12px;
  height: 36px;
  min-height: 36px;
  padding: 5px 4px;
}

.mini-stepper .quantity-button {
  border: 0;
  border-radius: 0;
}

.mini-stepper .quantity-button[data-delta="-1"] {
  background: #f8fafb;
  color: #667085;
}

.mini-stepper .quantity-button[data-delta="1"] {
  background: #eef8f6;
  color: var(--accent-dark);
}

.mini-stepper .quantity-value {
  background: #fff;
  border-bottom: 0;
  border-color: var(--line);
  border-top: 0;
  border-radius: 0;
  color: #15171d;
}

.remove-size {
  color: var(--danger);
  min-height: 36px;
  padding: 5px 0;
}

.generic-quantity-row {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.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: #fff;
  }
  45% {
    background: #dff4ef;
    color: var(--accent-dark);
  }
  100% {
    background: #fff;
  }
}

@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: center;
    gap: 8px;
    padding: 10px;
  }

  .brand {
    gap: 8px;
  }

  .brand-mark {
    flex-basis: 32px;
    font-size: 17px;
    height: 32px;
    width: 32px;
  }

  .brand p {
    display: none;
  }

  h1 {
    font-size: 15px;
  }

  .language-toggle {
    font-size: 12px;
    padding: 6px 7px;
  }

  .catalog-toolbar {
    gap: 6px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    padding-top: 6px;
  }

  .catalog-toolbar .search-box span {
    display: none;
  }

  .search-box input {
    padding: 9px 10px;
  }

  .toolbar-bottom {
    display: block;
  }

  .filter-row {
    gap: 4px;
    width: 100%;
  }

  .chip {
    font-size: 12px;
    min-height: 32px;
    padding: 6px 6px;
  }

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

  .product-card {
    gap: 8px;
    padding: 8px;
  }

  .image-slot {
    aspect-ratio: 1 / 1.08;
  }

  .quantity-stepper {
    gap: 6px;
    grid-template-columns: 38px repeat(2, minmax(0, 1fr));
  }

  .quantity-value,
  .quantity-button {
    min-height: 36px;
  }

  .quantity-value {
    height: 36px;
  }

  .result-count {
    display: none;
  }

  .checkout-item {
    gap: 10px;
    grid-template-columns: 1fr;
    padding: 8px;
  }

  .checkout-image-button img {
    max-height: 380px;
  }

  .size-chip {
    font-size: 12px;
    min-width: 38px;
    padding: 5px 7px;
  }

  .size-line {
    gap: 6px;
    grid-template-columns: 34px 104px minmax(0, 1fr) 28px;
    padding: 7px;
  }

  .size-color-input {
    font-size: 13px;
    min-width: 0;
    padding: 8px 9px;
  }

  .remove-size {
    min-height: 34px;
  }

  .mini-stepper {
    grid-template-columns: 31px 40px 31px;
  }

  .mini-stepper .quantity-value,
  .mini-stepper .quantity-button {
    height: 34px;
    min-height: 34px;
  }

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

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