

:root {
  --paper: #f5f3ef;
  --panel: rgba(255, 255, 255, 0.74);
  --white: #fff;
  --ink: #292d2b;
  --muted: #82847f;
  --line: rgba(44, 50, 47, 0.10);
  --sage: #7e9185;
  --sage-dark: #647a6d;
  --sage-pale: #e5ebe6;
  --clay: #b59282;
  --clay-pale: #eee4df;
  --shadow: 0 22px 60px rgba(63, 69, 65, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-geist-sans), -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--sage); outline-offset: 2px; }

.app-shell { min-height: 100vh; background: radial-gradient(circle at 82% -8%, rgba(195, 204, 197, 0.38), transparent 32%), var(--paper); }
.topbar { height: 76px; display: flex; align-items: center; padding: 0 38px; border-bottom: 1px solid var(--line); background: rgba(245, 243, 239, 0.78); backdrop-filter: blur(24px); position: sticky; top: 0; z-index: 20; }
.brand-mark { width: 36px; height: 36px; border-radius: 11px; background: var(--sage-dark); color: white; display: grid; place-items: center; font-family: Georgia, serif; font-size: 19px; margin-right: 12px; box-shadow: 0 7px 18px rgba(100, 122, 109, .23); }
.brand-copy { display: grid; line-height: 1.2; }
.brand-copy strong { font-size: 14px; letter-spacing: .02em; }
.brand-copy span { color: var(--muted); font-size: 11px; margin-top: 3px; }
.account-actions { margin-left: auto; position: relative; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--clay-pale); color: #7d6357; display: grid; place-items: center; font-size: 11px; }
.account-trigger { border: 0; background: transparent; display: flex; align-items: center; gap: 8px; padding: 5px 7px; border-radius: 12px; cursor: pointer; }
.account-trigger:hover, .account-trigger[aria-expanded="true"] { background: rgba(255,255,255,.62); }
.account-label { font-size: 10px; color: var(--muted); }
.account-chevron { color: #9a9d98; font-size: 13px; transform: translateY(-1px); }
.account-menu { position: absolute; right: 0; top: calc(100% + 9px); width: 250px; background: rgba(250,249,246,.98); border: 1px solid rgba(255,255,255,.9); border-radius: 17px; padding: 8px; box-shadow: 0 24px 65px rgba(43,50,46,.16); backdrop-filter: blur(22px); z-index: 35; animation: rise .18s ease; }
.account-menu-heading { padding: 10px 11px 12px; display: grid; gap: 3px; border-bottom: 1px solid var(--line); margin-bottom: 5px; }
.account-menu-heading strong { font-size: 11px; }
.account-menu-heading small { color: var(--muted); font-size: 8px; }
.account-menu-item { width: 100%; border: 0; background: transparent; border-radius: 11px; padding: 10px; display: flex; align-items: center; gap: 10px; text-align: left; text-decoration: none; color: var(--ink); cursor: pointer; }
.account-menu-item:hover { background: white; }
.account-menu-item > span { width: 29px; height: 29px; border-radius: 9px; display: grid; place-items: center; background: var(--sage-pale); color: var(--sage-dark); font-size: 14px; }
.account-menu-item.logout > span { background: var(--clay-pale); color: #9b7667; }
.account-menu-item div { display: grid; gap: 3px; }
.account-menu-item strong { font-size: 10px; }
.account-menu-item small { font-size: 8px; color: var(--muted); }

.workspace { min-height: calc(100vh - 76px); display: grid; grid-template-columns: 330px minmax(0, 1fr); max-width: 1530px; margin: 0 auto; }
.member-panel { border-right: 1px solid var(--line); padding: 35px 24px 25px 30px; min-height: calc(100vh - 76px); display: flex; flex-direction: column; background: rgba(250, 249, 246, .44); }
.panel-heading, .profile-header, .ledger-header { display: flex; align-items: center; justify-content: space-between; }
.eyebrow { margin: 0 0 7px; color: #979a94; font-size: 9px; font-weight: 650; letter-spacing: .18em; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 27px; margin-bottom: 0; letter-spacing: -.035em; }
.square-button { border: 0; width: 34px; height: 34px; border-radius: 10px; background: var(--ink); color: white; font-size: 22px; line-height: 1; cursor: pointer; box-shadow: 0 6px 15px rgba(30,35,32,.14); }
.search-box { height: 42px; display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.75); border: 1px solid var(--line); border-radius: 12px; margin: 27px 0 16px; padding: 0 12px; color: #999c97; }
.search-box input { border: 0; background: transparent; min-width: 0; flex: 1; font-size: 12px; color: var(--ink); outline: 0; }
.search-box button { border: 0; background: none; cursor: pointer; color: #aaa; }
.member-count { color: var(--muted); font-size: 10px; padding: 0 5px 9px; }
.member-list { display: grid; gap: 4px; overflow-y: auto; max-height: 560px; margin: 0 -8px; padding: 0 8px; }
.member-row { width: 100%; border: 0; background: transparent; border-radius: 14px; padding: 11px 10px; display: grid; grid-template-columns: 39px 1fr auto; gap: 10px; align-items: center; text-align: left; cursor: pointer; transition: .18s ease; }
.member-row:hover { background: rgba(255,255,255,.68); }
.member-row.selected { background: var(--white); box-shadow: 0 8px 24px rgba(72,76,73,.07); }
.member-avatar { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: #e6e5df; color: #686b66; font-size: 13px; }
.member-row:nth-child(3n+2) .member-avatar { background: var(--sage-pale); color: var(--sage-dark); }
.member-row:nth-child(3n) .member-avatar { background: var(--clay-pale); color: #8c6d61; }
.member-identity { display: grid; gap: 4px; min-width: 0; }
.member-identity strong { font-size: 12px; font-weight: 590; }
.member-identity small { font-size: 9px; color: var(--muted); }
.member-balance { font: 600 10px var(--font-geist-mono); }
.empty-list, .empty-ledger { color: var(--muted); font-size: 12px; text-align: center; padding: 40px 10px; }
.side-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); margin-top: auto; border-radius: 13px; overflow: hidden; border: 1px solid var(--line); }
.side-summary div { padding: 14px 13px; background: rgba(255,255,255,.62); display: grid; gap: 5px; }
.side-summary span { color: var(--muted); font-size: 9px; }
.side-summary strong { font-size: 12px; }

.content-panel { padding: 46px clamp(35px, 5vw, 78px) 60px; overflow: hidden; }
.daily-overview { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 34px; }
.overview-card { min-width: 0; background: rgba(255,255,255,.62); border: 1px solid var(--line); border-radius: 16px; padding: 17px 19px; display: grid; gap: 7px; position: relative; overflow: hidden; }
.overview-card::after { content: ""; position: absolute; right: -13px; top: -18px; width: 58px; height: 58px; border-radius: 50%; background: var(--sage-pale); opacity: .7; }
.overview-card.purchase::after { background: var(--clay-pale); }
.overview-card.balance::after { background: #e5e3dc; }
.overview-card span, .overview-card small { color: var(--muted); font-size: 9px; position: relative; z-index: 1; }
.overview-card strong { font: 590 19px var(--font-geist-mono); white-space: nowrap; position: relative; z-index: 1; }
.overview-card small { font-size: 8px; }
.profile-header { margin-bottom: 28px; }
.profile-title { display: flex; align-items: center; gap: 12px; }
.profile-title h2 { margin: 0; font-size: 31px; letter-spacing: -.045em; font-weight: 620; }
.status-pill { font-size: 9px; color: var(--sage-dark); background: var(--sage-pale); padding: 5px 8px; border-radius: 999px; }
.profile-meta { color: var(--muted); font-size: 10px; margin: 9px 0 0; display: flex; align-items: center; gap: 8px; }
.profile-meta i { width: 2px; height: 2px; border-radius: 50%; background: #aaa; }
.quiet-button { border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.62); font-size: 11px; padding: 9px 13px; cursor: pointer; }
.profile-actions { display: flex; gap: 8px; }
.delete-button { border: 0; border-radius: 10px; background: transparent; color: #a0796d; font-size: 10px; padding: 9px 10px; cursor: pointer; }
.delete-button:hover { background: var(--clay-pale); }
.balance-card { min-height: 180px; background: linear-gradient(118deg, #74887b, #87998e); border-radius: 22px; padding: 31px 34px; color: white; box-shadow: 0 22px 50px rgba(95,117,104,.19); display: flex; align-items: center; justify-content: space-between; overflow: hidden; position: relative; }
.balance-card::after { content: ""; position: absolute; width: 280px; height: 280px; border: 1px solid rgba(255,255,255,.09); border-radius: 50%; right: -80px; top: -145px; box-shadow: 0 0 0 36px rgba(255,255,255,.025), 0 0 0 72px rgba(255,255,255,.018); }
.balance-info, .balance-actions { position: relative; z-index: 1; }
.balance-info { display: grid; }
.balance-info > span { font-size: 11px; opacity: .72; }
.balance-info > strong { font: 500 clamp(35px, 4vw, 48px) var(--font-geist-mono); letter-spacing: -.055em; margin: 12px 0 14px; }
.balance-info small { font-size: 9px; opacity: .67; }
.balance-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.balance-actions button { min-width: 150px; border: 1px solid rgba(255,255,255,.2); border-radius: 14px; padding: 13px 14px; display: flex; align-items: center; gap: 11px; text-align: left; cursor: pointer; backdrop-filter: blur(10px); }
.balance-actions button > span { width: 29px; height: 29px; border-radius: 9px; display: grid; place-items: center; font-size: 18px; }
.balance-actions button div { display: grid; gap: 3px; }
.balance-actions button strong { color: inherit; font-size: 10px; }
.balance-actions button small { color: inherit; font-size: 8px; opacity: .63; }
.primary-action { background: #f8f7f3; color: #667b6e; }
.primary-action > span { background: var(--sage-pale); }
.secondary-action { background: rgba(50,66,57,.2); color: white; }
.secondary-action > span { background: rgba(255,255,255,.12); }
.metrics-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 15px 0 39px; }
.metric { background: rgba(255,255,255,.63); border: 1px solid var(--line); border-radius: 15px; padding: 17px 19px; display: grid; gap: 7px; }
.metric span, .metric small { color: var(--muted); font-size: 9px; }
.metric strong { font: 590 17px var(--font-geist-mono); }
.metric small { font-size: 8px; }
.ledger-header { margin-bottom: 16px; }
.ledger-header h3 { font-size: 18px; margin: 0; letter-spacing: -.025em; }
.ledger-tools { display: flex; align-items: center; gap: 9px; }
.export-button { border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.66); color: var(--ink); padding: 7px 11px; font-size: 9px; text-decoration: none; white-space: nowrap; }
.export-button:hover { background: white; }
.segment-control { background: #eae9e4; border-radius: 10px; padding: 3px; display: flex; }
.segment-control button { border: 0; background: transparent; border-radius: 8px; color: var(--muted); padding: 6px 12px; font-size: 9px; cursor: pointer; }
.segment-control button.active { background: white; color: var(--ink); box-shadow: 0 2px 7px rgba(50,55,52,.08); }
.ledger-table { background: rgba(255,255,255,.53); border: 1px solid var(--line); border-radius: 17px; overflow: hidden; }
.ledger-labels, .ledger-row { display: grid; grid-template-columns: minmax(190px, 1.4fr) minmax(100px, .6fr) minmax(70px, .4fr) minmax(110px, .55fr) 28px; align-items: center; gap: 10px; }
.ledger-labels { padding: 11px 18px; color: #a0a29e; font-size: 8px; border-bottom: 1px solid var(--line); }
.ledger-labels span:nth-child(4) { text-align: right; }
.ledger-row { min-height: 66px; padding: 10px 18px; border-bottom: 1px solid var(--line); font-size: 10px; }
.ledger-row:last-child { border-bottom: 0; }
.ledger-type { display: flex; align-items: center; gap: 11px; }
.ledger-type > span { width: 31px; height: 31px; border-radius: 9px; display: grid; place-items: center; font-size: 15px; }
.ledger-type > span.recharge { background: var(--sage-pale); color: var(--sage-dark); }
.ledger-type > span.purchase { background: var(--clay-pale); color: #9b7667; }
.ledger-type div { display: grid; gap: 5px; }
.ledger-type strong { font-size: 10px; }
.ledger-type small, .ledger-row time, .operator { color: var(--muted); font-size: 8px; }
.mobile-ledger-meta { display: none; }
.ledger-row > strong { text-align: right; font: 600 10px var(--font-geist-mono); }
.amount-in { color: var(--sage-dark); }
.amount-out { color: var(--ink); }
.more-button { border: 0; background: none; color: #aaa; letter-spacing: 1px; cursor: pointer; padding: 6px 0; }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(37,42,39,.24); backdrop-filter: blur(8px); display: grid; place-items: center; padding: 20px; animation: fade-in .18s ease; }
.modal { width: min(440px, 100%); background: #faf9f6; border: 1px solid rgba(255,255,255,.9); border-radius: 24px; padding: 31px; box-shadow: 0 30px 90px rgba(36,43,39,.18); position: relative; animation: rise .22s ease; }
.modal-close { position: absolute; right: 18px; top: 17px; width: 30px; height: 30px; border: 0; border-radius: 50%; background: #ecebe7; color: #777; cursor: pointer; font-size: 18px; }
.modal h3 { font-size: 23px; margin-bottom: 8px; letter-spacing: -.035em; }
.modal-intro { color: var(--muted); font-size: 10px; line-height: 1.6; margin-bottom: 25px; }
.modal label { display: grid; gap: 8px; font-size: 10px; font-weight: 580; margin-top: 15px; }
.modal input, .modal textarea { width: 100%; border: 1px solid var(--line); border-radius: 11px; background: white; padding: 12px 13px; color: var(--ink); resize: vertical; outline: 0; }
.modal input:focus, .modal textarea:focus { border-color: var(--sage); box-shadow: 0 0 0 3px rgba(126,145,133,.11); }
.money-input { position: relative; }
.money-input span { position: absolute; left: 14px; top: 13px; color: var(--muted); }
.money-input input { padding-left: 31px; font: 520 18px var(--font-geist-mono); }
.submit-button { width: 100%; border: 0; border-radius: 12px; color: white; background: var(--sage-dark); padding: 13px; margin-top: 24px; font-weight: 600; font-size: 11px; cursor: pointer; box-shadow: 0 8px 20px rgba(100,122,109,.2); }
.submit-button.consume { background: #8e7469; }
.submit-button:disabled { opacity: .55; cursor: wait; }
.confirmation-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 26px; }
.confirmation-actions button { border: 0; border-radius: 12px; padding: 13px; font-size: 11px; font-weight: 600; cursor: pointer; }
.cancel-button { background: #ebeae5; color: var(--ink); }
.danger-button { background: #9a7468; color: white; box-shadow: 0 8px 20px rgba(154,116,104,.18); }
.danger-button:disabled { opacity: .55; cursor: wait; }
.toast { position: fixed; z-index: 70; left: 50%; bottom: 28px; transform: translateX(-50%); background: #2f3531; color: white; border-radius: 999px; padding: 10px 16px; font-size: 10px; box-shadow: var(--shadow); animation: rise .22s ease; }
.status-card { max-width: 440px; margin: 16vh auto 0; background: white; border-radius: 20px; padding: 32px; text-align: center; box-shadow: var(--shadow); }
.status-card strong { font-size: 18px; }
.status-card p { color: var(--muted); font-size: 11px; margin: 10px 0 20px; }
.status-card button { border: 0; border-radius: 10px; padding: 10px 15px; background: var(--sage-dark); color: white; font-size: 10px; cursor: pointer; }
.loading-state { height: 60vh; display: flex; justify-content: center; align-items: center; gap: 7px; }
.loading-state span { width: 7px; height: 7px; border-radius: 50%; background: var(--sage); animation: pulse 1.2s infinite; }
.loading-state span:nth-child(2) { animation-delay: .15s; }.loading-state span:nth-child(3) { animation-delay: .3s; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 72% 15%, rgba(177,190,181,.34), transparent 34%), radial-gradient(circle at 13% 87%, rgba(192,160,146,.16), transparent 30%), var(--paper); }
.login-card { width: min(390px, 100%); background: rgba(255,255,255,.78); border: 1px solid rgba(255,255,255,.9); border-radius: 26px; padding: 38px; box-shadow: 0 30px 85px rgba(55,65,59,.13); backdrop-filter: blur(20px); }
.login-mark { width: 45px; height: 45px; border-radius: 14px; background: var(--sage-dark); color: white; display: grid; place-items: center; font: 21px Georgia, serif; box-shadow: 0 10px 24px rgba(100,122,109,.22); margin-bottom: 30px; }
.login-card h1 { font-size: 29px; margin: 0; letter-spacing: -.045em; }
.login-intro { color: var(--muted); font-size: 11px; margin: 9px 0 27px; }
.login-card label { display: grid; gap: 8px; font-size: 10px; font-weight: 580; margin-top: 16px; }
.login-card input { width: 100%; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.84); padding: 13px 14px; outline: 0; }
.login-card input:focus { border-color: var(--sage); box-shadow: 0 0 0 3px rgba(126,145,133,.11); }
.login-button { width: 100%; border: 0; border-radius: 12px; padding: 13px; background: var(--sage-dark); color: white; margin-top: 22px; font-size: 11px; font-weight: 600; cursor: pointer; box-shadow: 0 9px 22px rgba(100,122,109,.2); }
.login-button:disabled { opacity: .58; cursor: wait; }
.login-card > small { display: block; text-align: center; color: #aaa; font-size: 8px; margin-top: 16px; }
.login-error { color: #9a6258; background: #f2e5e1; border-radius: 9px; padding: 9px 11px; font-size: 9px; margin: 14px 0 -6px; }
@keyframes pulse { 50% { opacity: .25; transform: translateY(-4px); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(7px); } }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 270px minmax(0, 1fr); }
  .content-panel { padding: 34px 25px 50px; }
  .balance-card { align-items: flex-start; gap: 28px; flex-direction: column; }
  .balance-actions { width: 100%; }
  .balance-actions button { min-width: 0; }
  .ledger-labels { display: none; }
  .ledger-row { grid-template-columns: 1fr auto 28px; }
  .ledger-row time, .ledger-row .operator { display: none; }
}

@media (max-width: 680px) {
  .topbar { padding: 0 18px; height: 66px; }
  .brand-copy span { display: none; }
  .account-label { display: none; }
  .account-menu { position: fixed; top: 58px; right: 12px; width: min(270px, calc(100vw - 24px)); }
  .account-menu-item { min-height: 52px; }
  .workspace { display: block; }
  .member-panel { border: 0; min-height: auto; padding: 23px 18px 10px; }
  .panel-heading h1 { font-size: 24px; }
  .search-box { margin: 20px 0 14px; height: 46px; }
  .member-list { display: flex; overflow-x: auto; max-height: none; margin-right: -18px; }
  .member-row { min-width: 215px; min-height: 64px; background: rgba(255,255,255,.5); }
  .side-summary, .member-count { display: none; }
  .content-panel { padding: 22px 18px max(45px, env(safe-area-inset-bottom)); }
  .daily-overview { grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 28px; }
  .overview-card { padding: 15px; }
  .overview-card.balance { grid-column: 1 / -1; }
  .overview-card strong { font-size: 17px; }
  .profile-header { align-items: flex-start; gap: 16px; flex-direction: column; }
  .profile-actions { width: 100%; }
  .profile-actions button { min-height: 42px; flex: 1; }
  .profile-title h2 { font-size: 27px; }
  .balance-card { padding: 27px 24px; border-radius: 19px; }
  .balance-info > strong { font-size: 35px; }
  .balance-actions { grid-template-columns: 1fr; }
  .balance-actions button { min-height: 62px; }
  .metrics-grid { grid-template-columns: 1fr 1fr; overflow-x: auto; }
  .metric { min-width: 145px; }
  .metrics-grid .metric:last-child { display: none; }
  .ledger-header { align-items: stretch; gap: 14px; flex-direction: column; }
  .ledger-tools { justify-content: space-between; }
  .export-button { min-height: 40px; display: inline-flex; align-items: center; padding: 0 14px; }
  .segment-control button { min-height: 34px; padding-inline: 13px; }
  .ledger-row { padding: 11px 12px; min-height: 70px; }
  .ledger-row > strong { font-size: 9px; }
  .mobile-ledger-meta { display: block; }
  .modal-backdrop { inset: auto 0 0; top: var(--visible-viewport-top, 0px); height: var(--visible-viewport-height, 100dvh); align-items: end; padding: 12px; overflow: hidden; }
  .modal { padding: 27px 23px max(24px, env(safe-area-inset-bottom)); border-radius: 20px; max-height: calc(var(--visible-viewport-height, 100dvh) - 24px); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .modal input, .modal textarea { scroll-margin-block: 100px; }
  .modal input, .modal textarea, .submit-button, .confirmation-actions button { min-height: 46px; font-size: 16px; }
  .modal label, .modal-intro { font-size: 11px; }
}

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