:root {
  --bg: #0f172a;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --ink-muted: #475569;
  --line: #e2e8f0;
  --brand: #7c3aed;
  --brand-ink: #ffffff;
  --accent: #16a34a;
  --warn: #b45309;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-2);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

input, select, textarea, button {
  font: inherit;
  color: inherit;
}

img { max-width: 100%; display: block; }

.app {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px 96px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: relative;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-brand img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #fff;
  object-fit: contain;
  box-shadow: var(--shadow);
}

.topbar-brand strong { font-size: 15px; display: block; }
.topbar-brand small { color: var(--ink-muted); font-size: 12px; }

.topbar--wizard { padding-top: 4px; }
.topbar-title { text-align: center; flex: 1; }
.topbar-title strong { display: block; font-size: 15px; }
.topbar-title small { color: var(--ink-muted); font-size: 12px; }

/* Buttons */
.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.ghost-btn:active { background: var(--surface-2); }
.ghost-btn--block {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  text-decoration: none;
}

.primary-btn {
  background: var(--ink);
  color: #fff;
  border: 0;
  border-radius: var(--radius);
  padding: 16px 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  box-shadow: var(--shadow);
}
.primary-btn:active { transform: translateY(1px); }
.primary-btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.primary-btn--whatsapp {
  background: #25d366;
  color: #fff;
  text-decoration: none;
  flex-direction: column;
  gap: 4px;
}
.primary-btn--whatsapp:active { transform: translateY(1px); }

.primary-btn--xl {
  padding: 22px;
  font-size: 18px;
  flex-direction: column;
  gap: 4px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
}
.primary-btn-meta { font-size: 12px; opacity: 0.75; font-weight: 500; }

/* Hero */
.hero {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 18px 22px;
  box-shadow: var(--shadow);
}
.hero .eyebrow {
  margin: 0;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
}
.hero h1 {
  margin: 4px 0 6px;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.hero-status {
  margin: 0;
  font-size: 14px;
  color: var(--ink-muted);
}
.hero-status.done { color: var(--accent); font-weight: 600; }

/* Step list */
.step-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.step-list li {
  background: var(--surface);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--ink);
  box-shadow: var(--shadow);
}
.step-list-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

/* Secondary cards */
.secondary-row { display: grid; gap: 10px; }
.ghost-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: left;
  display: grid;
  gap: 4px;
  cursor: pointer;
}
.ghost-card strong { font-size: 14px; }
.ghost-card span { font-size: 12px; color: var(--ink-muted); }

/* Footer */
.footer {
  text-align: center;
  font-size: 12px;
  color: var(--ink-muted);
  padding: 16px 0 8px;
}
.footer a { color: var(--ink-muted); text-decoration: none; border-bottom: 1px dashed currentColor; }

/* Wizard */
.progress {
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--line);
  border-radius: 999px;
  position: relative;
  overflow: hidden;
}
.progress-fill {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
  width: 0;
  transition: width 250ms ease;
}

.wizard-body {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}

.wizard-body h2 {
  margin: 0;
  font-size: 18px;
}
.wizard-body .help {
  margin: 0;
  font-size: 13px;
  color: var(--ink-muted);
}

.wizard-foot {
  position: sticky;
  bottom: 0;
  margin: 0 -16px -12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(248, 250, 252, 0), var(--surface-2) 30%);
  display: grid;
  gap: 8px;
}
.wizard-foot-meta {
  text-align: center;
  font-size: 12px;
  color: var(--ink-muted);
  min-height: 14px;
}

/* Stock take */
.stock-cat {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.stock-cat[open] > summary { border-bottom: 1px solid var(--line); }
.stock-cat > summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-2);
  font-weight: 600;
  font-size: 14px;
}
.stock-cat > summary::-webkit-details-marker { display: none; }
.stock-cat > summary small { color: var(--ink-muted); font-weight: 500; font-size: 12px; }

.stock-tip {
  margin: 0 0 12px;
  padding: 10px 12px;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #78350f;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
}
.stock-tip strong { font-weight: 700; }
.stock-rows { display: grid; }
.stock-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
}
.stock-row:first-child { border-top: 0; }
.stock-row span { font-size: 14px; flex: 1; }
.stock-row-name { display: flex; flex-direction: column; gap: 2px; }
.stock-row-unit {
  font-size: 11px;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}
.stock-row input {
  width: 72px;
  padding: 8px 10px;
  text-align: right;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-variant-numeric: tabular-nums;
}
.stock-row input:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

/* Checklist */
.check-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  font-size: 15px;
}
.check-item input { display: none; }
.check-box {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  border: 2px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #fff;
}
.check-item input:checked ~ .check-box {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.check-item input:checked ~ .check-box::after { content: "✓"; font-weight: 700; font-size: 14px; }
.check-item input:checked ~ .check-label { text-decoration: line-through; color: var(--ink-muted); }

/* Form fields */
.form, .field-grid {
  display: grid;
  gap: 12px;
}
.field {
  display: grid;
  gap: 6px;
}
.field span {
  font-size: 12px;
  color: var(--ink-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.field input, .field select, .field textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fff;
  font-size: 15px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}
.field textarea { resize: vertical; min-height: 96px; }

.form { padding: 16px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.form .primary-btn { margin-top: 4px; }

/* Photo */
.photo-drop {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  background: var(--surface-2);
  display: grid;
  gap: 8px;
  cursor: pointer;
}
.photo-drop strong { font-size: 14px; }
.photo-drop span { color: var(--ink-muted); font-size: 12px; }
.photo-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.photo-list:empty { display: none; }
.photo-preview {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  position: relative;
}
.photo-preview img { display: block; width: 100%; height: auto; }
.photo-preview button {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}

/* Review summary */
.summary { display: grid; gap: 10px; }
.summary-card {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 12px 14px;
}
.summary-card strong { display: block; font-size: 13px; margin-bottom: 4px; }
.summary-card span { font-size: 13px; color: var(--ink-muted); }

/* Done */
.done {
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 40px 24px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  margin-top: 32px;
}
.done-tick {
  width: 64px;
  height: 64px;
  margin: 0 auto;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 800;
}
.done h1 { margin: 0; font-size: 20px; }
.done p { margin: 0; color: var(--ink-muted); font-size: 14px; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 50;
}

/* Brand grid (group landing) */
.brand-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.brand-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow);
}
.brand-card:active { transform: translateY(1px); }
.brand-card-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #7c3aed, #4338ca);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  flex-shrink: 0;
  overflow: hidden;
}
.brand-card-mark--img {
  background: #fff;
  border: 1px solid var(--line);
  padding: 4px;
}
.brand-card-mark--img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.brand-card-body { flex: 1; display: grid; gap: 2px; }
.brand-card-body strong { font-size: 15px; }
.brand-card-body small { font-size: 12px; color: var(--ink-muted); }
.brand-card-arrow { color: var(--ink-muted); font-size: 22px; line-height: 1; }
.brand-empty {
  background: var(--surface-2);
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 16px;
  font-size: 13px;
  color: var(--ink-muted);
  text-align: center;
}

/* Sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 40;
}
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  z-index: 41;
  max-height: 70vh;
  overflow: auto;
  box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.18);
}
.sheet header { padding: 4px 4px 12px; }
.shop-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.shop-list-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  font-weight: 700;
  padding: 10px 4px 4px;
}
.shop-list button {
  width: 100%;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.shop-list button.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.shop-list button .lock {
  font-size: 10px;
  background: rgba(124, 58, 237, 0.12);
  color: var(--brand);
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.shop-list button.active .lock {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

/* PIN sheet (close PIN gate) */
.pin-sheet header { display: grid; gap: 4px; padding: 4px 4px 16px; }
.pin-sheet header small { color: var(--ink-muted); font-size: 12px; }
.pin-form { display: grid; gap: 10px; }
.pin-form input {
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  text-align: center;
  letter-spacing: 0.4em;
  font-size: 18px;
  font-weight: 600;
}
.pin-form button {
  padding: 14px;
  border-radius: 10px;
  border: 0;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}
.pin-form small { color: var(--danger); font-size: 12px; min-height: 14px; text-align: center; }
