:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --primary: #2196f3;
  --primary-deep: #1178dd;
  --primary-soft: #eaf5ff;
  --ink: #111827;
  --ink-soft: #465267;
  --muted: #8591a3;
  --line: #edf1f6;
  --green: #12b76a;
  --green-soft: #e8f9f0;
  --red: #f04438;
  --red-soft: #fff0ee;
  --shadow: 0 22px 48px -34px rgba(17, 24, 39, 0.34);
  --radius-xl: 30px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --font: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(1100px 620px at 50% -14%, rgba(33, 150, 243, 0.12), transparent 65%),
    #eaf0f7;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.is-locked {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

svg {
  display: block;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: 100%;
  max-width: 560px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 28px 22px 142px;
  background: var(--bg);
}

.app-header {
  padding: 0 2px;
}

.brand {
  margin: 0;
  color: var(--primary);
  font-size: clamp(2.1rem, 11vw, 3.65rem);
  font-weight: 800;
  line-height: 0.98;
  letter-spacing: -0.05em;
  word-spacing: 0.08em;
}

#main-content {
  margin-top: 26px;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
  animation: screen-in 0.34s ease both;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Balance card ---------- */

.balance-card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 24px;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(150px 150px at 84% -20%, rgba(255, 255, 255, 0.27), transparent 70%),
    linear-gradient(140deg, #33a6ff 0%, #1788f2 52%, #0b6bd4 100%);
  box-shadow: 0 26px 54px -28px rgba(20, 127, 225, 0.72);
  color: #fff;
}

.balance-card::before,
.balance-card::after {
  position: absolute;
  z-index: -1;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 50%;
  content: "";
}

.balance-card::before {
  top: -118px;
  right: -74px;
  width: 260px;
  height: 260px;
}

.balance-card::after {
  right: -45px;
  bottom: -174px;
  width: 290px;
  height: 290px;
}

.balance-head {
  display: block;
}

.balance-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 7px;
}

.balance-label {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.balance-amount-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
}

.balance-amount {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: clamp(2rem, 8.7vw, 2.72rem);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.045em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.balance-amount.is-masked {
  letter-spacing: 0.08em;
  transform: translateY(-2px);
}

.balance-toggle {
  display: grid;
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  transition: background-color 0.18s ease, color 0.18s ease;
}

.balance-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.balance-toggle svg {
  width: 19px;
  height: 19px;
}

.month-chip {
  flex: none;
  padding: 7px 11px;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.035em;
  white-space: nowrap;
}

.balance-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.17);
}

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

.stat-icon {
  display: grid;
  flex: none;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.stat-icon svg {
  width: 17px;
  height: 17px;
}

.balance-stat > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.balance-stat span:not(.stat-icon) {
  margin-bottom: 2px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.67rem;
  font-weight: 600;
}

.balance-stat strong {
  overflow: hidden;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Quick actions ---------- */

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 15px;
}

.quick-action {
  display: flex;
  align-items: center;
  min-height: 68px;
  padding: 12px;
  gap: 11px;
  border: 1px solid rgba(21, 43, 72, 0.05);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 14px 30px -28px rgba(17, 24, 39, 0.45);
  text-align: left;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.quick-action:hover {
  box-shadow: 0 18px 34px -26px rgba(17, 24, 39, 0.38);
  transform: translateY(-2px);
}

.quick-action:active {
  transform: translateY(0);
}

.quick-icon {
  display: grid;
  flex: none;
  width: 39px;
  height: 39px;
  place-items: center;
  border-radius: 14px;
}

.quick-icon.income {
  background: var(--green-soft);
  color: var(--green);
}

.quick-icon.expense {
  background: var(--red-soft);
  color: var(--red);
}

.quick-icon svg {
  width: 17px;
  height: 17px;
}

.quick-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.quick-copy strong {
  overflow: hidden;
  font-size: 0.79rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-copy small {
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Sections and lists ---------- */

.section {
  margin-top: 29px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 4px 13px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.035em;
}

.section-total {
  color: var(--ink-soft);
  font-size: 0.77rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.text-button {
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: -0.005em;
}

.text-button:hover {
  color: var(--primary-deep);
}

.list-card,
.card {
  border: 1px solid rgba(21, 43, 72, 0.04);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.list-card {
  overflow: hidden;
}

.transaction-row {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 13px 16px;
  gap: 12px;
  border: 0;
  background: transparent;
  text-align: left;
  transition: background-color 0.16s ease;
}

.transaction-row + .transaction-row {
  border-top: 1px solid var(--line);
}

.transaction-row:hover {
  background: var(--surface-soft);
}

.category-icon {
  display: grid;
  flex: none;
  width: 43px;
  height: 43px;
  place-items: center;
  border-radius: 15px;
}

.category-icon svg {
  width: 19px;
  height: 19px;
}

.transaction-copy {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.transaction-copy strong {
  overflow: hidden;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: -0.012em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.transaction-copy span {
  overflow: hidden;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 500;
  text-overflow: ellipsis;
  text-transform: capitalize;
  white-space: nowrap;
}

.transaction-amount {
  flex: none;
  margin-left: 6px;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.015em;
}

.transaction-amount.income {
  color: var(--green);
}

.empty-state {
  display: flex;
  align-items: center;
  flex-direction: column;
  padding: 36px 24px;
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 48px;
  height: 48px;
  margin-bottom: 11px;
  place-items: center;
  border-radius: 16px;
  background: var(--primary-soft);
  color: var(--primary);
}

.empty-icon svg {
  width: 22px;
  height: 22px;
}

.empty-state strong {
  font-size: 0.83rem;
  font-weight: 800;
}

.empty-state p {
  max-width: 230px;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.71rem;
  line-height: 1.5;
}

/* ---------- Spending ---------- */

.spending-card {
  padding: 20px;
}

.spend-row + .spend-row {
  margin-top: 17px;
}

.spend-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.spend-name {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 700;
}

.spend-name i {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.spend-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spend-top strong {
  flex: none;
  font-size: 0.73rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.spend-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #f1f4f8;
}

.spend-track span {
  display: block;
  min-width: 5px;
  height: 100%;
  border-radius: inherit;
  transform-origin: left;
  animation: bar-grow 0.65s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes bar-grow {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

.spending-empty {
  padding: 13px 4px 5px;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.55;
  text-align: center;
}

/* ---------- Shared page heading ---------- */

.page-head {
  margin: 5px 4px 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.page-head h2 {
  margin: 0;
  font-size: clamp(1.75rem, 7.2vw, 2.2rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.05em;
}

/* ---------- Settings ---------- */

.settings-card {
  overflow: hidden;
  padding: 0 18px;
  border: 1px solid rgba(21, 43, 72, 0.04);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.settings-card + .settings-card {
  margin-top: 14px;
}

.setting-row,
.setting-action {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 16px 0;
  gap: 12px;
  border: 0;
  background: transparent;
  text-align: left;
}

.setting-row + .setting-row,
.setting-action + .setting-action {
  border-top: 1px solid var(--line);
}

.setting-action {
  transition: opacity 0.16s ease;
}

.setting-action:hover {
  opacity: 0.7;
}

.setting-icon {
  display: grid;
  flex: none;
  width: 41px;
  height: 41px;
  place-items: center;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
}

.setting-icon svg {
  width: 18px;
  height: 18px;
}

.setting-copy {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.setting-copy strong {
  font-size: 0.79rem;
  font-weight: 800;
  letter-spacing: -0.012em;
}

.setting-copy span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.65rem;
  line-height: 1.4;
}

.chevron {
  flex: none;
  width: 16px;
  height: 16px;
  color: #b2bcc9;
}

.setting-action.danger .setting-icon {
  background: var(--red-soft);
  color: var(--red);
}

.setting-action.danger .setting-copy strong {
  color: #d92d20;
}

.select-control {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
}

.select-control select {
  min-width: 88px;
  padding: 9px 30px 9px 11px;
  border: 1px solid #e5ebf3;
  border-radius: 12px;
  outline: none;
  appearance: none;
  background: #f8fafc;
  color: var(--ink-soft);
  font-size: 0.68rem;
  font-weight: 800;
  cursor: pointer;
}

.select-control svg {
  position: absolute;
  right: 9px;
  width: 13px;
  height: 13px;
  color: var(--muted);
  pointer-events: none;
}

.select-control select:focus-visible,
.amount-field:focus-within,
.field input[type="date"]:focus-visible,
.field input[type="text"]:focus-visible,
.field-select:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.12);
}

.switch {
  position: relative;
  display: inline-block;
  flex: none;
  width: 47px;
  height: 28px;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #dfe6ef;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.switch-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(17, 24, 39, 0.2);
  content: "";
  transition: transform 0.2s ease;
}

.switch input:checked + .switch-track {
  background: var(--primary);
}

.switch input:checked + .switch-track::after {
  transform: translateX(19px);
}

.switch input:focus-visible + .switch-track {
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.2);
}

.settings-note {
  display: flex;
  align-items: center;
  margin: 20px 4px 0;
  gap: 8px;
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.45;
}

.settings-note svg {
  flex: none;
  width: 14px;
  height: 14px;
}

.version {
  margin: 14px 0 0;
  color: #b5beca;
  font-size: 0.6rem;
  font-weight: 600;
  text-align: center;
}

/* ---------- Profile ---------- */

.profile-card {
  overflow: hidden;
  border: 1px solid rgba(21, 43, 72, 0.04);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.profile-banner {
  position: relative;
  height: 112px;
  overflow: hidden;
  background:
    radial-gradient(120px 120px at 78% 0%, rgba(255, 255, 255, 0.3), transparent 70%),
    linear-gradient(135deg, #33a6ff, #0b6bd4);
}

.profile-banner::after {
  position: absolute;
  top: -104px;
  right: -40px;
  width: 210px;
  height: 210px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  content: "";
}

.profile-avatar {
  position: relative;
  display: block;
  width: 84px;
  height: 84px;
  margin: -22px auto 0;
  padding: 0;
  border: 4px solid var(--surface);
  border-radius: 27px;
  background: var(--surface);
  box-shadow: 0 14px 26px -18px rgba(17, 24, 39, 0.38);
  color: var(--primary);
  cursor: pointer;
}

.profile-avatar:focus-visible {
  outline: 3px solid rgba(33, 150, 243, 0.3);
  outline-offset: 3px;
}

.profile-avatar-media {
  display: grid;
  width: 100%;
  height: 100%;
  overflow: hidden;
  place-items: center;
  border-radius: 22px;
  background: var(--surface);
}

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

.profile-avatar-initials {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.avatar-edit-badge {
  position: absolute;
  right: -5px;
  bottom: -5px;
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 5px 12px -6px rgba(17, 24, 39, 0.5);
  color: #fff;
  transition: background-color 0.16s ease, transform 0.16s ease;
}

.profile-avatar:hover .avatar-edit-badge {
  background: var(--primary-deep);
  transform: scale(1.05);
}

.avatar-edit-badge svg {
  width: 13px;
  height: 13px;
}

.remove-photo {
  display: block;
  margin: 7px auto 0;
  padding: 2px 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.remove-photo:hover {
  color: var(--red);
}

.profile-name {
  margin: 11px 20px 0;
  overflow: hidden;
  font-size: 1.16rem;
  font-weight: 800;
  letter-spacing: -0.035em;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-meta {
  margin: 4px 20px 0;
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 500;
  text-align: center;
}

.name-form {
  display: flex;
  max-width: 342px;
  margin: 18px auto 0;
  padding: 0 20px;
  gap: 8px;
}

.name-form input {
  width: 100%;
  min-width: 0;
  padding: 11px 13px;
  border: 1px solid #e5ebf3;
  border-radius: 13px;
  outline: none;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 0.73rem;
  font-weight: 600;
}

.name-form input:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.12);
}

.name-form button {
  flex: none;
  padding: 0 17px;
  border: 0;
  border-radius: 13px;
  background: var(--primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  transition: background-color 0.16s ease;
}

.name-form button:hover {
  background: var(--primary-deep);
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 22px;
  padding: 18px 12px 20px;
  border-top: 1px solid var(--line);
}

.profile-stats > div {
  display: flex;
  align-items: center;
  flex-direction: column;
  min-width: 0;
  padding: 0 6px;
}

.profile-stats > div + div {
  border-left: 1px solid var(--line);
}

.profile-stats strong {
  max-width: 100%;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-stats span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 600;
}

.profile-tip {
  display: flex;
  margin-top: 14px;
  padding: 17px;
  gap: 12px;
  border: 1px solid rgba(21, 43, 72, 0.04);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tip-icon {
  display: grid;
  flex: none;
  width: 37px;
  height: 37px;
  place-items: center;
  border-radius: 12px;
  background: var(--green-soft);
  color: var(--green);
}

.tip-icon svg {
  width: 18px;
  height: 18px;
}

.profile-tip strong {
  font-size: 0.76rem;
  font-weight: 800;
}

.profile-tip p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.5;
}

/* ---------- Bottom nav ---------- */

.bottom-nav {
  position: fixed;
  z-index: 40;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: min(calc(100% - 32px), 516px);
  height: 86px;
  padding: 10px 18px;
  border-radius: 999px;
  background:
    radial-gradient(180px 80px at 50% 0%, rgba(255, 255, 255, 0.14), transparent 68%),
    var(--primary);
  box-shadow: 0 22px 46px -18px rgba(18, 127, 226, 0.65);
  transform: translateX(-50%);
}

.nav-button {
  display: grid;
  width: 100%;
  height: 100%;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  opacity: 0.72;
  transition: opacity 0.18s ease, background-color 0.18s ease, transform 0.18s ease;
}

.nav-button svg {
  width: 28px;
  height: 28px;
}

.nav-button:hover {
  opacity: 1;
}

.nav-button.is-active {
  opacity: 1;
}

.nav-avatar {
  display: block;
  width: 29px;
  height: 29px;
  overflow: hidden;
  border: 1.5px solid rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
}

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

.nav-button:active {
  transform: scale(0.96);
}

.nav-button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -4px;
}

/* ---------- Modals ---------- */

.modal {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  visibility: hidden;
  transition: visibility 0s linear 0.34s;
}

.modal.is-open {
  visibility: visible;
  transition-delay: 0s;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 15, 27, 0.48);
  opacity: 0;
  backdrop-filter: blur(4px);
  transition: opacity 0.25s ease;
}

.modal.is-open .modal-backdrop {
  opacity: 1;
}

.sheet {
  position: relative;
  width: min(100%, 560px);
  max-height: 92dvh;
  overflow-y: auto;
  padding: 10px 22px calc(24px + env(safe-area-inset-bottom));
  border-radius: 32px 32px 0 0;
  background: var(--surface);
  box-shadow: 0 -24px 60px rgba(7, 15, 27, 0.18);
  transform: translateY(103%);
  transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
  overscroll-behavior: contain;
}

.modal.is-open .sheet {
  transform: translateY(0);
}

.sheet-handle {
  width: 39px;
  height: 5px;
  margin: 1px auto 18px;
  border-radius: 999px;
  background: #dde4ed;
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.sheet-head h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.045em;
}

.sheet-head .eyebrow {
  margin-bottom: 4px;
}

.icon-button {
  display: grid;
  flex: none;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--ink-soft);
  transition: background-color 0.16s ease;
}

.icon-button:hover {
  background: #eef3f9;
}

.icon-button svg {
  width: 16px;
  height: 16px;
}

/* ---------- Transaction form ---------- */

#transaction-form {
  margin-top: 20px;
}

.type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  gap: 4px;
  border-radius: 16px;
  background: #f2f5fa;
}

.type-option {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  gap: 7px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  transition: background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.type-option.is-active {
  background: var(--surface);
  box-shadow: 0 5px 14px -9px rgba(17, 24, 39, 0.35);
  color: var(--ink);
}

.type-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.type-dot.expense {
  background: var(--red);
}

.type-dot.income {
  background: var(--green);
}

.field {
  display: flex;
  flex-direction: column;
  margin-top: 16px;
}

.field-label {
  margin: 0 0 7px 2px;
  color: var(--ink-soft);
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.005em;
}

.optional {
  color: #a5afbd;
  font-weight: 500;
}

.amount-field {
  display: flex;
  align-items: center;
  padding: 7px 16px;
  border: 1.5px solid #e7edf5;
  border-radius: 18px;
  background: #f8fafc;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.amount-prefix {
  flex: none;
  color: var(--primary);
  font-size: 1.56rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.amount-field input {
  width: 100%;
  min-width: 0;
  padding: 2px 8px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.045em;
}

.amount-field input::placeholder {
  color: #c3ccd8;
}

.amount-field input::-webkit-outer-spin-button,
.amount-field input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

.amount-field input[type="number"] {
  appearance: textfield;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
}

.field .select-control,
.field-select {
  width: 100%;
}

.field-select select {
  width: 100%;
  min-height: 46px;
  padding: 11px 35px 11px 13px;
  border: 1.5px solid #e7edf5;
  border-radius: 14px;
  background: #f8fafc;
  font-size: 0.74rem;
  font-weight: 700;
}

.field input[type="date"],
.field input[type="text"] {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 1.5px solid #e7edf5;
  border-radius: 14px;
  outline: none;
  background: #f8fafc;
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 600;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.field input::placeholder {
  color: #aeb8c5;
  font-weight: 500;
}

.primary-button {
  width: 100%;
  min-height: 54px;
  margin-top: 22px;
  padding: 0 18px;
  border: 0;
  border-radius: 17px;
  background: linear-gradient(135deg, #2ca4ff, #0f7ce6);
  box-shadow: 0 16px 30px -18px rgba(18, 127, 226, 0.75);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.primary-button:hover {
  box-shadow: 0 20px 34px -18px rgba(18, 127, 226, 0.85);
  transform: translateY(-1px);
}

.primary-button:active {
  transform: translateY(0);
}

.delete-button {
  width: 100%;
  margin-top: 10px;
  padding: 13px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #d92d20;
  font-size: 0.72rem;
  font-weight: 800;
}

.delete-button:hover {
  background: var(--red-soft);
}

/* ---------- Activity ---------- */

.activity-sheet {
  max-height: 88dvh;
}

.filter-tabs {
  display: flex;
  margin: 20px 0 14px;
  padding: 4px;
  gap: 4px;
  border-radius: 15px;
  background: #f2f5fa;
}

.filter-tab {
  flex: 1;
  min-height: 38px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-size: 0.71rem;
  font-weight: 800;
  transition: background-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.filter-tab.is-active {
  background: var(--surface);
  box-shadow: 0 5px 14px -9px rgba(17, 24, 39, 0.35);
  color: var(--ink);
}

.activity-list {
  margin-bottom: 4px;
  box-shadow: none;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  z-index: 200;
  bottom: calc(124px + env(safe-area-inset-bottom));
  left: 50%;
  max-width: calc(100% - 44px);
  padding: 12px 18px;
  border-radius: 14px;
  background: #111c2e;
  box-shadow: 0 16px 36px -18px rgba(7, 15, 27, 0.65);
  color: #fff;
  font-size: 0.71rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transform: translate(-50%, 10px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Responsive and motion ---------- */

@media (max-width: 359px) {
  .app-shell {
    padding-right: 16px;
    padding-left: 16px;
  }

  .balance-card {
    padding: 20px;
  }

  .quick-action {
    padding: 10px;
    gap: 8px;
  }

  .quick-icon {
    width: 35px;
    height: 35px;
  }

  .quick-copy small {
    display: none;
  }

  .balance-stat {
    gap: 8px;
  }

  .stat-icon {
    width: 32px;
    height: 32px;
  }

  .bottom-nav {
    width: calc(100% - 24px);
    height: 80px;
  }

  .setting-copy span {
    display: none;
  }
}

@media (min-width: 640px) {
  .app-shell {
    min-height: 100vh;
    box-shadow:
      0 0 0 1px rgba(21, 43, 72, 0.03),
      0 28px 90px -40px rgba(17, 24, 39, 0.3);
  }

  .sheet {
    margin-bottom: 20px;
    border-radius: 32px;
  }

  .activity-sheet {
    margin-bottom: 20px;
  }

  .modal {
    align-items: center;
  }

  .modal.is-open .sheet {
    transform: translateY(0);
  }

  .sheet {
    transform: translateY(40px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.24s ease;
  }

  .modal.is-open .sheet {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
