:root {
  --bg: #0f172a; --panel: #1e293b; --card: #ffffff; --ink: #0f172a;
  --muted: #64748b; --line: #e2e8f0; --brand: #4f46e5; --brand-d: #4338ca;
  --green: #16a34a; --red: #dc2626; --soft: #f8fafc;
  --radius: 12px; --shadow: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--soft); color: var(--ink); font-size: 14px; line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }
.muted { color: var(--muted); }
.sm { font-size: 12.5px; }
.big { font-size: 22px; font-weight: 700; }
.hidden { display: none !important; }
.r { text-align: right; }
.centered { text-align: center; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 60px;
  background: var(--bg); color: #e2e8f0; position: sticky; top: 0; z-index: 10;
}
.topbar .brand { font-weight: 700; color: #fff; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: #cbd5e1; padding: 8px 12px; border-radius: 8px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.on { background: var(--brand); color: #fff; }
.userbox { display: flex; align-items: center; gap: 12px; }
.userbox .muted { color: #94a3b8; }

.container { max-width: 1120px; margin: 0 auto; padding: 24px; }
.footer { text-align: center; padding: 24px; }

/* Cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card h3 { margin: 0 0 14px; font-size: 15px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.page-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 22px; }
.filters, .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 10px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } .nav { display: none; } }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; }
.kpi-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi-val { font-size: 24px; font-weight: 700; margin-top: 6px; }
.kpi-val.income { color: var(--green); }
.kpi-val.expense { color: var(--red); }
@media (max-width: 800px) { .kpis { grid-template-columns: 1fr 1fr; } }

/* Forms */
.input { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; color: var(--ink); }
.input.sm { padding: 6px 9px; }
select.input { cursor: pointer; }
.btn { background: var(--brand); color: #fff; border: 0; padding: 9px 16px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--brand-d); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--soft); }
.btn.block { width: 100%; display: block; text-align: center; }
.btn.google { background: #fff; color: #1f2937; border: 1px solid var(--line); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 8px 10px; border-bottom: 2px solid var(--line); text-transform: uppercase; letter-spacing: .03em; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
.table.compact td, .table.compact th { padding: 6px 8px; font-size: 13px; }
.table-scroll { overflow-x: auto; max-height: 600px; }
.amount-pos { color: var(--green); font-weight: 600; }
.amount-neg { color: var(--red); font-weight: 600; }

/* Badges & chips */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.pending { background: #fef3c7; color: #92400e; }
.badge.reconciled { background: #dcfce7; color: #166534; }
.badge.duplicate { background: #fee2e2; color: #991b1b; }
.badge.ignored { background: #e2e8f0; color: #475569; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.list { list-style: none; padding: 0; margin: 0 0 12px; }
.list li { padding: 7px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; }

/* Alerts */
.alert { padding: 10px 14px; border-radius: 8px; background: var(--soft); border: 1px solid var(--line); margin: 8px 0; }
.alert.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert.info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert.success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }

/* Auth */
.auth-wrap { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.auth-card { max-width: 380px; width: 100%; text-align: center; }
.auth-card .brand { margin-bottom: 8px; }
.divider { display: flex; align-items: center; text-align: center; color: var(--muted); margin: 16px 0; font-size: 12px; }
.divider::before, .divider::after { content: ''; flex: 1; border-bottom: 1px solid var(--line); }
.divider span { padding: 0 10px; }

/* Budget bars */
.budget-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.budget-row:last-child { border-bottom: 0; }
.bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.bar-fill { height: 100%; background: var(--brand); border-radius: 999px; transition: width .3s; }
.bar-fill.over { background: var(--red); }

/* Badge for transfers / source */
.badge.transfer { background: #e0e7ff; color: #3730a3; }
.badge.manual { background: #f1f5f9; color: #475569; }
.badge.split { background: #fae8ff; color: #86198f; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: var(--radius); padding: 22px; width: 92%; max-width: 480px; max-height: 88vh; overflow: auto; }
.modal h3 { margin-top: 0; }
.modal .row { margin-bottom: 10px; }
.split-line { display: grid; grid-template-columns: 1fr 110px 28px; gap: 8px; margin-bottom: 8px; align-items: center; }
.icon-btn { background: none; border: 0; cursor: pointer; font-size: 16px; color: var(--muted); }
.actions-cell { white-space: nowrap; }
.actions-cell button { margin-left: 4px; }

/* Mapping grid */
.mapping-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.mapping-grid label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
