:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --surface: #ffffff;
  --surface-soft: #fff8ed;
  --text: #202124;
  --muted: #74706a;
  --line: #e7ded1;
  --brand: #20a35b;
  --brand-dark: #157a43;
  --accent: #ef6f74;
  --shadow: 0 16px 40px rgba(44, 37, 28, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell,
.screen {
  min-height: 100vh;
}

.screen {
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

.loading-screen,
.empty-state.full-height,
.payment-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
}

.loading-screen h1,
.empty-state h1,
.payment-card h1 {
  margin: 16px 0 8px;
  font-size: 28px;
  line-height: 1.08;
}

.loading-screen p,
.empty-state p,
.muted {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.brand-mark,
.success-check {
  width: 58px;
  height: 58px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: var(--brand);
  color: #fff;
  font-weight: 850;
  box-shadow: var(--shadow);
}

.success-check {
  border-radius: 50%;
  font-size: 32px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(247, 244, 238, 0.92);
  border-bottom: 1px solid rgba(231, 222, 209, 0.82);
  backdrop-filter: blur(16px);
}

.topbar-title {
  font-weight: 800;
  font-size: 16px;
}

.topbar-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.plain-icon,
.back-button,
.refresh-button {
  border: 0;
  background: var(--surface);
  color: var(--text);
  border-radius: 14px;
  min-width: 44px;
  height: 44px;
  font-weight: 800;
  box-shadow: 0 8px 22px rgba(44, 37, 28, 0.08);
}

.back-button,
.refresh-button {
  padding: 0 14px;
}

.cart-pill {
  border: 0;
  min-width: 112px;
  max-width: 148px;
  height: 44px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #202124;
  color: #fff;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
}

.cart-pill span {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--brand);
  font-size: 13px;
  font-weight: 800;
}

.cart-pill strong {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.catalog-view,
.cart-view,
.checkout-view {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 14px 14px 24px;
}

.market-hero {
  min-height: 96px;
  display: grid;
  align-items: center;
  padding: 16px 18px;
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(32, 163, 91, 0.92), rgba(29, 124, 179, 0.86)),
    url("data:image/svg+xml,%3Csvg width='420' height='260' viewBox='0 0 420 260' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='.18'%3E%3Crect x='38' y='34' width='72' height='92' rx='16'/%3E%3Crect x='128' y='58' width='84' height='120' rx='18'/%3E%3Crect x='238' y='28' width='58' height='92' rx='15'/%3E%3Crect x='312' y='74' width='70' height='118' rx='17'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  color: #fff;
  overflow: hidden;
}

.market-hero h1 {
  margin: 0 0 6px;
  font-size: 26px;
  line-height: 1.08;
  max-width: 430px;
}

.market-hero p {
  margin: 0;
  max-width: 360px;
  line-height: 1.35;
}

.eyebrow {
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 850;
  opacity: 0.84;
}

.notice {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid #ead6a6;
  border-radius: 16px;
  background: #fff6db;
  color: #765b12;
  line-height: 1.35;
  font-size: 14px;
}

.search-panel {
  display: grid;
  margin-top: 10px;
}

.search-box {
  height: 58px;
  display: grid;
  gap: 2px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.search-box span,
.field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.search-box input,
.text-field {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
}

.text-field {
  height: 54px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.scan-button {
  width: 100%;
  min-height: 54px;
  margin-top: 14px;
  border: 0;
  border-radius: 18px;
  background: var(--text);
  color: #fff;
  display: inline-grid;
  grid-template-columns: auto auto;
  justify-content: center;
  align-items: center;
  gap: 10px;
  font-weight: 850;
}

.scan-icon {
  width: 28px;
  height: 22px;
  border-top: 3px solid #fff;
  border-bottom: 3px solid #fff;
  position: relative;
}

.scan-icon::before,
.scan-icon::after {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: #fff;
}

.scan-icon::before {
  left: 5px;
}

.scan-icon::after {
  right: 5px;
}

.category-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 14px 2px 8px;
  scrollbar-width: none;
}

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

.category-chip {
  flex: 0 0 auto;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 15px;
  background: var(--surface);
  color: var(--text);
  font-weight: 760;
}

.category-chip.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.product-list,
.cart-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.product-card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 84px;
  padding: 10px;
  border: 1px solid rgba(231, 222, 209, 0.78);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 10px 26px rgba(44, 37, 28, 0.06);
}

.product-image {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  display: grid;
  align-self: center;
  place-items: center;
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0)),
    var(--accent);
  color: #fff;
  font-size: 20px;
  font-weight: 900;
}

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

.product-category,
.product-info p,
.cart-item p,
.small-note {
  color: var(--muted);
  font-size: 12px;
}

.product-category {
  font-weight: 800;
}

.product-info h2,
.cart-item h2 {
  margin: 4px 0 0;
  font-size: 16px;
  line-height: 1.18;
}

.product-info p,
.cart-item p {
  margin: 0 0 6px;
}

.product-buy {
  min-width: 86px;
  display: grid;
  gap: 8px;
  align-content: center;
  justify-items: end;
}

.price {
  font-size: 18px;
  font-weight: 900;
  white-space: nowrap;
}

.add-button,
.primary-button {
  min-height: 42px;
  border: 0;
  border-radius: 14px;
  padding: 0 14px;
  background: var(--brand);
  color: #fff;
  font-weight: 850;
  text-decoration: none;
  display: inline-grid;
  place-items: center;
}

.primary-button:disabled {
  opacity: 0.62;
}

.primary-button.wide {
  width: 100%;
  min-height: 54px;
  font-size: 17px;
}

.stepper {
  width: 94px;
  height: 38px;
  display: grid;
  grid-template-columns: 32px 1fr 32px;
  align-items: center;
  border-radius: 14px;
  background: #edf8f1;
  overflow: hidden;
}

.stepper button {
  height: 38px;
  border: 0;
  background: transparent;
  color: var(--brand-dark);
  font-size: 22px;
  font-weight: 850;
}

.stepper span {
  text-align: center;
  font-weight: 850;
}

.bottom-bar {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 15;
  width: min(692px, calc(100% - 24px));
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 22px;
  background: #202124;
  color: #fff;
  transform: translateX(-50%);
  box-shadow: var(--shadow);
}

.bottom-bar span {
  display: block;
  color: rgba(255, 255, 255, 0.66);
  font-size: 12px;
}

.bottom-bar strong {
  font-size: 20px;
}

.section-heading {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  margin: 8px 0 18px;
}

.section-heading h1 {
  margin: 0;
  font-size: 28px;
}

.cart-item,
.summary-card,
.checkout-form {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.cart-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
}

.summary-card {
  display: grid;
  gap: 12px;
  margin: 14px 0;
  padding: 16px;
}

.summary-card div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.summary-card span {
  color: var(--muted);
}

.checkout-form {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  align-items: end;
  background: rgba(17, 18, 20, 0.52);
}

.scanner-modal {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  border-radius: 26px 26px 0 0;
  background: var(--surface);
}

.scanner-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.scanner-head h1 {
  margin: 0;
  font-size: 22px;
}

.video-frame {
  position: relative;
  aspect-ratio: 1.15;
  margin: 14px 0;
  overflow: hidden;
  border-radius: 22px;
  background: #111;
}

.video-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#html5-reader,
#html5-reader video {
  width: 100%;
  height: 100%;
}

#html5-reader {
  overflow: hidden;
}

#html5-reader video {
  object-fit: cover;
}

#html5-reader__scan_region {
  height: 100%;
}

#html5-reader__dashboard,
#html5-reader__header_message,
#html5-reader__camera_selection {
  display: none !important;
}

.scan-frame {
  position: absolute;
  inset: 24%;
  border: 3px solid rgba(255, 255, 255, 0.92);
  border-radius: 18px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.28);
}

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

.payment-card {
  width: min(420px, 100%);
  padding: 26px 18px;
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.payment-total {
  margin: 18px 0;
  font-size: 34px;
  font-weight: 900;
}

.order-number {
  margin-top: 18px;
  padding: 12px;
  border-radius: 14px;
  background: var(--surface-soft);
  font-weight: 800;
  word-break: break-all;
}

.small-note {
  margin: 14px 0 0;
  line-height: 1.4;
}

@media (max-width: 480px) {
  .topbar {
    grid-template-columns: 38px minmax(0, 1fr) minmax(104px, auto);
    gap: 6px;
    padding-left: 8px;
    padding-right: 8px;
  }

  .plain-icon {
    min-width: 38px;
    height: 38px;
    border-radius: 12px;
  }

  .topbar-title {
    font-size: 14px;
  }

  .topbar-subtitle {
    font-size: 11px;
  }

  .cart-pill {
    min-width: 104px;
    max-width: 128px;
    height: 40px;
    padding: 5px 8px;
    gap: 6px;
  }

  .cart-pill span {
    width: 22px;
    height: 22px;
    font-size: 12px;
  }

  .cart-pill strong {
    display: block;
    font-size: 12px;
  }

  .market-hero {
    grid-template-columns: 1fr;
    min-height: 88px;
    padding: 14px 16px;
  }

  .market-hero h1 {
    font-size: 24px;
  }

  .refresh-button {
    width: fit-content;
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
  }

  .product-card {
    grid-template-columns: 58px minmax(0, 1fr) auto;
    min-height: 82px;
    padding: 9px;
    gap: 9px;
  }

  .product-image {
    width: 58px;
    height: 58px;
    min-height: 0;
    font-size: 18px;
  }

  .product-buy {
    grid-column: auto;
    display: grid;
    justify-content: end;
    align-content: center;
    min-width: 76px;
    gap: 6px;
  }

  .price {
    font-size: 16px;
  }

  .add-button {
    min-height: 36px;
    padding: 0 10px;
    border-radius: 12px;
    font-size: 13px;
  }

  .stepper {
    width: 82px;
    height: 36px;
    grid-template-columns: 28px 1fr 28px;
  }

  .manual-barcode {
    grid-template-columns: 1fr;
  }
}
