* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #0b0f14;
  --panel: #121820;
  --panel2: #1a222d;
  --border: #232d3a;
  --text: #e8eef5;
  --muted: #8a97a8;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --accent: #6366f1;
  --radius: 14px;
}
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.hidden { display: none !important; }
button { cursor: pointer; font: inherit; border: none; }
input, select {
  font: inherit;
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  color-scheme: dark;
}
input:focus, select:focus { outline: 2px solid var(--accent); }

/* login */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-card .logo { font-size: 48px; }
.login-card h1 { margin: 8px 0 4px; }
.login-card .sub { color: var(--muted); margin-bottom: 24px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.error { color: var(--red); margin-top: 12px; min-height: 20px; }

/* header */
header {
  display: flex; align-items: center; gap: 20px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.brand .logo { font-size: 24px; }
nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav button {
  background: transparent; color: var(--muted);
  padding: 8px 14px; border-radius: 8px; font-weight: 600;
}
nav button:hover { color: var(--text); }
nav button.active { background: var(--panel2); color: var(--text); }
.header-right { display: flex; gap: 10px; align-items: center; }
#month-picker { width: auto; }
.ghost {
  background: transparent; color: var(--muted);
  padding: 8px 14px; border-radius: 8px;
}
.ghost:hover { color: var(--text); background: var(--panel2); }
.primary {
  background: var(--accent); color: white;
  padding: 10px 18px; border-radius: 10px; font-weight: 600;
}
.primary:hover { filter: brightness(1.1); }

main { max-width: 1100px; margin: 0 auto; padding: 24px; }
.view h2 { margin-bottom: 16px; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.card-label { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.card-value { font-size: 26px; font-weight: 700; }
.card-sub { color: var(--muted); font-size: 13px; margin-top: 6px; }
.green { color: var(--green); }
.red { color: var(--red); }

.panel-row { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
@media (max-width: 800px) { .panel-row { grid-template-columns: 1fr; } }
.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.stat-line {
  display: flex; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  color: var(--muted); font-size: 14px;
}
.stat-line:last-child { border-bottom: none; }
.stat-line b { color: var(--text); }

/* category chart */
.cat-chart { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.cat-row { display: grid; grid-template-columns: 150px 1fr 90px; gap: 12px; align-items: center; }
@media (max-width: 600px) { .cat-row { grid-template-columns: 100px 1fr 70px; } }
.cat-name { font-size: 14px; display: flex; align-items: center; gap: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.bar-bg { background: var(--panel2); border-radius: 8px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 8px; min-width: 2px; transition: width .3s; }
.bar-fill.over { background: var(--red) !important; }
.cat-amount { font-size: 13px; text-align: right; color: var(--muted); }
.cat-amount b { color: var(--text); }

/* toolbar + filters */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.filters { display: flex; gap: 8px; margin-bottom: 14px; }
.filter-btn {
  background: var(--panel2); color: var(--muted);
  padding: 7px 14px; border-radius: 20px; font-size: 13px;
}
.filter-btn.active { background: var(--accent); color: white; }

/* tx list */
.tx-list { display: flex; flex-direction: column; gap: 8px; }
.tx-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 16px;
}
.tx-ico {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0; background: var(--panel2);
}
.tx-info { flex: 1; min-width: 0; }
.tx-name { font-weight: 600; }
.tx-meta { color: var(--muted); font-size: 13px; }
.tx-amount { font-weight: 700; font-size: 16px; }
.tx-actions { display: flex; gap: 6px; }
.icon-btn {
  background: transparent; color: var(--muted);
  width: 32px; height: 32px; border-radius: 8px; font-size: 14px;
}
.icon-btn:hover { background: var(--panel2); color: var(--text); }
.icon-btn.danger:hover { color: var(--red); }

/* category list */
.cat-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.cat-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; align-items: center; gap: 12px;
}
.cat-card .dot { width: 14px; height: 14px; }
.cat-card .info { flex: 1; }
.cat-card .name { font-weight: 600; }
.cat-card .budget { color: var(--muted); font-size: 13px; }

/* tips */
#tips-list { display: flex; flex-direction: column; gap: 10px; }
.tip {
  background: var(--panel); border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius); padding: 16px;
}
.tip.good { border-left-color: var(--green); }
.tip.warn { border-left-color: var(--amber); }
.tip.bad { border-left-color: var(--red); }
.tip.info { border-left-color: var(--accent); }
.tip h3 { margin-bottom: 6px; font-size: 15px; }
.tip p { color: var(--muted); font-size: 14px; line-height: 1.5; }

/* forms */
.inline-form { display: flex; gap: 10px; margin-top: 12px; }
.inline-form input { max-width: 200px; }
.inline-form button { width: auto; }
.stack-form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; max-width: 300px; }
.stack-form button { width: auto; }
.color-row { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.color-row input { width: 44px; height: 34px; padding: 2px; }
#password-msg { margin-top: 10px; min-height: 20px; }

/* modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  width: 100%; max-width: 400px;
}
.modal-card h3 { margin-bottom: 16px; }
#tx-form, #cat-form { display: flex; flex-direction: column; gap: 12px; }
.seg { display: flex; gap: 8px; }
.seg-btn {
  flex: 1; padding: 10px; border-radius: 10px;
  background: var(--panel2); color: var(--muted); font-weight: 600;
}
.seg-btn.active.expense { background: #7f1d1d; color: #fecaca; }
.seg-btn.active.income { background: #064e3b; color: #a7f3d0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* toast */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel2); border: 1px solid var(--border);
  padding: 12px 20px; border-radius: 10px; z-index: 200;
  font-size: 14px;
}
#toast.err { border-color: var(--red); color: var(--red); }
