:root {
  --ink: #14231d;
  --ink-soft: #3d4a45;
  --paper: #f4f1e8;
  --paper-deep: #e8e1d2;
  --card: #fffdf8;
  --gold: #f3c96b;
  --orange: #e05f43;
  --mint: #cfe6d4;
  --line: rgba(20, 35, 29, .13);
  --muted: #7a817d;
  --danger: #b44132;
  --shadow: 0 18px 50px rgba(20, 35, 29, .1);
  --radius: 24px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { background: var(--ink); }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--paper); }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: inherit; }

.app-shell { min-height: 100vh; padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(14px + env(safe-area-inset-top)) 20px 12px;
  display: flex; align-items: center; justify-content: space-between;
  color: #fff; background: rgba(20, 35, 29, .94); backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--gold); color: var(--ink); font-weight: 900; }
.brand-copy { line-height: 1.1; }
.brand-copy strong { display: block; font-size: 15px; letter-spacing: .05em; }
.brand-copy span { color: rgba(255,255,255,.62); font-size: 11px; }
.sync-pill { border: 1px solid rgba(255,255,255,.18); border-radius: 999px; padding: 7px 10px; display: flex; align-items: center; gap: 7px; color: rgba(255,255,255,.82); font-size: 12px; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: #86d39b; box-shadow: 0 0 0 4px rgba(134,211,155,.14); }
.sync-dot.demo { background: var(--gold); box-shadow: 0 0 0 4px rgba(243,201,107,.14); }

.page { max-width: 920px; margin: 0 auto; padding: 24px 18px 40px; }
.hero { position: relative; overflow: hidden; border-radius: 30px; padding: 28px 24px; color: #fff; background: var(--ink); box-shadow: var(--shadow); }
.hero::after { content: ""; position: absolute; right: -42px; top: -48px; width: 180px; height: 180px; border: 34px solid rgba(243,201,107,.2); border-radius: 50%; }
.eyebrow { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; color: var(--gold); font-weight: 750; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.eyebrow::before { content: ""; width: 18px; height: 2px; background: currentColor; }
.hero h1 { position: relative; z-index: 1; margin: 0; font-size: clamp(32px, 9vw, 56px); line-height: 1; letter-spacing: -.05em; }
.hero .sub { position: relative; z-index: 1; margin: 12px 0 0; color: rgba(255,255,255,.68); font-size: 14px; }
.hero-stats { position: relative; z-index: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 30px; }
.hero-stat span { display: block; color: rgba(255,255,255,.58); font-size: 12px; }
.hero-stat b { display: block; margin-top: 5px; font-size: 20px; font-variant-numeric: tabular-nums; }

.section-head { display: flex; align-items: end; justify-content: space-between; margin: 28px 4px 14px; }
.section-head h2 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.section-head button, .text-button { border: 0; padding: 0; background: transparent; color: var(--orange); font-weight: 700; cursor: pointer; }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.metric-card { min-height: 124px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.metric-card.wide { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; background: var(--gold); border-color: transparent; }
.metric-label { color: var(--muted); font-size: 12px; }
.metric-value { display: block; margin-top: 15px; font-size: 24px; font-weight: 800; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.metric-note { margin-top: 6px; color: var(--muted); font-size: 11px; }
.wide .metric-label, .wide .metric-note { color: rgba(20,35,29,.67); }
.wide .metric-value { font-size: 30px; }
.ring { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--ink) var(--progress, 64%), rgba(20,35,29,.16) 0); }
.ring::after { content: attr(data-label); width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--gold); font-size: 11px; font-weight: 800; }

.transaction-list { display: grid; gap: 10px; }
.transaction { width: 100%; border: 1px solid var(--line); border-radius: 20px; padding: 14px; display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; text-align: left; background: var(--card); cursor: pointer; }
.transaction-icon { width: 44px; height: 44px; border-radius: 15px; display: grid; place-items: center; background: var(--mint); font-size: 20px; }
.transaction.refund .transaction-icon { background: #d9e5f4; }
.transaction-main { min-width: 0; }
.transaction-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.transaction-main span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.transaction-amount { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.transaction-amount span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; font-weight: 500; }
.transaction.refund .transaction-amount { color: #397456; }

.review-card { border-radius: 24px; padding: 20px; background: var(--card); border: 1px solid var(--line); }
.bar-row { margin-top: 17px; }
.bar-copy { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.bar { height: 9px; margin-top: 8px; border-radius: 99px; overflow: hidden; background: var(--paper-deep); }
.bar > i { display: block; height: 100%; width: var(--value); background: var(--bar, var(--ink)); border-radius: inherit; }
.fact-card { margin-top: 12px; padding: 16px; border-left: 4px solid var(--orange); border-radius: 5px 18px 18px 5px; background: var(--card); }
.fact-card strong { display: flex; justify-content: space-between; gap: 12px; }
.fact-card p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }

.bottom-nav { position: fixed; z-index: 30; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(calc(100% - 24px), 640px); display: grid; grid-template-columns: repeat(5,1fr); padding: 7px; border: 1px solid rgba(255,255,255,.13); border-radius: 22px; background: rgba(20,35,29,.96); box-shadow: 0 18px 50px rgba(20,35,29,.28); backdrop-filter: blur(20px); }
.nav-item { min-height: 51px; border: 0; border-radius: 16px; display: grid; place-items: center; align-content: center; gap: 3px; background: transparent; color: rgba(255,255,255,.55); font-size: 10px; cursor: pointer; }
.nav-item svg { width: 20px; height: 20px; stroke-width: 2; }
.nav-item.active { color: var(--ink); background: var(--gold); }
.nav-item.add { color: #fff; }
.nav-item.add svg { width: 26px; height: 26px; }

.empty { padding: 38px 24px; border: 1px dashed rgba(20,35,29,.23); border-radius: 24px; text-align: center; color: var(--muted); background: rgba(255,255,255,.35); }
.empty strong { display: block; color: var(--ink); margin-bottom: 6px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); overflow: hidden; }
.setting-row { width: 100%; min-height: 64px; padding: 14px 16px; border: 0; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; text-align: left; background: transparent; cursor: pointer; }
.setting-row:last-child { border-bottom: 0; }
.setting-row strong { display: block; font-size: 14px; }
.setting-row small { display: block; margin-top: 4px; color: var(--muted); }
.chevron { color: var(--muted); font-size: 22px; }
.role-badge, .tag { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 9px; background: var(--mint); color: var(--ink); font-size: 11px; font-weight: 750; }
.tag.warn { background: #f7dfb1; }

.modal-backdrop { position: fixed; z-index: 100; inset: 0; padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom)); display: flex; align-items: end; justify-content: center; background: rgba(10,18,15,.58); backdrop-filter: blur(6px); }
.modal { width: min(100%, 620px); max-height: 92vh; overflow: auto; border-radius: 30px 30px 24px 24px; padding: 22px; background: var(--card); box-shadow: var(--shadow); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h2 { margin: 0; font-size: 21px; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 50%; display: grid; place-items: center; background: var(--paper-deep); cursor: pointer; }
.form-grid { display: grid; gap: 15px; }
.field { display: grid; gap: 7px; }
.field > span { color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 14px; padding: 11px 13px; background: #fff; color: var(--ink); outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(224,95,67,.1); }
.field.amount input { min-height: 74px; font-size: 34px; font-weight: 850; letter-spacing: -.04em; }
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.more-fields { display: none; padding-top: 4px; }
.more-fields.open { display: grid; gap: 15px; }
.primary-button, .secondary-button, .danger-button { width: 100%; min-height: 52px; border-radius: 15px; padding: 12px 16px; font-weight: 800; cursor: pointer; }
.primary-button { border: 0; color: #fff; background: var(--ink); }
.secondary-button { border: 1px solid var(--line); color: var(--ink); background: transparent; }
.danger-button { border: 1px solid rgba(180,65,50,.25); color: var(--danger); background: rgba(180,65,50,.06); }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-error { padding: 11px 13px; border-radius: 12px; color: var(--danger); background: rgba(180,65,50,.08); font-size: 13px; }
.helper { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.65; }

.gate { min-height: 100vh; padding: calc(32px + env(safe-area-inset-top)) 20px calc(32px + env(safe-area-inset-bottom)); display: grid; place-items: center; background: var(--ink); }
.gate-card { width: min(100%, 460px); border-radius: 32px; padding: 28px; background: var(--card); box-shadow: 0 28px 70px rgba(0,0,0,.26); }
.gate-logo { width: 58px; height: 58px; border-radius: 19px; display: grid; place-items: center; margin-bottom: 22px; background: var(--gold); font-size: 28px; }
.gate h1 { margin: 0; font-size: 30px; letter-spacing: -.04em; }
.gate .intro { margin: 10px 0 24px; color: var(--muted); line-height: 1.65; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 4px; margin-bottom: 18px; border-radius: 14px; background: var(--paper-deep); }
.segmented button { min-height: 40px; border: 0; border-radius: 11px; background: transparent; cursor: pointer; }
.segmented button.active { background: #fff; box-shadow: 0 4px 14px rgba(20,35,29,.08); font-weight: 800; }
.demo-link { display: block; width: 100%; margin-top: 16px; border: 0; background: transparent; color: var(--orange); font-weight: 750; cursor: pointer; }

.setup-step { display: grid; grid-template-columns: 34px 1fr; gap: 12px; margin-top: 18px; }
.step-no { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; background: var(--gold); font-weight: 900; }
.setup-step strong { display: block; font-size: 14px; }
.setup-step p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.code-box { margin-top: 10px; padding: 12px; border-radius: 12px; overflow-wrap: anywhere; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; background: #14231d; color: #d9e8df; }
.notice { margin-bottom: 18px; padding: 14px; border-radius: 16px; background: #f7dfb1; font-size: 13px; line-height: 1.55; }
.toast { position: fixed; z-index: 200; left: 50%; bottom: calc(104px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); max-width: calc(100% - 36px); padding: 12px 16px; border-radius: 999px; opacity: 0; pointer-events: none; color: #fff; background: rgba(20,35,29,.94); box-shadow: var(--shadow); transition: .22s ease; font-size: 13px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.loading { min-height: 60vh; display: grid; place-items: center; color: var(--muted); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--paper-deep); border-top-color: var(--orange); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 700px) {
  .page { padding: 34px 28px 60px; }
  .metric-grid { grid-template-columns: repeat(4, 1fr); }
  .metric-card.wide { grid-column: span 2; }
  .hero { padding: 38px; }
  .hero-stats { max-width: 440px; }
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 30px; }
}

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