/* =========================================================
   Expense Tracker — purple / pink theme (light + dark)
   ========================================================= */

:root {
  --bg: #f8f4fd;
  --bg-accent-1: rgba(168, 85, 247, 0.10);
  --bg-accent-2: rgba(236, 72, 153, 0.08);
  --surface: #ffffff;
  --surface-2: #f6f0fd;
  --surface-3: #efe5fb;
  --border: #ece2f8;
  --border-strong: #dccbf3;
  --text: #2b1745;
  --text-2: #5b4776;
  --muted: #8f7da8;
  --purple: #8b5cf6;
  --purple-deep: #7c3aed;
  --purple-soft: #ede4fe;
  --pink: #ec4899;
  --pink-soft: #fde7f3;
  --green: #059669;
  --green-soft: #d9f7ec;
  --red: #e11d48;
  --red-soft: #ffe4ea;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --grad: linear-gradient(135deg, #7c3aed 0%, #a855f7 50%, #ec4899 100%);
  --grad-soft: linear-gradient(135deg, #f3e8ff 0%, #fce7f3 100%);
  --shadow-sm: 0 1px 2px rgba(76, 29, 149, 0.06);
  --shadow: 0 4px 24px rgba(124, 58, 237, 0.08);
  --shadow-lg: 0 20px 60px rgba(124, 58, 237, 0.18);
  --radius: 18px;
  --radius-sm: 12px;
  --sidebar-w: 256px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #1b1129;
  --bg-accent-1: rgba(168, 85, 247, 0.16);
  --bg-accent-2: rgba(236, 72, 153, 0.12);
  --surface: #251838;
  --surface-2: #2d1f44;
  --surface-3: #372751;
  --border: #382854;
  --border-strong: #4a3570;
  --text: #f5edff;
  --text-2: #d6c6ee;
  --muted: #a592c2;
  --purple-soft: #3a2560;
  --pink-soft: #4a1f3d;
  --green: #34d399;
  --green-soft: #12392f;
  --red: #fb7185;
  --red-soft: #45192a;
  --amber: #fbbf24;
  --amber-soft: #3f2f12;
  --grad-soft: linear-gradient(135deg, #34205a 0%, #4a1f45 100%);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(900px 500px at 0% -10%, var(--bg-accent-1), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, var(--bg-accent-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.02em; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }
p { margin: 0; }
a { color: var(--purple); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 22px 16px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 40;
}
.logo { display: flex; align-items: center; gap: 12px; padding: 0 8px 22px; text-decoration: none; color: var(--text); }
.logo-mark {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--grad); color: #fff;
  font-weight: 800; font-size: 1.2rem;
  box-shadow: 0 6px 18px rgba(236, 72, 153, 0.35);
}
.logo strong { display: block; font-size: 1.05rem; }
.logo span { font-size: 0.75rem; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px;
  color: var(--text-2); text-decoration: none; font-weight: 600; font-size: 0.92rem;
  transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(168, 85, 247, 0.3); }
.nav a .badge { margin-left: auto; }

.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; margin-top: 12px;
  border-radius: 14px; background: var(--surface-2);
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  background: var(--grad); color: #fff; font-weight: 700;
}
.user-card .who { min-width: 0; flex: 1; }
.user-card .who strong { display: block; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .who span { display: block; font-size: 0.74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 16px 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar .titles { flex: 1; min-width: 0; }
.topbar .titles p { font-size: 0.82rem; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn.menu-btn { display: none; }
.content { padding: 24px 28px 48px; max-width: 1400px; width: 100%; margin: 0 auto; }
.view { animation: fadeUp 0.25s ease; }

.month-nav { display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 3px; }
.month-nav input { border: none; background: transparent; font: inherit; font-weight: 600; color: var(--text); padding: 5px 6px; width: 150px; }
.month-nav input:focus { outline: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 0.9rem;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 9px 16px; cursor: pointer;
  color: var(--text); background: var(--surface);
  transition: transform 0.12s, box-shadow 0.2s, background 0.2s, border-color 0.2s, opacity 0.2s;
  text-decoration: none; white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn svg.i { width: 18px; height: 18px; }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(236, 72, 153, 0.28); }
.btn.primary:hover { box-shadow: 0 8px 26px rgba(236, 72, 153, 0.42); }
.btn.outline { border-color: var(--border-strong); background: var(--surface); }
.btn.outline:hover { background: var(--surface-2); }
.btn.soft { background: var(--purple-soft); color: var(--purple-deep); }
:root[data-theme="dark"] .btn.soft { color: #d8c4ff; }
.btn.soft:hover { filter: brightness(0.97); }
.btn.danger { background: var(--red); color: #fff; }
.btn.ghost { background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 6px 11px; font-size: 0.82rem; border-radius: 10px; }
.btn.block { width: 100%; padding: 12px; }
.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center;
  border-radius: 11px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); cursor: pointer; transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 9px; }
.icon-btn.sm svg.i { width: 16px; height: 16px; }
.icon-btn.plain { border-color: transparent; background: transparent; }
.icon-btn.plain:hover { background: var(--surface-2); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }

/* ---------- Cards & grid ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head .sub { font-size: 0.8rem; color: var(--muted); }
.grid { display: grid; gap: 20px; }
.grid + .grid, .grid + .card, .card + .grid, .card + .card, .page-head + * { margin-top: 20px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-auto { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.greeting h2 { font-size: 1.35rem; }
.greeting p { color: var(--muted); font-size: 0.9rem; margin-top: 2px; }

/* ---------- Stat cards ---------- */
.stat {
  position: relative; overflow: hidden;
  padding: 20px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px;
}
.stat .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat .label { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.15; }
.stat .foot { font-size: 0.78rem; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.stat .ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 1.1rem; }
.stat.hero { background: var(--grad); border: none; color: #fff; box-shadow: 0 14px 40px rgba(168, 85, 247, 0.35); }
.stat.hero .label, .stat.hero .foot { color: rgba(255, 255, 255, 0.85); }
.stat.hero .ico { background: rgba(255, 255, 255, 0.2); }
.stat.hero::after {
  content: ""; position: absolute; width: 180px; height: 180px; border-radius: 50%;
  right: -60px; top: -70px; background: rgba(255, 255, 255, 0.14);
}
.ico.green { background: var(--green-soft); }
.ico.pink { background: var(--pink-soft); }
.ico.purple { background: var(--purple-soft); }
.ico.amber { background: var(--amber-soft); }

.trend-pill { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: 0.72rem; }
.trend-pill.up { background: var(--green-soft); color: var(--green); }
.trend-pill.down { background: var(--red-soft); color: var(--red); }
.trend-pill.flat { background: var(--surface-3); color: var(--muted); }
.stat.hero .trend-pill { background: rgba(255,255,255,0.22); color: #fff; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .field-label { font-size: 0.8rem; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 0.75rem; color: var(--muted); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--purple); background: var(--surface); box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15); }
input[type="color"] { padding: 4px; height: 42px; cursor: pointer; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--pink); }
select { cursor: pointer; }
.money { position: relative; }
.money::before { content: "$"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--pink); font-weight: 700; pointer-events: none; }
.money input { padding-left: 28px; font-weight: 700; font-size: 1.05rem; }
.money.big input { font-size: 1.6rem; padding: 14px 14px 14px 34px; }
.money.big::before { font-size: 1.4rem; left: 15px; }

.segment { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 13px; padding: 4px; gap: 4px; }
.segment label { flex: 1; text-align: center; cursor: pointer; }
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment span { display: block; padding: 8px 10px; border-radius: 10px; font-weight: 600; font-size: 0.88rem; color: var(--text-2); transition: background 0.15s, color 0.15s; }
.segment input:checked + span { background: var(--grad); color: #fff; box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3); }
.segment input:focus-visible + span { outline: 2px solid var(--purple); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: inherit; font-size: 0.78rem; font-weight: 600;
  padding: 5px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
  transition: all 0.15s;
}
.chip:hover { border-color: var(--pink); }
.chip.active { background: var(--pink); border-color: var(--pink); color: #fff; }
.emoji-picks { display: flex; flex-wrap: wrap; gap: 4px; }
.emoji-picks button { font-size: 1.1rem; width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; }
.emoji-picks button:hover { border-color: var(--pink); }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters .search { flex: 1 1 220px; position: relative; }
.filters .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }
.filters .search input { padding-left: 38px; }
.filters select { width: auto; min-width: 140px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.86rem; color: var(--text-2); cursor: pointer; font-weight: 500; }

/* ---------- Lists ---------- */
.tx-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.tx-day { display: flex; justify-content: space-between; padding: 14px 6px 6px; font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.tx-day:first-child { padding-top: 0; }
.tx {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto;
  align-items: center; gap: 12px;
  padding: 10px 8px; border-radius: 14px;
  transition: background 0.15s;
}
.tx:hover { background: var(--surface-2); }
.tx-ico { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; font-size: 1.2rem; background: var(--surface-3); }
.tx-main { min-width: 0; }
.tx-title { font-weight: 600; font-size: 0.93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 0.78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 6px; align-items: center; }
.tx-amt { font-weight: 700; text-align: right; white-space: nowrap; }
.tx-amt small { display: block; font-weight: 500; font-size: 0.72rem; color: var(--muted); }
.tx.income .tx-amt { color: var(--green); }
.tx.expense .tx-amt { color: var(--text); }
.tx.transfer .tx-amt { color: var(--purple); }
.tx-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s; }
.tx:hover .tx-actions, .tx:focus-within .tx-actions { opacity: 1; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 0.7rem; font-weight: 600; background: var(--surface-3); color: var(--text-2); }
.tag.auto { background: var(--purple-soft); color: var(--purple); }
.badge { display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px; font-size: 0.7rem; font-weight: 700; background: var(--pink-soft); color: var(--pink); }
.nav a.active .badge { background: rgba(255,255,255,0.25); color: #fff; }

.totals-bar { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.totals-bar .pill { padding: 8px 14px; border-radius: 12px; background: var(--surface-2); font-size: 0.85rem; font-weight: 600; }
.totals-bar .pill b { font-weight: 800; margin-left: 4px; }

/* ---------- Progress ---------- */
.progress { height: 9px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > div { height: 100%; border-radius: 99px; background: var(--grad); transition: width 0.6s cubic-bezier(.2,.8,.2,1); }
.progress.warn > div { background: linear-gradient(90deg, #f59e0b, #ec4899); }
.progress.over > div { background: linear-gradient(90deg, #e11d48, #fb7185); }
.progress.done > div { background: linear-gradient(90deg, #10b981, #34d399); }

.budget { padding: 14px 0; border-bottom: 1px solid var(--border); }
.budget:last-child { border-bottom: none; padding-bottom: 0; }
.budget:first-child { padding-top: 0; }
.budget .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.budget .name { display: flex; align-items: center; gap: 10px; font-weight: 600; min-width: 0; }
.budget .name .tx-ico { width: 36px; height: 36px; font-size: 1rem; border-radius: 10px; }
.budget .amounts { font-size: 0.85rem; font-weight: 600; text-align: right; }
.budget .status { font-size: 0.76rem; color: var(--muted); margin-top: 6px; display: flex; justify-content: space-between; }
.budget .status .over { color: var(--red); font-weight: 600; }

/* ---------- Account / goal cards ---------- */
.acct {
  position: relative; overflow: hidden;
  padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.acct::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--c, var(--purple)); }
.acct .head { display: flex; align-items: center; gap: 12px; }
.acct .head .tx-ico { background: color-mix(in srgb, var(--c, #8b5cf6) 16%, transparent); }
.acct .head strong { display: block; }
.acct .bal { font-size: 1.55rem; font-weight: 800; letter-spacing: -0.03em; }
.acct .foot { display: flex; justify-content: space-between; align-items: center; font-size: 0.78rem; color: var(--muted); }
.acct.archived { opacity: 0.6; }
.acct-strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(200px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 4px; }
.acct-strip .acct { padding: 14px 16px; gap: 6px; box-shadow: var(--shadow-sm); }
.acct-strip .acct .bal { font-size: 1.2rem; }

.goal { display: flex; flex-direction: column; gap: 14px; }
.goal .head { display: flex; align-items: center; gap: 12px; }
.goal .head .tx-ico { background: color-mix(in srgb, var(--c, #ec4899) 16%, transparent); }
.goal .head .grow { flex: 1; min-width: 0; }
.goal .ring-wrap { display: flex; align-items: center; gap: 18px; }
.ring { --p: 0; --c: var(--pink); width: 92px; height: 92px; border-radius: 50%; flex-shrink: 0;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-3) 0);
  display: grid; place-items: center; }
.ring > span { width: 72px; height: 72px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-weight: 800; font-size: 1.05rem; }
.goal .nums { display: flex; flex-direction: column; gap: 3px; font-size: 0.85rem; }
.goal .nums b { font-size: 1.25rem; }
.goal .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.mini-goal { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.mini-goal .grow { flex: 1; min-width: 0; }
.mini-goal .grow .row { display: flex; justify-content: space-between; font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; gap: 6px; }

.upcoming { display: flex; align-items: center; gap: 12px; padding: 9px 0; }
.upcoming .when { width: 46px; text-align: center; flex-shrink: 0; border-radius: 11px; background: var(--surface-2); padding: 4px 0; line-height: 1.15; }
.upcoming .when b { display: block; font-size: 1.05rem; }
.upcoming .when span { font-size: 0.66rem; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.upcoming .grow { flex: 1; min-width: 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th { text-align: left; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--surface-2); }
tfoot td { font-weight: 800; border-top: 2px solid var(--border-strong); }

.cat-bars { display: flex; flex-direction: column; gap: 12px; }
.cat-bar .row { display: flex; justify-content: space-between; gap: 10px; font-size: 0.86rem; margin-bottom: 5px; }
.cat-bar .row span:first-child { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-bar .progress > div { background: var(--c, var(--grad)); }

/* ---------- Charts ---------- */
.chart { position: relative; height: 260px; }
.chart.sm { height: 210px; }
.chart.lg { height: 320px; }
.donut-wrap { display: grid; grid-template-columns: 200px 1fr; gap: 18px; align-items: center; }
.donut-wrap .chart { height: 200px; }
.donut-center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; pointer-events: none; }
.donut-center b { display: block; font-size: 1.1rem; }
.donut-center span { font-size: 0.72rem; color: var(--muted); }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.legend .dot { width: 10px; height: 10px; border-radius: 4px; flex-shrink: 0; }
.legend .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend .amt { font-weight: 700; }
.legend .pct { width: 38px; text-align: right; color: var(--muted); font-size: 0.78rem; }

/* ---------- Insights ---------- */
.insights { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.insight { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: 14px; background: var(--grad-soft); }
.insight .tx-ico { background: var(--surface); }
.insight b { display: block; font-size: 1.02rem; }
.insight span { font-size: 0.76rem; color: var(--text-2); }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .big { font-size: 2.4rem; margin-bottom: 6px; }
.empty b { display: block; color: var(--text); margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

/* ---------- Settings ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; align-items: start; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: none; }
.setting-row p { font-size: 0.8rem; color: var(--muted); }

.cat-item { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 12px; }
.cat-item:hover { background: var(--surface-2); }
.cat-item .grow { flex: 1; min-width: 0; }
.cat-item .swatch { width: 12px; height: 12px; border-radius: 4px; }
.cat-item .acts { display: flex; gap: 2px; opacity: 0; }
.cat-item:hover .acts, .cat-item:focus-within .acts { opacity: 1; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 16px;
  background: rgba(43, 23, 69, 0.38);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.15s ease;
}
.modal-card {
  width: 100%; max-width: 460px; max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: pop 0.2s cubic-bezier(.2,.9,.3,1.2);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 0; }
.modal-head h2 { font-size: 1.15rem; }
.modal-body { padding: 18px 22px 22px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.modal-foot .btn { min-width: 110px; }
.confirm-ico { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; margin: 0 auto 12px; background: var(--red-soft); font-size: 1.6rem; }
.form-error { background: var(--red-soft); color: var(--red); padding: 10px 12px; border-radius: 10px; font-size: 0.85rem; font-weight: 500; }

.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  font-weight: 600; font-size: 0.9rem; max-width: 360px;
  animation: slideIn 0.25s cubic-bezier(.2,.9,.3,1.2);
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.toast.error::before { background: var(--red); }
.toast.out { opacity: 0; transform: translateY(8px); transition: all 0.25s; }

.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 12px; }
.overlay { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(0.96) translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { to { background-position: -200% 0; } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main { grid-template-columns: 1fr; }
  .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 280px;
    transform: translateX(-100%); transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .overlay.show { display: block; position: fixed; inset: 0; background: rgba(43, 23, 69, 0.35); z-index: 35; }
  .icon-btn.menu-btn { display: inline-grid; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .content { padding: 18px 16px 40px; }
  .g-2, .g-3 { grid-template-columns: 1fr; }
  .donut-wrap { grid-template-columns: 1fr; }
  .tx-actions { opacity: 1; }
  .cat-item .acts { opacity: 1; }
}
@media (max-width: 600px) {
  .g-4 { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat { padding: 14px; }
  .stat .value { font-size: 1.25rem; }
  .stat .ico { display: none; }
  .insights { grid-template-columns: 1fr 1fr; gap: 10px; }
  .insight { flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px; }
  .insight .tx-ico { width: 34px; height: 34px; font-size: 1rem; }
  .topbar .titles p { display: none; }
  .topbar h1 { font-size: 1.15rem; }
  .month-nav { order: 5; width: 100%; justify-content: space-between; }
  .month-nav input { flex: 1; width: auto; text-align: center; }
  .btn-add-label { display: none; }
  .tx { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; }
  .tx-ico { width: 40px; height: 40px; }
  .tx-actions { grid-column: 2 / -1; justify-content: flex-end; margin-top: -6px; }
  .row-2 { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .filters select { flex: 1 1 45%; min-width: 0; }
  .toast-stack { left: 16px; right: 16px; align-items: stretch; }
  .toast { max-width: none; }
}

/* =========================================================
   Login page
   ========================================================= */
.auth { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.auth-art {
  position: relative; overflow: hidden;
  background: var(--grad); color: #fff;
  padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-art::before, .auth-art::after {
  content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,0.12);
}
.auth-art::before { width: 420px; height: 420px; right: -140px; top: -120px; }
.auth-art::after { width: 300px; height: 300px; left: -100px; bottom: -110px; }
.auth-art .logo { color: #fff; position: relative; z-index: 1; padding: 0; }
.auth-art .logo-mark { background: rgba(255,255,255,0.22); box-shadow: none; }
.auth-art .logo span { color: rgba(255,255,255,0.8); }
.auth-art h2 { font-size: 2.4rem; line-height: 1.15; max-width: 460px; position: relative; z-index: 1; }
.auth-art p.lead { margin-top: 14px; font-size: 1.02rem; opacity: 0.9; max-width: 440px; position: relative; z-index: 1; }
.mock { position: relative; z-index: 1; display: grid; gap: 12px; max-width: 420px; }
.mock-card { background: rgba(255,255,255,0.16); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.25); border-radius: 18px; padding: 16px 18px; }
.mock-card .lbl { font-size: 0.78rem; opacity: 0.85; }
.mock-card .big { font-size: 1.8rem; font-weight: 800; }
.mock-row { display: flex; align-items: center; gap: 10px; font-size: 0.88rem; padding: 6px 0; }
.mock-row .e { width: 32px; height: 32px; border-radius: 10px; background: rgba(255,255,255,0.2); display: grid; place-items: center; }
.mock-row .g { flex: 1; }
.mock-row b { font-weight: 700; }
.auth-form-wrap { display: grid; place-items: center; padding: 32px 20px; }
.auth-form { width: 100%; max-width: 400px; }
.auth-form h1 { font-size: 1.8rem; }
.auth-form .sub { color: var(--muted); margin: 6px 0 24px; }
.auth-tabs { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); padding: 4px; border-radius: 13px; margin-bottom: 22px; }
.auth-tabs button { flex: 1; font: inherit; font-weight: 600; border: none; background: transparent; color: var(--text-2); padding: 9px; border-radius: 10px; cursor: pointer; }
.auth-tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 46px; }
.pw-wrap button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: none; background: none; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; font: inherit; font-size: 0.78rem; font-weight: 600; }
.auth-foot { margin-top: 22px; text-align: center; font-size: 0.82rem; color: var(--muted); }
.theme-float { position: fixed; top: 16px; right: 16px; z-index: 5; }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: 28px 24px; }
  .auth-art h2 { font-size: 1.6rem; }
  .auth-art .mock { display: none; }
  .auth-art .art-copy { margin-top: 18px; }
}

/* Hide number spinners on money inputs */
.money input::-webkit-outer-spin-button, .money input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.money input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
