:root {
  --bg: #130807;
  --text: #FFF6F1;
  --muted: rgba(255, 236, 228, .62);
  --faint: rgba(255, 236, 228, .38);
  --glass: rgba(255, 255, 255, .075);
  --glass-2: rgba(255, 255, 255, .12);
  --line: rgba(255, 255, 255, .13);
  --accent: #FF6A3D;
  --accent-2: #E8302A;
  --good: #3DDC97;
  --warn: #FFC145;
  --bad: #FF5C6C;
  --r-lg: 26px;
  --r-md: 18px;
  --r-sm: 12px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.2, .9, .25, 1);
  --spring: cubic-bezier(.2, 1.35, .4, 1);
  --input: rgba(255, 255, 255, .07);
  --input-f: rgba(255, 255, 255, .1);
  --option: #2a1210;
  --bg-grad: radial-gradient(120% 80% at 50% -10%, #3A0F0B 0%, #130807 60%);
  --orb-1: #E8302A; --orb-2: #FF7A30; --orb-3: #8A1E5C; --orb-op: 1;
  --seg: rgba(0, 0, 0, .25);
  --top: linear-gradient(to bottom, rgba(19, 8, 7, .88), rgba(19, 8, 7, .55) 70%, transparent);
  --tabs: rgba(40, 16, 13, .62);
  --tab-on: rgba(255, 255, 255, .1);
  --ico: linear-gradient(145deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, .04));
  --track: rgba(255, 255, 255, .07);
  --switch: rgba(255, 255, 255, .14);
  --sheet: rgba(42, 18, 15, .9);
  --grab: rgba(255, 255, 255, .25);
  --toast: rgba(50, 22, 18, .92);
  --shadow: rgba(0, 0, 0, .7);
  --banner: rgba(255, 193, 69, .1);
  font-family: -apple-system, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); transition: color .3s; }
body { overscroll-behavior: none; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
input, select, textarea {
  width: 100%; background: var(--input); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 13px 14px; outline: none; font-size: 16px;
  transition: border-color .2s, background .2s;
}
input:focus, select:focus, textarea:focus { border-color: rgba(255, 140, 100, .7); background: var(--input-f); }
select option { background: var(--option); }
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }

/* ---------- background ---------- */
.bg { position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none;
  background: var(--bg-grad); transition: background .4s; }
.orb { position: absolute; border-radius: 50%; filter: blur(60px); opacity: calc(.55 * var(--orb-op)); animation: drift 18s ease-in-out infinite alternate; }
.o1 { width: 340px; height: 340px; background: var(--orb-1); top: -120px; left: -90px; }
.o2 { width: 300px; height: 300px; background: var(--orb-2); top: 38%; right: -140px; animation-delay: -6s; opacity: calc(.38 * var(--orb-op)); }
.o3 { width: 260px; height: 260px; background: var(--orb-3); bottom: -90px; left: 10%; animation-delay: -11s; opacity: calc(.35 * var(--orb-op)); }
@keyframes drift { to { transform: translate(40px, 50px) scale(1.15); } }

#app { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; }
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; font-weight: 700; }
.boot img { width: 72px; height: 72px; background: #fff; border-radius: 22px; padding: 10px; animation: pop .7s var(--spring) both; }

/* ---------- glass ---------- */
.glass { background: var(--glass); border: 1px solid var(--line); border-radius: var(--r-lg);
  backdrop-filter: blur(22px) saturate(160%); -webkit-backdrop-filter: blur(22px) saturate(160%); }
.card { padding: 18px; margin-bottom: 14px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.center { text-align: center; }
.hide { display: none !important; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 50px; padding: 0 20px;
  border-radius: 16px; font-weight: 650; font-size: 16px; transition: transform .15s var(--ease), opacity .2s, background .2s; }
.btn:active { transform: scale(.96); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  box-shadow: 0 10px 30px -8px rgba(232, 48, 42, .65), inset 0 1px 0 rgba(255, 255, 255, .25); }
.btn.ghost { background: var(--glass-2); border: 1px solid var(--line); }
.btn.good { background: rgba(61, 220, 151, .16); color: var(--good); border: 1px solid rgba(61, 220, 151, .35); }
.btn.bad { background: rgba(255, 92, 108, .14); color: var(--bad); border: 1px solid rgba(255, 92, 108, .32); }
.btn.block { width: 100%; }
.btn.sm { height: 38px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.icon-btn { width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; background: var(--glass-2);
  border: 1px solid var(--line); transition: transform .15s; }
.icon-btn:active { transform: scale(.9); }
.icon-btn svg, .tab svg { width: 22px; height: 22px; }

/* ---------- auth / start ---------- */
.screen { padding: calc(var(--safe-t) + 22px) 18px calc(var(--safe-b) + 28px); max-width: 560px; margin: 0 auto; animation: fadeUp .45s var(--ease) both; }
.hero { text-align: center; padding: 34px 0 26px; }
.hero .logo { width: 84px; height: 84px; border-radius: 26px; background: #fff; display: grid; place-items: center; margin: 0 auto 18px;
  box-shadow: 0 20px 50px -12px rgba(232, 48, 42, .7); animation: pop .7s var(--spring) both; }
.hero .logo img { width: 62px; height: 62px; }
.hero h1 { font-size: 34px; font-weight: 800; }
.hero p { margin: 8px 0 0; color: var(--muted); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 16px; background: var(--seg); margin-bottom: 6px; }
.seg button { height: 40px; border-radius: 12px; font-weight: 600; color: var(--muted); transition: background .25s, color .25s; }
.seg button.on { background: var(--glass-2); color: var(--text); }
.pin { letter-spacing: .5em; text-align: center; font-size: 22px; font-weight: 700; }

.tour-card { padding: 18px; margin-bottom: 12px; display: block; width: 100%; text-align: left; transition: transform .2s var(--ease); }
.tour-card:active { transform: scale(.98); }
.tour-card h3 { font-size: 20px; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 99px; font-size: 12px;
  font-weight: 650; background: var(--glass-2); border: 1px solid var(--line); white-space: nowrap; }
.pill.good { color: var(--good); border-color: rgba(61, 220, 151, .35); background: rgba(61, 220, 151, .1); }
.pill.warn { color: var(--warn); border-color: rgba(255, 193, 69, .35); background: rgba(255, 193, 69, .1); }
.pill.bad { color: var(--bad); border-color: rgba(255, 92, 108, .35); background: rgba(255, 92, 108, .1); }
.pill.accent { color: #FFB59A; border-color: rgba(255, 106, 61, .4); background: rgba(255, 106, 61, .12); }

/* ---------- tour shell ---------- */
.top { position: sticky; top: 0; z-index: 5; padding: calc(var(--safe-t) + 10px) 16px 12px;
  background: var(--top);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.top h2 { font-size: 21px; font-weight: 760; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.sync { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); padding: 6px 10px; border-radius: 99px;
  background: var(--glass); border: 1px solid var(--line); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 10px var(--good); }
.dot.off { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.dot.busy { background: #7FB8FF; box-shadow: 0 0 10px #7FB8FF; animation: blink 1s infinite; }
.page { padding: 6px 16px calc(var(--safe-b) + 104px); max-width: 560px; margin: 0 auto; }
.page.enter { animation: fadeUp .35s var(--ease) both; }

.tabs { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 12px); z-index: 6;
  width: min(calc(100% - 24px), 520px); display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px; border-radius: 24px;
  background: var(--tabs); border: 1px solid var(--line); backdrop-filter: blur(24px) saturate(170%); -webkit-backdrop-filter: blur(24px) saturate(170%);
  box-shadow: 0 18px 40px -14px var(--shadow); }
.tab { position: relative; height: 54px; border-radius: 18px; display: grid; place-items: center; align-content: center; gap: 3px;
  font-size: 10.5px; font-weight: 600; color: var(--faint); transition: color .25s, background .25s; }
.tab.on { color: var(--text); background: var(--tab-on); }
.tab.on svg { color: var(--accent); }
.badge { position: absolute; top: 5px; right: calc(50% - 22px); min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px;
  background: var(--accent-2); color: #fff; font-size: 11px; display: grid; place-items: center; font-weight: 700; animation: pop .4s var(--spring); }

/* ---------- quick add ---------- */
.amount { text-align: center; padding: 18px 0 8px; }
.amount .cur { font-size: 20px; color: var(--muted); font-weight: 600; vertical-align: top; margin-right: 4px; position: relative; top: 10px; }
.amount .val { font-size: 58px; font-weight: 800; letter-spacing: -.04em; font-variant-numeric: tabular-nums; display: inline-block; }
.amount .val.bump { animation: bump .18s ease; }
.amount .val.zero { color: var(--faint); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; height: 42px; padding: 0 15px; border-radius: 14px; display: inline-flex; align-items: center; gap: 7px;
  background: var(--glass); border: 1px solid var(--line); font-weight: 600; font-size: 15px; transition: all .22s var(--ease); }
.chip.on { background: linear-gradient(135deg, rgba(255, 106, 61, .95), rgba(232, 48, 42, .95)); border-color: transparent; color: #fff;
  transform: translateY(-2px); box-shadow: 0 10px 22px -10px rgba(232, 48, 42, .9); }
.chip.sm { height: 34px; font-size: 13.5px; padding: 0 12px; border-radius: 11px; }
.section-label { font-size: 12px; text-transform: uppercase; letter-spacing: .09em; color: var(--faint); font-weight: 700; margin: 14px 2px 8px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 12px 0 14px; }
.key { height: 58px; border-radius: 18px; font-size: 24px; font-weight: 600; background: var(--glass); border: 1px solid var(--line);
  transition: transform .1s, background .15s; user-select: none; -webkit-user-select: none; }
.key svg { width: 26px; height: 26px; display: block; margin: 0 auto; }
.key:active { transform: scale(.93); background: var(--glass-2); }
.note-input { margin-bottom: 12px; }
.saved-burst { animation: burst .55s var(--ease); }

/* ---------- lists ---------- */
.day-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); font-weight: 650; margin: 18px 4px 8px; }
.item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 14px; border-radius: var(--r-md);
  background: var(--glass); border: 1px solid var(--line); margin-bottom: 8px; transition: transform .18s var(--ease);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); animation: fadeUp .35s var(--ease) both; }
.item:active { transform: scale(.98); }
.ico { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-size: 20px; flex: 0 0 auto;
  background: var(--ico); border: 1px solid var(--line); }
.item .t { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 12.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .amt { font-weight: 750; font-variant-numeric: tabular-nums; text-align: right; }
.item.queued { border-style: dashed; }
.banner { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--r-md); margin: 4px 0 12px;
  background: var(--banner); border: 1px solid rgba(255, 193, 69, .45); width: 100%; text-align: left; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .big { font-size: 44px; margin-bottom: 10px; }

/* ---------- stats ---------- */
.ring-wrap { display: flex; align-items: center; gap: 18px; }
.ring { width: 118px; height: 118px; flex: 0 0 auto; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .lbl { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .lbl b { font-size: 22px; }
.kv { display: flex; justify-content: space-between; padding: 7px 0; font-size: 15px; }
.kv b { font-variant-numeric: tabular-nums; }
.bar { margin: 12px 0; }
.bar .row { font-size: 14px; margin-bottom: 6px; }
.track { height: 10px; border-radius: 6px; background: var(--track); overflow: hidden; }
.fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transform-origin: left;
  animation: grow .9s var(--ease) both; }
.cols { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 8px; }
.col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; min-width: 0; }
.col .area { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.col .b { width: 100%; max-width: 34px; border-radius: 8px 8px 4px 4px; background: linear-gradient(180deg, var(--accent), var(--accent-2));
  transform-origin: bottom; animation: rise .8s var(--ease) both; min-height: 3px; }
.col span { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.big-num { font-size: 30px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }

/* ---------- people ---------- */
.code { font-size: 34px; font-weight: 800; letter-spacing: .18em; text-align: center; padding: 6px 0 2px; font-variant-numeric: tabular-nums; }
.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 750; flex: 0 0 auto;
  background: linear-gradient(145deg, #FF7A45, #C21F3A); color: #fff; }
.switch { width: 50px; height: 30px; border-radius: 15px; background: var(--switch); position: relative; transition: background .25s; flex: 0 0 auto; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff;
  transition: transform .3s var(--spring); box-shadow: 0 2px 6px rgba(0, 0, 0, .3); }
.switch.on { background: var(--good); }
.switch.on::after { transform: translateX(20px); }
.switch[disabled] { opacity: .5; }

/* ---------- sheet ---------- */
.scrim { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .5); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  animation: fade .25s both; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 88vh; overflow-y: auto; margin: 0 auto; max-width: 560px;
  padding: 10px 18px calc(var(--safe-b) + 22px); border-radius: 28px 28px 0 0; background: var(--sheet);
  border: 1px solid var(--line); border-bottom: 0; backdrop-filter: blur(30px) saturate(170%); -webkit-backdrop-filter: blur(30px) saturate(170%);
  animation: sheetUp .38s var(--ease) both; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--grab); margin: 0 auto 14px; }
.sheet h3 { font-size: 21px; margin-bottom: 4px; }
.closing .scrim { animation: fade .2s reverse both; }
.closing .sheet { animation: sheetDown .22s ease-in both; }
.actions { display: grid; gap: 10px; margin-top: 18px; }
.actions.two { grid-template-columns: 1fr 1fr; }

/* ---------- toast ---------- */
#toast { position: fixed; left: 50%; top: calc(var(--safe-t) + 14px); z-index: 40; transform: translate(-50%, -140%);
  padding: 12px 18px; border-radius: 16px; background: var(--toast); border: 1px solid var(--line); font-weight: 600; font-size: 14.5px;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); transition: transform .4s var(--spring); max-width: calc(100% - 32px);
  box-shadow: 0 14px 30px -10px var(--shadow); }
#toast.show { transform: translate(-50%, 0); }
#toast.err { border-color: rgba(255, 92, 108, .5); }


/* ---------- light mode ---------- */
html[data-theme="light"] {
  --bg: #FBF4EF;
  --text: #2B120D;
  --muted: rgba(60, 26, 18, .66);
  --faint: rgba(60, 26, 18, .42);
  --glass: rgba(255, 255, 255, .62);
  --glass-2: rgba(255, 255, 255, .9);
  --line: rgba(140, 50, 25, .13);
  --good: #11946A;
  --warn: #B87500;
  --bad: #D2293E;
  --input: rgba(255, 255, 255, .75);
  --input-f: #fff;
  --option: #fff;
  --bg-grad: radial-gradient(120% 80% at 50% -10%, #FFE2D2 0%, #FBF4EF 60%);
  --orb-1: #FF8A6A; --orb-2: #FFC07A; --orb-3: #F7A6C4; --orb-op: .7;
  --seg: rgba(140, 50, 25, .08);
  --top: linear-gradient(to bottom, rgba(251, 244, 239, .92), rgba(251, 244, 239, .6) 70%, transparent);
  --tabs: rgba(255, 255, 255, .72);
  --tab-on: rgba(255, 106, 61, .12);
  --ico: linear-gradient(145deg, #fff, rgba(255, 255, 255, .55));
  --track: rgba(140, 50, 25, .09);
  --switch: rgba(140, 50, 25, .16);
  --sheet: rgba(255, 250, 247, .94);
  --grab: rgba(60, 26, 18, .2);
  --toast: rgba(255, 255, 255, .95);
  --shadow: rgba(120, 40, 20, .22);
  --banner: rgba(255, 193, 69, .18);
  color-scheme: light;
}
html[data-theme="light"] .glass, html[data-theme="light"] .item { box-shadow: 0 8px 24px -16px rgba(120, 40, 20, .35); }
html[data-theme="light"] .tab.on svg { color: var(--accent-2); }
html[data-theme="light"] .chip.on, html[data-theme="light"] .btn.primary { color: #fff; }
html[data-theme="light"] .pill.accent { color: #C2411C; }
html[data-theme="light"] .hero .logo { box-shadow: 0 20px 44px -16px rgba(232, 48, 42, .55); }
html[data-theme="light"] .dot { box-shadow: none; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.6); } }
@keyframes bump { 50% { transform: scale(1.06); } }
@keyframes burst { 40% { transform: scale(1.08); color: var(--good); } }
@keyframes grow { from { transform: scaleX(0); } }
@keyframes rise { from { transform: scaleY(0); } }
@keyframes blink { 50% { opacity: .35; } }
@keyframes sheetUp { from { transform: translateY(100%); } }
@keyframes sheetDown { to { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
