*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --red:       #D0021B;
  --red-dark:  #A8011A;
  --red-soft:  #FFF0F2;
  --red-mid:   #FFD6DA;
  --white:     #FFFFFF;
  --gray-100:  #F7F7F8;
  --gray-200:  #EBEBED;
  --gray-400:  #AEAEB8;
  --gray-700:  #3A3A44;
  --gray-900:  #1A1A22;
  --radius:    12px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,.08);
  --shadow-md: 0 8px 32px rgba(208,2,27,.13);
  --shadow-lg: 0 20px 60px rgba(208,2,27,.18);
}

html, body {
  min-height: 100%;
  font-family: 'DM Sans', sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(208,2,27,.12) 0%, transparent 70%),
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 28px,
      rgba(208,2,27,.03) 28px,
      rgba(208,2,27,.03) 29px
    );
  pointer-events: none;
  z-index: 0;
}

.page {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 48px 16px 80px;
}

.header {
  text-align: center;
  margin-bottom: 36px;
}

.logo-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--red);
  color: var(--white);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: 999px;
  margin-bottom: 16px;
}
.logo-badge svg { width: 14px; height: 14px; fill: currentColor; flex-shrink: 0; }

.header h1 {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 800;
  font-size: clamp(28px, 7vw, 46px);
  line-height: 1.05;
  color: var(--gray-900);
  letter-spacing: -.5px;
}
.header h1 span { color: var(--red); }

.header p {
  margin-top: 10px;
  color: var(--gray-400);
  font-size: 14px;
  font-weight: 500;
}

.card {
  background: var(--white);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  padding: 28px 24px 32px;
  width: 100%;
  max-width: 540px;
  position: relative;
}

.search-wrap { position: relative; }

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  pointer-events: none;
  display: flex;
}
.search-icon svg { width: 20px; height: 20px; }

#searchInput {
  width: 100%;
  padding: 16px 48px 16px 48px;
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  font-weight: 500;
  color: var(--gray-900);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  background: var(--gray-100);
}
#searchInput::placeholder { color: var(--gray-400); font-weight: 400; }
#searchInput:focus {
  border-color: var(--red);
  background: var(--white);
  box-shadow: 0 0 0 4px rgba(208,2,27,.1);
}

.clear-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--gray-200);
  border: none;
  border-radius: 999px;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--gray-700);
  opacity: 0;
  transition: opacity .15s, background .15s;
}
.clear-btn.visible { opacity: 1; }
.clear-btn:hover { background: var(--red-mid); color: var(--red); }
.clear-btn svg { width: 14px; height: 14px; }

.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(0,0,0,.13);
  max-height: 320px;
  overflow-y: auto;
  z-index: 100;
  display: none;
  scrollbar-width: thin;
  scrollbar-color: var(--red-mid) transparent;
}
.dropdown.open { display: block; }

.dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
  transition: background .12s;
  font-size: 14px;
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover, .dropdown-item.active { background: var(--red-soft); }

.item-name { color: var(--gray-900); font-weight: 500; flex: 1; }
.item-name em { font-style: normal; color: var(--red); font-weight: 700; }

.item-code-badge {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--gray-400);
  background: var(--gray-100);
  border-radius: 6px;
  padding: 2px 8px;
  flex-shrink: 0;
}

.dropdown-empty {
  padding: 20px 16px;
  text-align: center;
  color: var(--gray-400);
  font-size: 14px;
}

.result-panel {
  margin-top: 24px;
  border-radius: var(--radius);
  overflow: hidden;
  display: none;
  animation: slideUp .25s ease;
}
.result-panel.show { display: block; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-label {
  background: var(--red);
  color: var(--white);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  padding: 8px 16px;
}

.result-body {
  background: var(--red-soft);
  border: 2px solid var(--red-mid);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 20px 20px 22px;
}

.result-product-name {
  font-size: 13px;
  color: var(--gray-400);
  font-weight: 500;
  margin-bottom: 8px;
}

.result-code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.result-code {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: clamp(36px, 10vw, 52px);
  font-weight: 800;
  letter-spacing: .06em;
  color: var(--red);
  line-height: 1;
}

.copy-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--red);
  color: var(--white);
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  flex-shrink: 0;
}
.copy-btn:hover { background: var(--red-dark); box-shadow: var(--shadow-md); }
.copy-btn:active { transform: scale(.96); }
.copy-btn svg { width: 15px; height: 15px; }
.copy-btn.copied { background: #1A7F3C; }

.stats-bar {
  margin-top: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--gray-400);
}
.stats-bar strong { color: var(--red); }

.footer {
  margin-top: 32px;
  font-size: 12px;
  color: var(--gray-400);
  text-align: center;
  line-height: 1.6;
}

@media (max-width: 400px) {
  .card { padding: 20px 16px 24px; }
  .result-code { font-size: 38px; }
}
