:root {
  --sidebar-w: 240px;
  --primary: #4f46e5; --primary-light: #eef2ff;
  --income: #10b981;  --expense: #ef4444;
  --bg: #f1f5f9; --card: #ffffff; --border: #e2e8f0;
  --text: #1e293b; --muted: #64748b;
  --sidebar-bg: #1e293b; --sidebar-text: #cbd5e1;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); }

/* ── Sidebar ─────────────────────────────────────── */
.sidebar { position:fixed; top:0; left:0; width:var(--sidebar-w); height:100vh; background:var(--sidebar-bg); display:flex; flex-direction:column; z-index:100; overflow-y:auto; }
.sidebar-brand { padding:20px 20px 16px; font-size:1.1rem; font-weight:700; color:#fff; border-bottom:1px solid rgba(255,255,255,.1); }
.sidebar-brand small { display:block; font-size:.7rem; font-weight:400; color:var(--sidebar-text); margin-top:2px; }
.sidebar-nav { list-style:none; padding:12px 0; flex:1; }
.sidebar-nav li a { display:flex; align-items:center; gap:10px; padding:9px 20px; color:var(--sidebar-text); text-decoration:none; font-size:.875rem; font-weight:500; border-left:3px solid transparent; transition:all .15s; }
.sidebar-nav li a:hover { background:rgba(255,255,255,.06); color:#fff; }
.sidebar-nav li a.active { background:rgba(79,70,229,.25); color:#fff; border-left-color:var(--primary); }
.sidebar-nav .nav-icon { font-size:1rem; width:20px; text-align:center; }
.sidebar-section { padding:6px 20px 3px; font-size:.68rem; font-weight:700; color:rgba(255,255,255,.3); text-transform:uppercase; letter-spacing:.08em; margin-top:6px; }
.sidebar-footer { padding:12px 20px; border-top:1px solid rgba(255,255,255,.1); }
.sidebar-footer small { color:var(--muted); font-size:.72rem; }

/* ── Layout ──────────────────────────────────────── */
.main { margin-left:var(--sidebar-w); min-height:100vh; display:flex; flex-direction:column; }
.topbar { background:var(--card); border-bottom:1px solid var(--border); padding:13px 28px; display:flex; align-items:center; justify-content:space-between; position:sticky; top:0; z-index:50; gap:12px; }
.topbar h1 { font-size:1.15rem; font-weight:700; flex:1; }
.content { padding:22px 28px; flex:1; }

/* ── Stat cards ──────────────────────────────────── */
.stat-card { background:var(--card); border-radius:14px; padding:18px 20px; border:1px solid var(--border); display:flex; align-items:center; gap:14px; }
.stat-icon { width:48px; height:48px; border-radius:12px; display:flex; align-items:center; justify-content:center; font-size:1.3rem; flex-shrink:0; }
.stat-label { font-size:.72rem; color:var(--muted); font-weight:600; text-transform:uppercase; letter-spacing:.04em; }
.stat-value { font-size:1.5rem; font-weight:800; line-height:1.1; margin-top:2px; }
.stat-sub { font-size:.75rem; color:var(--muted); margin-top:3px; }
.stat-chg { font-size:.72rem; font-weight:700; padding:2px 7px; border-radius:99px; display:inline-flex; align-items:center; gap:2px; }
.stat-chg.up   { background:#d1fae5; color:#065f46; }
.stat-chg.down { background:#fee2e2; color:#991b1b; }
.stat-chg.neu  { background:#f1f5f9; color:var(--muted); }

/* ── Chart / content cards ───────────────────────── */
.chart-card { background:var(--card); border-radius:14px; padding:20px 22px; border:1px solid var(--border); }
.chart-card h6 { font-size:.78rem; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.05em; margin-bottom:14px; }

/* ── Table ───────────────────────────────────────── */
.data-table { width:100%; border-collapse:separate; border-spacing:0; }
.data-table th { padding:9px 13px; font-size:.72rem; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.05em; border-bottom:1px solid var(--border); background:#f8fafc; white-space:nowrap; }
.data-table td { padding:11px 13px; border-bottom:1px solid var(--border); font-size:.875rem; vertical-align:middle; }
.data-table tr:hover td { background:#f8fafc; }
.data-table tr:last-child td { border-bottom:none; }

/* ── Badges ──────────────────────────────────────── */
.badge-entrata { background:#d1fae5; color:#065f46; font-size:.7rem; font-weight:700; padding:2px 8px; border-radius:99px; white-space:nowrap; }
.badge-uscita  { background:#fee2e2; color:#991b1b; font-size:.7rem; font-weight:700; padding:2px 8px; border-radius:99px; white-space:nowrap; }
.badge-pill    { font-size:.7rem; font-weight:700; padding:2px 9px; border-radius:99px; display:inline-block; }

/* ── Traffic lights ──────────────────────────────── */
.tl-ok   { color:#059669; } .tl-ok-bg   { background:#d1fae5; color:#065f46; }
.tl-warn { color:#d97706; } .tl-warn-bg { background:#fef3c7; color:#92400e; }
.tl-over { color:#dc2626; } .tl-over-bg { background:#fee2e2; color:#991b1b; }
.tl-none { color:var(--muted); }

/* ── Amount colors ───────────────────────────────── */
.amt-in  { color:var(--income);  font-weight:700; }
.amt-out { color:var(--expense); font-weight:700; }

/* ── Tag chip ────────────────────────────────────── */
.tag-chip { display:inline-flex; align-items:center; gap:3px; border-radius:99px; padding:2px 9px; font-size:.7rem; font-weight:700; }

/* ── Cat dot ─────────────────────────────────────── */
.cat-dot { display:inline-block; width:9px; height:9px; border-radius:50%; margin-right:5px; flex-shrink:0; }

/* ── Modal ───────────────────────────────────────── */
.modal-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,.45); z-index:200; align-items:center; justify-content:center; }
.modal-overlay.open { display:flex; }
.modal-box { background:var(--card); border-radius:16px; padding:26px; width:500px; max-width:96vw; max-height:92vh; overflow-y:auto; box-shadow:0 20px 60px rgba(0,0,0,.25); position:relative; }
.modal-box h5 { font-size:1rem; font-weight:700; margin-bottom:18px; }
.modal-close { position:absolute; top:10px; right:14px; background:none; border:none; font-size:1.4rem; cursor:pointer; color:var(--muted); line-height:1; }

/* ── Forms ───────────────────────────────────────── */
.form-group { margin-bottom:14px; }
.form-label { display:block; font-size:.78rem; font-weight:600; color:var(--muted); margin-bottom:5px; }
.form-control, .form-select { width:100%; padding:8px 12px; border:1px solid var(--border); border-radius:8px; font-size:.875rem; color:var(--text); background:#fff; transition:border-color .15s, box-shadow .15s; }
.form-control:focus, .form-select:focus { outline:none; border-color:var(--primary); box-shadow:0 0 0 3px rgba(79,70,229,.12); }
textarea.form-control { resize:vertical; }
.form-row { display:grid; gap:12px; }
.form-row-2 { grid-template-columns:1fr 1fr; }
.form-row-3 { grid-template-columns:1fr 1fr 1fr; }

/* ── Type toggle ─────────────────────────────────── */
.type-toggle { display:flex; gap:8px; margin-bottom:14px; }
.type-btn { flex:1; padding:9px; border-radius:9px; border:2px solid var(--border); background:#fff; cursor:pointer; font-size:.875rem; font-weight:600; transition:all .15s; text-align:center; }
.type-btn.active-in  { border-color:var(--income);  background:#d1fae5; color:#065f46; }
.type-btn.active-out { border-color:var(--expense); background:#fee2e2; color:#991b1b; }

/* ── Buttons ─────────────────────────────────────── */
.btn { padding:8px 16px; border-radius:9px; border:none; cursor:pointer; font-size:.875rem; font-weight:600; transition:opacity .15s, transform .1s; display:inline-flex; align-items:center; gap:6px; }
.btn:active { transform:scale(.97); }
.btn-primary { background:var(--primary); color:#fff; }
.btn-primary:hover { opacity:.9; }
.btn-success { background:var(--income); color:#fff; }
.btn-danger  { background:var(--expense); color:#fff; }
.btn-ghost   { background:#f1f5f9; color:var(--text); }
.btn-ghost:hover { background:#e2e8f0; }
.btn-outline { background:#fff; color:var(--text); border:1px solid var(--border); }
.btn-outline:hover { background:#f8fafc; }
.btn-sm { padding:5px 10px; font-size:.78rem; border-radius:7px; }
.btn-icon { background:none; border:none; cursor:pointer; font-size:.95rem; padding:4px 6px; border-radius:6px; line-height:1; }
.btn-icon:hover { background:#f1f5f9; }

/* ── Month nav ───────────────────────────────────── */
.month-nav { display:flex; align-items:center; gap:8px; }
.month-nav button { background:#f1f5f9; border:1px solid var(--border); border-radius:8px; padding:5px 10px; cursor:pointer; font-size:.85rem; }
.month-nav button:hover { background:var(--primary); color:#fff; border-color:var(--primary); }
.month-nav span { font-weight:700; min-width:130px; text-align:center; font-size:.9rem; }

/* ── Filter bar ──────────────────────────────────── */
.filter-bar { background:var(--card); border-radius:12px; padding:12px 16px; border:1px solid var(--border); display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.filter-bar .form-control, .filter-bar .form-select { width:auto; font-size:.82rem; padding:6px 10px; }

/* ── Progress bar ────────────────────────────────── */
.progress-outer { background:var(--border); border-radius:99px; height:7px; overflow:hidden; }
.progress-inner { height:100%; border-radius:99px; transition:width .4s; }

/* ── Section header ──────────────────────────────── */
.section-hdr { display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; }
.section-hdr h5 { font-size:.95rem; font-weight:700; }

/* ── Tabs ────────────────────────────────────────── */
.tab-nav { display:flex; gap:4px; background:#f1f5f9; border-radius:10px; padding:4px; margin-bottom:20px; width:fit-content; }
.tab-btn { padding:7px 16px; border-radius:8px; border:none; background:none; cursor:pointer; font-size:.85rem; font-weight:600; color:var(--muted); transition:all .15s; }
.tab-btn.active { background:#fff; color:var(--text); box-shadow:0 1px 4px rgba(0,0,0,.1); }
.tab-pane { display:none; }
.tab-pane.active { display:block; }

/* ── Calendar ────────────────────────────────────── */
.cal-grid { display:grid; grid-template-columns:repeat(7,1fr); gap:4px; }
.cal-head { text-align:center; font-size:.72rem; font-weight:700; color:var(--muted); padding:6px 0; }
.cal-day { min-height:80px; border-radius:10px; padding:7px 8px; border:1px solid var(--border); background:var(--card); cursor:pointer; transition:box-shadow .15s; }
.cal-day:hover { box-shadow:0 2px 10px rgba(0,0,0,.08); }
.cal-day.empty { background:#f8fafc; border-color:#f1f5f9; cursor:default; }
.cal-day.today { border-color:var(--primary); box-shadow:0 0 0 2px rgba(79,70,229,.15); }
.cal-day.has-tx { }
.cal-day-num { font-size:.8rem; font-weight:700; margin-bottom:4px; }
.cal-day-num.other-month { color:var(--muted); }
.cal-day-badge { font-size:.68rem; font-weight:700; padding:1px 5px; border-radius:4px; display:block; margin-top:1px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.cal-net-pos { background:#d1fae5; }
.cal-net-neg { background:#fee2e2; }

/* ── Category card ───────────────────────────────── */
.cat-card { background:var(--card); border:1px solid var(--border); border-radius:14px; padding:16px 18px; }
.cat-card-header { display:flex; align-items:center; gap:10px; margin-bottom:8px; }
.cat-card-icon { width:40px; height:40px; border-radius:10px; display:flex; align-items:center; justify-content:center; font-size:1.2rem; flex-shrink:0; }

/* ── Goal card ───────────────────────────────────── */
.goal-card { background:var(--card); border:1px solid var(--border); border-radius:14px; padding:18px 20px; }
.goal-progress-ring { width:72px; height:72px; flex-shrink:0; }

/* ── Recurring card ──────────────────────────────── */
.rec-card { background:var(--card); border:1px solid var(--border); border-radius:12px; padding:14px 16px; display:flex; align-items:center; gap:14px; }
.rec-icon { width:42px; height:42px; border-radius:10px; display:flex; align-items:center; justify-content:center; font-size:1.1rem; flex-shrink:0; }

/* ── Tag input ───────────────────────────────────── */
.tag-suggestions { display:none; position:absolute; background:#fff; border:1px solid var(--border); border-radius:8px; width:100%; z-index:10; max-height:150px; overflow-y:auto; box-shadow:0 4px 12px rgba(0,0,0,.1); top:100%; }
.tag-suggestions div { padding:7px 12px; cursor:pointer; font-size:.85rem; }
.tag-suggestions div:hover { background:#f1f5f9; }
.tag-wrap { position:relative; }

/* ── Notification banner ─────────────────────────── */
.notif-banner { background:#fffbeb; border:1px solid #fbbf24; border-radius:10px; padding:10px 16px; display:flex; align-items:center; gap:10px; font-size:.875rem; margin-bottom:16px; }

/* ── Empty state ─────────────────────────────────── */
.empty-state { text-align:center; padding:48px 20px; color:var(--muted); }
.empty-state .empty-icon { font-size:2.8rem; margin-bottom:10px; }

/* ── Toast ───────────────────────────────────────── */
#toast { position:fixed; bottom:22px; right:22px; padding:11px 18px; border-radius:10px; font-size:.875rem; font-weight:500; opacity:0; transform:translateY(10px); transition:all .25s; z-index:999; pointer-events:none; }
#toast.show { opacity:1; transform:translateY(0); }
#toast.success { background:#1e293b; color:#fff; }
#toast.error   { background:var(--expense); color:#fff; }
#toast.info    { background:var(--primary); color:#fff; }

/* ── Receipt preview ─────────────────────────────── */
.receipt-preview { display:flex; align-items:center; gap:8px; background:#f8fafc; border-radius:8px; padding:8px 12px; font-size:.82rem; }
.receipt-preview img { width:36px; height:36px; object-fit:cover; border-radius:5px; }

/* ── Responsive ──────────────────────────────────── */
@media (max-width:900px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform:translateX(-240px); transition:transform .25s; width:240px; }
  .sidebar.open { transform:translateX(0); }
  .main { margin-left:0; }
  .content { padding:14px; }
}
