:root{
  --bg:#f3f4f8;
  --card:#ffffff;
  --border:#e5e7eb;
  --text:#0f172a;
  --muted:#64748b;
  --green:#22c55e;
  --green-dark:#16a34a;
  --red:#ef4444;
  --navy:#1e1b4b;
  --navy-2:#334155;
  --black:#0b0f19;
  --radius:20px;
}

*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  background:var(--bg);
  color:var(--text);
  -webkit-font-smoothing:antialiased;
}

#app{
  max-width:480px;
  margin:0 auto;
  min-height:100vh;
  background:var(--bg);
  display:flex;
  flex-direction:column;
  position:relative;
}

/* Header */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:18px 20px 14px;
  background:var(--bg);
}
.topbar-left{
  display:flex;
  align-items:center;
  gap:10px;
}
.topbar-icon{
  width:22px;height:22px;color:var(--text);
}
.topbar h1{
  font-size:20px;
  font-weight:800;
  margin:0;
  letter-spacing:-0.3px;
}
.avatar{
  width:38px;height:38px;border-radius:50%;
  object-fit:cover;
  border:2px solid #fff;
  box-shadow:0 0 0 1px var(--border);
  background:#ddd;
}

/* Main scroll area */
main{
  flex:1;
  overflow-y:auto;
  padding:0 20px 100px;
}

.page-title{
  font-size:28px;
  font-weight:800;
  margin:6px 0 4px;
  letter-spacing:-0.5px;
}
.page-sub{
  color:var(--muted);
  font-size:14.5px;
  margin:0 0 20px;
  line-height:1.4;
}

/* Cards */
.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:20px;
  margin-bottom:16px;
}

.card-hero{
  border-top:3px solid var(--green);
  position:relative;
  overflow:hidden;
}
.hero-icon{
  position:absolute;
  right:16px;
  top:10px;
  width:70px;height:70px;
  color:#e2e8f0;
  opacity:.7;
}
.hero-avatars{
  display:flex;
  gap:0;
  margin-bottom:10px;
}
.mini-avatar{
  width:26px;height:26px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  font-size:11px;font-weight:700;color:#fff;
  background:#94a3b8;
  border:2px solid #fff;
  margin-left:-8px;
}
.mini-avatar:first-child{margin-left:0;}
.mini-avatar.m{background:#6366f1;}
.mini-avatar.s{background:#ec4899;}

.card-label{
  display:flex;
  align-items:center;
  gap:8px;
  color:var(--muted);
  font-size:13.5px;
  font-weight:600;
  margin-bottom:6px;
}
.card-label svg{width:16px;height:16px;}

.card-amount{
  font-size:36px;
  font-weight:800;
  letter-spacing:-1px;
  margin:2px 0 18px;
}
.card-amount.sm{font-size:28px;margin-bottom:6px;}

.hero-actions{
  display:flex;
  gap:10px;
}
.btn{
  border:none;
  border-radius:14px;
  padding:14px 16px;
  font-size:15px;
  font-weight:700;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  cursor:pointer;
  flex:1;
  font-family:inherit;
}
.btn svg{width:18px;height:18px;}
.btn-black{background:var(--black);color:#fff;}
.btn-black:active{opacity:.85;}
.btn-outline{background:#fff;color:var(--text);border:1.5px solid #d1d5db;}

.trend{
  font-size:13px;
  font-weight:600;
  display:flex;
  align-items:center;
  gap:5px;
}
.trend.up{color:var(--green-dark);}
.trend.flat{color:var(--muted);}

.person-icon{
  width:34px;height:34px;
  border-radius:50%;
  background:#e0e7ff;
  color:#6366f1;
  display:flex;align-items:center;justify-content:center;
  margin-bottom:10px;
}
.person-icon svg{width:18px;height:18px;}

/* Recent activity */
.section-title{
  font-size:20px;
  font-weight:800;
  margin-bottom:14px;
}
.activity-row{
  display:flex;
  align-items:center;
  gap:12px;
  padding:12px 0;
  border-bottom:1px solid #f1f5f9;
}
.activity-row:last-of-type{border-bottom:none;}
.activity-icon{
  width:42px;height:42px;
  border-radius:12px;
  display:flex;align-items:center;justify-content:center;
  flex-shrink:0;
  position:relative;
}
.activity-icon svg{width:20px;height:20px;color:#fff;}
.activity-icon .badge{
  position:absolute;
  bottom:-4px;right:-4px;
  width:16px;height:16px;
  border-radius:50%;
  background:#475569;
  border:2px solid #fff;
  display:flex;align-items:center;justify-content:center;
}
.activity-icon .badge svg{width:9px;height:9px;color:#fff;}
.activity-info{flex:1;min-width:0;}
.activity-name{font-weight:700;font-size:15px;}
.activity-meta{color:var(--muted);font-size:13px;margin-top:1px;}
.activity-amount{font-weight:700;font-size:15px;white-space:nowrap;}
.activity-amount.neg{color:var(--red);}
.activity-amount.pos{color:var(--green-dark);}

.view-all{
  display:block;
  text-align:center;
  padding:14px;
  color:var(--muted);
  font-weight:600;
  font-size:14.5px;
  text-decoration:none;
  cursor:pointer;
}

/* Chart */
.chart-legend{
  display:flex;
  gap:16px;
  align-items:center;
}
.legend-item{
  display:flex;align-items:center;gap:6px;
  font-size:13px;color:var(--muted);font-weight:600;
}
.legend-dot{width:9px;height:9px;border-radius:50%;}
.chart-header{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  margin-bottom:24px;
}
.chart-wrap{
  display:flex;
  align-items:flex-end;
  gap:14px;
  height:180px;
  padding-left:34px;
  position:relative;
}
.chart-yaxis{
  position:absolute;
  left:0;top:0;bottom:0;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
  color:var(--muted);
  font-size:12px;
  padding:0 0 0 0;
}
.bar-col{
  flex:1;
  display:flex;
  flex-direction:column;
  justify-content:flex-end;
  align-items:center;
  height:100%;
}
.bar{
  width:100%;
  max-width:34px;
  border-radius:6px 6px 0 0;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}
.bar .joint{background:var(--navy);}
.bar .personal{background:var(--navy-2);}
.bar-label{margin-top:8px;font-size:12px;color:var(--muted);font-weight:600;}

/* Toggle */
.toggle-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
}
.toggle-title{font-weight:700;font-size:15.5px;}
.toggle-sub{color:var(--muted);font-size:13px;margin-top:2px;}
.switch{
  position:relative;
  width:52px;height:30px;
  background:#e2e8f0;
  border-radius:999px;
  cursor:pointer;
  flex-shrink:0;
  transition:background .2s;
}
.switch.on{background:var(--black);}
.switch-knob{
  position:absolute;
  top:3px;left:3px;
  width:24px;height:24px;
  border-radius:50%;
  background:#fff;
  display:flex;align-items:center;justify-content:center;
  transition:left .2s;
  box-shadow:0 1px 3px rgba(0,0,0,.3);
}
.switch.on .switch-knob{left:25px;}
.switch-knob svg{width:12px;height:12px;color:var(--black);}

/* Category grid */
.field-label{
  font-weight:700;
  font-size:15px;
  margin:22px 0 12px;
}
.category-scroll{
  display:flex;
  gap:10px;
  overflow-x:auto;
  padding-bottom:4px;
  scrollbar-width:none;
}
.category-scroll::-webkit-scrollbar{display:none;}
.cat-btn{
  flex:0 0 auto;
  width:84px;
  padding:16px 8px;
  border-radius:16px;
  border:1.5px solid var(--border);
  background:#fff;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:8px;
  font-size:12.5px;
  font-weight:700;
  color:var(--text);
  cursor:pointer;
}
.cat-btn svg{width:22px;height:22px;}
.cat-btn.active{
  background:var(--green);
  border-color:var(--green);
  color:#052e16;
}

.input-field{
  width:100%;
  padding:14px 16px;
  border:1.5px solid var(--border);
  border-radius:14px;
  background:#fff;
  font-size:15px;
  font-family:inherit;
  color:var(--text);
  display:flex;
  align-items:center;
  gap:10px;
}
.input-field input, .input-field select{
  border:none;outline:none;flex:1;font-size:15px;font-family:inherit;background:transparent;color:var(--text);
}
.input-field svg{width:18px;height:18px;color:var(--muted);flex-shrink:0;}

.payer-row{display:flex;gap:12px;}
.payer-btn{
  flex:1;
  display:flex;
  align-items:center;
  gap:10px;
  padding:14px;
  border-radius:16px;
  border:1.5px solid var(--border);
  background:#fff;
  cursor:pointer;
  font-weight:700;
  font-size:14.5px;
}
.payer-btn.active{
  border-color:#6366f1;
  background:#eef2ff;
}
.payer-avatar{
  width:32px;height:32px;border-radius:50%;
  background:#cbd5e1;
  display:flex;align-items:center;justify-content:center;
  font-size:13px;font-weight:700;color:#fff;
  overflow:hidden;
}

.amount-card{
  background:#fff;
  border:1.5px solid var(--border);
  border-radius:18px;
  padding:26px 20px;
  text-align:center;
  margin-top:22px;
}
.amount-card .label{color:var(--muted);font-size:13px;font-weight:600;margin-bottom:4px;}
.amount-display{
  font-size:44px;
  font-weight:800;
  display:flex;
  justify-content:center;
  align-items:baseline;
  gap:4px;
}
.amount-display .cur{color:var(--muted);font-size:26px;}

.keypad{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:10px;
  background:#eef0f6;
  border-radius:18px;
  padding:14px;
  margin-top:16px;
}
.key{
  background:transparent;
  border:none;
  padding:16px;
  font-size:22px;
  font-weight:600;
  border-radius:12px;
  cursor:pointer;
  color:var(--text);
  font-family:inherit;
}
.key:active{background:#dfe2ec;}
.key svg{width:20px;height:20px;}

.save-btn{
  width:100%;
  margin-top:18px;
  padding:17px;
  background:var(--black);
  color:#fff;
  border:none;
  border-radius:16px;
  font-size:16px;
  font-weight:700;
  display:flex;align-items:center;justify-content:center;gap:8px;
  cursor:pointer;
}
.save-btn svg{width:18px;height:18px;}

/* Family / budget */
.progress-track{
  width:100%;
  height:10px;
  background:#e2e8f0;
  border-radius:999px;
  overflow:hidden;
  margin:14px 0 10px;
}
.progress-fill{
  height:100%;
  background:linear-gradient(90deg,#818cf8,#4338ca);
  border-radius:999px;
}
.progress-labels{
  display:flex;
  justify-content:space-between;
  font-size:13px;
  color:var(--muted);
  font-weight:600;
}
.category-dots{
  display:flex;
  gap:18px;
  margin-top:16px;
  flex-wrap:wrap;
}
.dot-item{display:flex;align-items:center;gap:6px;font-size:12.5px;font-weight:600;color:var(--muted);}

.person-row{
  display:flex;
  align-items:center;
  gap:14px;
  padding:12px 0;
}
.person-row-avatar{
  width:46px;height:46px;border-radius:50%;
  object-fit:cover;
  background:#e2e8f0;
}
.person-row-info{flex:1;}
.person-row-name{font-weight:700;font-size:15px;}
.person-row-sub{color:var(--muted);font-size:13px;margin-top:1px;}
.ring{
  position:relative;
  width:44px;height:44px;
}
.ring svg{transform:rotate(-90deg);width:44px;height:44px;}
.ring-text{
  position:absolute;inset:0;
  display:flex;align-items:center;justify-content:center;
  font-size:11px;font-weight:800;
}

/* Filter pills (history) */
.pill-row{
  display:flex;
  gap:8px;
  overflow-x:auto;
  padding-bottom:6px;
  margin-bottom:18px;
  scrollbar-width:none;
}
.pill-row::-webkit-scrollbar{display:none;}
.pill{
  flex:0 0 auto;
  padding:10px 18px;
  border-radius:999px;
  background:#fff;
  border:1px solid var(--border);
  font-size:13.5px;
  font-weight:700;
  color:var(--text);
  cursor:pointer;
  white-space:nowrap;
}
.pill.active{background:var(--black);color:#fff;border-color:var(--black);}

.date-heading{
  color:var(--muted);
  font-size:12.5px;
  font-weight:700;
  letter-spacing:.5px;
  text-transform:uppercase;
  margin:18px 0 10px;
}
.tx-card{
  background:#fff;
  border:1px solid var(--border);
  border-radius:18px;
  padding:16px;
  display:flex;
  align-items:center;
  gap:14px;
  margin-bottom:10px;
}
.tx-tag{
  display:inline-flex;
  align-items:center;
  gap:4px;
  background:#eef2ff;
  color:#4338ca;
  font-size:11.5px;
  font-weight:700;
  padding:2px 8px;
  border-radius:999px;
}
.tx-tag.personal{background:#f1f5f9;color:#334155;}
.tx-tag .dot{width:6px;height:6px;border-radius:50%;background:currentColor;}
.tx-right{text-align:right;flex-shrink:0;}
.tx-payer{color:var(--muted);font-size:12.5px;margin-top:2px;}
.tx-actions{display:flex;gap:8px;margin-top:8px;}
.tx-action-btn{
  background:none;
  border:none;
  color:#cbd5e1;
  cursor:pointer;
  padding:2px;
  display:flex;
}
.tx-action-btn svg{width:15px;height:15px;}
.tx-action-btn:hover{color:var(--text);}

.empty-space{height:20px;}

/* Bottom nav */
nav.bottom-nav{
  position:sticky;
  bottom:0;
  left:0;right:0;
  background:#fff;
  border-top:1px solid var(--border);
  display:flex;
  padding:8px 6px calc(8px + env(safe-area-inset-bottom));
  max-width:480px;
  margin:0 auto;
  width:100%;
}
.nav-item{
  flex:1;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:3px;
  padding:6px 2px;
  color:var(--muted);
  text-decoration:none;
  font-size:11px;
  font-weight:600;
  cursor:pointer;
  background:none;
  border:none;
  font-family:inherit;
}
.nav-item svg{width:22px;height:22px;}
.nav-item.active{color:var(--text);}
.nav-item.center .nav-icon-wrap{
  width:44px;height:44px;
  border-radius:50%;
  background:var(--black);
  color:#fff;
  display:flex;align-items:center;justify-content:center;
  margin-top:-22px;
  box-shadow:0 4px 10px rgba(0,0,0,.25);
}
.nav-item.center.active .nav-icon-wrap{background:var(--green);color:#052e16;}

.page{display:none;}
.page.active{display:block;}
.view{display:none;}

.login-wrap{
  min-height:100vh;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  padding:32px;
  text-align:center;
}
.login-wrap .logo{
  width:64px;height:64px;
  border-radius:20px;
  background:var(--black);
  color:#fff;
  display:flex;align-items:center;justify-content:center;
  margin-bottom:20px;
}
.login-wrap .logo svg{width:32px;height:32px;}
.login-wrap h1{font-size:24px;font-weight:800;margin:0 0 6px;}
.login-wrap p{color:var(--muted);font-size:14.5px;margin:0 0 28px;}
.login-form{width:100%;max-width:340px;display:flex;flex-direction:column;gap:12px;}
.login-error{color:var(--red);font-size:13px;font-weight:600;min-height:18px;}

.lang-switcher{margin-bottom:6px;}
.login-wrap .lang-switcher{align-self:flex-end;width:100%;display:flex;justify-content:flex-end;margin-bottom:10px;}

.lang-dd{position:relative;}
.lang-dd-toggle{
  display:flex;
  align-items:center;
  gap:7px;
  border:1.5px solid var(--border);
  background:#fff;
  border-radius:999px;
  padding:6px 10px 6px 6px;
  font-size:12.5px;
  font-weight:700;
  color:var(--text);
  font-family:inherit;
  cursor:pointer;
  letter-spacing:0.3px;
}
.lang-dd-toggle:hover{border-color:#c7cbd4;}
.lang-dd.open .lang-dd-toggle{border-color:var(--text);}
.lang-flag{
  width:20px;height:20px;
  border-radius:50%;
  overflow:hidden;
  flex-shrink:0;
  display:block;
  box-shadow:0 0 0 1px rgba(0,0,0,.06);
}
.lang-flag svg{width:100%;height:100%;display:block;}
.lang-dd-chevron{width:13px;height:13px;color:var(--muted);transition:transform .15s;}
.lang-dd.open .lang-dd-chevron{transform:rotate(180deg);}

.lang-dd-menu{
  position:absolute;
  top:calc(100% + 8px);
  right:0;
  min-width:190px;
  background:#fff;
  border:1px solid var(--border);
  border-radius:16px;
  box-shadow:0 12px 28px rgba(15,23,42,.14);
  padding:6px;
  display:flex;
  flex-direction:column;
  gap:2px;
  opacity:0;
  visibility:hidden;
  transform:translateY(-6px);
  transition:opacity .15s, transform .15s, visibility .15s;
  z-index:50;
}
.lang-dd.open .lang-dd-menu{
  opacity:1;
  visibility:visible;
  transform:translateY(0);
}
.lang-dd-item{
  display:flex;
  align-items:center;
  gap:10px;
  padding:9px 10px;
  border-radius:10px;
  border:none;
  background:none;
  font-family:inherit;
  font-size:14px;
  font-weight:600;
  color:var(--text);
  text-align:left;
  cursor:pointer;
}
.lang-dd-item:hover{background:#f1f3f8;}
.lang-dd-item.active{background:#ecfdf3;color:var(--green-dark);}
.lang-dd-item.active .lang-flag{box-shadow:0 0 0 2px var(--green);}

/* Month navigator */
.month-nav{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin:4px 0 16px;
}
.month-nav-btn{
  width:38px;height:38px;
  border-radius:12px;
  border:1.5px solid var(--border);
  background:#fff;
  display:flex;align-items:center;justify-content:center;
  cursor:pointer;
  color:var(--text);
}
.month-nav-btn svg{width:18px;height:18px;}
.month-nav-label{font-size:16px;font-weight:800;}

/* Joint/split summary */
.split-row{
  display:flex;
  justify-content:space-between;
  gap:8px;
  margin:6px 0 14px;
}
.split-row > div{flex:1;text-align:center;}
.split-num{font-size:17px;font-weight:800;letter-spacing:-0.3px;}
.split-cap{font-size:11.5px;color:var(--muted);font-weight:600;margin-top:2px;}

.member-summary-card{
  background:#fff;
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:16px 20px;
  margin-bottom:16px;
}
.member-summary-head{
  display:flex;
  align-items:center;
  gap:10px;
  margin-bottom:10px;
}
.member-summary-avatar{
  width:30px;height:30px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  color:#fff;font-weight:700;font-size:12.5px;flex-shrink:0;
}
.member-summary-name{font-weight:700;font-size:14.5px;}

/* Bill cards */
.bill-card{
  background:#fff;
  border:1px solid var(--border);
  border-radius:18px;
  padding:14px 16px;
  display:flex;
  align-items:flex-start;
  gap:12px;
  margin-bottom:10px;
}
.bill-card.paid{opacity:.6;}
.bill-check{
  width:24px;height:24px;
  border-radius:50%;
  border:2px solid #cbd5e1;
  flex-shrink:0;
  margin-top:2px;
  display:flex;align-items:center;justify-content:center;
  cursor:pointer;
  background:#fff;
}
.bill-check svg{width:14px;height:14px;color:#fff;opacity:0;}
.bill-check.checked{background:var(--green);border-color:var(--green);}
.bill-check.checked svg{opacity:1;}
.bill-day{
  width:42px;height:42px;
  border-radius:12px;
  background:#f1f3f8;
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  flex-shrink:0;
  font-weight:800;
  font-size:15px;
  line-height:1;
}
.bill-day span{font-size:9px;font-weight:700;color:var(--muted);text-transform:uppercase;margin-top:2px;}
.bill-info{flex:1;min-width:0;}
.bill-name{font-weight:700;font-size:15px;}
.bill-recurring-badge{
  display:inline-flex;
  width:16px;height:16px;
  color:#6366f1;
  vertical-align:-3px;
  cursor:pointer;
}
.bill-recurring-badge svg{width:100%;height:100%;}
.bill-card.paid .bill-name{text-decoration:line-through;}
.bill-meta{color:var(--muted);font-size:12.5px;margin-top:2px;}
.bill-shares{display:flex;gap:10px;margin-top:6px;flex-wrap:wrap;}
.bill-share-chip{
  font-size:11.5px;
  font-weight:600;
  background:#f1f3f8;
  border-radius:999px;
  padding:3px 9px;
  color:var(--text);
}
.bill-right{text-align:right;flex-shrink:0;display:flex;flex-direction:column;align-items:flex-end;gap:6px;}
.bill-amount{font-weight:800;font-size:15.5px;}
.bill-delete{
  background:none;border:none;color:#cbd5e1;cursor:pointer;padding:2px;
}
.bill-delete svg{width:16px;height:16px;}
.bill-delete:hover{color:var(--red);}

.share-input-row{
  display:flex;
  align-items:center;
  gap:10px;
  margin-bottom:10px;
}
.share-input-row .share-avatar{
  width:32px;height:32px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  color:#fff;font-weight:700;font-size:12.5px;flex-shrink:0;
}
.share-input-row .input-field{flex:1;margin:0;}

/* Income comparison */
.income-row{margin-bottom:16px;}
.income-row:last-child{margin-bottom:0;}
.income-row-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:6px;
}
.income-row-left{
  display:flex;
  align-items:center;
  gap:8px;
}
.income-row-avatar{
  width:26px;height:26px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  color:#fff;font-weight:700;font-size:11px;flex-shrink:0;
}
.income-row-name{font-weight:700;font-size:14px;}
.income-row-day{font-size:11.5px;color:var(--muted);font-weight:600;margin-top:1px;}
.income-row-amount{
  display:flex;
  align-items:center;
  gap:6px;
  font-weight:800;
  font-size:15px;
}
.income-edit-btn{
  background:none;
  border:none;
  color:var(--muted);
  cursor:pointer;
  padding:2px;
  display:flex;
}
.income-edit-btn svg{width:15px;height:15px;}
.income-edit-btn:hover{color:var(--text);}
.income-bar-track{
  width:100%;
  height:10px;
  background:#eef0f6;
  border-radius:999px;
  overflow:hidden;
}
.income-bar-fill{
  height:100%;
  border-radius:999px;
}
