:root {
  --bg: #f4f5f3;
  --surface: #ffffff;
  --border: #dfe3e0;
  --text: #1f2a24;
  --text-muted: #647069;
  --primary: #0e6f5c;
  --primary-dark: #0a5548;
  --accent: #b8862d;
  --danger: #b3261e;
  --danger-bg: #fbeceb;
  --success-bg: #e8f3ee;
  --success-text: #0e6f5c;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior-y: contain;
}

.hidden { display: none !important; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-brand { font-weight: 700; color: var(--primary-dark); font-size: 1rem; white-space: nowrap; }
.location-badge {
  background: var(--success-bg);
  color: var(--primary-dark);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.lang-switch { display: flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.lang-btn {
  border: none;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
}
.lang-btn.active { background: var(--primary); color: #fff; }
.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  width: 36px;
  height: 36px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* App shell */
.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px calc(24px + var(--safe-bottom));
  min-height: calc(100vh - 56px);
}

h1 { font-size: 1.3rem; margin: 0 0 4px; }
p.subtitle { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 20px; }

.screen-center {
  min-height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05), 0 1px 6px rgba(0,0,0,0.04);
}
.card + .card { margin-top: 14px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
label { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
input, select {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

/* Buttons */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  margin-top: 8px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn:disabled { opacity: 0.5; }
.btn-lg { padding: 20px; font-size: 1.15rem; }

/* Alerts */
.alert { padding: 12px 14px; border-radius: 10px; font-size: 0.9rem; margin-bottom: 14px; }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success-text); }
.alert-warning { background: #fdf1e3; color: #8a5a12; }

/* Scan screen */
.scan-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}
.scan-viewport video { width: 100%; height: 100%; object-fit: cover; }
.scan-viewport video.mirror { transform: scaleX(-1); }
.scan-frame {
  position: absolute;
  inset: 12%;
  border: 3px solid rgba(255,255,255,0.85);
  border-radius: 18px;
  box-shadow: 0 0 0 999px rgba(0,0,0,0.35);
}
.scan-instructions { text-align: center; color: var(--text-muted); font-size: 0.9rem; margin: 14px 0; }
.manual-lookup { margin-top: 20px; text-align: center; }
.manual-lookup summary { cursor: pointer; color: var(--primary-dark); font-weight: 600; font-size: 0.88rem; }
.manual-lookup .field { margin-top: 12px; text-align: left; }

/* Guest verify card */
.guest-photo-lg {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg);
  border: 1px solid var(--border);
  display: block;
  margin: 0 auto 12px;
}
.guest-photo-placeholder-lg {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-align: center;
  margin: 0 auto 12px;
  padding: 6px;
}
.guest-name-lg { text-align: center; font-size: 1.25rem; font-weight: 700; margin-bottom: 6px; }
.guest-meta-row { display: flex; justify-content: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
}
.badge-tier-standard { background: #eef0ee; color: #4b564e; }
.badge-tier-silver { background: #e7ebef; color: #3d5266; }
.badge-tier-gold { background: #f7ecd3; color: var(--accent); }
.badge-tier-vip { background: #f3e6e9; color: #8a2f45; }
.points-display { text-align: center; margin-bottom: 4px; }
.points-display .value { font-size: 2rem; font-weight: 700; color: var(--primary-dark); }
.points-display .label { font-size: 0.78rem; color: var(--text-muted); }

/* Charge screen */
.amount-input-wrap { position: relative; }
.amount-input-wrap input { font-size: 1.6rem; font-weight: 700; text-align: center; padding: 16px; }
.points-preview {
  text-align: center;
  background: var(--success-bg);
  border-radius: 10px;
  padding: 12px;
  margin: 14px 0;
}
.points-preview .value { font-size: 1.6rem; font-weight: 700; color: var(--primary-dark); }
.points-preview .label { font-size: 0.78rem; color: var(--text-muted); }

/* Success screen */
.success-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--success-bg);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 16px;
}

/* Transactions list */
.tx-list { display: flex; flex-direction: column; gap: 8px; }
.tx-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.tx-row .tx-main { min-width: 0; }
.tx-row .tx-guest { font-weight: 600; font-size: 0.92rem; }
.tx-row .tx-meta { font-size: 0.76rem; color: var(--text-muted); }
.tx-row .tx-note { font-size: 0.8rem; color: var(--text); margin-top: 2px; font-style: italic; }
.tx-row .tx-points { font-weight: 700; font-size: 1rem; white-space: nowrap; }
.tx-points.earn { color: var(--success-text); }
.tx-points.redeem { color: #8a5a12; }

.empty-state { color: var(--text-muted); font-size: 0.9rem; padding: 40px 0; text-align: center; }
