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

/* ── Brand tokens (momox Inbound Brand Guidelines v1) ─────────────────── */
:root {
  --blue:        #3A69FF;
  --blue-50:     #F1F5FF;
  --blue-100:    #E7EEFE;
  --blue-200:    #C2D3FF;
  --blue-300:    #99B1FF;
  --blue-400:    #7294FF;
  --blue-700:    #2746AA;
  --blue-800:    #1D3580;
  --blue-900:    #132355;

  --black:       #191919;
  --grey-700:    #686868;
  --grey-600:    #AAAAAA;
  --grey-500:    #D4D4D4;
  --grey-300:    #EFEFEF;
  --grey-50:     #F9F9F9;
  --white:       #FFFFFF;

  --green:       #106737;
  --green-light: #DAF4D1;

  --orange:      #FF5027;
  --orange-light:#FFEDE1;

  --font-head: 'Ubuntu', sans-serif;
  --font-body: 'Lato', sans-serif;

  --r-sm:  8px;
  --r:     12px;
  --r-lg:  20px;
  --r-xl:  28px;

  --shadow-sm: 0 1px 3px rgba(58,105,255,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 16px rgba(58,105,255,.10);
  --shadow-lg: 0 8px 32px rgba(58,105,255,.14);
}

/* ── Base ──────────────────────────────────────────────────────────────── */
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--grey-50);
  color: var(--black);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ────────────────────────────────────────────────────────────── */
header {
  background: var(--white);
  border-bottom: 1.5px solid var(--grey-300);
  height: 58px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.wordmark {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--blue);
  letter-spacing: -0.5px;
  line-height: 1;
}
.wordmark-sub {
  font-family: var(--font-head);
  font-weight: 400;
  font-size: 1.25rem;
  color: var(--blue);
  letter-spacing: -0.5px;
}

/* ── Layout ────────────────────────────────────────────────────────────── */
main {
  max-width: 600px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

/* ── Screens ───────────────────────────────────────────────────────────── */
.screen { display: none; }
.screen.active { display: block; }

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--r-lg);
  border: 1.5px solid var(--grey-300);
  box-shadow: var(--shadow-sm);
  padding: 20px 20px;
  margin-bottom: 14px;
}
.card-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--grey-600);
  margin-bottom: 12px;
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: .9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 12px 22px;
  border: none;
  border-radius: 100px;
  cursor: pointer;
  transition: transform .1s, opacity .12s, box-shadow .12s;
  white-space: nowrap;
}
.btn:active  { transform: scale(.97); }
.btn:disabled{ opacity: .35; cursor: default; pointer-events: none; }

.btn-primary {
  background: var(--blue);
  color: var(--white);
  box-shadow: 0 2px 10px rgba(58,105,255,.35);
}
.btn-primary:hover:not(:disabled) {
  background: var(--blue-700);
  box-shadow: 0 4px 16px rgba(58,105,255,.45);
}
.btn-success {
  background: var(--green);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(16,103,55,.25);
}
.btn-success:hover:not(:disabled) { opacity: .88; }
.btn-outline {
  background: var(--white);
  color: var(--black);
  border: 1.5px solid var(--grey-300);
}
.btn-outline:hover { background: var(--grey-50); }
.btn-ghost {
  background: none;
  color: var(--grey-700);
  border: none;
  font-size: .85rem;
  font-weight: 600;
}
.btn-ghost:hover { color: var(--black); }
.btn-full { width: 100%; }
.btn-lg   { padding: 15px 28px; font-size: .95rem; }
.btn-sq   { width: 46px; height: 46px; padding: 0; border-radius: var(--r-sm); font-size: 1.2rem; flex-shrink: 0; }

/* ── Fields ────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--grey-700);
}
.field input {
  font-family: var(--font-body);
  font-size: .95rem;
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--grey-300);
  border-radius: var(--r-sm);
  color: var(--black);
  background: var(--white);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(58,105,255,.12);
}
.field input::placeholder { color: var(--grey-500); }

/* ── Hero ──────────────────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 28px 16px 24px;
  margin-bottom: 4px;
}
.hero-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 2rem;
  color: var(--blue);
  letter-spacing: -1px;
  line-height: 1.15;
  margin-bottom: 10px;
}
.hero-title span { font-weight: 400; }
.hero-sub {
  font-size: .9rem;
  color: var(--grey-700);
  max-width: 380px;
  margin: 0 auto;
  line-height: 1.5;
}

/* ── Camera scan button ────────────────────────────────────────────────── */
.scan-camera-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 18px 20px;
  background: var(--blue-50);
  border: 2px dashed var(--blue-200);
  border-radius: var(--r);
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .1s;
  font-family: var(--font-body);
}
.scan-camera-btn:hover {
  background: var(--blue-100);
  border-color: var(--blue-300);
}
.scan-camera-btn:active { transform: scale(.98); }
.scan-camera-icon { font-size: 1.6rem; }
.scan-camera-text {
  font-size: .95rem;
  font-weight: 700;
  color: var(--blue-700);
}

.scan-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
}
.scan-divider::before, .scan-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--grey-300);
}
.scan-divider span {
  font-size: .72rem;
  font-weight: 600;
  color: var(--grey-600);
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
}

/* ── EAN input row ─────────────────────────────────────────────────────── */
.scan-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
#ean-input {
  flex: 1;
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 13px 16px;
  border: 2px solid var(--grey-300);
  border-radius: var(--r-sm);
  color: var(--black);
  background: var(--white);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#ean-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(58,105,255,.12);
}
#ean-input.flash-ok  { border-color: var(--green); background: var(--green-light); }
#ean-input.flash-err { border-color: var(--orange); background: var(--orange-light); }
#ean-input::placeholder { color: var(--grey-500); }

#scan-feedback {
  margin-top: 10px;
  min-height: 20px;
  font-size: .84rem;
  font-weight: 600;
  border-radius: var(--r-sm);
}

/* Feedback card (inline result) */
.feedback-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  background: var(--grey-50);
  border: 1.5px solid var(--grey-300);
  animation: slideIn .18s ease;
}
.feedback-card.ok  { background: var(--green-light); border-color: #A3D9A5; }
.feedback-card.err { background: var(--orange-light); border-color: #FFCBB8; }
.feedback-cover {
  width: 36px; height: 50px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--grey-300);
}
.feedback-cover-placeholder {
  width: 36px; height: 50px;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--blue-50);
  border: 1px solid var(--blue-200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}
.feedback-info { flex: 1; min-width: 0; }
.feedback-title {
  font-size: .88rem;
  font-weight: 700;
  color: var(--black);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.feedback-author {
  font-size: .75rem;
  color: var(--grey-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.feedback-price {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 700;
  color: var(--green);
  white-space: nowrap;
  flex-shrink: 0;
}
.feedback-price.none { color: var(--orange); font-size: .8rem; font-family: var(--font-body); font-weight: 600; }
.feedback-msg {
  font-size: .84rem;
  font-weight: 600;
}
.feedback-msg.ok  { color: var(--green); }
.feedback-msg.err { color: var(--orange); }

/* ── Cart list ─────────────────────────────────────────────────────────── */
.cart-list { list-style: none; }
.cart-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--grey-300);
  animation: slideIn .18s ease;
}
.cart-list li:last-child { border-bottom: none; }
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}
.cart-cover {
  width: 36px; height: 50px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--grey-300);
}
.cart-cover-placeholder {
  width: 36px; height: 50px;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--blue-50);
  border: 1px solid var(--blue-200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.cart-info { flex: 1; min-width: 0; }
.cart-title {
  font-size: .86rem;
  font-weight: 600;
  color: var(--black);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cart-author {
  font-size: .74rem;
  color: var(--grey-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.cart-ean {
  font-size: .67rem;
  color: var(--grey-600);
  font-family: monospace;
  margin-top: 1px;
}
.cart-price {
  font-family: var(--font-head);
  font-size: .9rem;
  font-weight: 700;
  color: var(--green);
  white-space: nowrap;
  flex-shrink: 0;
}
.remove-btn {
  background: none;
  border: none;
  color: var(--grey-500);
  cursor: pointer;
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  transition: background .1s, color .1s;
  flex-shrink: 0;
}
.remove-btn:hover { background: var(--orange-light); color: var(--orange); }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 16px;
  gap: 8px;
}
.empty-state .icon { font-size: 2rem; }
.empty-state p {
  font-size: .84rem;
  color: var(--grey-600);
}

/* ── Total bar ─────────────────────────────────────────────────────────── */
.total-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 2px solid var(--blue-100);
}
.total-bar .lbl { font-size: .82rem; font-weight: 600; color: var(--grey-700); }
.total-bar .amt {
  font-family: var(--font-head);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: -1px;
}

/* ── Done button area ──────────────────────────────────────────────────── */
#btn-done-wrap {
  margin-top: 6px;
}

/* ── Spinner inside button ─────────────────────────────────────────────── */
.btn-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Email screen ──────────────────────────────────────────────────────── */
.screen-heading {
  font-family: var(--font-head);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--black);
  margin-bottom: 6px;
}
.screen-sub {
  font-size: .88rem;
  color: var(--grey-700);
  margin-bottom: 24px;
  line-height: 1.5;
}
.order-summary-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--blue-50);
  border: 1.5px solid var(--blue-200);
  border-radius: 100px;
  padding: 6px 16px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--blue-800);
  margin-bottom: 20px;
}

/* ── Done screen ───────────────────────────────────────────────────────── */
.done-icon {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--green-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 18px;
}
.done-title {
  font-family: var(--font-head);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--black);
  text-align: center;
  margin-bottom: 8px;
}
.done-sub {
  font-size: .88rem;
  color: var(--grey-700);
  text-align: center;
  line-height: 1.6;
  margin-bottom: 24px;
}
.done-steps {
  background: var(--blue-50);
  border: 1.5px solid var(--blue-200);
  border-radius: var(--r);
  padding: 16px 18px;
  margin-bottom: 24px;
}
.done-steps p {
  font-size: .82rem;
  font-weight: 700;
  color: var(--blue-800);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.done-steps ol {
  font-size: .84rem;
  color: var(--grey-700);
  padding-left: 18px;
  line-height: 1.8;
}
#done-countdown {
  font-size: .75rem;
  color: var(--grey-600);
  text-align: center;
  margin-top: 14px;
}

/* ── Camera overlay ────────────────────────────────────────────────────── */
#camera-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 200;
  flex-direction: column;
}
#camera-overlay.show { display: flex; }
#scanner-container {
  width: 100%;
  flex: 1;
  overflow: hidden;
  background: #000;
}
#scanner-container video { object-fit: cover !important; width: 100% !important; height: 100% !important; }
#scanner-flash {
  position: fixed;
  inset: 0;
  z-index: 210;
  background: rgba(58,105,255,.2);
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
}
#scanner-flash.show { opacity: 1; }
#scanner-hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 220;
  padding: 16px 20px;
  padding-top: max(16px, env(safe-area-inset-top));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: linear-gradient(to bottom, rgba(0,0,0,.7), transparent);
  pointer-events: none;
}
#scanner-hud > * { pointer-events: auto; }
.scanner-hud-title { color: #fff; font-size: 15px; font-weight: 700; }
.scanner-hud-sub { color: rgba(255,255,255,.65); font-size: 12px; margin-top: 2px; }
#camera-close {
  background: rgba(255,255,255,.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid rgba(255,255,255,.3);
  color: #fff;
  width: 40px; height: 40px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#camera-close:hover { background: rgba(255,255,255,.35); }
#scanner-bottom {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 220;
  padding: 16px 20px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0,0,0,.75), transparent);
  text-align: center;
}
#scanner-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 14px;
  border-radius: 100px;
  margin-bottom: 8px;
}
#scanner-count:empty { display: none; }
#scanner-status {
  color: rgba(255,255,255,.8);
  font-size: 13px;
  font-weight: 600;
}

/* ── Legal overlay ─────────────────────────────────────────────────────── */
#legal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--white);
  z-index: 300;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#legal-overlay.show { display: block; }
.legal-header {
  background: var(--blue);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.legal-header h2 {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1rem;
  color: var(--white);
  flex: 1;
}
#legal-close {
  background: rgba(255,255,255,.2);
  border: none;
  color: var(--white);
  font-size: 1.1rem;
  width: 34px; height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#legal-close:hover { background: rgba(255,255,255,.35); }
.legal-body {
  max-width: 680px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}
.legal-body h1 { font-family: var(--font-head); font-size: 1.3rem; font-weight: 700; margin-bottom: 18px; }
.legal-body h2 { font-family: var(--font-head); font-size: 1rem; font-weight: 700; margin: 20px 0 8px; color: var(--blue-800); }
.legal-body h3 { font-size: .9rem; font-weight: 700; margin: 14px 0 6px; }
.legal-body p  { font-size: .88rem; line-height: 1.65; color: var(--grey-700); margin-bottom: 12px; }
.legal-body ul, .legal-body ol { font-size: .88rem; line-height: 1.65; color: var(--grey-700); padding-left: 20px; margin-bottom: 12px; }
.legal-body li { margin-bottom: 4px; }
.legal-body a  { color: var(--blue); text-decoration: none; }
.legal-body a:hover { text-decoration: underline; }
.legal-body .faq-q { font-weight: 700; color: var(--black); margin-top: 16px; margin-bottom: 4px; font-size: .88rem; }
.legal-body .faq-a { font-size: .88rem; color: var(--grey-700); line-height: 1.65; }

/* ── Footer ────────────────────────────────────────────────────────────── */
footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--white);
  border-top: 1px solid var(--grey-300);
  padding: 10px 20px;
  display: flex;
  justify-content: center;
  gap: 20px;
  z-index: 40;
}
footer a {
  font-size: .73rem;
  color: var(--grey-600);
  text-decoration: none;
  font-weight: 600;
}
footer a:hover { color: var(--blue); }

/* ── Toast ─────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 58px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--black);
  color: var(--white);
  padding: 10px 22px;
  border-radius: 100px;
  font-size: .82rem;
  font-weight: 600;
  transition: transform .28s cubic-bezier(.34,1.56,.64,1);
  z-index: 999;
  white-space: nowrap;
  box-shadow: var(--shadow);
}
#toast.show  { transform: translateX(-50%) translateY(0); }
#toast.ok    { background: var(--green); }
#toast.error { background: var(--orange); }
