:root {
  --bg: #F7F4EF;
  --card: #FFFFFF;
  --ink: #18181B;
  --ink-2: #52525B;
  --ink-3: #A1A1AA;
  --line: #E9E4DC;
  --accent: #FF5B2E;
  --accent-2: #FFE6DD;
  --green: #17945A;  --green-bg: #DDF5E8;
  --amber: #C27C00;  --amber-bg: #FFF1D1;
  --red: #D13A3A;    --red-bg: #FCE2E2;
  --blue: #2F6FEB;   --blue-bg: #E2ECFF;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(24,24,27,.04), 0 6px 24px rgba(24,24,27,.06);
  --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; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.45 "Plus Jakarta Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.app { max-width: 560px; margin: 0 auto; padding: calc(64px + var(--safe-top)) 16px calc(96px + var(--safe-bottom)); }
.app.no-chrome { padding-top: calc(32px + var(--safe-top)); }
.loading { text-align: center; color: var(--ink-3); padding: 80px 0; }

/* top bar */
.topbar { position: fixed; inset: 0 0 auto 0; z-index: 50; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-top)) 16px 10px; background: rgba(247,244,239,.88); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.brand { font-weight: 800; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; font-size: 16px; }
.brand-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-2); }

/* tab bar */
.tabbar { position: fixed; inset: auto 0 0 0; z-index: 50; display: flex; justify-content: space-around;
  padding: 8px 8px calc(8px + var(--safe-bottom)); background: rgba(255,255,255,.94); backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600;
  color: var(--ink-3); padding: 4px 12px; border-radius: 12px; }
.tabbar a.active { color: var(--ink); }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar .tab-new svg { background: var(--accent); color: #fff; border-radius: 10px; padding: 3px; width: 30px; height: 26px; }
.badge { position: absolute; top: 0; right: 14px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent);
  color: #fff; font-size: 11px; line-height: 18px; text-align: center; }

/* generic */
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 24px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); font-size: 13px; }
.small { font-size: 13px; }
.center { text-align: center; }
.mt { margin-top: 8px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card-link { display: block; transition: transform .12s; }
.card-link:active { transform: scale(.985); }
.card.hl { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: var(--line); color: var(--ink-2); white-space: nowrap; }
.chip-wallet { background: var(--ink); color: #fff; font-size: 13px; padding: 6px 12px; }
.chip.green { background: var(--green-bg); color: var(--green); }
.chip.amber { background: var(--amber-bg); color: var(--amber); }
.chip.red { background: var(--red-bg); color: var(--red); }
.chip.blue { background: var(--blue-bg); color: var(--blue); }
.chip.accent { background: var(--accent-2); color: var(--accent); }

.btn { display: inline-flex; justify-content: center; align-items: center; gap: 8px; border: 0; border-radius: 14px; padding: 13px 18px;
  font-weight: 700; cursor: pointer; white-space: nowrap; background: var(--line); color: var(--ink); transition: transform .1s, opacity .1s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-green { background: var(--green); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-block { width: 100%; }
.btn-xl { padding: 20px; font-size: 18px; border-radius: 18px; }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input { width: 100%; border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 14px; outline: none; }
.input:focus { border-color: var(--ink); }
textarea.input { resize: vertical; min-height: 72px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.seg { display: flex; background: var(--line); border-radius: 12px; padding: 3px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 10px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

/* event list */
.ev { display: grid; grid-template-columns: 52px 1fr; gap: 14px; align-items: center; }
.ev-date { background: var(--bg); border-radius: 14px; text-align: center; padding: 6px 0; }
.ev-date b { display: block; font-size: 20px; line-height: 1.1; }
.ev-date small { font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase; }
.ev-title { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { text-align: center; padding: 28px 16px; color: var(--ink-3); border: 1.5px dashed var(--line); border-radius: var(--radius); }

/* map */
.map { height: 240px; border-radius: var(--radius); overflow: hidden; z-index: 1; }
.map-tall { height: 300px; }
.leaflet-container { font: inherit; background: #e8e4dc; }
.pin { width: 22px; height: 22px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--accent); border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.me-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--blue); border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(47,111,235,.25); }

/* people */
.person { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.person:first-child { border-top: 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; flex: none; font-size: 15px; }
.avatar.lg { width: 72px; height: 72px; font-size: 28px; }
.score { font-weight: 800; font-size: 12px; padding: 2px 7px; border-radius: 8px; }

/* stats */
.ring { --p: 0; --c: var(--green); width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--line) 0); }
.ring > div { width: 94px; height: 94px; border-radius: 50%; background: #fff; display: grid; place-items: center; text-align: center; }
.ring b { font-size: 30px; font-weight: 800; line-height: 1; }
.ring small { font-size: 11px; color: var(--ink-3); font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { background: var(--bg); border-radius: 14px; padding: 12px; }
.kpi b { display: block; font-size: 22px; font-weight: 800; }
.kpi span { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar { display: grid; grid-template-columns: 78px 1fr 28px; gap: 10px; align-items: center; font-size: 13px; }
.bar-track { height: 10px; border-radius: 6px; background: var(--bg); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: var(--ink); }

/* check-in */
.checkin { text-align: center; padding: 22px 16px; background: linear-gradient(160deg, #FF5B2E, #FF8A3D); color: #fff; }
.checkin .count { font-size: 38px; font-weight: 800; letter-spacing: -.02em; }
.checkin .btn { background: #fff; color: var(--accent); }
.result { padding: 16px; border-radius: var(--radius); text-align: center; font-weight: 700; }
.result.green { background: var(--green-bg); color: var(--green); }
.result.amber { background: var(--amber-bg); color: var(--amber); }
.result.red { background: var(--red-bg); color: var(--red); }

/* invite suggestions */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-x { cursor: pointer; background: var(--ink); color: #fff; }
.suggest { background: #fff; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; }
.suggest button { display: flex; width: 100%; gap: 10px; align-items: center; border: 0; background: #fff; padding: 10px 12px; text-align: left; cursor: pointer; }
.suggest button + button { border-top: 1px solid var(--line); }

/* notifications & tx */
.notif { display: flex; gap: 12px; padding: 14px 16px; }
.notif + .notif { border-top: 1px solid var(--line); }
.notif.unread { background: #FFF8F5; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 7px; flex: none; }
.notif.read .notif-dot { background: transparent; }
.list { padding: 0; overflow: hidden; }
.tx { display: flex; justify-content: space-between; padding: 12px 16px; gap: 12px; }
.tx + .tx { border-top: 1px solid var(--line); }
.plus { color: var(--green); font-weight: 700; }
.minus { color: var(--ink); font-weight: 700; }

/* auth */
.hero { text-align: center; padding: 24px 0 8px; }
.hero .logo { width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 22px; background: var(--accent); display: grid; place-items: center;
  box-shadow: 0 10px 30px rgba(255,91,46,.35); }
.hero .logo span { width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 7px rgba(255,255,255,.35); }
.hero h1 { font-size: 30px; }

/* toast & modal */
.toast-wrap { position: fixed; top: calc(12px + var(--safe-top)); left: 0; right: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
.toast { pointer-events: auto; max-width: 520px; width: 100%; background: var(--ink); color: #fff; border-radius: 14px; padding: 12px 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2); animation: drop .25s ease-out; cursor: pointer; }
.toast.err { background: var(--red); }
.toast b { display: block; }
@keyframes drop { from { transform: translateY(-16px); opacity: 0; } }
.modal-wrap { position: fixed; inset: 0; z-index: 90; background: rgba(24,24,27,.45); display: flex; align-items: flex-end; justify-content: center; padding: 12px; }
.modal { background: #fff; border-radius: 22px; width: 100%; max-width: 520px; padding: 22px 18px calc(18px + var(--safe-bottom)); animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 600px) { .modal-wrap { align-items: center; } }

/* offline */
.offline-bar { position: fixed; z-index: 49; left: 0; right: 0; top: calc(52px + var(--safe-top)); text-align: center; font-size: 13px; font-weight: 700;
  padding: 7px 12px; background: var(--ink); color: #fff; }
.offline-bar.pending { background: var(--amber-bg); color: var(--amber); }
.offline-bar:not([hidden]) ~ .app { padding-top: calc(98px + var(--safe-top)); }
