:root {
  --bg: #0f172a;
  --surface: #111827;
  --card: #ffffff;
  --muted: #64748b;
  --text: #0f172a;
  --white: #ffffff;
  --line: rgba(15, 23, 42, .1);
  --accent: #22c55e;
  --accent-dark: #16a34a;
  --danger: #ef4444;
  --shadow: 0 14px 34px rgba(2, 6, 23, .18);
  --shadow-strong: 0 18px 44px rgba(2, 6, 23, .26);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(34, 197, 94, .24), transparent 32%),
    linear-gradient(180deg, #111827 0%, #0f172a 38%, #f1f5f9 38%, #f1f5f9 100%);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 430px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 14px 22px;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  color: var(--white);
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 3px;
  color: rgba(255, 255, 255, .62);
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.85rem, 8vw, 2.65rem);
  line-height: .92;
  letter-spacing: -.055em;
}

.month-nav {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.month-nav-btn,
.month-pill {
  border: 1px solid rgba(255, 255, 255, .16);
  color: rgba(255, 255, 255, .92);
  background: rgba(255, 255, 255, .08);
  backdrop-filter: blur(12px);
  cursor: pointer;
}

.month-nav-btn {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border-radius: 12px;
  padding: 0;
}

.month-nav-btn svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

.month-nav-btn:disabled {
  opacity: .34;
  cursor: not-allowed;
}

.month-pill {
  flex: 0 0 auto;
  min-width: 78px;
  padding: 8px 8px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 850;
  text-align: center;
  white-space: nowrap;
}

.month-pill.is-history {
  border-color: rgba(34, 197, 94, .55);
  background: rgba(34, 197, 94, .16);
}

.budget-wrap {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-areas:
    "card-one card-two"
    "actions actions";
  align-items: stretch;
  gap: 9px;
  margin-bottom: 14px;
}

#cardOne {
  grid-area: card-one;
}

#cardTwo {
  grid-area: card-two;
}

.budget-card {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 94px;
  border: 0;
  border-radius: var(--radius);
  padding: 11px 10px 10px;
  text-align: left;
  background: rgba(255, 255, 255, .93);
  box-shadow: var(--shadow);
  color: var(--text);
  outline: 2px solid transparent;
  transform: translateY(0);
  transition:
    transform .18s ease,
    box-shadow .18s ease,
    outline-color .18s ease,
    background .18s ease;
}

.budget-card.active {
  background: #ffffff;
  outline-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-strong);
}

.budget-card:active {
  transform: scale(.985);
}

.budget-card.active:active {
  transform: translateY(-2px) scale(.985);
}

.card-title {
  display: block;
  min-height: 1.15em;
  color: #475569;
  font-size: .76rem;
  font-weight: 850;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.card-balance {
  display: block;
  max-width: 100%;
  margin-top: 6px;
  font-size: clamp(1.05rem, 5.7vw, 1.42rem);
  line-height: 1;
  letter-spacing: -.045em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.card-balance.negative {
  color: var(--danger);
}

.card-sub {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: .66rem;
  font-weight: 750;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-actions {
  grid-area: actions;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding-top: 1px;
}

.icon-btn,
.add-expense-btn {
  border: 0;
  box-shadow: 0 9px 22px rgba(2, 6, 23, .2);
  cursor: pointer;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 15px;
  color: #111827;
  background: #ffffff;
}

.add-expense-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 148px;
  height: 38px;
  padding: 0 16px;
  border-radius: 15px;
  color: #ffffff;
  background: var(--accent);
  font-size: .82rem;
  font-weight: 900;
  letter-spacing: -.01em;
  white-space: nowrap;
}

.icon-btn svg,
.add-expense-btn svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.add-expense-btn svg {
  width: 19px;
  height: 19px;
}

.icon-btn:active,
.add-expense-btn:active {
  transform: scale(.95);
}

.list-panel {
  overflow: hidden;
  width: 100%;
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 12px 34px rgba(15, 23, 42, .12);
}

.list-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  padding: 15px 14px 12px;
  border-bottom: 1px solid var(--line);
}

.list-head h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.1;
  letter-spacing: -.03em;
}

.list-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 700;
}

.list-head span {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: .7rem;
  font-weight: 850;
  white-space: nowrap;
}

.expense-list {
  min-height: 270px;
}

.expense-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 32px;
  gap: 8px;
  align-items: center;
  padding: 13px 10px 13px 14px;
  border-bottom: 1px solid var(--line);
}

.expense-row:last-child {
  border-bottom: 0;
}

.expense-main {
  min-width: 0;
}

.expense-desc {
  margin: 0 0 4px;
  font-size: .9rem;
  line-height: 1.2;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.expense-date {
  margin: 0;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 700;
}

.expense-amount {
  font-size: .86rem;
  font-weight: 900;
  white-space: nowrap;
}

.menu-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 12px;
  background: #f8fafc;
  color: #475569;
  cursor: pointer;
}

.menu-btn svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

.menu-btn:active {
  transform: scale(.94);
}

.row-menu {
  position: absolute;
  right: 10px;
  top: 44px;
  z-index: 5;
  display: none;
  min-width: 112px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, .18);
}

.row-menu.open {
  display: grid;
  gap: 4px;
}

.row-menu button {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 9px 10px;
  background: #f8fafc;
  text-align: left;
  font-size: .82rem;
  font-weight: 850;
  cursor: pointer;
}

.row-menu button.delete {
  color: var(--danger);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 270px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  display: block;
  color: #334155;
  font-size: 1rem;
  margin-bottom: 5px;
}

.empty-state p {
  margin: 0;
  max-width: 250px;
  font-size: .84rem;
  line-height: 1.45;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(2, 6, 23, .62);
}

.modal {
  width: min(100%, 430px);
  max-height: calc(100vh - 24px);
  overflow: auto;
  border-radius: 24px;
  padding: 18px;
  background: #ffffff;
  box-shadow: 0 22px 70px rgba(2, 6, 23, .34);
  animation: modalIn .18s ease-out;
}

@keyframes modalIn {
  from {
    transform: translateY(16px);
    opacity: .7;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal h3 {
  margin: 0 40px 16px 0;
  font-size: 1.18rem;
  line-height: 1.15;
  letter-spacing: -.04em;
}

.modal-close {
  float: right;
  width: 33px;
  height: 33px;
  border: 0;
  border-radius: 12px;
  background: #f1f5f9;
  color: #334155;
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
}

.confirm-copy {
  margin: 0 0 16px;
  color: #475569;
  font-size: .9rem;
  line-height: 1.45;
  font-weight: 700;
}

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

.modal-actions #modalFields {
  display: contents;
}

.modal-actions .confirm-copy {
  grid-column: 1 / -1;
  margin-bottom: 4px;
}

.modal-actions .submit-btn {
  margin-top: 0;
}

.secondary-btn {
  width: 100%;
  border: 0;
  border-radius: 15px;
  padding: 13px 15px;
  background: #f1f5f9;
  color: #334155;
  font-weight: 900;
  cursor: pointer;
}

.secondary-btn:active {
  transform: scale(.99);
}

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  margin-bottom: 7px;
  color: #475569;
  font-size: .78rem;
  font-weight: 850;
}

.field input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 15px;
  padding: 13px 13px;
  outline: 0;
  background: #ffffff;
  color: #0f172a;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, .14);
}

.submit-btn {
  width: 100%;
  margin-top: 4px;
  border: 0;
  border-radius: 15px;
  padding: 13px 15px;
  background: #111827;
  color: #ffffff;
  font-weight: 900;
  cursor: pointer;
}

.submit-btn:active {
  transform: scale(.99);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 80;
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  min-width: 180px;
  max-width: calc(100% - 28px);
  padding: 11px 13px;
  border-radius: 999px;
  background: #111827;
  color: #ffffff;
  text-align: center;
  font-size: .84rem;
  font-weight: 850;
  box-shadow: 0 14px 34px rgba(2, 6, 23, .3);
  transition: opacity .18s ease, transform .18s ease;
}

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

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

  .app-header {
    gap: 8px;
    margin-bottom: 12px;
  }

  h1 {
    font-size: clamp(1.7rem, 7.5vw, 2.2rem);
  }

  .month-nav {
    gap: 3px;
  }

  .month-nav-btn {
    width: 29px;
    height: 29px;
    border-radius: 11px;
  }

  .month-nav-btn svg {
    width: 18px;
    height: 18px;
  }

  .month-pill {
    min-width: 72px;
    padding: 7px 7px;
    font-size: .66rem;
  }

  .budget-wrap {
    gap: 8px;
  }

  .budget-card {
    min-height: 88px;
    padding: 10px 9px 9px;
  }

  .card-title {
    font-size: .71rem;
  }

  .card-balance {
    margin-top: 5px;
    font-size: clamp(1rem, 5.5vw, 1.22rem);
  }

  .card-sub {
    margin-top: 6px;
    font-size: .62rem;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 14px;
  }

  .add-expense-btn {
    min-width: 138px;
    height: 36px;
    padding: 0 14px;
    border-radius: 14px;
    font-size: .78rem;
  }

  .add-expense-btn svg {
    width: 18px;
    height: 18px;
  }

  .expense-row {
    grid-template-columns: minmax(0, 1fr) auto 31px;
    gap: 7px;
    padding-left: 12px;
  }

  .expense-desc {
    font-size: .86rem;
  }

  .expense-amount {
    font-size: .82rem;
  }
}

@media (min-width: 680px) {
  body {
    background:
      radial-gradient(circle at top left, rgba(34, 197, 94, .18), transparent 30%),
      linear-gradient(135deg, #0f172a 0%, #111827 44%, #e2e8f0 44%, #f8fafc 100%);
  }

  .app-shell {
    width: min(100%, 520px);
    padding-top: 32px;
  }

  .budget-card {
    min-height: 108px;
    padding: 13px 12px;
  }

  .card-title {
    font-size: .84rem;
  }

  .card-balance {
    font-size: clamp(1.28rem, 4vw, 1.65rem);
  }

  .card-sub {
    font-size: .72rem;
  }

  .modal-backdrop {
    place-items: center;
  }
}
