:root {
  color-scheme: light;
  --bg: #f4f7f4;
  --panel: #ffffff;
  --text: #162018;
  --muted: #647067;
  --line: #dce5dd;
  --accent: #187a4d;
  --accent-strong: #0f5c39;
  --sale: #b42318;
  --gold: #f2b84b;
  --shadow: 0 16px 40px rgba(23, 42, 28, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: linear-gradient(180deg, #e8f0e8 0, var(--bg) 260px);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

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

.search-panel {
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 18px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 5vw, 3.1rem);
  line-height: 1;
}

.status {
  min-width: 112px;
  padding: 8px 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
  white-space: nowrap;
}

.status.ok {
  color: var(--accent-strong);
  border-color: rgba(24, 122, 77, 0.35);
  background: rgba(24, 122, 77, 0.08);
}

.status.error {
  color: var(--sale);
  border-color: rgba(180, 35, 24, 0.3);
  background: rgba(180, 35, 24, 0.08);
}

.search-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.search-box {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
}

.search-box input {
  width: 100%;
  min-height: 58px;
  padding: 0 18px;
  border: 2px solid #cfdad1;
  border-radius: 8px;
  outline: none;
  background: #fff;
  font-size: 1.2rem;
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(24, 122, 77, 0.12);
}

.search-box button {
  min-width: 126px;
  min-height: 58px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

.search-box .camera-button {
  min-width: 104px;
  color: var(--accent-strong);
  background: #eef6ef;
  border: 1px solid rgba(24, 122, 77, 0.28);
}

.search-box button:hover {
  background: var(--accent-strong);
}

.search-box .camera-button:hover {
  color: #fff;
}

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

.scanner-panel {
  width: min(560px, 100%);
  padding: 14px;
  background: var(--panel);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.scanner-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.close-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.camera-frame {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: #0d1710;
  border-radius: 8px;
}

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

.scan-mark {
  position: absolute;
  inset: 22%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.22);
}

.scan-mark::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  height: 2px;
  background: #f2b84b;
}

.scanner-status {
  min-height: 22px;
  margin: 12px 2px 0;
  color: var(--muted);
  font-weight: 700;
}

.scanner-status.error {
  color: var(--sale);
}

.auth-panel {
  max-width: 380px;
}

.pin-input {
  width: 100%;
  min-height: 54px;
  padding: 0 16px;
  border: 2px solid #cfdad1;
  border-radius: 8px;
  outline: none;
  font-size: 1.2rem;
}

.pin-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(24, 122, 77, 0.12);
}

.auth-button {
  width: 100%;
  min-height: 54px;
  margin-top: 12px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

.content {
  padding-top: 18px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 30px;
  color: var(--muted);
  border: 1px dashed #cbd8ce;
  border-radius: 8px;
  text-align: center;
}

.empty-state strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 1.5rem;
}

.results {
  display: grid;
  gap: 12px;
}

.product-card {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) minmax(150px, auto);
  gap: 16px;
  align-items: center;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.product-image {
  width: 110px;
  aspect-ratio: 1;
  object-fit: contain;
  background: #f8faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.product-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.product-top h2 {
  min-width: 0;
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.28;
  overflow-wrap: anywhere;
}

.badge {
  display: none;
  flex: 0 0 auto;
  padding: 5px 8px;
  color: #4b3404;
  background: var(--gold);
  border-radius: 8px;
  font-size: 0.76rem;
  font-weight: 800;
}

.product-card.has-wholesale .badge {
  display: inline-flex;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 12px 0 0;
}

.meta div {
  min-width: 90px;
}

.meta dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.meta dd {
  margin: 2px 0 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.price-area {
  display: grid;
  justify-items: end;
  gap: 12px;
}

.retail-price,
.wholesale-price {
  display: grid;
  justify-items: end;
  gap: 3px;
}

.retail-price span,
.wholesale-price span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.price {
  color: var(--accent-strong);
  font-size: 2rem;
  line-height: 1;
  white-space: nowrap;
}

.wholesale-value {
  color: var(--sale);
  font-size: 1.35rem;
  line-height: 1;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 20px, 560px);
    padding-top: 10px;
  }

  .search-panel {
    padding: 14px;
  }

  .brand-row {
    align-items: flex-start;
    margin-bottom: 12px;
  }

  .status {
    min-width: 86px;
    padding: 7px 8px;
    font-size: 0.82rem;
  }

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

  .search-box input,
  .search-box button {
    min-height: 54px;
  }

  .search-box .camera-button {
    min-width: 100%;
  }

  .scanner-modal {
    align-items: start;
    padding: 10px;
  }

  .scanner-panel {
    margin-top: 6px;
  }

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

  .product-image {
    width: 86px;
  }

  .price-area {
    grid-column: 1 / -1;
    justify-items: stretch;
    padding-top: 8px;
    border-top: 1px solid var(--line);
  }

  .retail-price,
  .wholesale-price {
    justify-items: start;
  }

  .price {
    font-size: 2.35rem;
  }

  .wholesale-value {
    font-size: 1.75rem;
  }
}
