:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --text: #1e2330;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #14162a;
  color: #cbd0e0;
  padding: 20px 0;
}
.sidebar .brand {
  font-weight: 700;
  font-size: 18px;
  color: #fff;
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 12px;
}
.sidebar nav a {
  display: block;
  padding: 10px 20px;
  color: #cbd0e0;
  font-size: 14px;
}
.sidebar nav a:hover, .sidebar nav a.active {
  background: rgba(99,102,241,0.18);
  color: #fff;
  text-decoration: none;
}
.sidebar .section-label {
  padding: 16px 20px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
}

.main { flex: 1; padding: 28px 36px; max-width: 1200px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.topbar h1 { font-size: 22px; margin: 0; }
.topbar .user-info { font-size: 13px; color: var(--text-muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.card h2, .card h3 { margin-top: 0; }

.grid { display: grid; gap: 20px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.stat { }
.stat .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}
.badge-muted { background: #9ca3af; }
.badge-success { background: var(--success); }
.badge-danger { background: var(--danger); }
.badge-warning { background: var(--warning); color: #1e2330; }

.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 8px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: #e5e7eb; color: var(--text); }
.btn-secondary:hover { background: #d1d5db; color: var(--text); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

form.inline { display: inline; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=file], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
textarea { resize: vertical; min-height: 70px; }

.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #6366f1, #14162a);
  padding: 20px;
}
.auth-card {
  background: #fff;
  border-radius: 14px;
  padding: 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}
.auth-card h1 { font-size: 20px; margin-top: 0; }
.auth-card .switch-link { text-align: center; margin-top: 16px; font-size: 13px; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.flash-success { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }
.flash-info { background: #e0e7ff; color: #3730a3; }

.calendar { width: 100%; border-collapse: collapse; table-layout: fixed; }
.calendar th { text-align: center; padding: 8px; font-size: 12px; }
.calendar td {
  vertical-align: top;
  height: 100px;
  border: 1px solid var(--border);
  padding: 6px;
  font-size: 12px;
}
.calendar td.other-month { background: #fafafa; color: #ccc; }
.calendar td.today { background: #eef2ff; }
.calendar .day-num { font-weight: 600; margin-bottom: 4px; }
.calendar .due-item {
  display: block;
  background: var(--primary);
  color: #fff;
  border-radius: 5px;
  padding: 2px 5px;
  margin-bottom: 3px;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.calendar-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }

.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

.receipt-thumb {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 8px;
  background: #f3f4f6;
  display: block;
}
.receipt-card { padding: 12px; }
.receipt-card .meta { font-size: 12px; color: var(--text-muted); margin: 8px 0; }
