/* CPITEX user app — see DESIGN.md. Light graphite neutrals, emerald accent, 430px frame. */
:root {
  --page: #fafafa; --card: #ffffff; --raised: #f4f4f5; --sunk: #efeff1;
  --line: rgba(23, 23, 23, .08); --line-2: rgba(23, 23, 23, .14);
  --ink: #171717; --ink-2: #525252; --muted: #737373;
  --accent: #047857; --accent-hover: #065f46; --accent-tint: #ecfdf5;
  --pos: #16a34a; --neg: #dc2626; --warn: #b45309; --info: #2563eb;
  --r-tag: 6px; --r-ctl: 10px; --r-card: 16px; --r-frame: 20px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow: 0 1px 2px rgba(23, 23, 23, .04);
  --nav-h: 64px;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: var(--sunk); -webkit-font-smoothing: antialiased; font-size: 15px; line-height: 22px; font-weight: 400; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
b, strong { font-weight: 500; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Frame */
.app { max-width: 430px; margin: 0 auto; min-height: 100vh; background: var(--page); position: relative; padding-bottom: calc(var(--nav-h) + 32px + env(safe-area-inset-bottom)); }
@media (min-width: 480px) { .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }
.page { padding: 4px 20px 0; }

/* Top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 60px; padding: 0 20px; position: sticky; top: 0; background: rgba(250, 250, 250, .94); backdrop-filter: blur(8px); z-index: 20; }
.topbar h1 { font-size: 17px; line-height: 24px; margin: 0; font-weight: 500; }
.back { width: 36px; height: 36px; border-radius: var(--r-ctl); display: grid; place-items: center; color: var(--ink-2); border: 1px solid var(--line); background: var(--card); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: #fff; }
.brand-mark svg { stroke-width: 2; }
.icon-btn { position: relative; width: 36px; height: 36px; border-radius: var(--r-ctl); display: grid; place-items: center; color: var(--ink-2); border: 1px solid var(--line); background: var(--card); }
.dot { position: absolute; top: 7px; right: 8px; width: 6px; height: 6px; background: var(--accent); border-radius: 50%; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--raised); color: var(--ink-2); display: grid; place-items: center; font-weight: 500; font-size: 14px; border: 1px solid var(--line); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Bottom nav */
.nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 430px; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); z-index: 30; }
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; line-height: 16px; color: var(--muted); transition: color 140ms var(--ease); }
.nav a.on { color: var(--ink); font-weight: 500; }
.nav a.on svg { color: var(--accent); }

/* Type */
.greet small { display: block; color: var(--muted); font-size: 12px; line-height: 16px; }
.greet b { font-size: 17px; line-height: 24px; font-weight: 500; }
.h2 { font-size: 15px; line-height: 20px; font-weight: 500; margin: 32px 0 12px; display: flex; justify-content: space-between; align-items: center; }
.h2 a { font-size: 13px; color: var(--ink-2); font-weight: 400; display: inline-flex; align-items: center; gap: 4px; }
.h2 a:hover { color: var(--ink); }
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 20px; }
.tiny { font-size: 12px; line-height: 16px; }
.center { text-align: center; }
.right { text-align: right; }
.mt { margin-top: 16px; } .mt2 { margin-top: 24px; } .mb { margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Cards */
.card { background: var(--raised); border-radius: var(--r-card); padding: 16px; }
.card.white { background: var(--card); border: 1px solid var(--line); }
.stack > * + * { margin-top: 12px; }

/* Balance statement (moment 1) */
.hero { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-frame) var(--r-frame) 0 0; padding: 20px 20px 28px; position: relative; }
.hero::after { content: ""; position: absolute; left: -1px; right: -1px; bottom: -8px; height: 8px; background: radial-gradient(circle at 6px 8px, var(--page) 5px, var(--card) 5.5px) 0 0 / 12px 8px repeat-x; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.hero .label { font-size: 13px; line-height: 20px; color: var(--muted); display: flex; justify-content: space-between; }
.hero .big { font-size: 40px; line-height: 44px; font-weight: 500; letter-spacing: -.02em; margin: 8px 0 0; font-variant-numeric: tabular-nums; }
.hero .big small { font-size: 15px; color: var(--muted); font-weight: 400; letter-spacing: 0; margin-left: 4px; }
.hero .sub { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 20px; }
.hero .sub div { background: var(--raised); border-radius: var(--r-ctl); padding: 8px 12px; font-size: 12px; line-height: 16px; color: var(--muted); }
.hero .sub b { display: block; font-size: 15px; line-height: 22px; color: var(--ink); font-variant-numeric: tabular-nums; margin-top: 2px; }
.hero-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.hero-actions a { height: 44px; border-radius: var(--r-ctl); font-weight: 500; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 15px; background: var(--accent); color: #fff; transition: background-color 140ms var(--ease), transform 140ms var(--ease); }
.hero-actions a:hover { background: var(--accent-hover); }
.hero-actions a:active { transform: scale(.98); }
.hero-actions a.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line-2); }
.hero-actions a.ghost:hover { background: var(--raised); }
.hero-ref { margin-top: 20px; }

/* Quick actions */
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 32px; }
.quick a { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 12px; line-height: 16px; color: var(--ink-2); }
.quick span { width: 48px; height: 48px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); color: var(--ink-2); display: grid; place-items: center; transition: background-color 140ms var(--ease), transform 140ms var(--ease); }
.quick a:hover span { background: var(--raised); }
.quick a:active span { transform: scale(.97); }

/* Banners */
.carousel { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 12px; margin: 24px -20px 0; padding: 0 20px; scrollbar-width: none; }
.carousel::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; scroll-snap-align: center; border-radius: var(--r-card); min-height: 148px; padding: 20px; background: var(--card) no-repeat right center / auto 100%; border: 1px solid var(--line); position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; }
.slide > * { position: relative; max-width: 58%; }
.slide h3 { margin: 0; font-size: 17px; line-height: 24px; font-weight: 500; }
.slide p { margin: 4px 0 0; font-size: 13px; line-height: 20px; color: var(--ink-2); }
.slide .pill { margin-top: 12px; align-self: flex-start; color: var(--ink); font-weight: 500; border: 1px solid var(--line-2); border-radius: var(--r-ctl); padding: 6px 12px; background: var(--card); }
.slide .pill::before { display: none; }
.slide.has-img { color: #fff; background-size: cover; background-position: center; border: 0; }
.slide.has-img::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(23,23,23,.72), rgba(23,23,23,.1)); }
.slide.has-img p { color: rgba(255,255,255,.8); }
.dots { display: flex; justify-content: center; gap: 4px; margin-top: 12px; }
.dots i { width: 6px; height: 6px; border-radius: 4px; background: var(--line-2); transition: width 200ms var(--ease), background-color 200ms var(--ease); }
.dots i.on { width: 16px; background: var(--ink-2); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: var(--r-ctl); height: 44px; padding: 0 20px; font: inherit; font-weight: 500; cursor: pointer; background: var(--accent); color: #fff; transition: background-color 140ms var(--ease), transform 140ms var(--ease); width: 100%; font-size: 15px; }
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(.98); }
.btn:disabled, .btn.disabled { background: var(--raised); color: var(--muted); cursor: not-allowed; transform: none; }
.btn.light { background: var(--card); color: var(--ink); border: 1px solid var(--line-2); }
.btn.light:hover, .btn.outline:hover { background: var(--raised); }
.btn.outline { background: var(--card); color: var(--ink); border: 1px solid var(--line-2); }
.btn.danger { background: var(--card); color: var(--neg); border: 1px solid var(--line-2); }
.btn.danger:hover { background: #fef2f2; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; width: auto; }

/* Status: dot + muted text (not bright pills) */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; line-height: 16px; color: var(--ink-2); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--pos); flex: 0 0 auto; }
.pill.gray::before { background: #a3a3a3; }
.pill.amber::before { background: #d97706; }
.pill.red::before { background: var(--neg); }
.pill.blue::before { background: var(--info); }
.pill.demo { color: var(--warn); }
.pill.demo::before { background: #d97706; }

/* Lists */
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 64px; }
.item + .item { border-top: 1px solid var(--line); }
a.item { transition: background-color 140ms var(--ease); }
a.item:hover { background: var(--raised); }
.item .ico { width: 36px; height: 36px; border-radius: var(--r-ctl); background: var(--raised); display: grid; place-items: center; color: var(--ink-2); flex: 0 0 auto; }
.item .ico.in, .item .ico.out { color: var(--ink-2); }
.item .t { font-weight: 500; font-size: 14px; line-height: 20px; }
.item .s { font-size: 12px; line-height: 16px; color: var(--muted); }
.amt-in { color: var(--pos); font-weight: 500; font-variant-numeric: tabular-nums; }
.amt-out { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); font-size: 13px; line-height: 20px; }
.empty img { width: 96px; height: 96px; margin: 0 auto 12px; }

/* Plan card (moment 2: object artwork) */
.plan { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: 16px; }
.plan + .plan { margin-top: 12px; }
.plan .top { display: flex; gap: 12px; align-items: center; }
.plan .thumb { width: 56px; height: 56px; border-radius: 12px; background: var(--raised); flex: 0 0 auto; overflow: hidden; }
.plan .thumb img { width: 100%; height: 100%; }
.plan .price { font-size: 28px; line-height: 32px; font-weight: 500; margin: 16px 0 12px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.plan .meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; font-size: 12px; line-height: 16px; color: var(--muted); }
.plan .meta b { display: block; color: var(--ink); font-size: 13px; line-height: 20px; margin-top: 2px; }
.progress { height: 6px; background: var(--raised); border-radius: 3px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* Chips */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 4px -20px 16px; padding: 0 20px; }
.chips::-webkit-scrollbar { display: none; }
.chips a { white-space: nowrap; height: 32px; display: inline-flex; align-items: center; padding: 0 12px; border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--card); font-size: 13px; color: var(--ink-2); transition: background-color 140ms var(--ease); }
.chips a:hover { background: var(--raised); }
.chips a.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Forms */
label.f { display: block; font-size: 13px; line-height: 20px; font-weight: 500; color: var(--ink-2); margin: 16px 0 8px; }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line-2); background: var(--card); border-radius: var(--r-ctl); height: 44px; padding: 0 12px; font: inherit; color: var(--ink); outline: none; transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease); }
textarea.input { height: auto; min-height: 112px; padding: 12px; resize: vertical; }
input[type=file].input { padding: 10px 12px; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(4, 120, 87, .12); }
.hint { font-size: 12px; line-height: 16px; color: var(--muted); margin-top: 8px; }
.err { font-size: 12px; line-height: 16px; color: var(--neg); margin-top: 8px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; line-height: 20px; color: var(--ink-2); margin-top: 16px; }
.check input { margin-top: 2px; accent-color: var(--accent); width: 16px; height: 16px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--raised); padding: 4px; border-radius: 12px; }
.seg label { text-align: center; height: 36px; display: grid; place-items: center; border-radius: 8px; font-size: 13px; cursor: pointer; color: var(--muted); transition: background-color 140ms var(--ease), color 140ms var(--ease); }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--card); color: var(--ink); font-weight: 500; box-shadow: var(--shadow), 0 0 0 1px var(--line); }

/* Alerts */
.alert { border-radius: 12px; padding: 12px 16px; font-size: 13px; line-height: 20px; margin: 12px 0; display: flex; gap: 8px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); color: var(--ink-2); }
.alert svg { flex: 0 0 auto; margin-top: 1px; }
.alert.ok svg { color: var(--pos); } .alert.bad { color: var(--neg); border-color: rgba(220, 38, 38, .2); } .alert.warn svg { color: #d97706; } .alert.info svg { color: var(--info); }

/* Misc */
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; font-size: 14px; line-height: 20px; }
.kv + .kv { border-top: 1px solid var(--line); }
.kv span { color: var(--muted); }
.copybox { display: flex; gap: 8px; align-items: center; background: var(--raised); border-radius: var(--r-ctl); padding: 6px 6px 6px 12px; min-height: 44px; font-family: var(--mono); font-size: 12px; line-height: 16px; word-break: break-all; color: var(--ink-2); }
.qr { width: 176px; height: 176px; margin: 16px auto; background: #fff; padding: 12px; border-radius: 12px; border: 1px solid var(--line); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat small { color: var(--muted); font-size: 12px; line-height: 16px; display: block; }
.stat b { font-size: 17px; line-height: 24px; font-variant-numeric: tabular-nums; }
.reward { border-radius: var(--r-card); padding: 16px; background: var(--card); border: 1px solid var(--line); }
.reward .amt { font-size: 28px; line-height: 32px; font-weight: 500; font-variant-numeric: tabular-nums; margin-top: 4px; }
.reward img { width: 56px; height: 56px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal div { aspect-ratio: 1; border-radius: 8px; display: grid; place-items: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cal div.on { background: var(--accent-tint); color: var(--accent); font-weight: 500; }
.cal div.today { box-shadow: inset 0 0 0 1px var(--ink-2); color: var(--ink); }
.pager { display: flex; justify-content: space-between; align-items: center; margin: 16px 0; }
.pager a, .pager span { font-size: 13px; height: 32px; display: inline-flex; align-items: center; padding: 0 12px; border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--card); }
.pager span { color: var(--muted); }
.pager small { border: 0 !important; background: none !important; }
.auth { padding: 24px 24px 40px; }
.auth-art { margin: 0 -24px 8px; height: 200px; background: var(--raised) center / cover no-repeat; border-bottom: 1px solid var(--line); }
.auth h1 { font-size: 28px; line-height: 32px; font-weight: 500; letter-spacing: -.01em; margin: 24px 0 4px; }
.disclaimer { font-size: 12px; line-height: 18px; color: var(--muted); border-top: 1px solid var(--line); padding: 16px 0 0; margin-top: 24px; }
.chat { display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 85%; padding: 8px 12px; border-radius: 14px; font-size: 14px; line-height: 20px; white-space: pre-wrap; }
.bubble.me { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 4px; }
.bubble.them { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.spark { width: 100%; height: 120px; }
.fade-in { animation: rise 320ms var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Page artwork panels */
.page-art { background: #eef3f0; border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; display: grid; place-items: center; }
.page-art img { width: 100%; max-width: 360px; height: auto; }
.page-art.object { height: 176px; }
.page-art.object img { width: 160px; height: 160px; }
.brand img { display: block; height: 30px; width: auto; }

/* ---------- desktop: side rail instead of empty space ---------- */
.rail { display: none; }
@media (min-width: 1100px) {
  body.signed { display: grid; grid-template-columns: 1fr minmax(0, 480px) 1fr; }
  body.signed .app { grid-column: 2; max-width: 480px; width: 100%; }
  body.signed .nav { display: none; }
  body.signed .app { padding-bottom: 48px; }
  .rail { display: flex; flex-direction: column; gap: 24px; grid-column: 1; justify-self: end; position: sticky; top: 0; height: 100vh; width: 260px; padding: 32px 24px; }
  .rail-logo img { width: 124px; height: 32px; }
  .rail nav { display: flex; flex-direction: column; gap: 4px; }
  .rail nav a { display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px; border-radius: 10px; color: var(--ink-2); font-size: 15px; text-decoration: none; transition: background .15s cubic-bezier(.22,1,.36,1), color .15s cubic-bezier(.22,1,.36,1); }
  .rail nav a:hover { background: var(--raised, #f4f4f5); color: var(--ink); }
  .rail nav a.on { background: var(--card, #fff); color: var(--ink); font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,.05); border: 1px solid var(--line); }
  .rail-app { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--card, #fff); text-decoration: none; color: var(--ink); }
  .rail-app .t { font-weight: 500; }
  .rail-app .s { font-size: 13px; line-height: 18px; color: var(--ink-2); }
  .rail-app .b { display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; color: var(--accent); font-weight: 500; font-size: 14px; }
}
/* ---------- Android: suggest the app ---------- */
.app-banner { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; background: var(--card, #fff); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 25; }
.app-banner[hidden] { display: none; }
.app-banner .x { background: none; border: 0; padding: 8px; color: var(--muted); cursor: pointer; }
.app-banner .btn.sm { height: 34px; padding: 0 14px; width: auto; font-size: 14px; }
/* ---------- profile ---------- */
.uid { margin-top: 6px; display: inline-flex; align-items: center; gap: 6px; background: var(--raised, #f4f4f5); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; font-size: 12px; color: var(--ink-2); cursor: pointer; }
/* ---------- Google button ---------- */
.google-auth { margin: 20px 0 4px; }
.google-auth .or { display: flex; align-items: center; gap: 12px; margin: 16px 0 0; color: var(--muted); font-size: 13px; }
.google-auth .or::before, .google-auth .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
/* ---------- live support chat ---------- */
.chat-img { display: block; max-width: 240px; max-height: 240px; width: auto; border-radius: 10px; margin-bottom: 6px; }
.bubble .meta { font-size: 11px; opacity: .7; margin-top: 4px; }
.composer { display: flex; align-items: flex-end; gap: 8px; margin-top: 12px; position: sticky; bottom: calc(var(--nav-h) + 8px); background: var(--page); padding: 8px 0; }
.composer textarea { flex: 1; min-height: 44px; max-height: 140px; resize: none; }
.composer .btn { width: 44px; height: 44px; padding: 0; flex: none; }
.composer .attach { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink-2); cursor: pointer; }
@media (min-width: 1100px) { body.signed .composer { bottom: 8px; } }
