:root {
  color-scheme: dark;
  --bg: #0b1020;
  --surface: #12182b;
  --surface-soft: #182036;
  --line: rgba(255,255,255,0.08);
  --text: #eef2ff;
  --muted: #98a2b3;
  --accent: #7c3aed;
  --accent-soft: rgba(124, 58, 237, 0.16);
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: radial-gradient(circle at top left, rgba(124,58,237,.18), transparent 30%), var(--bg);
  color: var(--text);
}
button, input, select { font: inherit; }
.app {
  min-height: 100vh;
  padding: 20px;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}
.burger-btn {
  width: 52px;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 0 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.burger-btn span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 999px;
}
.topbar-copy h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
}
.eyebrow, .label {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .72rem;
  color: var(--muted);
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.dashboard,
.view {
  display: none;
  gap: 18px;
}
.view.active {
  display: grid;
}
.month-row {
  padding: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.month-row strong {
  font-size: 1.1rem;
}
.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
.stat-card {
  padding: 22px;
}
.stat-card strong {
  display: block;
  margin-bottom: 10px;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  line-height: 1.05;
}
.chart-card {
  padding: 22px;
}
.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.chart-head h2 {
  margin: 0;
  font-size: 1.2rem;
}
.cashflow-chart {
  display: grid;
  gap: 14px;
}
.chart-row {
  display: grid;
  gap: 8px;
}
.chart-row-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.chart-track {
  height: 14px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  overflow: hidden;
}
.chart-fill {
  height: 100%;
  border-radius: inherit;
}
.chart-fill.income { background: linear-gradient(90deg, #10b981, #34d399); }
.chart-fill.subscriptions { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.chart-fill.nicol { background: linear-gradient(90deg, #ec4899, #f472b6); }
.chart-fill.debts { background: linear-gradient(90deg, #6366f1, #8b5cf6); }
.stat-primary {
  background: linear-gradient(135deg, #6d28d9, #7c3aed);
  color: white;
  border-color: transparent;
}
.stat-primary .label,
.stat-primary .muted {
  color: rgba(255,255,255,.84);
}
.income-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
}
.income-layout.single-column {
  grid-template-columns: 1fr;
}
.form-card,
.income-list-card {
  padding: 22px;
}
.income-form {
  display: grid;
  gap: 14px;
}
label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}
input,
select {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 12px 14px;
}
select {
  min-width: 180px;
}
.primary-btn {
  border: 0;
  border-radius: 16px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #6d28d9, #7c3aed);
  color: white;
  cursor: pointer;
}
.income-list {
  display: grid;
  gap: 12px;
}
.income-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-soft);
}
.income-main {
  display: grid;
  gap: 6px;
}
.income-title {
  font-weight: 600;
}
.income-amount {
  font-weight: 700;
}
.income-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.icon-action-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1rem;
}
.plus-btn {
  color: #c4b5fd;
  background: rgba(124, 58, 237, 0.12);
  border-color: rgba(124, 58, 237, 0.25);
  font-size: 1.4rem;
  line-height: 1;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
  z-index: 30;
}
.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.modal-card {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(.98);
  width: min(520px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
  padding: 22px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 31;
}
.modal-card.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.modal-actions.single-end {
  justify-content: flex-end;
}
.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  cursor: pointer;
}
.recurring-select {
  display: grid;
  gap: 8px;
}
.hidden {
  display: none !important;
}
.toggle-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.toggle-ui {
  position: relative;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  border: 1px solid var(--line);
  transition: background .18s ease, border-color .18s ease;
}
.toggle-ui::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform .18s ease;
}
.toggle-input:checked + .toggle-ui {
  background: rgba(124, 58, 237, 0.5);
  border-color: rgba(124, 58, 237, 0.8);
}
.toggle-input:checked + .toggle-ui::after {
  transform: translateX(18px);
}
.ghost-btn {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 18px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.danger-btn {
  color: #fda4af;
}
.muted { color: var(--muted); }
.drawer {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(280px, calc(100vw - 32px));
  padding: 20px;
  transform: translateX(-110%);
  transition: transform .22s ease;
  z-index: 20;
}
.drawer.open {
  transform: translateX(0);
}
.drawer-card {
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.34);
  padding: 22px;
}
.drawer-nav {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}
.drawer-link {
  border: 0;
  background: var(--surface-soft);
  color: var(--text);
  padding: 14px 16px;
  border-radius: 16px;
  text-align: left;
}
.drawer-link.active {
  background: var(--accent-soft);
  color: #c4b5fd;
  font-weight: 600;
}
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
  z-index: 10;
}
.backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
@media (max-width: 900px) {
  .stats-grid,
  .income-layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .app { padding: 16px; }
  .month-row {
    align-items: flex-start;
    flex-direction: column;
  }
  select {
    width: 100%;
    min-width: 0;
  }
}
