:root {
  --bg: #f3f6f2;
  --surface: #ffffff;
  --surface-2: #eaf2ed;
  --text: #12251c;
  --muted: #68766f;
  --green: #0b6b45;
  --green-dark: #0d2b1f;
  --lime: #d8f05a;
  --gold: #f1b93e;
  --red: #c63c3c;
  --border: rgba(13, 43, 31, .10);
  --shadow: 0 14px 40px rgba(12, 42, 29, .09);
  --radius: 22px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
button, input, textarea, select { font: inherit; }
button, a { touch-action: manipulation; }
.hidden { display: none !important; }

.state-screen { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 32px; text-align: center; }
.state-screen h1 { margin: 8px 0 0; font-size: 26px; }
.state-screen p { max-width: 310px; margin: 0; color: var(--muted); line-height: 1.55; }
.brand-mark { width: 72px; height: 72px; border-radius: 24px; display: grid; place-items: center; color: var(--lime); background: var(--green-dark); font-weight: 900; font-size: 38px; box-shadow: var(--shadow); }
.brand-mark.small { width: 42px; height: 42px; border-radius: 14px; font-size: 23px; flex: 0 0 auto; }
.brand-mark.danger { color: white; background: var(--red); }
.spinner { width: 28px; height: 28px; border: 3px solid #d8e1da; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.app-shell { max-width: 760px; margin: 0 auto; min-height: 100vh; padding-bottom: 92px; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; background: var(--bg); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(16px); border-bottom: 1px solid var(--border); }
.brand-row { display: flex; align-items: center; gap: 11px; }
.brand-row strong { display: block; font-size: 14px; letter-spacing: .08em; }
.brand-row span { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.live-pill { display: flex; align-items: center; gap: 6px; padding: 7px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; font-size: 11px; font-weight: 700; color: var(--green); }
.live-pill i { width: 7px; height: 7px; border-radius: 50%; background: #22bb70; box-shadow: 0 0 0 4px rgba(34,187,112,.12); }

main { padding: 16px; }
.view { display: none; animation: rise .22s ease-out; }
.view.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.hero-card { position: relative; overflow: hidden; padding: 24px; min-height: 180px; border-radius: 30px; color: white; background: radial-gradient(circle at 85% 15%, rgba(216,240,90,.25), transparent 30%), linear-gradient(145deg, #0f3727, #086b45); box-shadow: 0 18px 42px rgba(7,82,51,.22); }
.hero-card::after { content: "O"; position: absolute; right: -18px; bottom: -56px; font-size: 190px; line-height: 1; font-weight: 900; color: rgba(255,255,255,.06); }
.eyebrow { display: inline-block; color: var(--green); font-size: 11px; line-height: 1.4; letter-spacing: .12em; font-weight: 850; }
.hero-card .eyebrow { color: var(--lime); }
.hero-card strong { display: inline-block; margin-top: 18px; font-size: clamp(42px, 12vw, 62px); line-height: 1; letter-spacing: -.05em; }
.hero-card small { color: #dfe9e3; font-weight: 650; }
.hero-card p { margin: 16px 0 0; color: #d8e4dc; font-size: 13px; }
h1 { margin: 2px 0 0; font-size: 28px; letter-spacing: -.03em; }
h2 { margin: 24px 2px 12px; font-size: 17px; }
.muted, .empty { color: var(--muted); font-size: 13px; line-height: 1.55; }
.empty { text-align: center; padding: 8px 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.panel { margin-top: 14px; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(13,43,31,.04); }
.panel summary { cursor: pointer; font-weight: 800; list-style: none; }
.panel summary::-webkit-details-marker { display: none; }
.panel summary::after { content: "+"; float: right; color: var(--muted); font-size: 20px; }
.panel[open] summary::after { content: "−"; }
.status-card { margin-top: 14px; padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); display: flex; align-items: center; gap: 14px; }
.status-icon { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-2); font-size: 25px; }
.status-card b { display: block; }
.status-card p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.status-card .coin-balance { margin-left: auto; text-align: right; }
.status-card .coin-balance b { color: var(--green); font-size: 19px; }

.quick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.quick-card { min-height: 96px; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; padding: 16px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 20px; text-decoration: none; cursor: pointer; }
.quick-card span { font-size: 24px; }
.quick-card b { font-size: 14px; }
.quick-card.disabled { opacity: .55; pointer-events: none; }
#info-panel p { white-space: pre-line; }

.section-heading { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 16px; }
.icon-button { width: 42px; height: 42px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--green); font-size: 22px; cursor: pointer; }
.stats-row, .stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; }
.stat span { display: block; color: var(--muted); font-size: 11px; }
.stat b { display: block; margin-top: 5px; font-size: 20px; }

label { display: block; margin-bottom: 8px; font-size: 12px; color: var(--muted); font-weight: 700; }
input, textarea, select { width: 100%; min-height: 48px; padding: 12px 14px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 14px; outline: none; }
textarea { resize: vertical; min-height: 110px; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(11,107,69,.10); }
.input-action { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
.form-stack { display: grid; gap: 10px; margin-top: 15px; }
.form-top { margin-top: 15px; }
.button { min-height: 48px; padding: 0 18px; border: 0; border-radius: 14px; font-weight: 800; cursor: pointer; }
.button.primary { color: white; background: var(--green); }
.button.secondary { color: var(--green-dark); background: var(--surface-2); border: 1px solid var(--border); }
.button.danger { color: white; background: var(--red); }
.button.wide { width: 100%; margin-top: 10px; }
.button:disabled { opacity: .55; cursor: wait; }

.loyalty-card { position: relative; overflow: hidden; padding: 24px; border-radius: 28px; color: white; background: linear-gradient(135deg, #0d2b1f, #176744); box-shadow: var(--shadow); }
.loyalty-card::after { content: "OMAD"; position: absolute; right: -12px; bottom: 0; font-weight: 900; font-size: 72px; color: rgba(255,255,255,.045); }
.loyalty-card .card-number { margin: 30px 0 8px; font: 700 23px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }
.loyalty-card .card-meta { display: flex; justify-content: space-between; color: #d3e4d9; font-size: 12px; }
.balance-card { text-align: center; }
.balance-card strong { display: block; color: var(--green); font-size: 34px; letter-spacing: -.03em; }
.balance-card span { color: var(--muted); font-size: 12px; }
.progress { height: 9px; margin: 14px 0 7px; overflow: hidden; background: var(--surface-2); border-radius: 999px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), #4bbd77); border-radius: inherit; }
.progress.compact { margin: -5px 18px 0; }
.qr-wrap { display: grid; place-items: center; }
.qr-wrap img { width: min(240px, 75vw); border-radius: 20px; border: 10px solid white; }

.receipt-list, .member-list { display: grid; gap: 9px; margin-top: 14px; }
.receipt, .member { padding: 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 16px; }
.receipt-head, .member-head { display: flex; justify-content: space-between; gap: 10px; }
.receipt p, .member p { margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.member-actions { display: flex; gap: 8px; margin-top: 11px; }
.member-actions .button { min-height: 38px; padding: 0 12px; font-size: 12px; }
.badge { display: inline-flex; align-items: center; padding: 5px 8px; border-radius: 999px; background: var(--surface-2); color: var(--green); font-size: 10px; font-weight: 800; }
.success-panel { border-color: rgba(11,107,69,.25); background: #ecf8f1; }
.summary-lines { margin-top: 12px; }
.summary-lines p { display: flex; justify-content: space-between; gap: 16px; margin: 0; padding: 11px 0; border-bottom: 1px solid var(--border); }
.summary-lines span { color: var(--muted); }
.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0 8px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.pagination { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 14px; }
#scanner-video { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 17px; background: #081510; }
#scanner-panel p { text-align: center; color: var(--muted); font-size: 12px; }

.bottom-nav { position: fixed; z-index: 30; left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(calc(100% - 20px), 720px); display: flex; padding: 7px; background: rgba(255,255,255,.94); border: 1px solid var(--border); border-radius: 22px; box-shadow: 0 18px 50px rgba(10,40,27,.18); backdrop-filter: blur(18px); }
.nav-button { flex: 1; min-height: 54px; border: 0; border-radius: 16px; background: transparent; color: var(--muted); font-size: 10px; font-weight: 750; cursor: pointer; }
.nav-button span { display: block; margin-bottom: 3px; font-size: 20px; }
.nav-button.active { color: white; background: var(--green-dark); }

.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; padding: 14px; background: rgba(3,16,10,.55); backdrop-filter: blur(5px); }
.modal-card { position: relative; width: min(100%, 720px); max-height: 88vh; overflow: auto; margin: 0 auto; padding: 24px; background: var(--surface); border-radius: 26px; animation: sheet .2s ease-out; }
@keyframes sheet { from { transform: translateY(30px); opacity: 0; } }
.modal-close { position: absolute; right: 16px; top: 12px; width: 38px; height: 38px; border: 0; border-radius: 12px; background: var(--bg); font-size: 24px; cursor: pointer; }
.toast { position: fixed; z-index: 120; left: 50%; bottom: 94px; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); padding: 12px 16px; color: white; background: var(--green-dark); border-radius: 14px; box-shadow: var(--shadow); font-size: 13px; text-align: center; }
.toast.error { background: var(--red); }

@media (min-width: 620px) {
  main { padding: 22px; }
  .quick-grid { grid-template-columns: repeat(4, 1fr); }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; scroll-behavior: auto !important; }
}
