:root {
  --bg-page: #f3f3f4;
  --bg-app: #ffffff;
  --bg-card: #f5f5f7;
  --bg-card-hover: #ececef;
  --bg-subtle: #ededf0;
  --ink: #111111;
  --ink-secondary: #6e6e73;
  --ink-tertiary: #9a9aa2;
  --border: #e7e7eb;
  --accent-pink: #ec4899;
  --accent-pink-deep: #db2777;
  --accent-danger: #e11d48;
  --accent-warn: #d97706;
  --accent-ok: #16a34a;
  --radius-card: 22px;
  --radius-pill: 999px;
  --font-display: 'Archivo', 'Figtree', system-ui, -apple-system, sans-serif;
  --font-body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --shadow-nav: 0 8px 30px rgba(11, 11, 12, 0.09), 0 1px 3px rgba(11, 11, 12, 0.06);
  --shadow-sheet: 0 -10px 40px rgba(11, 11, 12, 0.14);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-page);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

button, input, select {
  font-family: inherit;
  color: inherit;
}

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

.hidden {
  display: none !important;
}

/* App Shell */
.app-shell {
  max-width: 440px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg-app);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 0 1px rgba(11, 11, 12, 0.04);
}

@media (min-width: 480px) {
  .app-shell {
    box-shadow: 0 12px 48px rgba(11, 11, 12, 0.08);
  }
}

/* Top Bar */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 18px 10px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.month-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border-radius: var(--radius-pill);
  padding: 6px 10px;
}

.month-label {
  font-weight: 600;
  font-size: 14px;
  min-width: 84px;
  text-align: center;
  text-transform: capitalize;
}

.icon-btn-sm {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-secondary);
  transition: background 0.15s, color 0.15s;
}

.icon-btn-sm:hover {
  background: var(--bg-card-hover);
  color: var(--ink);
}

.circle-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-card);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  transition: background 0.15s, transform 0.12s;
}

.circle-icon-btn:active {
  transform: scale(0.94);
}

.circle-icon-btn.muted {
  color: var(--ink-tertiary);
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 4px 18px calc(108px + env(safe-area-inset-bottom, 0px));
}

/* Mascot Hero */
.hero-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 6px;
  margin-bottom: 18px;
}

.speech-bubble {
  position: relative;
  background: var(--ink);
  color: #ffffff;
  border-radius: 18px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  text-align: center;
  max-width: 330px;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  box-shadow: 0 6px 20px rgba(11, 11, 12, 0.12);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid var(--ink);
}

.arc-stage {
  position: relative;
  width: 236px;
  height: 204px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: -14px;
}

.arc-svg {
  width: 236px;
  height: 236px;
  overflow: visible;
}

.arc-track {
  fill: none;
  stroke: var(--bg-subtle);
  stroke-width: 12;
  stroke-linecap: round;
}

.arc-progress {
  fill: none;
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s cubic-bezier(0.22, 1, 0.36, 1), stroke 0.45s ease;
}

.mascot-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -46%);
  width: 124px;
  height: 124px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mascot-btn:active {
  transform: translate(-50%, -46%) scale(0.92);
}

.mascot-svg {
  width: 112px;
  height: 112px;
  filter: drop-shadow(0 8px 16px rgba(11, 11, 12, 0.08));
}

.mascot-body {
  transition: fill 0.5s ease;
}

/* Hero Numbers */
.hero-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-secondary);
  margin-top: 2px;
}

.hero-amount {
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin: 2px 0 4px;
  color: var(--ink);
}

.hero-amount.negative {
  color: var(--accent-danger);
}

.hero-cents {
  font-size: 24px;
  font-weight: 700;
}

.hero-sub {
  font-size: 13px;
  color: var(--ink-secondary);
  margin-bottom: 10px;
}

.pace-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 600;
  background: var(--bg-card);
  color: var(--ink);
}

.pace-badge.warn {
  background: #fef3c7;
  color: #92400e;
}

.pace-badge.danger {
  background: #ffe4e6;
  color: #be123c;
}

/* Quick Actions Row */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 18px 0 22px;
}

.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}

.quick-action-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: background 0.15s, transform 0.12s;
}

.quick-action-btn:active .quick-action-circle {
  transform: scale(0.93);
  background: var(--bg-card-hover);
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  padding: 18px;
  margin-bottom: 14px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

.card-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-secondary);
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
}

.summary-row + .summary-row {
  border-top: 1px solid rgba(11, 11, 12, 0.05);
}

.summary-row.total {
  padding-top: 12px;
  margin-top: 4px;
  border-top: 1px solid rgba(11, 11, 12, 0.1);
}

.summary-left {
  display: flex;
  flex-direction: column;
}

.summary-name {
  font-weight: 600;
  font-size: 14.5px;
}

.summary-desc {
  font-size: 12px;
  color: var(--ink-secondary);
}

.summary-val {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
}

.summary-val.pos {
  color: var(--accent-ok);
}

.summary-val.neg {
  color: var(--ink);
}

/* Category Limit Rows */
.limit-item {
  padding: 10px 0;
}

.limit-item + .limit-item {
  border-top: 1px solid rgba(11, 11, 12, 0.05);
}

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

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

.cat-icon-badge {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.limit-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.limit-nums {
  font-size: 12.5px;
  color: var(--ink-secondary);
  white-space: nowrap;
}

.limit-nums strong {
  color: var(--ink);
  font-weight: 700;
}

.progress-bar {
  height: 6px;
  border-radius: 99px;
  background: rgba(11, 11, 12, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--ink);
  transition: width 0.35s ease, background 0.3s ease;
}

.progress-fill.warn {
  background: var(--accent-warn);
}

.progress-fill.danger {
  background: var(--accent-danger);
}

.alert-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  margin-left: 6px;
}

.alert-pill.warn {
  background: #fef3c7;
  color: #92400e;
}

.alert-pill.danger {
  background: #ffe4e6;
  color: #be123c;
}

/* Primary Pill Button */
.btn-primary {
  width: 100%;
  background: var(--ink);
  color: #ffffff;
  font-weight: 700;
  font-size: 15px;
  padding: 14px 20px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.15s, transform 0.12s;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  padding: 11px 16px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-danger-ghost {
  color: var(--accent-danger);
  font-weight: 600;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 10px;
}

.btn-danger-ghost:hover {
  background: #ffe4e6;
}

/* Screen Title */
.screen-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 6px 0 16px;
}

/* Search & Filter Pills */
.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border-radius: var(--radius-pill);
  padding: 11px 16px;
  margin-bottom: 12px;
}

.search-box input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 14.5px;
}

.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  transition: background 0.15s, color 0.15s;
}

.filter-pill.active {
  background: var(--ink);
  color: #ffffff;
}

/* Transaction List */
.tx-group-date {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 16px 0 8px 4px;
}

.tx-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-card);
  border-radius: 18px;
  padding: 12px 14px;
  margin-bottom: 8px;
}

.tx-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.tx-info {
  min-width: 0;
}

.tx-title {
  font-weight: 600;
  font-size: 14.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-meta {
  font-size: 12px;
  color: var(--ink-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.life-hours-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #ffffff;
  color: var(--ink-secondary);
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}

.tx-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.tx-amount {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  text-align: right;
}

.tx-amount.income {
  color: var(--accent-ok);
}

.tx-del-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-tertiary);
}

.tx-del-btn:hover {
  background: #ffe4e6;
  color: var(--accent-danger);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--ink-secondary);
}

.empty-state strong {
  display: block;
  color: var(--ink);
  font-size: 15px;
  margin-bottom: 4px;
}

/* Plan & Settings Grid */
.two-col-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.stat-mini {
  background: #ffffff;
  border-radius: 16px;
  padding: 12px 14px;
}

.stat-mini-label {
  font-size: 12px;
  color: var(--ink-secondary);
}

.stat-mini-val {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  margin-top: 2px;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 0;
}

.list-row + .list-row {
  border-top: 1px solid rgba(11, 11, 12, 0.06);
}

.check-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--ink-tertiary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}

.check-circle.checked {
  background: var(--ink);
  border-color: var(--ink);
  color: #ffffff;
}

/* Bottom Navigation */
.bottom-nav-wrap {
  position: fixed;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 408px;
  z-index: 30;
  pointer-events: none;
}

.bottom-nav {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-nav);
  border: 1px solid rgba(11, 11, 12, 0.06);
}

.nav-item {
  width: 46px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-tertiary);
  transition: color 0.15s, background 0.15s;
}

.nav-item.active {
  color: var(--ink);
  background: var(--bg-card);
}

.nav-fab {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--ink);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(11, 11, 12, 0.25);
  transition: transform 0.15s;
}

.nav-fab:active {
  transform: scale(0.92);
}

/* Modal / Bottom Sheet */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(11, 11, 12, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.18s ease;
}

.modal-sheet {
  width: 100%;
  max-width: 440px;
  max-height: 94dvh;
  overflow-y: auto;
  background: #ffffff;
  border-radius: 28px 28px 0 0;
  padding: 14px 18px calc(20px + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--shadow-sheet);
  animation: slideUp 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.sheet-handle {
  width: 38px;
  height: 4px;
  border-radius: 99px;
  background: var(--border);
  margin: 0 auto 12px;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.sheet-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  margin: 0;
}

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

.seg-btn {
  padding: 9px 12px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink-secondary);
  transition: all 0.15s;
}

.seg-btn.active {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(11, 11, 12, 0.08);
}

.amount-display-wrap {
  text-align: center;
  margin-bottom: 10px;
}

.amount-display {
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.amount-display.zero {
  color: var(--ink-tertiary);
}

.amount-hint {
  font-size: 13px;
  color: var(--ink-secondary);
  margin-top: 2px;
}

/* Category Horizontal Picker */
.cat-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 6px 2px 12px;
  scrollbar-width: none;
}

.cat-scroll::-webkit-scrollbar {
  display: none;
}

.cat-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 66px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-secondary);
}

.cat-chip-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: all 0.15s;
}

.cat-chip.selected {
  color: var(--ink);
}

.cat-chip.selected .cat-chip-circle {
  background: var(--ink);
  color: #ffffff;
  transform: scale(1.06);
}

.cat-chip-label {
  max-width: 68px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Account Chips */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 14px;
  background: var(--bg-card);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  border: 1.5px solid transparent;
}

.account-chip.selected {
  background: var(--ink);
  color: #ffffff;
}

/* Custom Numeric Keypad */
.quick-add-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.quick-add-pill {
  background: var(--bg-card);
  border-radius: var(--radius-pill);
  padding: 9px 0;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--ink);
}

.quick-add-pill:active {
  background: var(--bg-card-hover);
}

.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.key-btn {
  background: var(--bg-card);
  border-radius: 14px;
  height: 44px;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, transform 0.08s;
}

.key-btn:active {
  background: var(--bg-card-hover);
  transform: scale(0.96);
}

/* Form Fields */
.field-group {
  margin-bottom: 12px;
}

.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-secondary);
  margin-bottom: 6px;
}

.field-input {
  width: 100%;
  background: var(--bg-card);
  border: 1.5px solid transparent;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
}

.field-input:focus {
  border-color: var(--ink);
  background: #ffffff;
}

.details-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-secondary);
  margin-bottom: 8px;
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-pill);
  padding: 4px 8px;
}

.stepper-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #ffffff;
  font-weight: 700;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Toggle Switch */
.switch {
  position: relative;
  width: 46px;
  height: 26px;
  border-radius: 99px;
  background: var(--border);
  transition: background 0.2s;
  flex-shrink: 0;
}

.switch.on {
  background: var(--ink);
}

.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.2s;
}

.switch.on::after {
  transform: translateX(20px);
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--ink);
  color: #ffffff;
  padding: 11px 16px;
  border-radius: var(--radius-pill);
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(11, 11, 12, 0.24);
  white-space: nowrap;
}

.toast-action {
  color: #f9a8d4;
  font-weight: 800;
  text-decoration: underline;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
