:root {
  --bg: #0a0a0a;
  --card: #141414;
  --card-2: #1c1c1c;
  --line: #262626;
  --line-2: #333;
  --text: #f2f2f2;
  --muted: #8c8c8c;
  --dim: #5c5c5c;
  --lime: #c6f432;
  --lime-ink: #0a0a0a;
  --lime-soft: rgba(198, 244, 50, 0.12);
  --red: #ff6b5e;
  --amber: #f5b84b;
  --radius: 18px;
  --radius-sm: 12px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
body.noscroll { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
button:disabled { opacity: 0.3; cursor: default; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }

.ico { width: 20px; height: 20px; flex: none; }
.tab-num, .num-xl, .num-md, .hero-num, .detail-num, .tx-amt, .acc-bal { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.lime { color: var(--lime); }
.pos { color: var(--lime); }
.neg { color: var(--red); }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.row.baseline { align-items: baseline; }
.label { font-size: 12px; color: var(--muted); letter-spacing: 0.02em; }
.emoji { filter: grayscale(1) brightness(1.15); font-size: 17px; line-height: 1; }

/* ---------- layout ---------- */
#app { max-width: 560px; margin: 0 auto; }
.page { padding: 4px 16px calc(var(--tabbar-h) + var(--safe-b) + 28px); display: flex; flex-direction: column; gap: 12px; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-t) + 12px) 16px 10px;
  background: rgba(10, 10, 10, 0.86);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}
.brand { font-weight: 650; font-size: 24px; letter-spacing: -0.04em; display: flex; align-items: baseline; }
.brand .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--lime); margin-left: 3px; display: inline-block; }
.brand.big { font-size: 40px; }
.brand.big .dot { width: 11px; height: 11px; margin-left: 4px; }
.page-title { margin: 0; font-size: 26px; font-weight: 650; letter-spacing: -0.03em; }
.top-actions { display: flex; gap: 8px; align-items: center; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--card); border: 1px solid var(--line);
}
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.sm .ico { width: 17px; height: 17px; }
.sync-pill { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); background: var(--card); color: var(--dim); }
.sync-pill.ok { color: var(--lime); }
.sync-pill.err { color: var(--red); }
.sync-pill.busy { color: var(--muted); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: block; width: 100%;
}
.card.list { padding: 4px 0; }
.card.list.flat { padding: 2px 0; }
.card.pad { padding: 14px 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.link { color: var(--lime); font-size: 13px; font-weight: 500; }
.section-title { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin: 10px 4px 0; font-weight: 500; }
.section-title .ico { width: 16px; height: 16px; }
.hint { color: var(--dim); font-size: 12.5px; margin: 4px 4px 0; }
.empty { color: var(--dim); font-size: 14px; margin: 6px 0; display: flex; align-items: center; gap: 6px; }
.empty.big { text-align: center; justify-content: center; padding: 36px 16px; }

.hero { padding: 8px 4px 4px; display: flex; flex-direction: column; gap: 6px; }
.hero.compact { align-items: flex-start; }
.hero-num, .detail-num { font-size: 44px; font-weight: 650; letter-spacing: -0.045em; line-height: 1.05; }
.detail-num { font-size: 38px; margin: 2px 0 10px; }
.cents { font-size: 0.55em; color: var(--muted); letter-spacing: -0.02em; }
.hero-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.hero-split button { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; font-variant-numeric: tabular-nums; font-weight: 550; }
.streak { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--lime); background: var(--lime-soft); padding: 4px 10px 4px 7px; border-radius: 99px; font-weight: 550; }
.streak .ico { width: 15px; height: 15px; }

.safe { display: flex; flex-direction: column; gap: 2px; }
.num-xl { font-size: 32px; font-weight: 650; letter-spacing: -0.035em; line-height: 1.15; }
.num-md { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }

.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.grid3 > div { min-width: 0; }
.grid3 .num-md { font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.month-switch { display: flex; align-items: center; justify-content: space-between; }
.month-label { font-weight: 600; font-size: 15px; padding: 4px 8px; }

.bar { height: 6px; border-radius: 99px; background: var(--card-2); overflow: hidden; margin-top: 7px; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--text); transition: width 0.4s ease; }
.bar.plain i { background: #9a9a9a; }
.bar.lime i { background: var(--lime); }
.bar.amber i { background: var(--amber); }
.bar.red i { background: var(--red); }

.cat-row { display: flex; gap: 12px; align-items: center; width: 100%; padding: 8px 0; }
.cat-row .emoji { width: 32px; height: 32px; border-radius: 10px; background: var(--card-2); display: grid; place-items: center; font-size: 15px; flex: none; }
.cat-main { flex: 1; min-width: 0; font-size: 14px; }

.mini-goal { padding: 6px 0; font-size: 14px; }

.chart { width: 100%; height: auto; display: block; }
.chart .b-in { fill: var(--lime); }
.chart .b-out { fill: #5a5a5a; }
.chart .b-lbl { fill: var(--dim); font-size: 10.5px; }
.chart .b-lbl.on { fill: var(--text); }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.lg-in { background: var(--lime); } .lg-out { background: #5a5a5a; }

/* nudges */
.nudge { display: flex; flex-direction: column; gap: 12px; border-color: var(--line-2); }
.nudge-text { display: flex; flex-direction: column; gap: 2px; }
.nudge-actions { display: flex; gap: 8px; }
.nudge-line { display: flex; align-items: center; gap: 12px; text-align: left; }
.nudge-line > span { flex: 1; display: flex; flex-direction: column; }
.nudge-line .ico:first-child { color: var(--lime); }
.onboard h2 { margin: 4px 0 6px; font-size: 22px; letter-spacing: -0.03em; }
.onboard p { margin: 0 0 14px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px; padding: 0 18px; border-radius: 14px; font-weight: 600; font-size: 15px; text-align: center; }
.btn .ico { width: 18px; height: 18px; }
.btn.sm { height: 36px; padding: 0 14px; font-size: 14px; border-radius: 11px; }
.btn.block { width: 100%; }
.btn.primary { background: var(--lime); color: var(--lime-ink); }
.btn.ghost { background: var(--card-2); border: 1px solid var(--line); }
.btn.outline { border: 1px dashed var(--line-2); color: var(--muted); }
.btn.danger-ghost { color: var(--red); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

/* ---------- chips ---------- */
.chips { display: flex; gap: 8px; }
.chips.wrap { flex-wrap: wrap; }
.chips.scroll { overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); font-size: 14px; white-space: nowrap; color: #cfcfcf; }
.chip .ico { width: 14px; height: 14px; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.on .emoji { filter: grayscale(1) brightness(0.2); }
.chip.dashed { border-style: dashed; color: var(--muted); }

.search { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 0 12px; height: 44px; color: var(--dim); }
.search input.search-input { flex: 1; height: 100%; padding: 0; background: none; border: 0; border-radius: 0; outline: 0; font-size: 16px; color: var(--text); }
.card:not(.list) > .bill-row { padding-left: 0; padding-right: 0; }
.card:not(.list) > .bill-row + .bill-row::before { left: 0; }
.card.pad p { margin: 0; }

/* ---------- lists ---------- */
.day-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin: 8px 4px 6px; }
.tx-row, .acc-row, .set-row, .bill-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 16px; position: relative; }
.tx-row + .tx-row::before, .acc-row + .acc-row::before, .set-row + .set-row::before, .bill-row + .bill-row::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 1px solid var(--line);
}
.tx-ico { width: 38px; height: 38px; border-radius: 12px; background: var(--card-2); display: grid; place-items: center; flex: none; color: var(--muted); }
.tx-ico .ico { width: 18px; height: 18px; }
.tx-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tx-title { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-amt { font-weight: 600; white-space: nowrap; display: flex; flex-direction: column; align-items: flex-end; }
.tx-amt small { color: var(--dim); font-weight: 400; font-size: 12px; }

.bank { padding: 0; }
.bank-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.bank-name { display: flex; align-items: center; gap: 12px; }
.bank-name > span:last-child { display: flex; flex-direction: column; }
.bank-mono { width: 38px; height: 38px; border-radius: 12px; background: var(--text); color: var(--bg); display: grid; place-items: center; font-weight: 700; font-size: 16px; }
.bank .list { padding-bottom: 4px; }
.acc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.acc-title { font-weight: 550; display: flex; align-items: center; gap: 8px; }
.acc-bal { font-weight: 600; }
.ceil { display: flex; flex-direction: column; max-width: 220px; }
.ceil .bar { margin-top: 5px; height: 4px; }
.tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line-2); border-radius: 99px; padding: 1px 7px; font-weight: 500; white-space: nowrap; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.bill-main { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.bill-day { width: 38px; height: 38px; border-radius: 12px; background: var(--card-2); display: grid; place-items: center; flex: none; font-size: 15px; }
.bill-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-weight: 600; }
.status, .status-btn { font-size: 12px; font-weight: 550; border-radius: 99px; padding: 3px 9px; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.status .ico { width: 13px; height: 13px; }
.status.paid { color: var(--muted); }
.status-btn.upcoming { background: var(--lime-soft); color: var(--lime); }
.status-btn.overdue { background: rgba(255, 107, 94, 0.14); color: var(--red); }

.goal { display: flex; flex-direction: column; gap: 4px; text-align: left; }
.goal.emergency { border-color: var(--line-2); }

.set-row { text-align: left; }
.set-row.card { padding: 14px 16px; }
.set-row .ico:last-child { color: var(--dim); width: 17px; height: 17px; }
.set-row.add { color: var(--lime); }
.set-row.add .ico { color: var(--lime); }
.set-row.danger { color: var(--red); }
.set-row.static > span.grow { display: flex; flex-direction: column; }
.sync-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--dim); flex: none; }
.sync-dot.synced { background: var(--lime); }
.sync-dot.error { background: var(--red); }
.steps { margin: 0; padding-left: 20px; color: #cfcfcf; font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.check-row { display: grid; grid-template-columns: 70px 1fr auto; gap: 8px; padding: 10px 16px; font-size: 14px; align-items: center; }

/* ---------- tab bar ---------- */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(6, 1fr); align-items: center;
  max-width: 560px; margin: 0 auto;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding: 0 6px var(--safe-b);
  background: rgba(10, 10, 10, 0.9); border-top: 1px solid var(--line);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; color: var(--dim); font-weight: 500; }
.tab .ico { width: 22px; height: 22px; }
.tab.on { color: var(--text); }
.tab-add { justify-self: center; width: 50px; height: 50px; border-radius: 17px; background: var(--lime); color: var(--lime-ink); display: grid; place-items: center; }
.tab-add .ico { width: 26px; height: 26px; stroke-width: 2.4; }

/* ---------- sheets ---------- */
#sheet-root { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
#sheet-root.open { pointer-events: auto; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); animation: fade 0.2s ease; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px;
  max-height: 92dvh; display: flex; flex-direction: column;
  background: #111; border: 1px solid var(--line); border-bottom: 0;
  border-radius: 24px 24px 0 0; animation: up 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.grabber { width: 38px; height: 5px; border-radius: 9px; background: var(--line-2); margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px 6px 20px; }
.sheet-head h2 { margin: 0; font-size: 19px; letter-spacing: -0.02em; }
.sheet-body { overflow-y: auto; padding: 6px 16px calc(20px + var(--safe-b)); -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 8px; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form.tight { gap: 10px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span:first-child { font-size: 13px; color: var(--muted); }
.field.inline { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.field.inline > span:first-child { color: var(--text); font-size: 14px; }
.field.inline input { max-width: 140px; text-align: right; }
input:not([type="file"]), select, textarea {
  width: 100%; height: 46px; padding: 0 14px; font-size: 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 13px; outline: none;
  -webkit-appearance: none; appearance: none;
}
input:focus, select:focus { border-color: #555; }
input[type="date"] { min-height: 46px; }
select { background-image: linear-gradient(45deg, transparent 50%, #777 50%), linear-gradient(135deg, #777 50%, transparent 50%); background-position: calc(100% - 18px) 20px, calc(100% - 13px) 20px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row2.icon-name { grid-template-columns: 80px 1fr; }
.form-error { color: var(--red); font-size: 13.5px; margin: 0; min-height: 0; }
.form-error:empty { display: none; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--card); border: 1px solid var(--line); border-radius: 13px; padding: 3px; }
.seg button { height: 36px; border-radius: 10px; font-weight: 550; font-size: 14px; color: var(--muted); text-align: center; }
.seg button.on { background: var(--text); color: var(--bg); }

.amount-wrap { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding: 6px 0 8px; }
.amount-input.amount-input { border: 0; background: none; height: 64px; padding: 0; font-size: 46px; font-weight: 650; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.cur-select.cur-select { width: 92px; flex: none; height: 38px; font-weight: 600; font-size: 15px; border-radius: 99px; background-color: var(--card-2); }
.fx { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 14px; }
.fx-conv { font-weight: 600; color: var(--lime); }
.fx-rate { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.fx-rate input { width: 96px; height: 32px; padding: 0 8px; font-size: 14px; border-radius: 9px; }
.fx-src { width: 100%; }
.ceil-box { margin-bottom: 8px; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px); z-index: 40;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); border-radius: 99px; padding: 10px 16px;
  font-weight: 550; font-size: 14px; display: flex; gap: 14px; align-items: center; white-space: nowrap;
  transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { color: #3a5a00; font-weight: 700; }

/* ---------- welcome ---------- */
#welcome { position: fixed; inset: 0; z-index: 25; background: var(--bg); display: none; }
#welcome.open { display: flex; flex-direction: column; }
.welcome-lang { display: flex; justify-content: flex-end; gap: 6px; padding: calc(var(--safe-t) + 14px) 16px 0; }
.welcome-lang button { font-size: 13px; font-weight: 600; color: var(--dim); padding: 6px 10px; border-radius: 99px; border: 1px solid var(--line); }
.welcome-lang button.on { color: var(--text); border-color: var(--line-2); background: var(--card); }
.welcome-inner { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 14px; padding: 24px 24px calc(var(--safe-b) + 32px); max-width: 480px; width: 100%; margin: 0 auto; }
.welcome-inner .brand.big { margin-bottom: auto; margin-top: 18vh; font-size: 52px; }
.welcome-inner h1 { margin: 0; font-size: 30px; line-height: 1.15; letter-spacing: -0.035em; }
.welcome-inner p { margin: 0 0 10px; font-size: 16px; }
.welcome-actions { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.welcome-actions .link { margin-top: 6px; color: var(--muted); font-size: 14px; }
.backup strong { display: inline-flex; align-items: center; gap: 8px; }
.backup strong .ico { color: var(--lime); }
.link.center { align-self: center; }

/* ---------- lock ---------- */
#lock { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: none; place-items: center; }
#lock.open { display: grid; }
.lock-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 24px; }
.pin-dots { display: flex; gap: 14px; margin: 6px 0 10px; }
.pin-dots i { width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid var(--muted); }
.pin-dots i.on { background: var(--lime); border-color: var(--lime); }
.keypad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px; }
.keypad button { height: 76px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); font-size: 26px; font-weight: 500; text-align: center; }
.keypad button:active { background: var(--card-2); }

@media (hover: hover) {
  .tx-row:hover, .acc-row:hover, .set-row:hover, .cat-row:hover { background: rgba(255, 255, 255, 0.025); }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
