@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@500;600;700;800&display=swap");

:root {
  --ink: #10251c;
  --muted: #6e7d76;
  --lime: #caff4a;
  --lime-dark: #b8ef35;
  --paper: #f7f8f3;
  --white: #fff;
  --danger: #d64b3d;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background: #dfe4de;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
button, input { font: inherit; }
button { color: inherit; }
body { min-height: 100dvh; }

.app-shell {
  position: relative;
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background:
    radial-gradient(circle at 94% 10%, rgba(202,255,74,.22), transparent 20rem),
    var(--paper);
}

.topbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(20px, env(safe-area-inset-top)) 24px 12px;
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--ink); }
.brand-mark svg { width: 23px; fill: var(--lime); }
.brand strong, .brand small { display: block; font-family: "Manrope", sans-serif; line-height: .92; letter-spacing: .1em; }
.brand strong { font-size: 15px; font-weight: 800; }
.brand small { margin-top: 5px; font-size: 8px; font-weight: 700; color: #708078; }

.icon-button, .round-button {
  display: grid; place-items: center; border: 0; border-radius: 50%; cursor: pointer;
}
.icon-button { width: 44px; height: 44px; background: #e8ebe5; }
.icon-button svg { width: 21px; fill: none; stroke: var(--ink); stroke-width: 1.7; stroke-linejoin: round; }

.view { display: none; }
.view.active { display: block; animation: view-in .35s ease-out; }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } }

#homeView { padding: 10.5vh 24px 32px; }
.hero-copy { max-width: 410px; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .24em; color: #738078; }
h1, h2 { margin: 0; font-family: "Manrope", sans-serif; }
h1 { margin-top: 15px; font-size: clamp(54px, 16vw, 78px); line-height: .92; letter-spacing: -.07em; }
h1 em { color: var(--lime-dark); font-style: normal; }
.hero-copy p { max-width: 330px; margin: 25px 0 0; color: var(--muted); font-size: 16px; line-height: 1.55; }

.scan-card {
  position: relative;
  display: grid;
  grid-template-columns: 76px 1fr 36px;
  align-items: center;
  width: 100%;
  margin-top: 9vh;
  padding: 18px;
  border: 0;
  border-radius: 25px;
  background: var(--ink);
  color: white;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 18px 42px rgba(16,37,28,.22);
  transition: transform .15s ease;
}
.scan-card:active { transform: scale(.98); }
.scan-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 19px; background: var(--lime); }
.scan-icon svg { width: 42px; fill: none; stroke: var(--ink); stroke-width: 2.8; stroke-linecap: round; }
.scan-label strong, .scan-label small { display: block; font-family: "Manrope", sans-serif; }
.scan-label strong { font-size: 21px; letter-spacing: .08em; }
.scan-label small { margin-top: 3px; color: #9dafA6; font-size: 11px; letter-spacing: .16em; }
.arrow { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid #526159; border-radius: 50%; font-size: 19px; }

.manual-link {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; margin-top: 25px; border: 0; background: none; color: #536159;
  font-weight: 600; font-size: 13px; cursor: pointer;
}
.manual-link svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }

.scanner-view { position: absolute; inset: 0; z-index: 20; background: #10251c; color: white; }
.scanner-view.active { display: block; }
#camera { width: 100%; height: 100%; object-fit: cover; }
.camera-shade { position: absolute; inset: 0; background: linear-gradient(rgba(5,16,11,.55), transparent 30%, transparent 68%, rgba(5,16,11,.75)); }
.scanner-toolbar { position: absolute; top: max(20px, env(safe-area-inset-top)); left: 20px; right: 20px; display: flex; align-items: center; justify-content: space-between; }
.scanner-toolbar > span { font-size: 11px; font-weight: 700; letter-spacing: .2em; }
.round-button { width: 44px; height: 44px; background: rgba(255,255,255,.15); color: white; font-size: 26px; backdrop-filter: blur(10px); }
.round-button svg { width: 20px; fill: var(--lime); }
.scan-frame { position: absolute; top: 50%; left: 50%; width: min(82vw, 390px); height: 215px; transform: translate(-50%, -50%); }
.scan-frame i { position: absolute; width: 38px; height: 38px; border-color: var(--lime); border-style: solid; }
.scan-frame i:nth-child(1) { top: 0; left: 0; border-width: 4px 0 0 4px; border-radius: 15px 0 0; }
.scan-frame i:nth-child(2) { top: 0; right: 0; border-width: 4px 4px 0 0; border-radius: 0 15px 0 0; }
.scan-frame i:nth-child(3) { bottom: 0; right: 0; border-width: 0 4px 4px 0; border-radius: 0 0 15px; }
.scan-frame i:nth-child(4) { bottom: 0; left: 0; border-width: 0 0 4px 4px; border-radius: 0 0 0 15px; }
.laser { position: absolute; top: 50%; left: 12px; right: 12px; height: 2px; background: var(--lime); box-shadow: 0 0 12px var(--lime); animation: scan 2s ease-in-out infinite; }
@keyframes scan { 0%, 100% { transform: translateY(-65px); opacity: .5; } 50% { transform: translateY(65px); opacity: 1; } }
.scanner-help { position: absolute; bottom: max(45px, env(safe-area-inset-bottom)); width: 100%; text-align: center; color: #dce4df; font-size: 13px; }

.result-view { min-height: calc(100dvh - 74px); padding: 4vh 24px 28px; background: var(--ink); color: white; }
.result-view.active { display: flex; flex-direction: column; }
.result-view + * { position: relative; z-index: 30; }
body:has(.result-view.active) .topbar { background: var(--ink); }
body:has(.result-view.active) .brand { color: white; }
body:has(.result-view.active) .brand-mark { background: var(--lime); }
body:has(.result-view.active) .brand-mark svg { fill: var(--ink); }
body:has(.result-view.active) .icon-button { background: #263a31; }
body:has(.result-view.active) .icon-button svg { stroke: white; }
.back-button { align-self: flex-start; border: 0; background: none; color: #b5c0ba; font-size: 23px; cursor: pointer; }
.back-button span { margin-left: 8px; font-size: 10px; font-weight: 700; letter-spacing: .18em; vertical-align: 3px; }
.product-card { margin: auto 0; text-align: center; }
.result-label { display: block; margin-bottom: 8px; color: var(--lime); font-size: 11px; font-weight: 700; letter-spacing: .27em; }
.price { font-family: "Manrope", sans-serif; font-size: clamp(75px, 23vw, 112px); font-weight: 800; line-height: 1; letter-spacing: -.075em; color: var(--lime); white-space: nowrap; }
.promo-badge { display: inline-block; margin-top: 17px; padding: 8px 13px; border-radius: 30px; background: var(--lime); color: var(--ink); font-size: 11px; font-weight: 800; letter-spacing: .06em; }
.promo-badge[hidden] { display: none; }
.rule { width: 44px; height: 3px; margin: 28px auto; border-radius: 2px; background: #476055; }
.product-card h2 { font-size: clamp(26px, 8vw, 38px); line-height: 1.1; letter-spacing: -.04em; }
.product-card > p { margin: 12px 0 22px; color: #aebbb5; font-size: 14px; }
.barcode-pill { display: inline-flex; align-items: center; gap: 10px; padding: 9px 15px; border-radius: 30px; background: #263b32; color: #c8d1cc; font-size: 12px; letter-spacing: .06em; }
.barcode-pill svg { width: 24px; fill: none; stroke: #c8d1cc; stroke-width: 1.5; }
.result-footer { margin: 0; color: #6f8278; text-align: center; font-size: 11px; }

dialog { width: min(calc(100% - 30px), 480px); padding: 0; border: 0; border-radius: 26px; color: var(--ink); box-shadow: 0 30px 90px rgba(0,0,0,.28); }
dialog::backdrop { background: rgba(9,24,17,.65); backdrop-filter: blur(4px); }
dialog form { padding: 27px; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 26px; }
.dialog-head h2 { margin-top: 7px; font-size: 25px; letter-spacing: -.04em; }
.dialog-close { width: 36px; height: 36px; border: 0; border-radius: 50%; background: #eef0ec; font-size: 23px; cursor: pointer; }
dialog label:not(.toggle-row) { display: block; margin: 17px 0 7px; font-size: 12px; font-weight: 700; }
dialog input:not([type="checkbox"]) { width: 100%; padding: 15px; border: 1px solid #d9dfda; border-radius: 12px; outline: none; font-size: 16px; }
dialog input:focus { border-color: #8caf37; box-shadow: 0 0 0 3px rgba(202,255,74,.3); }
.field-hint { margin: 8px 2px 0; color: var(--muted); font-size: 11px; }
.primary-button { display: flex; align-items: center; justify-content: center; gap: 20px; width: 100%; margin-top: 24px; padding: 16px; border: 0; border-radius: 13px; background: var(--ink); color: white; font-family: "Manrope", sans-serif; font-size: 13px; font-weight: 700; letter-spacing: .1em; cursor: pointer; }
.primary-button span { font-size: 20px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 22px; padding: 15px; border-radius: 13px; background: #f1f3ef; }
.toggle-row strong, .toggle-row small { display: block; }
.toggle-row strong { font-size: 13px; }
.toggle-row small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.toggle-row input { width: 22px; height: 22px; accent-color: var(--ink); }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 25px; max-width: calc(100% - 40px); padding: 12px 18px; border-radius: 30px; background: #202b26; color: white; font-size: 13px; opacity: 0; pointer-events: none; transform: translate(-50%, 15px); transition: .25s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 700px) {
  body { padding: 24px 0; }
  .app-shell { min-height: calc(100dvh - 48px); border-radius: 28px; box-shadow: 0 22px 70px rgba(28,47,38,.16); }
  #homeView { min-height: calc(100dvh - 128px); }
  .scanner-view { border-radius: 28px; }
}
