:root {
  --bg: #050506;
  --bg-elev: #0c0c0e;
  --card: #141417;
  --card-2: #1b1b20;
  --text: #f5f5f7;
  --muted: #8e8e96;
  --faint: #5c5c64;
  --line: rgba(255, 255, 255, 0.07);
  --income: #3ddc84;
  --income-dim: rgba(61, 220, 132, 0.16);
  --expense: #ff4d5a;
  --expense-dim: rgba(255, 77, 90, 0.16);
  --accent: #4c8dff;
  --accent-dim: rgba(76, 141, 255, 0.16);
  --danger: #ff6b6b;
  --radius: 18px;
  --tap: 44px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.35;
  color-scheme: dark;
  touch-action: manipulation;
}

body {
  padding: 0;
  overscroll-behavior: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
}

input,
textarea,
select {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  width: 100%;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: rgba(76, 141, 255, 0.55);
}

#app {
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

.nums {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  letter-spacing: -0.02em;
}

.screen {
  min-height: 100dvh;
  padding: calc(var(--safe-top) + 16px) 16px calc(var(--safe-bot) + 112px);
}

.screen.auth,
.screen.pin {
  padding-bottom: calc(var(--safe-bot) + 24px);
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.faint {
  color: var(--faint);
  font-size: 12px;
}

.brand {
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  font-size: 28px;
  letter-spacing: -0.04em;
  margin: 6px 0 8px;
  font-weight: 700;
}

h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 10px;
  letter-spacing: -0.02em;
}

.hero {
  margin: 28px 0 24px;
}

.screen.pin .hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.btn {
  min-height: var(--tap);
  border-radius: 14px;
  padding: 0 16px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 8px;
  text-decoration: none;
  box-sizing: border-box;
}

.btn.primary {
  background: var(--text);
  color: #111;
}

.btn.ghost {
  background: var(--card);
  color: var(--text);
}

.btn.danger {
  background: var(--expense-dim);
  color: var(--expense);
}

.btn.small {
  width: auto;
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 10px;
}

.row {
  display: flex;
  gap: 8px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 8px;
  min-height: var(--tap);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: var(--accent-dim);
  color: var(--accent);
  overflow: hidden;
  flex-shrink: 0;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar.lg {
  width: 64px;
  height: 64px;
  border-radius: 22px;
  font-size: 24px;
}

.avatar.face {
  font-size: 22px;
  background: var(--card-2);
}

.dash-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.profile-hit {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  min-width: 0;
}

.profile-hit b {
  display: block;
  font-size: 16px;
}

.add-mini {
  background: #e11d48;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 14px;
  white-space: nowrap;
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0 8px;
}

.avatar-btn {
  padding: 0;
}

.avatar-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.avatar-pick {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--card-2);
  font-size: 20px;
}

.avatar-pick.on {
  outline: 2px solid var(--accent);
}

.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: var(--text);
  background: transparent;
}

.icon-btn:active {
  background: var(--card);
}

.balance-block {
  margin: 10px 0 16px;
}

.balance-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.balance-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.balance {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 1.05;
  margin: 4px 0 8px;
}

.flow {
  display: flex;
  gap: 14px;
  font-size: 14px;
  font-weight: 600;
}

.flow .up {
  color: var(--income);
}

.flow .down {
  color: var(--expense);
}

.spark {
  width: 92px;
  height: 42px;
  flex: 0 0 92px;
}

.periods {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.period {
  background: var(--card);
  border-radius: 14px;
  padding: 10px 8px;
  text-align: center;
}

.period .name {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.period .up,
.period .down {
  font-size: 12px;
  font-weight: 600;
}

.period .up {
  color: var(--income);
}

.period .down {
  color: var(--expense);
}

.tip {
  background: #152033;
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 18px;
}

.tip .k {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8fb4ff;
  margin-bottom: 6px;
}

.tip p {
  margin: 0;
  font-size: 13px;
  color: #d5e4ff;
}

.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.col-title {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
}

.cat-card {
  background: var(--card);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 8px;
  width: 100%;
  text-align: left;
}

.cat-head {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.cat-name {
  font-size: 13px;
  font-weight: 600;
}

.cat-sum {
  font-size: 13px;
  font-weight: 700;
}

.bar {
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  margin-bottom: 8px;
}

.bar > span {
  display: block;
  height: 100%;
  border-radius: 99px;
}

.recent {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 3px;
}

.fab {
  display: none;
}

.nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--safe-bot) + 12px);
  width: min(420px, calc(100% - 20px));
  background: rgba(20, 20, 23, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: 22px;
  display: grid;
  grid-template-columns: 1fr 1fr 58px 1fr 1fr;
  align-items: center;
  padding: 6px;
  z-index: 15;
}

.nav-add {
  width: 46px;
  height: 46px;
  margin: 0 auto;
  border-radius: 50%;
  background: #e11d48;
  color: #fff;
  font-size: 28px;
  font-weight: 500;
  line-height: 1;
  display: grid;
  place-items: center;
  touch-action: manipulation;
}

.nav button {
  min-height: 40px;
  border-radius: 12px;
  font-size: 11px;
  color: var(--muted);
}

.nav button.on {
  background: var(--card-2);
  color: var(--text);
  font-weight: 600;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet {
  pointer-events: auto;
  width: min(480px, 100%);
  background: #121215;
  border-radius: 24px 24px 0 0;
  padding: 10px 16px calc(var(--safe-bot) + 16px);
  max-height: 92dvh;
  overflow: auto;
}

.handle {
  width: 36px;
  height: 4px;
  border-radius: 99px;
  background: #3a3a40;
  margin: 4px auto 12px;
}

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--card);
  padding: 4px;
  border-radius: 14px;
  margin-bottom: 14px;
}

.seg button {
  min-height: 40px;
  border-radius: 11px;
  color: var(--muted);
  font-weight: 600;
}

.seg button.on.income {
  background: var(--income-dim);
  color: var(--income);
}

.seg button.on.expense {
  background: var(--expense-dim);
  color: var(--expense);
}

.amount-show {
  text-align: center;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.04em;
  margin: 8px 0 14px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.chip {
  min-height: 36px;
  padding: 0 10px;
  border-radius: 11px;
  background: var(--card);
  font-size: 13px;
}

.chip.on {
  outline: 1px solid var(--text);
  background: var(--card-2);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 8px 0 12px;
}

.key {
  min-height: 52px;
  border-radius: 14px;
  background: var(--card);
  font-size: 22px;
  font-weight: 500;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  width: 100%;
  text-align: left;
}

.search {
  margin-bottom: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bot) + 88px);
  transform: translateX(-50%);
  background: #2a2a32;
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  z-index: 50;
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 13px;
  width: min(420px, calc(100% - 32px));
}

.toast button {
  color: var(--accent);
  font-weight: 700;
  margin-left: auto;
}

.empty {
  background: var(--card);
  border-radius: 16px;
  padding: 18px 14px;
  color: var(--muted);
  font-size: 13px;
}

.starter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 16px;
}

.starter .chip.on {
  outline-color: var(--accent);
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 28px 0;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid #4a4a52;
}

.dot.on {
  background: var(--text);
  border-color: var(--text);
}

.settings-card {
  background: var(--card);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 10px;
}

.note-block {
  display: block;
  width: 100%;
  text-align: left;
  white-space: pre-wrap;
  background: var(--card);
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 10px;
  font-size: 14px;
  line-height: 1.45;
}

.token {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  word-break: break-all;
  white-space: pre-wrap;
  background: var(--card-2);
  padding: 10px;
  border-radius: 10px;
  margin: 6px 0;
}

.cat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border-radius: 14px;
  padding: 10px;
  margin-bottom: 8px;
}

.grow {
  flex: 1;
  text-align: left;
}

.emoji-grid,
.color-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 12px;
}

.emoji-grid button,
.color-grid button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--card);
}

.color-grid button {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.over {
  color: #ffb020 !important;
}

.error {
  color: var(--expense);
  font-size: 13px;
  min-height: 1.2em;
  margin: 0 0 12px;
}
