:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-soft: #eef2ff;
  --accent: #10b981;
  --ink: #111827;
  --muted: #667085;
  --line: #e5e7eb;
  --surface: #ffffff;
  --background: #f5f7fb;
  --danger: #dc2626;
  --shadow: 0 24px 70px rgba(43, 51, 82, .12);
  --radius: 22px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--background); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 6% 8%, rgba(79, 70, 229, .11), transparent 26rem),
    radial-gradient(circle at 94% 84%, rgba(16, 185, 129, .08), transparent 28rem),
    var(--background);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .6; }
[hidden] { display: none !important; }

.public-header,
.app-topbar {
  width: min(1180px, calc(100% - 40px));
  height: 86px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -.5px;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: white;
  font-size: 20px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  box-shadow: 0 8px 20px rgba(79, 70, 229, .28);
}

.header-caption { color: var(--muted); font-size: 14px; }

.auth-view {
  width: min(1120px, calc(100% - 40px));
  min-height: calc(100vh - 172px);
  margin: 0 auto;
  padding: 40px 0 70px;
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 86px;
  align-items: center;
}

.hero-copy { max-width: 560px; }
.eyebrow {
  display: block;
  margin-bottom: 10px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.8px;
}
.eyebrow.light { color: #c7d2fe; }

.hero-copy h1 {
  margin: 0;
  font-size: clamp(48px, 7vw, 78px);
  line-height: .98;
  letter-spacing: -4px;
}

.hero-copy > p {
  max-width: 520px;
  margin: 28px 0;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.65;
}

.trust-row { display: flex; gap: 20px; flex-wrap: wrap; color: #475467; font-size: 13px; font-weight: 650; }

.auth-card {
  width: 100%;
  max-width: 470px;
  justify-self: end;
  overflow: hidden;
  border: 1px solid rgba(229, 231, 235, .85);
  border-radius: 26px;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 7px; margin: 20px 24px 0; border-radius: 13px; background: #f2f4f7; }
.auth-tab { border: 0; padding: 11px; border-radius: 9px; color: var(--muted); background: transparent; font-weight: 700; }
.auth-tab.active { color: var(--primary-dark); background: white; box-shadow: 0 2px 10px rgba(16, 24, 40, .08); }
.auth-form { padding: 28px 32px 34px; }
.form-heading { margin-bottom: 24px; }
.form-heading h2 { margin: 0 0 7px; font-size: 28px; letter-spacing: -.8px; }
.form-heading p { margin: 0; color: var(--muted); line-height: 1.5; }
.mail-icon { width: 44px; height: 44px; display: grid; place-items: center; margin-bottom: 15px; border-radius: 14px; background: var(--primary-soft); }

label { display: grid; gap: 8px; margin-bottom: 17px; color: #344054; font-size: 13px; font-weight: 700; }
label span { color: #98a2b3; font-weight: 500; }
input, select {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid #d0d5dd;
  border-radius: 11px;
  outline: none;
  color: var(--ink);
  background: white;
  transition: border-color .18s, box-shadow .18s;
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79, 70, 229, .12); }
.code-input { text-align: center; font-size: 25px; font-weight: 800; letter-spacing: 8px; }
.password-hint { margin: -8px 0 18px; color: var(--muted); font-size: 12px; }

.primary-button,
.secondary-button,
.light-button {
  min-height: 46px;
  border: 0;
  border-radius: 11px;
  padding: 0 18px;
  font-weight: 750;
  transition: transform .15s, box-shadow .15s, background .15s;
}
.primary-button { width: 100%; color: white; background: linear-gradient(135deg, var(--primary), #6d28d9); box-shadow: 0 10px 24px rgba(79, 70, 229, .22); }
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 13px 28px rgba(79, 70, 229, .28); }
.secondary-button { color: var(--primary-dark); border: 1px solid #c7d2fe; background: white; }
.secondary-button:hover { background: var(--primary-soft); }
.secondary-button.small { min-height: 38px; padding: 0 14px; }
.light-button { color: var(--primary-dark); background: white; }
.text-button { width: 100%; margin-top: 14px; padding: 4px; border: 0; color: var(--primary); background: transparent; font-weight: 700; }
.text-button.muted { color: var(--muted); font-weight: 600; }
.form-message { min-height: 20px; margin: 14px 0 0; color: var(--danger); font-size: 13px; text-align: center; }
.form-message.success { color: #047857; }

.public-footer { width: min(1180px, calc(100% - 40px)); min-height: 86px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

.app-view { min-height: 100vh; }
.app-topbar { width: 100%; height: 72px; padding: 0 max(24px, calc((100% - 1180px) / 2)); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.88); backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 20; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-name { color: #475467; font-size: 13px; font-weight: 650; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; color: var(--primary); background: white; font-size: 20px; }
.app-container { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 54px 0 80px; }
.welcome-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.welcome-row h1 { margin: 0 0 7px; font-size: clamp(34px, 6vw, 48px); letter-spacing: -2px; }
.welcome-row p { margin: 0; color: var(--muted); }
.status-pill, .owner-pill { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 999px; font-size: 12px; font-weight: 750; }
.status-pill { color: #047857; background: #ecfdf3; }
.status-pill span { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.owner-pill { color: white; background: rgba(255,255,255,.16); }

.customer-code-card { min-height: 190px; padding: 34px 38px; display: flex; align-items: center; justify-content: space-between; gap: 30px; overflow: hidden; position: relative; color: white; border-radius: var(--radius); background: linear-gradient(125deg, #312e81, #4f46e5 55%, #7c3aed); box-shadow: 0 22px 50px rgba(49, 46, 129, .22); }
.customer-code-card::after { content: ""; width: 260px; height: 260px; position: absolute; right: -80px; top: -135px; border: 40px solid rgba(255,255,255,.09); border-radius: 50%; }
.customer-code-card > * { position: relative; z-index: 1; }
.card-label { display: block; margin-bottom: 8px; color: #c7d2fe; font-size: 11px; font-weight: 800; letter-spacing: 1.6px; }
.customer-code-card strong { display: block; font-size: clamp(34px, 7vw, 52px); letter-spacing: 6px; }
.customer-code-card p { margin: 9px 0 0; color: #e0e7ff; font-size: 13px; }

.content-section { margin-top: 52px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.section-heading h2, .section-heading h3 { margin: 0; letter-spacing: -.8px; }
.section-heading h2 { font-size: 27px; }
.section-heading h3 { font-size: 21px; }
.section-heading.compact { margin-bottom: 22px; }

.memberships-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.membership-card, .empty-card, .transactions-list, .business-card { border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 7px 25px rgba(16, 24, 40, .05); }
.membership-card { padding: 26px; }
.membership-top { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.merchant-avatar { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; color: white; background: linear-gradient(135deg, #f97316, #dc2626); font-size: 19px; font-weight: 850; }
.merchant-title { flex: 1; }
.merchant-title strong { display: block; }
.merchant-title span { color: var(--muted); font-size: 12px; }
.points-balance { margin: 27px 0 20px; }
.points-balance strong { display: block; font-size: 44px; letter-spacing: -2px; }
.points-balance span { color: var(--muted); font-size: 13px; }
.progress-track { height: 9px; overflow: hidden; border-radius: 10px; background: #eef2f6; }
.progress-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--accent)); }
.progress-0 { width: 0; }
.progress-5 { width: 5%; }
.progress-10 { width: 10%; }
.progress-15 { width: 15%; }
.progress-20 { width: 20%; }
.progress-25 { width: 25%; }
.progress-30 { width: 30%; }
.progress-35 { width: 35%; }
.progress-40 { width: 40%; }
.progress-45 { width: 45%; }
.progress-50 { width: 50%; }
.progress-55 { width: 55%; }
.progress-60 { width: 60%; }
.progress-65 { width: 65%; }
.progress-70 { width: 70%; }
.progress-75 { width: 75%; }
.progress-80 { width: 80%; }
.progress-85 { width: 85%; }
.progress-90 { width: 90%; }
.progress-95 { width: 95%; }
.progress-100 { width: 100%; }
.reward-line { display: flex; justify-content: space-between; margin-top: 9px; color: var(--muted); font-size: 11px; }
.empty-card { padding: 34px; color: var(--muted); text-align: center; }

.transactions-list { overflow: hidden; }
.transaction-row { min-height: 76px; padding: 15px 20px; display: flex; align-items: center; gap: 14px; border-bottom: 1px solid #f0f2f5; }
.transaction-row:last-child { border-bottom: 0; }
.transaction-icon { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 12px; font-weight: 850; }
.transaction-icon.earn { color: #047857; background: #ecfdf3; }
.transaction-icon.redeem { color: #b42318; background: #fef3f2; }
.transaction-info { flex: 1; min-width: 0; }
.transaction-info strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.transaction-info span { color: var(--muted); font-size: 12px; }
.transaction-points { font-size: 16px; font-weight: 850; }
.transaction-points.earn { color: #047857; }
.transaction-points.redeem { color: #b42318; }

.business-section { margin-top: 64px; padding: 34px; border-radius: 26px; color: white; background: #111827; box-shadow: 0 25px 60px rgba(17, 24, 39, .22); }
.business-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.business-heading h2 { margin: 0 0 6px; font-size: 30px; }
.business-heading p { margin: 0; color: #98a2b3; }
.metrics-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.metric-card { padding: 20px; border: 1px solid #344054; border-radius: 15px; background: #1d2939; }
.metric-card span { display: block; margin-bottom: 6px; color: #98a2b3; font-size: 12px; }
.metric-card strong { font-size: 29px; }
.business-grid { display: grid; grid-template-columns: .9fr 1.1fr; gap: 18px; }
.business-card { padding: 25px; color: var(--ink); }
.form-two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.customer-directory { max-height: 590px; display: flex; flex-direction: column; }
.business-customers { overflow: auto; border-top: 1px solid var(--line); }
.business-customer { padding: 14px 2px; display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); }
.business-customer strong, .business-customer span { display: block; }
.business-customer span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.select-customer { border: 0; border-radius: 8px; padding: 8px 10px; color: var(--primary-dark); background: var(--primary-soft); font-size: 11px; font-weight: 750; }

.toast { max-width: min(420px, calc(100% - 30px)); position: fixed; top: 20px; left: 50%; z-index: 100; transform: translateX(-50%); padding: 13px 18px; border-radius: 12px; color: white; background: #101828; box-shadow: 0 14px 40px rgba(16,24,40,.25); font-size: 13px; font-weight: 650; }
.toast.error { background: #b42318; }
.loading { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; gap: 12px; color: #344054; background: rgba(245,247,251,.78); backdrop-filter: blur(5px); font-weight: 700; }
.spinner { width: 24px; height: 24px; border: 3px solid #c7d2fe; border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 850px) {
  .auth-view { grid-template-columns: 1fr; gap: 35px; padding-top: 30px; }
  .hero-copy { text-align: center; margin: 0 auto; }
  .hero-copy h1 { letter-spacing: -3px; }
  .trust-row { justify-content: center; }
  .auth-card { justify-self: center; }
  .business-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .public-header, .public-footer, .auth-view, .app-container { width: min(100% - 28px, 1120px); }
  .public-header { height: 70px; }
  .header-caption, .topbar-name { display: none; }
  .auth-view { min-height: auto; padding: 28px 0 55px; }
  .hero-copy h1 { font-size: 48px; }
  .hero-copy > p { margin: 20px 0; font-size: 16px; }
  .trust-row { gap: 9px 15px; font-size: 11px; }
  .auth-card { border-radius: 21px; }
  .auth-tabs { margin: 15px 15px 0; }
  .auth-form { padding: 24px 21px 27px; }
  .public-footer { padding: 20px 0; flex-direction: column; justify-content: center; gap: 6px; text-align: center; }
  .app-topbar { padding: 0 14px; }
  .app-container { padding-top: 35px; }
  .welcome-row { align-items: flex-start; flex-direction: column; }
  .customer-code-card { min-height: 245px; padding: 28px 23px; align-items: flex-start; flex-direction: column; }
  .customer-code-card strong { font-size: 37px; letter-spacing: 4px; }
  .customer-code-card .light-button { width: 100%; }
  .content-section { margin-top: 42px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .section-heading > button { width: 100%; }
  .memberships-grid { grid-template-columns: 1fr; }
  .business-section { margin-left: -7px; margin-right: -7px; padding: 26px 18px; border-radius: 22px; }
  .business-heading { flex-direction: column; }
  .metrics-grid { grid-template-columns: 1fr; }
  .form-two-columns { grid-template-columns: 1fr; gap: 0; }
}
