:root {
  --bg: #edf7f4;
  --surface: #ffffff;
  --surface-soft: #e9f4f0;
  --surface-tint: #f7fbf9;
  --ink: #111827;
  --muted: #667085;
  --line: #d9e7e2;
  --nav: #061a22;
  --green: #00b889;
  --mint: #b8f36b;
  --blue: #3867ff;
  --cyan: #18b8cf;
  --coral: #ff6b5f;
  --gold: #ffb84d;
  --purple: #7c5cff;
  --shadow: 0 22px 55px rgba(16, 40, 48, 0.11);
  --shadow-soft: 0 12px 28px rgba(16, 40, 48, 0.08);
  --radius: 20px;
  --radius-sm: 14px;
  --font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 0%, rgba(184, 243, 107, 0.32), transparent 28%),
    radial-gradient(circle at 100% 12%, rgba(24, 184, 207, 0.22), transparent 30%),
    linear-gradient(135deg, #f9fffc 0%, var(--bg) 52%, #e6f0ff 100%);
  color: var(--ink);
  font-family: var(--font);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 42%),
    var(--nav);
  color: #f8fffc;
  position: relative;
  overflow: hidden;
}

.sidebar::after {
  content: "";
  position: absolute;
  right: -80px;
  bottom: 120px;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: rgba(0, 184, 137, 0.22);
  filter: blur(8px);
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--mint), #34e6b4 52%, #7dc7ff);
  color: var(--ink);
  font-weight: 900;
  box-shadow: 0 16px 35px rgba(0, 184, 137, 0.24);
}

.brand h1,
.brand p,
.eyebrow {
  margin: 0;
}

.brand h1 {
  font-size: 1.28rem;
}

.brand p,
.eyebrow {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar .brand p {
  color: #9dc9c0;
}

.nav-list {
  display: grid;
  gap: 8px;
  position: relative;
  z-index: 1;
}

.nav-item,
.reset-btn {
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: #c6d9d5;
  padding: 13px 14px;
  text-align: left;
  font-weight: 850;
}

.nav-item:hover,
.nav-item.active,
.reset-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  box-shadow: inset 4px 0 0 var(--mint);
}

.reset-btn {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.16);
  position: relative;
  z-index: 1;
}

.main {
  min-width: 0;
  padding: 34px;
}

.topbar,
.panel-head,
.dialog-head,
.dialog-actions,
.filters,
.split-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  margin-bottom: 24px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: var(--shadow-soft);
  padding: 18px 20px;
  backdrop-filter: blur(18px);
}

.topbar h2 {
  margin: 4px 0 0;
  font-size: clamp(1.85rem, 4vw, 2.8rem);
  letter-spacing: 0;
}

.primary-btn,
.ghost-btn,
.icon-btn {
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 850;
}

.primary-btn,
.ghost-btn {
  padding: 11px 16px;
}

.primary-btn {
  background: linear-gradient(135deg, var(--green), #0f86ff);
  color: #ffffff;
  box-shadow: 0 15px 30px rgba(0, 184, 137, 0.22);
}

.primary-btn:hover {
  background: linear-gradient(135deg, #009f77, #2954e8);
}

.ghost-btn {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.icon-btn {
  width: 34px;
  height: 34px;
  background: var(--surface-soft);
  color: var(--ink);
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

.balance-grid,
.budget-grid,
.pots-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.balance-card,
.panel,
.budget-card,
.pot-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.balance-card {
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.balance-card:first-child {
  background:
    linear-gradient(135deg, rgba(184, 243, 107, 0.22), transparent 38%),
    linear-gradient(145deg, #061a22, #0b3441 58%, #0f6f75);
  color: #ffffff;
}

.balance-card:not(:first-child)::after {
  content: "";
  position: absolute;
  top: 16px;
  right: 16px;
  width: 38px;
  height: 38px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(0, 184, 137, 0.16), rgba(56, 103, 255, 0.12));
}

.balance-card span,
.balance-card p,
.transaction-row span,
.compact-row span,
.bill-row span,
.pot-card p {
  color: var(--muted);
}

.balance-card:first-child span,
.balance-card:first-child p {
  color: #b6d7d0;
}

.balance-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.55rem, 3vw, 2rem);
}

.balance-card p {
  margin: 8px 0 0;
}

.overview-grid,
.lower-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.panel,
.budget-card {
  padding: 20px;
}

.panel h3,
.budget-card h3,
.pot-card h3 {
  margin: 4px 0 0;
}

.chart-wrap {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  align-items: center;
  gap: 22px;
}

.donut {
  width: 220px;
  height: 220px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  position: relative;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 34px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px var(--line);
}

.donut span {
  position: relative;
  z-index: 1;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 900;
}

.donut small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

.category-list,
.compact-list,
.bill-list,
#transaction-table,
#pots-summary {
  display: grid;
  gap: 10px;
}

.category-item,
.transaction-row,
.compact-row,
.bill-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-tint);
  padding: 11px;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.category-item:hover,
.transaction-row:hover,
.compact-row:hover,
.bill-row:hover {
  border-color: rgba(0, 184, 137, 0.38);
  box-shadow: 0 12px 24px rgba(16, 40, 48, 0.08);
  transform: translateY(-1px);
}

.category-item span {
  width: 14px;
  height: 14px;
  border-radius: 5px;
}

.category-item em,
.transaction-row em,
.compact-row em,
.bill-row em,
.workload-item em {
  font-style: normal;
  font-weight: 850;
}

.merchant-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: #ffffff;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.32);
}

.transaction-row div:nth-child(2) span {
  display: block;
  margin-top: 4px;
}

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

.expense {
  color: var(--coral);
}

.filters {
  margin-bottom: 14px;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  padding: 12px 14px;
  outline: 0;
}

input:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(0, 184, 137, 0.14);
}

.filters input {
  flex: 1;
}

.filters select {
  max-width: 190px;
}

.budget-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.budget-card {
  position: relative;
  overflow: hidden;
}

.budget-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--green), var(--blue), var(--mint));
}

.progress-track {
  overflow: hidden;
  height: 13px;
  border-radius: 999px;
  background: #dbeae5;
  margin: 16px 0 10px;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  box-shadow: 0 5px 14px rgba(0, 184, 137, 0.22);
}

.pots-grid,
#pots-summary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#pots-summary {
  grid-template-columns: 1fr;
}

.pot-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 16px;
}

.pot-orb {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  color: #ffffff;
  font-weight: 900;
  box-shadow: 0 16px 28px rgba(16, 40, 48, 0.14);
}

.bill-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.bill-summary article {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #ffffff, var(--surface-soft));
  padding: 14px;
}

.bill-summary span,
.bill-summary strong {
  display: block;
}

.bill-summary strong {
  margin-top: 6px;
  font-size: 1.5rem;
}

.status {
  justify-self: start;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.72rem;
  font-weight: 850;
}

.paid {
  background: #d9fbea;
  color: #067456;
}

.due-soon {
  background: #fff0d1;
  color: #8c5600;
}

.upcoming {
  background: #e8eeff;
  color: #294fd6;
}

.dialog {
  width: min(520px, calc(100vw - 32px));
  border: 0;
  background: transparent;
  padding: 0;
}

.dialog:not([open]) {
  display: none;
}

.dialog[open] {
  display: block;
  position: fixed;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
}

.dialog::backdrop {
  background: rgba(6, 26, 34, 0.58);
}

.dialog form {
  display: grid;
  gap: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  padding: 20px;
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  border-radius: 999px;
  background: var(--nav);
  color: #ffffff;
  padding: 12px 16px;
  font-weight: 850;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    border-radius: 0 0 28px 28px;
  }

  .nav-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .nav-item,
  .reset-btn {
    text-align: center;
  }

  .balance-grid,
  .overview-grid,
  .budget-grid,
  .pots-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .main {
    padding: 16px;
  }

  .topbar,
  .filters,
  .chart-wrap,
  .dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar,
  .filters,
  .chart-wrap {
    display: flex;
  }

  .topbar {
    border-radius: 22px;
  }

  .nav-list,
  .balance-grid,
  .overview-grid,
  .budget-grid,
  .pots-grid,
  #pots-summary,
  .bill-summary {
    grid-template-columns: 1fr;
  }

  .filters select {
    max-width: none;
  }

  .donut {
    width: 190px;
    height: 190px;
  }

  .sidebar {
    padding: 18px;
  }
}
