:root {
  --bg: #0c111b; --surface: #131a28; --surface-2: #1c2436; --border: #283248;
  --text: #e8edf6; --muted: #8a97ad;
  --brand: #10b981; --brand-2: #34d399; --ok: #22c55e; --danger: #f87171; --warn: #fbbf24;
  --radius: 14px; --shadow: 0 8px 30px rgba(0,0,0,.32); --sidebar-w: 232px;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}
[data-theme="light"] {
  --bg: #f3f6fb; --surface: #ffffff; --surface-2: #eef2f8; --border: #dde4ee;
  --text: #111826; --muted: #59657a; --shadow: 0 8px 30px rgba(30,50,90,.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body { font-family: Inter, system-ui, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; transition: background .25s, color .25s; }
button, input, select { font-family: inherit; color: inherit; }
.pos { color: var(--ok); } .neg { color: var(--danger); }
.muted-text { color: var(--muted); font-size: 13.5px; }
.skip-link { position: absolute; left: -999px; }
.skip-link:focus { left: 12px; top: 12px; background: var(--brand); color: #042; padding: 8px 14px; border-radius: 8px; z-index: 99; }

.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 18px 14px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 900; font-size: 20px; padding: 6px 8px 18px; display: flex; align-items: center; gap: 9px; }
.brand-mark { font-size: 22px; }
.brand-accent { color: var(--brand); }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; background: none; border: none; color: var(--muted); font-size: 15px; font-weight: 600; padding: 11px 12px; border-radius: 10px; cursor: pointer; transition: .15s; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #042312; box-shadow: 0 6px 16px rgba(16,185,129,.3); }
.ni-ic { font-size: 15px; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.priv { font-size: 12px; color: var(--brand); font-weight: 600; }
.ghost-link { font-size: 12.5px; color: var(--muted); text-decoration: none; }
.ghost-link:hover { color: var(--text); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px clamp(16px,3vw,30px); border-bottom: 1px solid var(--border); position: sticky; top: 0; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(8px); z-index: 20; }
.topbar-title { font-size: 19px; font-weight: 800; flex: 1; }
.menu-btn { display: none; }
.month-input { background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: 9px; padding: 8px 10px; font-size: 13.5px; }
.month-input:focus { outline: none; border-color: var(--brand); }
.icon-btn { background: var(--surface-2); border: 1px solid var(--border); width: 38px; height: 38px; border-radius: 9px; cursor: pointer; font-size: 15px; display: inline-grid; place-items: center; flex: none; }
.icon-btn:hover { border-color: var(--brand); }
.icon-btn.sm { width: 30px; height: 30px; font-size: 12px; }

.view { padding: clamp(16px,3vw,28px); flex: 1; display: flex; flex-direction: column; gap: 16px; max-width: 1120px; width: 100%; }

/* buttons */
.btn { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 16px; font-size: 14px; font-weight: 700; cursor: pointer; }
.btn:hover { border-color: var(--brand); }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #042312; border-color: transparent; }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; border-color: transparent; }
.link-btn { background: none; border: none; color: var(--brand); font-weight: 700; font-size: 13px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.row { display: flex; align-items: center; } .row.gap { gap: 10px; } .row.wrap { flex-wrap: wrap; }

/* cards & grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.card-head h2 { font-size: 16px; font-weight: 800; }
.grid { display: grid; gap: 14px; }
.grid.stats { grid-template-columns: repeat(4, 1fr); }
.grid.two { grid-template-columns: 1fr 1fr; }
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat-k { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat b { font-size: 24px; font-weight: 900; font-family: var(--mono); letter-spacing: -.02em; }

/* charts */
.donut-row { display: flex; align-items: center; gap: 16px; }
.chart-donut { width: 100px; height: 100px; flex: none; }
.legend { list-style: none; display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.legend i, .bars-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 7px; }
.chart-bars { width: 100%; height: 140px; }
.bars-legend { display: flex; gap: 16px; justify-content: center; font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* transactions */
.tx-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.tx-list.big .tx { background: var(--surface); }
.tx { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.tx-list.big .tx { border: 1px solid var(--border); border-radius: 11px; padding: 11px 13px; }
.tx:last-child { border-bottom: none; }
.tx-ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; flex: none; }
.tx-main { flex: 1; min-width: 0; }
.tx-main b { font-size: 14.5px; }
.tx-main small { display: block; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-amt { font-family: var(--mono); font-weight: 700; font-size: 15px; }

/* toolbar */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; }
.search { flex: 1; min-width: 200px; background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: 10px; padding: 10px 13px; font-size: 14px; }
.search:focus, .select:focus { outline: none; border-color: var(--brand); }
.select { background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: 10px; padding: 10px 12px; font-size: 14px; }

/* budgets */
.budget-summary { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; text-align: center; }
.budget-summary b { display: block; font-size: 22px; font-weight: 900; font-family: var(--mono); margin-top: 4px; }
.budget-list { display: flex; flex-direction: column; gap: 14px; }
.budget-row { display: flex; align-items: center; gap: 12px; }
.budget-main { flex: 1; min-width: 0; }
.budget-top { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 5px; }
.budget-input { width: 96px; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 9px; padding: 8px 10px; font-size: 13.5px; flex: none; }
.budget-input:focus { outline: none; border-color: var(--brand); }
.progress { height: 9px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 6px; transition: width .4s; }
.progress.over span { background: var(--danger); }

/* settings */
.field.inline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 8px; }
.cat-chip { display: flex; align-items: center; gap: 7px; background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--c); border-radius: 9px; padding: 9px 11px; font-size: 13.5px; font-weight: 600; cursor: pointer; text-align: left; }
.cat-chip:hover { border-color: var(--brand); }
.cat-chip small { color: var(--muted); margin-left: auto; font-weight: 500; font-size: 11px; }

/* forms / modal */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: 13.5px; font-weight: 600; }
.field input, .field select { background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 9px; padding: 10px 12px; font-size: 14px; font-weight: 500; }
.field input:focus, .field select:focus { outline: none; border-color: var(--brand); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 4px; margin-bottom: 14px; }
.seg-btn { flex: 1; background: none; border: none; padding: 9px; border-radius: 7px; font-weight: 700; font-size: 14px; color: var(--muted); cursor: pointer; }
.seg-btn.on { background: var(--bg); color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 18px; z-index: 50; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 18px; }

/* empty */
.empty { text-align: center; padding: 48px 20px; margin: auto; max-width: 440px; }
.empty-ic { font-size: 50px; margin-bottom: 12px; }
.empty h3 { font-size: 20px; font-weight: 800; margin-bottom: 8px; }
.empty p { color: var(--muted); margin-bottom: 18px; }
.empty-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* toast */
.toast-host { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 80; }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--ok); border-radius: 10px; padding: 11px 15px; font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow); animation: slidein .25s ease; }
.toast.err { border-left-color: var(--danger); }
.toast.hide { opacity: 0; transform: translateX(20px); transition: .3s; }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } }

/* footer */
.footer { border-top: 1px solid var(--border); margin-top: auto; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px clamp(16px,3vw,30px); color: var(--muted); font-size: 13px; }
.foot-socials { display: flex; gap: 10px; }
.foot-socials a { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); transition: .2s; }
.foot-socials a:hover { color: var(--brand); border-color: var(--brand); transform: translateY(-2px); }
.footer-bottom { border-top: 1px solid var(--border); text-align: center; padding: 11px; color: var(--muted); font-size: 12px; }

@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; width: 260px; transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .menu-btn { display: inline-grid; }
  .grid.stats { grid-template-columns: 1fr 1fr; }
  .grid.two { grid-template-columns: 1fr; }
  .topbar-title { font-size: 17px; }
}
@media (max-width: 480px) { .budget-summary { grid-template-columns: 1fr; } .row2 { grid-template-columns: 1fr; } }
