@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@400;500;600;700;800&display=swap");

:root {
  color-scheme: dark;
  font-family: "DM Sans", sans-serif;
  --background: #0c1220;
  --surface: #141d2e;
  --surface-soft: #192438;
  --border: #263248;
  --text: #edf2fb;
  --muted: #8290a9;
  --purple: #8276fa;
  --purple-light: #aaa2ff;
  --green: #67d6a0;
  --red: #fb8794;
  --gold: #efbd68;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(ellipse at 70% -15%, rgb(91 78 189 / 16%), transparent 42%),
    var(--background);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--purple-light);
  outline-offset: 3px;
}

.finance-app { width: min(1120px, calc(100% - 48px)); margin: 0 auto; }

.topbar {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgb(130 144 169 / 14%);
}

.brand, .header-actions, .brand-mark, .summary-label, .panel-heading, .summary-icon, .month-picker,
.search-box, .privacy-note, .transaction-main, .transaction-category, .transaction-amount,
.transaction-actions, .dialog-heading, .form-row, .type-toggle label span, .filters {
  display: flex;
  align-items: center;
}

.brand { gap: 11px; color: var(--text); text-decoration: none; }
.brand-mark {
  width: 39px;
  height: 39px;
  justify-content: center;
  border: 1px solid rgb(170 162 255 / 24%);
  border-radius: 12px;
  background: linear-gradient(145deg, #393578, #252448);
  color: var(--purple-light);
}
.brand-mark svg { width: 21px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.brand-copy { display: grid; gap: 2px; }
.brand-copy strong { font-family: "Manrope", sans-serif; font-size: 15px; letter-spacing: -0.3px; }
.brand-copy small { color: var(--muted); font-size: 8px; font-weight: 700; letter-spacing: 1.4px; }
.header-actions { gap: 10px; }

.icon-button, .primary-button, .secondary-button, .close-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease, border-color 160ms ease;
}
.icon-button {
  width: 39px;
  height: 39px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #151e2f;
  color: #aab5c9;
}
.icon-button:hover { border-color: #514c8a; background: #1b2540; }
.icon-button svg { width: 18px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.primary-button {
  min-height: 40px;
  gap: 8px;
  padding: 0 14px;
  border-radius: 10px;
  background: #6b5ff0;
  color: white;
  font-size: 11px;
  font-weight: 700;
}
.primary-button:hover { transform: translateY(-1px); background: #7d72fa; }
.primary-button svg { width: 17px; stroke: currentColor; stroke-linecap: round; stroke-width: 1.9; }

.dashboard { padding: 36px 0 30px; }
.welcome-row { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 9px;
  color: #a39afd;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1.35px;
}
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px rgb(103 214 160 / 65%); }
h1, h2, h3, p { margin-top: 0; }
.welcome-row h1 {
  margin: 0;
  font-family: "Manrope", sans-serif;
  font-size: clamp(29px, 4vw, 39px);
  letter-spacing: -1.7px;
  line-height: 1.15;
}
.welcome-row h1 span { color: var(--purple-light); }
.welcome-description { margin: 8px 0 0; color: #929eb3; font-size: 11px; line-height: 1.6; }
.month-picker {
  height: 38px;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #131c2c;
  color: #aab5c9;
}
.month-picker svg { width: 16px; flex: 0 0 auto; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; }
.month-picker input { width: 118px; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 10px; color-scheme: dark; }

.summary-grid { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 13px; }
.summary-card, .panel {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: linear-gradient(145deg, #151f31, #121a29);
}
.summary-card { min-height: 133px; padding: 16px 17px; }
.balance-card {
  border-color: #47427a;
  background:
    radial-gradient(circle at 100% 0, rgb(130 118 250 / 18%), transparent 45%),
    linear-gradient(145deg, #211f42, #191d32);
}
.summary-label { gap: 9px; color: #aab5c9; font-size: 10px; font-weight: 600; }
.summary-icon, .panel-icon {
  width: 29px;
  height: 29px;
  flex: 0 0 auto;
  justify-content: center;
  border-radius: 9px;
}
.summary-icon svg, .panel-icon svg { width: 16px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.balance-icon { background: rgb(130 118 250 / 17%); color: var(--purple-light); }
.income-icon { background: rgb(103 214 160 / 12%); color: var(--green); }
.expense-icon { background: rgb(251 135 148 / 12%); color: var(--red); }
.summary-value { margin: 13px 0 3px; font-family: "Manrope", sans-serif; font-size: clamp(21px, 3vw, 28px); font-weight: 700; letter-spacing: -1px; }
.summary-value.negative { color: var(--red); }
.income-card .summary-value, #income-value { color: var(--green); }
#expense-value { color: var(--red); }
.summary-footnote { margin: 0; color: #8290a9; font-size: 9px; }
.balance-decoration { position: absolute; right: 18px; bottom: -30px; color: rgb(170 162 255 / 10%); font-size: 112px; line-height: 1; transform: rotate(-15deg); }

.insights-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; margin-top: 13px; }
.panel { padding: 17px; }
.panel-heading { justify-content: space-between; gap: 15px; }
.panel-heading .eyebrow { margin-bottom: 5px; }
.panel-heading h2, .transactions-heading h2 { margin: 0; font-family: "Manrope", sans-serif; font-size: 15px; letter-spacing: -0.4px; }
.panel-icon { background: #20233c; color: #aaa2ff; }
.budget-main { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin: 22px 0 13px; }
.budget-caption { margin: 0 0 5px; color: var(--muted); font-size: 9px; }
.budget-numbers { display: flex; align-items: baseline; gap: 5px; margin: 0; color: #aab5c9; font-size: 11px; }
.budget-numbers strong { color: var(--text); font-family: "Manrope", sans-serif; font-size: 20px; letter-spacing: -0.5px; }
.budget-numbers span:last-child { color: #b7c1d2; }
.text-button {
  min-height: 29px;
  padding: 0 9px;
  border: 1px solid #343456;
  border-radius: 7px;
  background: #20213a;
  color: #b8b2ff;
  cursor: pointer;
  font-size: 9px;
  font-weight: 600;
}
.text-button:hover { border-color: #5c568e; background: #282846; }
.progress-track { height: 7px; overflow: hidden; border-radius: 10px; background: #293247; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #7065ed, #a59aff); transition: width 250ms ease; }
.progress-track.over-budget span { background: linear-gradient(90deg, #e1a34b, #fb8794); }
.budget-status { margin: 9px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.category-content { display: grid; grid-template-columns: 126px 1fr; align-items: center; gap: 18px; min-height: 136px; padding-top: 13px; }
.donut-chart {
  position: relative;
  display: grid;
  width: 120px;
  aspect-ratio: 1;
  place-content: center;
  border: 1px solid #293247;
  border-radius: 50%;
  background: conic-gradient(#2c3548 0deg 360deg);
  text-align: center;
}
.donut-chart::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 83px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #141d2e;
  content: "";
  transform: translate(-50%, -50%);
}
.donut-chart span, .donut-chart small { position: relative; z-index: 1; }
.donut-chart span { align-self: end; font-family: "Manrope", sans-serif; font-size: 14px; font-weight: 700; }
.donut-chart small { align-self: start; margin-top: 2px; color: var(--muted); font-size: 8px; }
.category-legend { display: grid; gap: 9px; }
.legend-item { display: grid; grid-template-columns: 7px minmax(0, 1fr) auto; align-items: center; gap: 7px; min-width: 0; color: #b3bed0; font-size: 9px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; }
.legend-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-value { color: #e2e7f0; font-variant-numeric: tabular-nums; }
.legend-empty { color: var(--muted); font-size: 10px; line-height: 1.6; }

.transactions-panel { margin-top: 13px; padding: 17px; }
.transactions-heading { display: flex; align-items: end; justify-content: space-between; gap: 14px; }
.transactions-heading .eyebrow { margin-bottom: 5px; }
.search-box { width: min(220px, 45%); height: 34px; gap: 7px; padding: 0 9px; border: 1px solid var(--border); border-radius: 8px; background: #101827; }
.search-box svg { width: 15px; flex: 0 0 auto; stroke: var(--muted); stroke-linecap: round; stroke-width: 1.6; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 10px; }
.search-box input::placeholder { color: #77859d; }
.filters { gap: 5px; margin: 17px 0 8px; }
.filter-button { min-height: 27px; padding: 0 11px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: #8996ac; cursor: pointer; font-size: 9px; font-weight: 600; }
.filter-button:hover { background: #1b2638; color: var(--text); }
.filter-button.active { border-color: #39375f; background: #252444; color: #c1bbff; }
.transaction-list { display: grid; }
.transaction-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 13px;
  min-height: 64px;
  border-top: 1px solid rgb(130 144 169 / 12%);
}
.transaction-main { min-width: 0; gap: 10px; }
.transaction-icon { display: grid; width: 35px; height: 35px; flex: 0 0 auto; place-items: center; border-radius: 11px; background: #202840; color: #b0a9ff; }
.transaction-icon svg { width: 17px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; }
.transaction-copy { min-width: 0; }
.transaction-copy strong { display: block; overflow: hidden; color: #e5eaf3; font-size: 10px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.transaction-copy small { display: block; overflow: hidden; margin-top: 4px; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.transaction-category { gap: 6px; color: #a2aec2; font-size: 9px; white-space: nowrap; }
.transaction-amount { justify-content: end; color: var(--text); font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.transaction-amount.income { color: var(--green); }
.transaction-amount.expense { color: #f09aa4; }
.transaction-actions { gap: 2px; opacity: 0; transition: opacity 140ms ease; }
.transaction-row:hover .transaction-actions, .transaction-actions:focus-within { opacity: 1; }
.mini-action { display: grid; width: 27px; height: 27px; place-items: center; border: 0; border-radius: 7px; background: transparent; color: #9aa7bc; cursor: pointer; }
.mini-action:hover { background: #253149; color: var(--text); }
.mini-action.delete:hover { color: var(--red); }
.mini-action svg { width: 14px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.empty-state { display: grid; justify-items: center; padding: 44px 15px 26px; text-align: center; }
.empty-icon { display: grid; width: 44px; height: 44px; place-items: center; margin-bottom: 12px; border: 1px solid #303752; border-radius: 13px; background: #1d2639; color: #aca5ff; }
.empty-icon svg { width: 21px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; }
.empty-state h3 { margin: 0; font-size: 13px; }
.empty-state p { margin: 6px 0 14px; color: var(--muted); font-size: 10px; }
.privacy-note { justify-content: center; gap: 6px; margin: 14px 0 0; color: #66748c; font-size: 9px; }
.privacy-note svg { width: 13px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5; }

.app-dialog { width: min(100% - 24px, 480px); max-height: min(90dvh, 760px); padding: 0; overflow: auto; border: 1px solid #354159; border-radius: 15px; background: #151f31; color: var(--text); box-shadow: 0 24px 80px rgb(0 0 0 / 45%); }
.app-dialog::backdrop { background: rgb(3 7 14 / 72%); backdrop-filter: blur(3px); }
.dialog-form { display: grid; gap: 15px; padding: 21px; }
.dialog-heading { justify-content: space-between; gap: 12px; margin-bottom: 1px; }
.dialog-heading .eyebrow { margin-bottom: 5px; }
.dialog-heading h2 { margin: 0; font-family: "Manrope", sans-serif; font-size: 18px; letter-spacing: -0.5px; }
.close-button { width: 31px; height: 31px; flex: 0 0 auto; border-radius: 8px; background: #263349; color: #b3bed0; font-size: 20px; }
.close-button:hover { background: #354159; }
.type-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; padding: 0; border: 0; }
.type-toggle legend { margin-bottom: 8px; color: #c3ccda; font-size: 10px; font-weight: 600; }
.type-toggle label { position: relative; cursor: pointer; }
.type-toggle input { position: absolute; opacity: 0; }
.type-toggle label span { min-height: 39px; justify-content: center; gap: 7px; border: 1px solid #303b51; border-radius: 9px; background: #111a29; color: #9ca9bf; font-size: 10px; font-weight: 600; }
.type-toggle label span svg { width: 15px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.type-toggle input:checked + span { border-color: #554f99; background: #262547; color: #c0baff; }
.type-toggle label:nth-of-type(2) input:checked + span { border-color: #34745a; background: #173327; color: #8de0b5; }
.type-toggle input:focus-visible + span { outline: 2px solid var(--purple-light); outline-offset: 2px; }
.form-field { display: grid; min-width: 0; gap: 7px; color: #c3ccda; font-size: 10px; font-weight: 600; }
.form-field input, .form-field select, .form-field textarea { width: 100%; min-width: 0; min-height: 39px; padding: 9px 10px; border: 1px solid #303b51; border-radius: 9px; outline: 0; background: #0f1827; color: var(--text); font-size: 11px; font-weight: 400; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: #7770c6; }
.form-field textarea { min-height: 62px; resize: vertical; line-height: 1.5; }
.form-field input::placeholder, .form-field textarea::placeholder { color: #65738b; }
.form-row { align-items: start; gap: 10px; }
.form-row > .form-field { flex: 1; }
.amount-input { display: flex; min-height: 39px; align-items: center; gap: 8px; padding-left: 10px; border: 1px solid #303b51; border-radius: 9px; background: #0f1827; color: #9ba8bd; }
.amount-input:focus-within { border-color: #7770c6; }
.amount-input > span { font-size: 11px; }
.amount-input input { min-height: 36px; padding-left: 0; border: 0; background: transparent; }
.amount-input input:focus { border: 0; }
.optional { color: var(--muted); font-weight: 400; }
.dialog-description { margin: 0; color: #9aa7bc; font-size: 11px; line-height: 1.6; }
.dialog-description strong { color: #dce3ee; }
.form-error { margin: 0; color: var(--red); font-size: 10px; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 9px; margin-top: 2px; }
.secondary-button { min-height: 39px; border: 1px solid #354159; border-radius: 9px; background: #202b3e; color: #c1cada; font-size: 10px; font-weight: 600; }
.secondary-button:hover { background: #2a374e; }
.dialog-actions .primary-button { min-height: 39px; }
.toast { position: fixed; z-index: 4; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); left: 16px; width: fit-content; max-width: calc(100% - 32px); margin-inline: auto; padding: 11px 15px; border: 1px solid #354159; border-radius: 10px; background: #222e43; color: var(--text); font-size: 11px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity 160ms ease, transform 160ms ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; clip-path: inset(50%); }
[hidden] { display: none !important; }

@media (max-width: 760px) {
  .finance-app { width: min(100% - 32px, 620px); }
  .dashboard { padding-top: 27px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .balance-card { grid-column: 1 / -1; min-height: 116px; }
  .summary-card { min-height: 116px; }
  .insights-grid { grid-template-columns: 1fr; }
  .category-content { grid-template-columns: 126px 1fr; }
  .transaction-actions { opacity: 1; }
}

@media (max-width: 480px) {
  .finance-app { width: calc(100% - 24px); }
  .topbar { min-height: 66px; }
  .brand-mark { width: 35px; height: 35px; }
  .header-actions { gap: 7px; }
  .header-actions .primary-button { width: 39px; min-width: 39px; height: 39px; min-height: 39px; padding: 0; }
  .header-actions .primary-button span { display: none; }
  .welcome-row { align-items: start; flex-direction: column; gap: 13px; margin-bottom: 17px; }
  .welcome-row h1 { font-size: 30px; }
  .welcome-description { max-width: 330px; }
  .month-picker { align-self: flex-start; }
  .summary-grid { gap: 8px; }
  .summary-card { min-height: 108px; padding: 13px 12px; }
  .balance-card { min-height: 112px; }
  .summary-label { gap: 7px; font-size: 9px; }
  .summary-icon { width: 26px; height: 26px; }
  .summary-value { font-size: 21px; }
  .panel, .transactions-panel { padding: 14px 12px; }
  .category-content { grid-template-columns: 100px minmax(0, 1fr); gap: 11px; }
  .donut-chart { width: 96px; }
  .donut-chart::before { width: 67px; }
  .donut-chart span { font-size: 11px; }
  .legend-item { gap: 5px; font-size: 8px; }
  .transactions-heading { align-items: stretch; flex-direction: column; gap: 12px; }
  .search-box { width: 100%; }
  .transaction-row { grid-template-columns: minmax(0, 1fr) auto; gap: 6px; min-height: 61px; }
  .transaction-category { display: none; }
  .transaction-main { gap: 8px; }
  .transaction-icon { width: 31px; height: 31px; }
  .transaction-amount { grid-column: 2; grid-row: 1; }
  .transaction-actions { grid-column: 1 / -1; grid-row: 2; justify-self: end; margin-top: -6px; }
  .transaction-row { padding-block: 8px; }
  .transaction-copy strong { max-width: 195px; }
  .filters { margin-top: 12px; }
  .dialog-form { padding: 16px; }
}

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