:root {
  color-scheme: light;
  --ink: #17181c;
  --subtle: #545b68;
  --muted: #7b8493;
  --line: #e2e6ee;
  --line-strong: #cfd7e6;
  --page: #f3f7ef;
  --surface: #ffffff;
  --surface-soft: #f8fbf5;
  --accent: #7fb54d;
  --accent-dark: #5f9636;
  --accent-soft: #edf7e7;
  --warm: #ed7c2f;
  --ok: #147a3f;
  --warn: #9a6700;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(31, 47, 77, 0.1);
  --shadow-soft: 0 8px 22px rgba(31, 47, 77, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, #eef7e9 0, #f8fbf5 340px, #f3f7ef 100%);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

body.modal-open {
  overflow: hidden;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 42px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 4px 0 20px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-logo {
  width: 68px;
  height: 68px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 18px;
  object-fit: contain;
  background: transparent;
  box-shadow: none;
  mix-blend-mode: multiply;
}

.eyebrow {
  margin: 0 0 5px;
  color: #5f7f45;
  font-size: 10px;
  font-style: italic;
  font-weight: 650;
  letter-spacing: 0.12em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.brand-title {
  margin-bottom: 0;
  color: #46513f;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 25px;
  font-weight: 500;
  line-height: 1.18;
  letter-spacing: 0;
}

.tagline {
  margin: 8px 0 0;
  color: #5f6673;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
}

h2 {
  margin-bottom: 8px;
  font-size: 18px;
  letter-spacing: 0;
}

.status-stack {
  display: none;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sync-pill,
.system-pill,
.stock-pill {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 0 11px;
  border: 1px solid rgba(207, 215, 230, 0.9);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--subtle);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
  backdrop-filter: blur(10px);
}

.system-pill.is-ready,
.stock-pill.available {
  border-color: #b8dfc5;
  color: var(--ok);
  background: #f1fbf4;
}

.system-pill.is-error,
.stock-pill.unavailable {
  border-color: #f3b8b1;
  color: var(--danger);
  background: #fff4f2;
}

.stock-pill.low-stock {
  border-color: #efd18b;
  color: var(--warn);
  background: #fff9e8;
}

.search-panel,
.result-panel {
  border: 1px solid rgba(214, 221, 233, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.search-panel {
  position: relative;
  overflow: hidden;
  padding: 26px;
}

.search-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, #a8d175, #7fb54d 48%, #5f9636);
}

.intro-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.intro-row h2 {
  margin-bottom: 0;
  font-size: 19px;
}

#helperText {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.pagination-bar button,
.product-foot button,
.recent-searches button,
.ocr-candidates button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.search-form {
  display: grid;
  grid-template-columns: 1fr 118px;
  gap: 11px;
  margin-top: 17px;
}

.input-wrap {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  min-height: 58px;
  padding: 0 17px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.input-wrap:focus-within {
  border-color: #95c866;
  box-shadow: 0 0 0 4px rgba(127, 181, 77, 0.15);
}

.input-wrap svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
}

.input-wrap input {
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.input-wrap input::placeholder {
  color: #98a2b3;
}

.search-form > button {
  min-height: 58px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(180deg, #8cc158, var(--accent-dark));
  box-shadow: 0 10px 18px rgba(95, 150, 54, 0.22);
  font-weight: 900;
}

.search-form > button:hover {
  background: linear-gradient(180deg, #7fb54d, #52852f);
}

.image-search-row {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 13px;
}

.image-search-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  position: relative;
  overflow: hidden;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid #c6dfaf;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #f0f8eb);
  color: #5f9636;
  font-weight: 900;
  box-shadow: 0 5px 14px rgba(95, 150, 54, 0.08);
}

.image-search-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.image-search-button:hover {
  border-color: #a6cf82;
  background: #eef8e8;
}

.image-search-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.image-search-hint {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  text-align: right;
}

.recent-searches {
  margin-top: 17px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.recent-searches__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.recent-searches__head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

#recentSearches,
#ocrCandidates {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recent-searches button,
.ocr-candidates button {
  min-height: 32px;
  padding: 0 11px;
  color: var(--subtle);
  background: var(--surface-soft);
  font-size: 13px;
}

.results-layout {
  margin-top: 16px;
}

.result-panel {
  padding: 20px;
}

.image-preview {
  margin: 12px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.image-preview img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  background: #fff;
}

.ocr-candidates {
  margin: 12px 0;
}

.ocr-candidates p {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.result-toolbar,
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.result-toolbar {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.pagination-bar--bottom {
  margin-top: 14px;
  margin-bottom: 0;
}

.result-toolbar h2 {
  margin-bottom: 0;
}

#lastQuery {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.helper-text {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.pagination-bar {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.pagination-bar button {
  min-height: 34px;
  padding: 0 12px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 270px;
  border: 1px dashed #c8d2e1;
  border-radius: 8px;
  color: var(--muted);
  background: linear-gradient(180deg, #fbfcfe, #f7f9fc);
  text-align: center;
}

.barcode-icon {
  width: 78px;
  height: 44px;
  margin-bottom: 12px;
  background: repeating-linear-gradient(90deg, var(--accent) 0 3px, transparent 3px 7px, var(--accent) 7px 9px, transparent 9px 13px);
  opacity: 0.2;
}

.product-list {
  display: grid;
  gap: 12px;
}

.product-card {
  display: grid;
  grid-template-columns: 138px minmax(0, 1fr);
  gap: 15px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 0 rgba(17, 24, 39, 0.02);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.product-card:hover {
  border-color: #cfe5bf;
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.product-image-button {
  width: 138px;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.product-image-button:hover {
  border-color: #a9cf8a;
}

.product-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.product-image.placeholder {
  width: 138px;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #f2f5f9, #ffffff);
}

.product-info {
  min-width: 0;
}

.product-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.product-card h3 {
  display: -webkit-box;
  overflow: hidden;
  margin-bottom: 8px;
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: 0;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.product-price {
  margin-bottom: 7px;
  color: #111827;
  font-size: 20px;
  font-weight: 950;
}

.order-rule {
  display: inline-flex;
  margin-bottom: 10px;
  padding: 6px 10px;
  border: 1px solid #f1c59b;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a4c12;
  font-size: 13px;
  font-weight: 900;
}

.product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 10px;
  color: var(--muted);
  font-size: 13px;
}

.product-meta span {
  display: inline-flex;
  gap: 5px;
}

.product-meta b {
  color: #4b5563;
}

.product-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.product-foot button {
  min-height: 34px;
  padding: 0 12px;
  color: var(--accent);
  background: var(--accent-soft);
  border-color: #c8e3b5;
}

.product-foot button:hover {
  background: #e3f3da;
}

.is-hidden {
  display: none !important;
}

.site-footer {
  margin-top: 24px;
  color: #7a8472;
  font-size: 12px;
  text-align: center;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(16, 20, 14, 0.72);
}

.image-modal img {
  display: block;
  max-width: min(92vw, 980px);
  max-height: 88vh;
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.image-modal__close {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #26301f;
  font-size: 28px;
  line-height: 1;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
    padding-top: 12px;
  }

  .site-header,
  .intro-row,
  .result-toolbar,
  .product-foot {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-header {
    gap: 12px;
    padding-bottom: 16px;
  }

  .status-stack {
    justify-content: flex-start;
  }

  .brand-logo {
    width: 56px;
    height: 56px;
    border-radius: 12px;
  }

  .brand-title {
    font-size: 20px;
    font-weight: 500;
    line-height: 1.2;
  }

  .eyebrow {
    font-size: 9px;
    letter-spacing: 0.1em;
  }

  .tagline {
    max-width: 30em;
    font-size: 13px;
  }

  .search-panel,
  .result-panel {
    padding: 16px;
  }

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

  .product-card {
    grid-template-columns: 112px minmax(0, 1fr);
  }

  .search-form > button {
    min-height: 50px;
  }

  .image-search-row {
    align-items: flex-start;
    justify-content: flex-start;
  }

  .image-search-hint {
    text-align: left;
  }

  .product-image-button,
  .product-image.placeholder {
    width: 112px;
    max-height: none;
  }
}

@media (max-width: 560px) {
  .brand-lockup {
    align-items: center;
    gap: 12px;
  }

  .brand-logo {
    width: 52px;
    height: 52px;
  }

  .brand-title {
    font-size: 19px;
  }

  .product-card {
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 12px;
  }

  .product-image-button,
  .product-image.placeholder {
    width: 96px;
    max-height: none;
  }

  .product-card h3 {
    -webkit-line-clamp: 4;
  }
}
