:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f1f5f9;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: var(--bg);
  color: #cbd5e1;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { font-size: 1.15rem; font-weight: 700; color: #fff; margin-bottom: 20px; display: flex; align-items: center; gap: 8px; }
.brand small { display: block; font-weight: 400; font-size: .72rem; color: #64748b; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; color: #cbd5e1; font-size: .92rem;
}
.nav a:hover { background: var(--bg-soft); text-decoration: none; color: #fff; }
.nav a.active { background: var(--brand); color: #fff; }
.sidebar .spacer { flex: 1; }
.sidebar .user-box { font-size: .82rem; color: #94a3b8; border-top: 1px solid #1e293b; padding-top: 14px; }

.content { flex: 1; padding: 28px 34px; max-width: 1200px; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-head h1 { font-size: 1.5rem; margin: 0; }
.muted { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand); color: #fff; border: 0; cursor: pointer;
  padding: 10px 16px; border-radius: 10px; font-size: .9rem; font-weight: 600;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.secondary { background: #e2e8f0; color: var(--ink); }
.btn.secondary:hover { background: #cbd5e1; }
.btn.danger { background: var(--red); }
.btn.small { padding: 6px 10px; font-size: .8rem; }

/* ---------- Cards / grids ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card {
  background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.account-card { border-left: 6px solid var(--brand); }
.account-card .acc-type { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.account-card .acc-name { font-weight: 700; font-size: 1.05rem; margin: 4px 0; display: flex; align-items: center; gap: 8px; }
.account-card .acc-balance { font-size: 1.35rem; font-weight: 700; margin-top: 8px; }
.balance-neg { color: var(--red); }
.balance-pos { color: var(--green); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat .label { font-size: .82rem; color: var(--muted); }
.stat .value { font-size: 1.5rem; font-weight: 700; margin-top: 6px; }

.section { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 22px; }
.section h2 { font-size: 1.05rem; margin: 0 0 14px; }
.two-col { display: grid; grid-template-columns: 1.3fr 1fr; gap: 22px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tbody tr:hover { background: #f8fafc; }
.amount { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.tag {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 600;
}
.tag.income { background: #dcfce7; color: #15803d; }
.tag.expense { background: #fee2e2; color: #b91c1c; }
.tag.transfer { background: #dbeafe; color: #1d4ed8; }
.tag.adjustment { background: #fef3c7; color: #b45309; }

/* ---------- Forms ---------- */
.form-card { background: var(--card); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); max-width: 620px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: .92rem;
  background: #fff; color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--brand); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.inline-form { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }

/* ---------- Login ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 20px; }
.auth-card { background: #fff; border-radius: 18px; padding: 36px; width: 100%; max-width: 400px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 0 0 4px; font-size: 1.4rem; }
.auth-card .sub { color: var(--muted); font-size: .9rem; margin-bottom: 22px; }
.auth-card .btn { width: 100%; justify-content: center; }
.auth-switch { text-align: center; margin-top: 16px; font-size: .88rem; color: var(--muted); }
.error { background: #fee2e2; color: #b91c1c; padding: 10px 14px; border-radius: 10px; font-size: .86rem; margin-bottom: 16px; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

/* ---------- Filters bar ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 18px; }
.filters .field { margin-bottom: 0; }

/* ---------- Mobile ---------- */
.menu-toggle { display: none; }
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: relative; flex-direction: row; flex-wrap: wrap;
    align-items: center; padding: 14px 16px; gap: 8px;
  }
  .brand { margin-bottom: 0; }
  .brand small { display: none; }
  .sidebar .spacer, .sidebar .user-box { display: none; }
  .nav { display: flex; gap: 4px; flex-wrap: wrap; width: 100%; }
  .nav a { padding: 8px 10px; font-size: .85rem; }
  .content { padding: 18px; }
  .two-col { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
}
