:root {
  --bg: #fff8ef;
  --surface: #ffffff;
  --surface-warm: #fff1dc;
  --text: #30261d;
  --muted: #7a6b5d;
  --primary: #a65f2b;
  --primary-dark: #7f431d;
  --accent: #e7b46a;
  --border: #ead8c2;
  --success: #3b7f51;
  --danger: #ad3d32;
  --shadow: 0 20px 50px rgba(102, 62, 23, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at top left, #ffe9c7 0, transparent 35%), var(--bg);
  color: var(--text);
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 26px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 14px;
  z-index: 10;
}

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

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(145deg, var(--primary), var(--accent));
  color: white;
  font-weight: 900;
  letter-spacing: -1px;
}

.brand strong { display: block; font-size: 1.05rem; }
.brand span { color: var(--muted); font-size: 0.86rem; }

.role-switcher {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.role-btn,
.secondary-btn,
.primary-btn,
.wallet-btn,
.icon-btn {
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.role-btn, .secondary-btn, .icon-btn {
  background: #fff6ea;
  color: var(--primary-dark);
  border: 1px solid var(--border);
}

.role-btn.active,
.primary-btn,
.wallet-btn {
  background: var(--primary);
  color: white;
  box-shadow: 0 10px 22px rgba(127, 67, 29, 0.22);
}

button:hover { transform: translateY(-1px); }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: stretch;
  padding: 46px 8px 28px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--primary);
  font-weight: 800;
  font-size: 0.78rem;
}

h1, h2, h3 { margin: 0; line-height: 1.1; }
h1 { font-size: clamp(2rem, 5vw, 4.7rem); letter-spacing: -0.06em; max-width: 900px; }
h2 { font-size: clamp(1.6rem, 3vw, 2.5rem); letter-spacing: -0.04em; }
h3 { font-size: 1.15rem; }

.hero-text {
  max-width: 720px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.7;
}

.hero-card,
.panel,
.customer-card {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}

.hero-card span,
.hero-card small,
.muted { color: var(--muted); }
.hero-card strong { font-size: 1.35rem; }

.mini-progress,
.big-progress {
  width: 100%;
  overflow: hidden;
  background: #f0dfca;
  border-radius: 999px;
}

.mini-progress { height: 10px; }
.big-progress { height: 18px; }

.mini-progress span,
.big-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: inherit;
  transition: width 0.3s ease;
}

.view { display: none; }
.active-view { display: block; }

.section-heading,
.panel-headline,
.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.layout-grid {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
}

.stat-card span { color: var(--muted); font-size: 0.9rem; }
.stat-card strong { display: block; margin-top: 8px; font-size: 1.7rem; }

.panel {
  padding: 22px;
  margin-bottom: 18px;
}

.warm-panel { background: var(--surface-warm); }

.stack-list,
.reward-list,
.timeline {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.list-item,
.reward-item,
.timeline-item {
  border: 1px solid var(--border);
  border-radius: 20px;
  background: #fffaf4;
  padding: 14px;
}

.list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.list-item.active { border-color: var(--primary); background: #fff0dc; }
.list-item strong, .reward-item strong { display: block; }
.list-item span, .reward-item span, .timeline-item span { color: var(--muted); font-size: 0.9rem; }

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff2df;
  color: var(--primary-dark);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 0.9rem;
}

input, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fffaf5;
  color: var(--text);
  padding: 13px 14px;
  outline: none;
  margin: 8px 0 14px;
}

input:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(166, 95, 43, 0.12); }
label { color: var(--muted); font-weight: 700; font-size: 0.9rem; }

.scan-box {
  border: 2px dashed var(--border);
  border-radius: 24px;
  padding: 18px;
  background: #fff8ef;
}

.scan-icon {
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  background: var(--surface-warm);
  border-radius: 20px;
  color: var(--primary);
  font-size: 2rem;
  margin-bottom: 10px;
}

.result-box {
  margin-top: 14px;
  padding: 16px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: #fff4e5;
}

.hidden { display: none !important; }

.calculation-preview {
  margin: 4px 0 14px;
  padding: 14px;
  background: #fff0dc;
  border-radius: 16px;
  color: var(--primary-dark);
  font-weight: 800;
}

.customer-card {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 28px;
  margin-bottom: 18px;
  background: linear-gradient(145deg, #fff, #fff1db);
}

.qr-card {
  width: min(280px, 100%);
  text-align: center;
  display: grid;
  gap: 10px;
  justify-items: center;
}

.fake-qr {
  width: 140px;
  height: 140px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  color: var(--primary-dark);
  font-weight: 900;
  font-size: 2rem;
  background:
    linear-gradient(90deg, rgba(48,38,29,.12) 50%, transparent 50%) 0 0 / 20px 20px,
    linear-gradient(rgba(48,38,29,.12) 50%, transparent 50%) 0 0 / 20px 20px,
    #fffaf4;
  border: 8px solid white;
  box-shadow: var(--shadow);
}

.reward-item.can-redeem { border-color: var(--success); background: #eef9f0; }
.reward-item.locked { opacity: 0.72; }
.reward-item.redeemed { border-color: var(--success); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 13px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 100;
}

.danger-btn {
  background: #fff2ef;
  color: var(--danger);
  border: 1px solid #f0c2bc;
  border-radius: 999px;
  padding: 9px 12px;
}

.success-text { color: var(--success); font-weight: 800; }

@media (max-width: 900px) {
  .topbar, .customer-card, .section-heading, .progress-header { align-items: flex-start; flex-direction: column; }
  .hero, .two-columns, .stats-grid { grid-template-columns: 1fr; }
  .role-switcher { justify-content: flex-start; }
}

.small {
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

.role-btn.disabled,
.role-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.auth-toggle-btn {
  white-space: nowrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(48, 38, 29, 0.42);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 200;
}

.modal-card {
  width: min(460px, 100%);
  position: relative;
  background: rgba(255, 250, 244, 0.98);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: 0 30px 80px rgba(48, 38, 29, 0.22);
  padding: 26px;
}

.modal-card h2 {
  margin-bottom: 10px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff6ea;
  color: var(--primary-dark);
  font-size: 1.3rem;
  line-height: 1;
}

.full-width {
  width: 100%;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

@media (max-width: 900px) {
  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

body.app-loading .role-switcher,
body.app-loading #platformAdminView,
body.app-loading #businessAdminView {
  display: none !important;
}