@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --ink: #1c2b28;
  --primary: #2f6f5e;
  --primary-dark: #1f4d40;
  --primary-light: #e4f2ed;
  --danger: #b3452c;
  --danger-light: #fbe8e2;
  --warn: #c98a1c;
  --warn-light: #fbf0dc;
  --bg: #f5f7f5;
  --card: #ffffff;
  --line: #e2e8e4;
  --muted: #6b7d76;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(28,43,40,0.06);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: 'Inter', sans-serif; background: var(--bg); color: var(--ink); }
h1, h2, h3 { margin: 0 0 0.4rem; font-weight: 700; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ---------- login ---------- */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, var(--primary-dark), var(--primary) 60%, #4a9179); }
.login-card { background: var(--card); border-radius: var(--radius); padding: 2.4rem; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,0.25); }
.brand { text-align: center; margin-bottom: 1.6rem; }
.brand-icon { font-size: 2.4rem; }
.brand p { color: var(--muted); font-size: 0.9rem; margin-top: 0.3rem; }
#loginForm label { display: block; font-size: 0.82rem; font-weight: 600; margin: 0.8rem 0 0.3rem; color: var(--muted); }
#loginForm input { width: 100%; padding: 0.65rem 0.8rem; border: 1px solid var(--line); border-radius: 8px; font-size: 0.95rem; }
.error-msg { color: var(--danger); font-size: 0.85rem; min-height: 1.2rem; margin-top: 0.5rem; }

/* ---------- buttons ---------- */
.btn { border: none; border-radius: 8px; padding: 0.6rem 1.1rem; font-weight: 600; font-size: 0.88rem; transition: 0.15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); text-decoration: none; display: inline-block; }
.btn-outline:hover { background: var(--primary-light); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-ghost:hover { background: #f0f2f0; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; margin-top: 1.2rem; }
.icon-btn { background: transparent; border: none; font-size: 1.1rem; color: var(--muted); padding: 0.3rem 0.5rem; border-radius: 6px; }
.icon-btn:hover { background: #eee; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 250px; background: var(--primary-dark); color: #fff; display: flex; flex-direction: column; padding: 1.4rem 1rem; flex-shrink: 0; }
.sidebar-brand { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1.6rem; padding: 0 0.4rem; }
.sidebar-brand strong { display: block; font-size: 1rem; }
.sidebar-brand small { display: block; color: #b9d6cb; font-size: 0.75rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; }
.nav-btn { text-align: left; background: transparent; border: none; color: #d8ece4; padding: 0.65rem 0.8rem; border-radius: 8px; font-size: 0.9rem; }
.nav-btn:hover { background: rgba(255,255,255,0.08); }
.nav-btn.active { background: var(--primary); color: #fff; }

.main { flex: 1; padding: 1.6rem 2rem; max-width: 100%; overflow-x: hidden; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.4rem; flex-wrap: wrap; gap: 0.8rem; }
.month-picker { display: flex; align-items: center; gap: 0.3rem; background: #fff; border-radius: 8px; padding: 0.3rem; box-shadow: var(--shadow); }
.month-picker input { border: none; font-weight: 600; font-size: 0.95rem; padding: 0.2rem; }
.topbar-actions { display: flex; gap: 0.6rem; }

.view-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; gap: 0.6rem; }

/* ---------- cards ---------- */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.6rem; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 1.1rem 1.3rem; box-shadow: var(--shadow); border-left: 4px solid var(--primary); }
.stat-card.income { border-color: var(--primary); }
.stat-card.expense { border-color: var(--danger); }
.stat-card.balance { border-color: #2a6fb0; }
.stat-card.alert { border-color: var(--warn); }
.stat-label { display: block; font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.stat-value { display: block; font-size: 1.6rem; font-weight: 800; margin: 0.2rem 0; }
.stat-sub { display: block; font-size: 0.78rem; color: var(--muted); }

.panel { background: var(--card); border-radius: var(--radius); padding: 1.2rem 1.4rem; box-shadow: var(--shadow); margin-bottom: 1.4rem; }
.panel h3 { font-size: 1rem; margin-bottom: 0.8rem; }

/* ---------- lists (bills/incomes status) ---------- */
.list { display: flex; flex-direction: column; gap: 0.5rem; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; padding: 0.7rem 0.9rem; border: 1px solid var(--line); border-radius: 8px; flex-wrap: wrap; }
.list-item .li-main { display: flex; align-items: center; gap: 0.6rem; }
.li-icon { font-size: 1.2rem; }
.li-title { font-weight: 600; font-size: 0.92rem; }
.li-sub { font-size: 0.78rem; color: var(--muted); }
.li-amount { font-weight: 700; }
.badge { padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700; }
.badge-paid { background: var(--primary-light); color: var(--primary-dark); }
.badge-pending { background: var(--warn-light); color: #8a5c10; }
.badge-overdue { background: var(--danger-light); color: var(--danger); }
.empty-state { color: var(--muted); font-size: 0.88rem; padding: 0.6rem; }

/* ---------- tables ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 0.5rem 0.6rem; border-bottom: 2px solid var(--line); }
.data-table td { padding: 0.6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.row-actions { display: flex; gap: 0.4rem; }
.row-actions button { background: transparent; border: none; font-size: 0.9rem; padding: 0.25rem 0.4rem; border-radius: 6px; }
.row-actions button:hover { background: #f0f2f0; }
.pill { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.76rem; font-weight: 600; }
.amount-income { color: var(--primary-dark); font-weight: 700; }
.amount-expense { color: var(--danger); font-weight: 700; }

/* ---------- modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(20,30,28,0.5); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem; }
.modal { background: #fff; border-radius: var(--radius); width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.3rem; border-bottom: 1px solid var(--line); }
.modal-body { padding: 1.3rem; }
.form-grid { display: flex; flex-direction: column; gap: 0.9rem; }
.form-grid label { font-size: 0.82rem; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 0.3rem; }
.form-grid input, .form-grid select, .form-grid textarea { font-size: 0.92rem; padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); }
.form-row { display: flex; gap: 0.8rem; }
.form-row > label { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 0.4rem; }
.checkbox-row { flex-direction: row !important; align-items: center; gap: 0.5rem !important; }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 1.4rem; right: 1.4rem; background: var(--primary-dark); color: #fff; padding: 0.8rem 1.2rem; border-radius: 8px; box-shadow: var(--shadow); z-index: 200; font-size: 0.88rem; }
.toast.error { background: var(--danger); }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 0.8rem; }
  .sidebar-brand { margin-bottom: 0; margin-right: auto; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .main { padding: 1rem; }
}
