:root{
  color-scheme: dark;
  --bg:#0A0A0C;
  --surface:#131316;
  --surface-alt:#18181C;
  --border:rgba(255,255,255,0.07);
  --border-strong:rgba(255,255,255,0.14);
  --text:#F5F5F7;
  --text-muted:#8B8B93;
  --accent:#6D5DFC;
  --accent-soft:rgba(109,93,252,0.16);
  --income:#22C55E;
  --expense:#FF5C7A;
  --shadow: 0 24px 60px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.4);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
}
*{ box-sizing:border-box; }
html{ color-scheme:dark; background:var(--bg) !important; height:100%; }
/* App-like feel: scrolling only, no pinch or double-tap zoom. */
html{ touch-action:pan-x pan-y; -webkit-text-size-adjust:100%; text-size-adjust:100%; }
body{
  margin:0; min-height:100vh; background:var(--bg) !important;
  font-family: var(--font); color:var(--text); -webkit-font-smoothing:antialiased;
}
*:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; }
button{ font-family:var(--font); }

.shell{ display:flex; min-height:100vh; width:100%; }

/* ---------- sidebar ---------- */
.sidebar{
  width:248px; flex-shrink:0; padding:20px 16px;
  display:flex; flex-direction:column; gap:22px;
  border-right:1px solid var(--border);
  opacity:0; animation:slideIn .5s ease-out forwards;
}
@keyframes slideIn{ from{ opacity:0; transform:translateX(-8px);} to{ opacity:1; transform:translateX(0);} }

.workspace{ display:flex; align-items:center; gap:10px; padding:10px; border-radius:12px; border:1px solid var(--border); background:var(--surface); }
.workspace .mark{ width:34px; height:34px; border-radius:9px; flex-shrink:0; background:linear-gradient(135deg, var(--accent), #4A3ACB); display:flex; align-items:center; justify-content:center; font-weight:800; font-size:1rem; }
.workspace .meta{ flex:1; min-width:0; }
.workspace .meta .name{ font-weight:700; font-size:0.92rem; line-height:1.2; }
.workspace .meta .sub{ font-size:0.74rem; color:var(--text-muted); }
.workspace .caret{ color:var(--text-muted); font-size:0.8rem; opacity:0.7; }

nav.navlist{ display:flex; flex-direction:column; gap:2px; }
.navitem{ display:flex; align-items:center; gap:11px; padding:9px 10px; border-radius:9px; cursor:pointer; color:var(--text-muted); font-size:0.89rem; font-weight:500; }
.navitem .ic{ width:17px; text-align:center; opacity:0.9; font-size:0.95rem; }
.navitem .badge{ margin-left:auto; font-size:0.7rem; font-weight:700; color:#0B0C10; background:var(--income); border-radius:999px; padding:1px 7px; }
.navitem:hover{ color:var(--text); background:rgba(255,255,255,0.04); }
.navitem.active{ color:var(--text); background:var(--surface); }

.tipcard{ margin-top:auto; background:var(--surface); border:1px solid var(--border); border-radius:14px; padding:16px; position:relative; }
.tipcard .tag{ display:inline-block; font-size:0.65rem; font-weight:700; color:#0B0C10; background:var(--income); border-radius:999px; padding:2px 8px; margin-bottom:10px; }
.tipcard .x{ position:absolute; top:12px; right:12px; background:none; border:none; color:var(--text-muted); cursor:pointer; font-size:0.9rem; }
.tipcard .x:hover{ color:var(--text); }
.tipcard h4{ margin:0 0 6px; font-size:0.88rem; font-weight:700; }
.tipcard p{ margin:0 0 12px; font-size:0.78rem; color:var(--text-muted); line-height:1.45; }
.tipcard .try{ display:inline-flex; align-items:center; gap:5px; font-size:0.78rem; font-weight:600; background:var(--surface-alt); border:1px solid var(--border-strong); color:var(--text); padding:7px 12px; border-radius:9px; cursor:pointer; }
.tipcard .try:hover{ background:#1E1E24; }

.footnav{ display:flex; flex-direction:column; gap:2px; }

@media (max-width:760px){
  .shell{ flex-direction:column; }
  .sidebar{ display:none; }
  main{ padding:18px 16px calc(32px + env(safe-area-inset-bottom)); }
  .topbar{ margin-bottom:14px; }
  h2.pagehead{ font-size:1.28rem; }
  .card{ padding:18px 16px 16px; border-radius:14px; }
  .kpi-inline{ gap:8px; }
  .pillbadge{ padding:7px 12px; font-size:0.82rem; }
  .toolbar{ gap:10px; }
  .rangepick input[type=date]{ width:auto; flex:1; min-width:0; }
  .modal{ padding:22px 18px; max-width:calc(100% - 24px); }
  .card-head{ flex-wrap:wrap; gap:8px; }
  .btn-cta{ padding:9px 14px; font-size:0.82rem; }
  .kpi-inline .pillbadge b{ font-size:0.95em; }
}

/* ---------- main ---------- */
main{ flex:1; padding:30px 34px 90px; min-width:0; max-width:1500px; }

.topbar{ display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:18px; flex-wrap:wrap; }
.titlewrap{ display:flex; align-items:center; gap:8px; }
h2.pagehead{ font-weight:800; font-size:1.45rem; margin:0; letter-spacing:-0.02em; }
.caret-deco{ color:var(--text-muted); font-size:0.85rem; opacity:0.6; }
.btn-cta{ display:inline-flex; align-items:center; gap:7px; padding:10px 18px; border-radius:10px; border:none; background:var(--text); color:#0B0C10; font-weight:700; font-size:0.86rem; cursor:pointer; }
.btn-cta:hover{ background:#DADADF; }

.toolbar{ display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:20px; flex-wrap:wrap; }
.searchbox{ position:relative; max-width:280px; flex:1; min-width:180px; }
.searchbox input{ width:100%; padding:9px 14px 9px 36px !important; font-size:0.85rem; border:1px solid var(--border-strong); border-radius:9px; background:var(--surface); color:var(--text); font-family:var(--font); }
.searchbox .ic{ position:absolute; left:12px; top:50%; transform:translateY(-50%); width:16px; text-align:center; line-height:1; color:var(--text-muted); font-size:0.8rem; pointer-events:none; }

.rangepick{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.rangepick input[type=date]{ width:150px; padding:8px 10px; font-size:0.82rem; }
.rangepick .sep{ color:var(--text-muted); font-size:0.85rem; }

.segmented{ display:inline-flex; background:var(--surface); border:1px solid var(--border-strong); border-radius:9px; padding:3px; gap:2px; }
.seg-btn{ border:none; background:transparent; color:var(--text-muted); padding:6px 12px; border-radius:7px; font-size:0.8rem; font-weight:600; cursor:pointer; }
.seg-btn.active{ background:var(--surface-alt); color:var(--text); }

p.pagesub{ margin:-8px 0 20px; color:var(--text-muted); font-size:0.88rem; }

.kpi-inline{ display:flex; gap:10px; flex-wrap:wrap; margin-bottom:22px; }
.pillbadge{ display:inline-flex; align-items:center; gap:8px; padding:8px 15px; border-radius:999px; border:1px solid var(--border-strong); background:var(--surface); font-size:0.86rem; font-variant-numeric:tabular-nums; }
.pillbadge .swdot{ width:7px; height:7px; border-radius:50%; flex-shrink:0; }
.pillbadge b{ font-weight:700; }
.pillbadge.small{ padding:5px 11px; font-size:0.8rem; }
.pillbadge .chev{ opacity:0.45; font-size:0.72rem; margin-left:1px; }

.card{ background:var(--surface); border:1px solid var(--border); border-radius:18px; padding:22px 22px 18px; margin-bottom:18px; }
.card-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; }
.card-head h3{ margin:0; font-size:0.95rem; font-weight:700; }
.month-nav-btn{
  width:28px; height:28px; border-radius:50%; border:1px solid var(--border-strong);
  background:var(--surface-alt); color:var(--text); font-size:1rem; line-height:1;
  cursor:pointer; display:flex; align-items:center; justify-content:center;
}
.month-nav-btn:hover:not(:disabled){ background:var(--accent); border-color:var(--accent); color:#fff; }
.month-nav-btn:disabled{ opacity:0.3; cursor:default; }
.bignum-label{ font-size:0.78rem; color:var(--text-muted); margin-bottom:4px; }
.bignum{ font-size:1.7rem; font-weight:800; letter-spacing:-0.01em; margin-bottom:16px; font-variant-numeric:tabular-nums; }

.grid2{ display:grid; grid-template-columns:1.3fr 1fr; gap:18px; }
@media (max-width:900px){ .grid2{ grid-template-columns:1fr; } }

/* glowing dot */
.glowdot{ border-radius:50%; flex-shrink:0; }

/* forms */
label.field{ display:block; margin-bottom:16px; }
label.field span{ display:block; font-size:0.78rem; color:var(--text-muted); margin-bottom:6px; }
input[type=text], input[type=number], input[type=date], input[type=password], select{
  width:100%; padding:10px 12px; font-size:0.9rem; border:1px solid var(--border-strong); border-radius:9px;
  background:var(--surface-alt); color:var(--text); font-family:var(--font);
}
input::placeholder{ color:#5C5C64; }
.hint{ font-size:0.76rem; color:var(--text-muted); margin-top:-10px; margin-bottom:16px; }
.readonlynote{
  padding:9px 12px; border-radius:9px; background:var(--surface-alt); border:1px solid var(--border);
  font-size:0.83rem; color:var(--text-muted); margin-bottom:16px;
}

.kindrow{ display:flex; gap:8px; }
.kindbtn{ flex:1; padding:10px; border-radius:9px; border:1px solid var(--border-strong); background:var(--surface-alt); cursor:pointer; font-size:0.84rem; font-weight:500; color:var(--text-muted); text-align:center; }
.kindbtn.selected.income{ background:rgba(34,197,94,0.14); border-color:var(--income); color:var(--income); }
.kindbtn.selected.expense{ background:rgba(255,92,122,0.14); border-color:var(--expense); color:var(--expense); }

.swatches{ display:flex; flex-wrap:wrap; gap:8px; }
.swatch{ width:26px; height:26px; border-radius:50%; cursor:pointer; border:2px solid transparent; }
.swatch.selected{ border-color:var(--text); }

.btn{ display:inline-block; padding:10px 20px; border-radius:9px; border:none; background:var(--accent); color:#fff; font-weight:700; font-size:0.86rem; cursor:pointer; font-family:var(--font); }
.btn:hover{ background:#7D6EFF; }
.btn.ghost{ background:transparent; color:var(--text-muted); border:1px solid var(--border-strong); }
.btn.ghost:hover{ color:var(--text); border-color:var(--text-muted); }
.btn.small{ padding:6px 13px; font-size:0.78rem; }

.catgroup{ margin-bottom:6px; }
.catrow{ display:flex; align-items:center; gap:12px; padding:11px 0; border-bottom:1px solid var(--border); }
.catrow.sub{ padding-left:26px; }
.catgroup:last-child .catrow:last-child{ border-bottom:none; }
.catrow .name{ flex:1; font-weight:500; font-size:0.9rem; }
.catrow .kindlabel{ font-size:0.68rem; color:var(--text-muted); text-transform:uppercase; letter-spacing:0.05em; background:var(--surface-alt); padding:3px 8px; border-radius:999px; }
.catrow .budgetlabel{ text-transform:none; letter-spacing:0; color:var(--text); font-variant-numeric:tabular-nums; }
.catrow .iconbtn{ background:none; border:none; color:var(--text-muted); cursor:pointer; font-size:0.9rem; padding:4px 6px; }
.catrow .iconbtn:hover{ color:var(--text); }
.catrow .iconbtn.danger:hover{ color:var(--expense); }
.addsubbtn{ background:none; border:1px dashed var(--border-strong); color:var(--text-muted); cursor:pointer; font-size:0.76rem; padding:6px 11px; border-radius:8px; margin:6px 0 4px 26px; }
.addsubbtn:hover{ color:var(--text); border-color:var(--text-muted); }

.empty{ text-align:center; padding:50px 20px; color:var(--text-muted); }
.empty .big{ font-weight:700; font-size:1.05rem; color:var(--text); margin-bottom:6px; }

/* table */
.table-wrap{ overflow-x:auto; }
.table-wrap::-webkit-scrollbar, .chartwrap::-webkit-scrollbar{ height:8px; }
.table-wrap::-webkit-scrollbar-track, .chartwrap::-webkit-scrollbar-track{ background:var(--surface); border-radius:8px; }
.table-wrap::-webkit-scrollbar-thumb, .chartwrap::-webkit-scrollbar-thumb{ background:var(--border-strong); border-radius:8px; }
.table-wrap::-webkit-scrollbar-thumb:hover, .chartwrap::-webkit-scrollbar-thumb:hover{ background:var(--accent); }
.table-wrap, .chartwrap{ scrollbar-width:thin; scrollbar-color: var(--border-strong) var(--surface); }
html{ scrollbar-width:thin; scrollbar-color: var(--border-strong) var(--bg); }
::-webkit-scrollbar{ width:10px; height:10px; }
::-webkit-scrollbar-track{ background:var(--bg); }
::-webkit-scrollbar-thumb{ background:var(--border-strong); border-radius:8px; }
::-webkit-scrollbar-thumb:hover{ background:var(--accent); }
table.monthtable{ width:100%; border-collapse:collapse; font-size:0.85rem; }
table.monthtable th, table.monthtable td{ padding:10px 15px; text-align:right; white-space:nowrap; border-bottom:1px solid var(--border); font-variant-numeric: tabular-nums; }
table.monthtable thead th{ color:var(--text-muted); font-weight:500; border-bottom:1px solid var(--border-strong); }
table.monthtable thead tr.grouprow th{ color:#5E5E68; font-size:0.7rem; text-transform:uppercase; letter-spacing:0.05em; font-weight:600; border-bottom:1px solid var(--border); padding-bottom:6px; padding-top:0; }
table.monthtable .rowhead, table.monthtable .colhead-month{ text-align:left; position:sticky; left:0; background:var(--surface); z-index:1; font-weight:500; }
table.monthtable tbody tr:hover td{ background:rgba(255,255,255,0.025); }
table.monthtable .zero{ color:#45454C; }
table.monthtable tfoot td{ border-top:2px solid var(--border-strong); border-bottom:none; }
table.monthtable tfoot .rowhead{ background:var(--surface); font-weight:700; }
table.monthtable tfoot .overbudget{ color:var(--expense); font-weight:800; }
.cat-chip{ display:inline-flex; align-items:center; gap:7px; }
.groupbudget{ font-weight:400; color:var(--text-muted); text-transform:none; letter-spacing:0; }
tr.guidelinerow td{ font-style:italic; color:var(--text-muted); border-bottom:1px dashed var(--border-strong); background:rgba(255,255,255,0.015); }
tr.guidelinerow td.rowhead{ font-weight:600; }
table.monthtable .datesub{ font-size:0.7rem; color:var(--text-muted); margin-top:2px; font-weight:400; }
table.monthtable .totalcolcell{ background:rgba(255,255,255,0.025); font-weight:700; }
table.monthtable thead th.totalcolcell{ color:var(--text); }

table.itemtable{ width:100%; border-collapse:collapse; font-size:0.85rem; }
table.itemtable th{ text-align:left; padding:8px 14px; font-weight:500; color:var(--text-muted); border-bottom:1px solid var(--border-strong); white-space:nowrap; }
table.itemtable th:last-child{ text-align:right; }
table.itemtable td{ padding:9px 14px; border-bottom:1px solid var(--border); vertical-align:middle; }
table.itemtable tbody tr:last-child td{ border-bottom:none; }
table.itemtable tbody tr:hover td{ background:rgba(255,255,255,0.025); }
table.itemtable td.datecell{ color:var(--text-muted); white-space:nowrap; width:1%; }
table.itemtable td.catcell{ white-space:nowrap; }
table.itemtable td.notecell{ color:var(--text-muted); }
table.itemtable td.amtcell{ text-align:right; font-weight:600; font-variant-numeric:tabular-nums; white-space:nowrap; }
th.checkcell, td.checkcell{ width:1%; padding-right:4px !important; }
.tx-checkbox, #txSelectAll{
  appearance:none; -webkit-appearance:none; -moz-appearance:none;
  width:18px; height:18px; border-radius:5px;
  border:1.5px solid var(--border-strong); background:var(--surface-alt);
  cursor:pointer; position:relative; display:inline-block; vertical-align:middle;
  margin:0; flex-shrink:0;
}
.tx-checkbox:hover, #txSelectAll:hover{ border-color:var(--accent); }
.tx-checkbox:checked, #txSelectAll:checked{ background:var(--accent); border-color:var(--accent); }
.tx-checkbox:checked::after, #txSelectAll:checked::after{
  content:''; position:absolute; left:5px; top:1px; width:5px; height:9px;
  border:solid #fff; border-width:0 2px 2px 0; transform:rotate(45deg);
}
table.itemtable tbody tr.selectedrow td{ background:rgba(109,93,252,0.08); }
.bulkbar{
  display:flex; align-items:center; gap:10px; margin:-8px 0 16px;
  padding:10px 14px; background:var(--surface); border:1px solid var(--border-strong);
  border-radius:10px; font-size:0.85rem; color:var(--text);
}

td.kebabcell{ position:relative; text-align:right; width:1%; white-space:nowrap; }
.kebab-btn{ background:none; border:none; color:var(--text-muted); cursor:pointer; font-size:1.05rem; padding:4px 9px; border-radius:7px; line-height:1; }
.kebab-btn:hover{ background:rgba(255,255,255,0.06); color:var(--text); }
.kebab-menu{
  position:fixed; z-index:40;
  background:var(--surface-alt); border:1px solid var(--border-strong); border-radius:10px;
  box-shadow:var(--shadow); overflow:hidden; min-width:120px;
}
.kebab-menu button{ display:block; width:100%; text-align:left; padding:9px 14px; background:none; border:none; color:var(--text); font-size:0.85rem; cursor:pointer; }
.kebab-menu button:hover{ background:rgba(255,255,255,0.06); }
.kebab-menu button.danger{ color:var(--expense); }

/* leaderboard */
.lbrow{ display:flex; align-items:center; gap:12px; margin-bottom:11px; }
.lb-rank{ width:16px; color:var(--text-muted); font-size:0.78rem; font-weight:600; flex-shrink:0; }
.lb-bar-wrap{ flex:1; display:flex; min-width:0; }
.lb-pill{ display:flex; align-items:center; gap:7px; padding:8px 13px; border-radius:999px; font-weight:600; font-size:0.82rem; white-space:nowrap; overflow:hidden; min-width:34%; }
.lb-pill .swdot{ width:7px; height:7px; border-radius:50%; background:rgba(255,255,255,0.85); flex-shrink:0; }
.lb-value{ font-size:0.85rem; font-weight:600; color:var(--text-muted); font-variant-numeric:tabular-nums; flex-shrink:0; }

.chartwrap{ overflow-x:auto; padding-bottom:4px; }

.modal-overlay{ position:fixed; inset:0; background:rgba(4,4,6,0.65); display:flex; align-items:center; justify-content:center; padding:20px; z-index:50; backdrop-filter: blur(3px); }
.modal{ background:var(--surface); border:1px solid var(--border-strong); border-radius:18px; padding:26px; width:100%; max-width:400px; box-shadow:var(--shadow); }
.modal h3{ font-weight:700; margin:0 0 18px; font-size:1.1rem; }
.modalfoot{ display:flex; justify-content:flex-end; gap:10px; margin-top:6px; }

.toast{ position:fixed; left:50%; bottom:24px; transform:translateX(-50%); background:var(--surface-alt); border:1px solid var(--border-strong); color:var(--text); padding:10px 18px; border-radius:9px; font-size:0.85rem; opacity:0; pointer-events:none; transition:opacity .25s ease; z-index:80; }
.toast.show{ opacity:1; }

.loading{ text-align:center; padding:100px 20px; color:var(--text-muted); }

img.mark{ display:block; object-fit:cover; background:none !important; }

/* ---------- auth page ---------- */
.authwrap{ min-height:100vh; display:flex; align-items:center; justify-content:center; padding:20px; }
.authcard{ width:100%; max-width:380px; background:var(--surface); border:1px solid var(--border); border-radius:18px; padding:30px 28px; box-shadow:var(--shadow); }
.authcard .mark{ width:40px; height:40px; border-radius:10px; background:linear-gradient(135deg, var(--accent), #4A3ACB); display:flex; align-items:center; justify-content:center; font-weight:800; font-size:1.1rem; margin-bottom:18px; }
.authcard h2{ margin:0 0 4px; font-size:1.3rem; font-weight:800; letter-spacing:-0.02em; }
.authcard p.sub{ margin:0 0 22px; color:var(--text-muted); font-size:0.86rem; }
.authtabs{ display:flex; gap:2px; background:var(--surface-alt); border:1px solid var(--border-strong); border-radius:9px; padding:3px; margin-bottom:22px; }
.authtabs button{ flex:1; border:none; background:transparent; color:var(--text-muted); padding:8px; border-radius:7px; font-size:0.84rem; font-weight:600; cursor:pointer; font-family:var(--font); }
.authtabs button.active{ background:var(--surface); color:var(--text); }
.autherror{ background:rgba(255,92,122,0.12); border:1px solid rgba(255,92,122,0.35); color:var(--expense); font-size:0.82rem; padding:9px 12px; border-radius:9px; margin-bottom:16px; display:none; }
.autherror.show{ display:block; }
.authcard .btn{ width:100%; text-align:center; }

/* ---------- home: quick add ---------- */
.home{
  display:flex; flex-direction:column; max-width:440px; margin:0 auto;
  -webkit-user-select:none; user-select:none; -webkit-touch-callout:none;
  min-height:calc(100vh - 120px);
}
.home-head{ display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.home-eyebrow{ font-size:0.78rem; color:var(--text-muted); font-weight:500; }
.home-spent{ font-size:1.05rem; font-weight:700; font-variant-numeric:tabular-nums; margin-top:2px; }

.home-amount-wrap{
  flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:18px; padding:28px 0 20px; position:relative;
}
.home-amount-wrap::before{
  content:''; position:absolute; width:260px; height:260px; border-radius:50%;
  background:radial-gradient(circle, rgba(109,93,252,0.20), transparent 68%);
  pointer-events:none; z-index:0;
}
.home-amount{
  position:relative; z-index:1; display:flex; align-items:baseline; justify-content:center; gap:10px;
  font-size:4.4rem; font-weight:700; letter-spacing:-0.04em; line-height:1;
  font-variant-numeric:tabular-nums; max-width:100%; white-space:nowrap;
}
.home-amount .d, .home-amount .amt-cur{ display:inline-block; }
.home-amount .sep{ display:inline-block; width:0.12em; }
.home-amount .enter{ animation:digitIn .38s cubic-bezier(.2,.8,.2,1) both; }
@keyframes digitIn{
  from{ opacity:0; transform:translateY(-0.5em); filter:blur(10px); }
  60%{ opacity:1; }
  to{ opacity:1; transform:none; filter:blur(0); }
}
@media (prefers-reduced-motion: reduce){
  .home-amount .enter{ animation:none; }
}
.home-amount.sm{ font-size:3.4rem; }
.home-amount.xs{ font-size:2.6rem; }
.home-amount .amt-num.placeholder{ color:#3E3E46; }
.home-amount .amt-cur{ font-size:0.4em; font-weight:600; color:var(--text-muted); letter-spacing:0; }
.home-amount.shake{ animation:shake .32s ease; }
@keyframes shake{ 20%,60%{ transform:translateX(-6px); } 40%,80%{ transform:translateX(6px); } }

.cat-pill{
  position:relative; z-index:1; display:inline-flex; align-items:center; gap:9px; max-width:100%;
  padding:10px 14px 10px 16px; border-radius:999px; cursor:pointer;
  background:var(--surface); border:1px solid var(--border-strong); color:var(--text);
  font-size:0.92rem; font-weight:600;
}
.cat-pill:active{ transform:scale(0.97); }
.cat-pill-name{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.cat-pill-chev{ display:flex; color:var(--text-muted); }
.cat-pill-tag{ font-size:0.64rem; font-weight:700; text-transform:uppercase; letter-spacing:0.05em; color:var(--income); background:rgba(34,197,94,0.14); border-radius:999px; padding:2px 7px; }

.home-chips{ display:flex; gap:8px; margin-bottom:10px; }
.chip{
  position:relative; display:inline-flex; align-items:center; gap:7px; flex-shrink:0;
  padding:0 14px; height:40px; border-radius:12px; cursor:pointer;
  background:var(--surface); border:1px solid var(--border); color:var(--text-muted);
  font-size:0.86rem; font-weight:500;
}
.chip span{ color:var(--text); }
.chip input[type=date]{ position:absolute; inset:0; width:100%; height:100%; opacity:0; cursor:pointer; padding:0; border:none; }
.chip-note{ flex:1; flex-shrink:1; min-width:0; cursor:text; }
.chip-note input{
  -webkit-user-select:text; user-select:text;
  flex:1; min-width:0; height:100%; padding:0 !important; border:none !important;
  background:transparent !important; color:var(--text); font-size:16px; /* 16px stops iOS zooming in */
}
.chip-note input:focus{ outline:none; }
.chip:focus-within{ border-color:var(--border-strong); }

.keypad{ display:grid; grid-template-columns:repeat(3, 1fr); gap:4px; margin-bottom:12px; }
.key{
  height:60px; border:none; border-radius:16px; background:transparent; color:var(--text);
  font-size:1.65rem; font-weight:500; cursor:pointer; touch-action:manipulation;
  display:flex; align-items:center; justify-content:center; -webkit-tap-highlight-color:transparent;
  transition:background .12s ease, transform .08s ease;
}
/* Hover only on real pointers: on touch screens :hover sticks after a tap and leaves the key grey. */
@media (hover:hover){ .key:hover{ background:rgba(255,255,255,0.04); } }
.key:focus{ outline:none; }
.key:focus-visible{ outline:2px solid var(--accent); outline-offset:-2px; }
.key.pressed{ background:rgba(255,255,255,0.09); transform:scale(0.95); transition:none; }
.key[data-key=back]{ color:var(--text-muted); }

.home-cta{
  width:100%; height:56px; border:none; border-radius:18px; cursor:pointer;
  background:linear-gradient(135deg, #7D6EFF, var(--accent) 55%, #5446E0);
  color:#fff; font-family:var(--font); font-size:1rem; font-weight:700; letter-spacing:0.01em;
  box-shadow:0 10px 28px rgba(109,93,252,0.35); touch-action:manipulation;
  transition:opacity .15s ease, transform .08s ease, box-shadow .15s ease;
}
.home-cta:active:not(:disabled){ transform:scale(0.98); }
.home-cta:disabled{ opacity:0.35; box-shadow:none; cursor:default; }
.home-cta{ display:flex; align-items:center; justify-content:center; gap:8px; }
.home-cta.success, .home-cta.success:disabled{
  opacity:1; background:var(--income); box-shadow:0 10px 28px rgba(34,197,94,0.3);
  animation:pop .3s ease;
}
@keyframes pop{ 40%{ transform:scale(1.03); } }

.home-empty{ margin:auto 0; text-align:center; }

/* bottom sheet */
.sheet-overlay{
  position:fixed; inset:0; z-index:60; background:rgba(4,4,6,0.6);
  backdrop-filter:blur(3px); -webkit-backdrop-filter:blur(3px);
  display:flex; align-items:flex-end; justify-content:center;
  animation:fadeIn .18s ease-out;
}
.sheet{
  width:100%; max-width:480px; max-height:78vh; display:flex; flex-direction:column;
  background:var(--surface); border:1px solid var(--border-strong); border-bottom:none;
  border-radius:24px 24px 0 0; padding:8px 12px max(16px, env(safe-area-inset-bottom));
  animation:sheetUp .26s cubic-bezier(.2,.9,.3,1);
}
@keyframes fadeIn{ from{ opacity:0; } to{ opacity:1; } }
@keyframes sheetUp{ from{ transform:translateY(100%); } to{ transform:translateY(0); } }
.sheet-grabber{ width:38px; height:5px; border-radius:999px; background:var(--border-strong); margin:4px auto 12px; }
.sheet-title{ font-weight:700; font-size:1.02rem; padding:0 8px 10px; }
.sheet-body{ overflow-y:auto; -webkit-overflow-scrolling:touch; }
.sheet-group{ font-size:0.7rem; font-weight:600; text-transform:uppercase; letter-spacing:0.06em; color:var(--text-muted); padding:14px 10px 6px; }
.sheet-row{
  display:flex; align-items:center; gap:12px; width:100%; padding:14px 10px; border:none; border-radius:12px;
  background:transparent; color:var(--text); font-family:var(--font); font-size:0.95rem; font-weight:500; text-align:left; cursor:pointer;
}
.sheet-row:active{ background:rgba(255,255,255,0.05); }
@media (hover:hover){ .sheet-row:hover{ background:rgba(255,255,255,0.05); } }
.sheet-row.selected{ background:var(--accent-soft); }
.sheet-row-name{ flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sheet-row-check{ display:flex; color:var(--accent); width:18px; }

@media (max-width:760px){
  main{ padding-top:max(18px, env(safe-area-inset-top)); }
  .toast{ bottom:calc(24px + env(safe-area-inset-bottom)); }

  /* Home fits exactly one screen: no page scroll, no rubber-band bounce. */
  html:has(main.main-home), html:has(main.main-home) body{ height:100%; overflow:hidden; overscroll-behavior:none; }
  main.main-home{
    height:100dvh; overflow:hidden; display:flex; flex-direction:column;
    padding-bottom:max(16px, env(safe-area-inset-bottom));
  }
  .home{ flex:1; min-height:0; width:100%; }
  .home-amount-wrap{ min-height:0; padding:12px 0; }
  .key{ height:clamp(46px, 8dvh, 66px); }
}
/* Touch devices: let scrollbars stay the native overlay kind instead of a permanent bar. */
@media (hover:none) and (pointer:coarse){
  html{ scrollbar-width:none; }
  ::-webkit-scrollbar{ width:0; height:0; background:transparent; }
}

/* ---------- hamburger menu (phones) ---------- */
.topbar-actions{ display:flex; align-items:center; gap:10px; margin-left:auto; }
.menu-btn{ display:none; }
@media (max-width:760px){
  .menu-btn{
    display:flex; flex-direction:column; align-items:center; justify-content:center; gap:4px;
    position:relative; z-index:71; flex-shrink:0;
    width:42px; height:42px; border-radius:50%; cursor:pointer; padding:0;
    background:var(--surface); border:1px solid var(--border-strong);
    -webkit-tap-highlight-color:transparent; touch-action:manipulation;
    transition:background .2s ease, transform .1s ease;
  }
  .menu-btn:active{ transform:scale(0.94); }
  .topbar{ flex-wrap:nowrap; }
  .titlewrap{ min-width:0; }
  .topbar .btn-cta{ width:42px; height:42px; padding:0; border-radius:50%; justify-content:center; flex-shrink:0; }
  .topbar .btn-cta .cta-label{ display:none; }
  .topbar .btn-cta .cta-plus{ font-size:1.45rem; font-weight:500; line-height:1; margin-top:-2px; }
  .menu-btn span{
    display:block; width:16px; height:1.8px; border-radius:2px; background:var(--text);
    transition:transform .28s cubic-bezier(.2,.8,.2,1), opacity .2s ease;
  }
  .menu-btn.open{ background:var(--surface-alt); }
  .menu-btn.open span:nth-child(1){ transform:translateY(5.8px) rotate(45deg); }
  .menu-btn.open span:nth-child(2){ opacity:0; transform:scaleX(0.3); }
  .menu-btn.open span:nth-child(3){ transform:translateY(-5.8px) rotate(-45deg); }
}
.menu-overlay{
  position:fixed; inset:0; z-index:70; background:rgba(4,4,6,0.45);
  backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px);
  animation:fadeIn .18s ease-out;
}
.menu-panel{
  position:absolute; right:16px; top:calc(max(18px, env(safe-area-inset-top)) + 52px);
  width:min(260px, calc(100% - 32px)); padding:8px; border-radius:20px;
  background:rgba(28,28,34,0.82); border:1px solid rgba(255,255,255,0.12);
  backdrop-filter:blur(24px) saturate(180%); -webkit-backdrop-filter:blur(24px) saturate(180%);
  box-shadow:0 24px 60px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.08);
  transform-origin:top right; animation:menuIn .26s cubic-bezier(.2,.9,.3,1.1);
}
@keyframes menuIn{ from{ opacity:0; transform:scale(0.85) translateY(-8px); } to{ opacity:1; transform:none; } }
.menu-item{
  display:flex; align-items:center; gap:12px; width:100%; padding:12px 12px; border:none; border-radius:13px;
  background:transparent; color:var(--text-muted); font-family:var(--font); font-size:0.95rem; font-weight:500;
  text-align:left; cursor:pointer; -webkit-tap-highlight-color:transparent;
  animation:menuItemIn .3s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes menuItemIn{ from{ opacity:0; transform:translateX(8px); } to{ opacity:1; transform:none; } }
.menu-item span{ flex:1; }
.menu-item:active{ background:rgba(255,255,255,0.07); }
@media (hover:hover){ .menu-item:hover{ background:rgba(255,255,255,0.05); color:var(--text); } }
.menu-item.active{ color:var(--text); background:var(--accent-soft); }
.menu-item.active svg{ color:var(--accent); }
.menu-badge{ flex:0 !important; font-size:0.7rem; font-weight:700; color:#0B0C10; background:var(--income); border-radius:999px; padding:1px 7px; }
.menu-foot{ border-top:1px solid var(--border); margin:6px 4px 0; padding:10px 8px 4px; font-size:0.76rem; color:var(--text-muted); }
.menu-foot b{ color:var(--text); font-weight:600; }
@media (prefers-reduced-motion: reduce){ .menu-panel, .menu-item{ animation:none; } }
