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

/* Clean White & Blue Palette */
:root {
  --bg-primary: #f0f4f8;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-glass: rgba(59, 130, 246, 0.04);
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent-1: #2563eb;
  --accent-2: #1d4ed8;
  --accent-3: #3b82f6;
  --accent-light: #dbeafe;
  --accent-green: #059669;
  --accent-green-light: #d1fae5;
  --accent-amber: #d97706;
  --accent-rose: #e11d48;
  --gradient-primary: linear-gradient(135deg, #2563eb, #3b82f6);
  --gradient-soft: linear-gradient(135deg, #eff6ff, #dbeafe);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.08);
  --shadow-blue: 0 4px 20px rgba(37,99,235,0.15);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  position: relative;
}

/* ===== LOGIN SCREEN ===== */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, #eff6ff 0%, #f0f4f8 50%, #e0e7ff 100%);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.5s ease-out;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .logo-icon {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: var(--gradient-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 16px;
  box-shadow: var(--shadow-blue);
}

.login-logo h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-2);
}

.login-logo p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 6px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group select,
.form-group input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  transition: var(--transition);
  outline: none;
}

.form-group select:focus,
.form-group input:focus {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
  background: #fff;
}

.form-group select option {
  background: #fff;
  color: var(--text-primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  width: 100%;
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: var(--shadow-blue);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(37,99,235,0.25);
}

.btn-secondary {
  background: var(--bg-primary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--accent-light);
  color: var(--accent-2);
  border-color: var(--accent-3);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
  border-radius: 8px;
}

.admin-link {
  text-align: center;
  margin-top: 24px;
}

.admin-link button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}

.admin-link button:hover {
  color: var(--accent-1);
}

.error-msg {
  color: var(--accent-rose);
  font-size: 13px;
  margin-top: 8px;
  display: none;
}

/* ===== HEADER ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.app-header .brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-header .brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.app-header .brand h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.app-header .brand span {
  font-size: 12px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--accent-light);
  border: 1px solid rgba(37,99,235,0.15);
  border-radius: 100px;
  font-size: 13px;
  color: var(--accent-2);
  font-weight: 500;
}

.user-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
}

/* ===== STATS CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  animation: fadeInUp 0.4s ease-out both;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }

.stat-card .stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 14px;
}

.stat-card .stat-icon.purple { background: #dbeafe; }
.stat-card .stat-icon.green { background: #d1fae5; }
.stat-card .stat-icon.amber { background: #fef3c7; }
.stat-card .stat-icon.rose { background: #fce7f3; }

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-muted);
}

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 24px;
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.tab-btn:hover { color: var(--text-primary); }

.tab-btn.active {
  background: var(--accent-1);
  color: #fff;
  box-shadow: var(--shadow-blue);
}

/* ===== DATA TABLE ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  animation: fadeInUp 0.4s ease-out both;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
}

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.card-body { padding: 24px; }

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
}

tbody tr { transition: var(--transition); }
tbody tr:hover { background: var(--bg-glass); }

.amount { font-weight: 600; color: var(--accent-green); font-variant-numeric: tabular-nums; }
.amount.zero { color: var(--text-muted); }

/* ===== YEAR FILTER ===== */
.filters {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filters select {
  padding: 8px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  outline: none;
}

.filters select option {
  background: #fff;
}

/* ===== MEMBER CARDS ===== */
.members-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.member-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: var(--transition);
  animation: fadeInUp 0.4s ease-out both;
  box-shadow: var(--shadow-sm);
}

.member-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-3);
}

.member-card .member-avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 14px;
}

.member-card .member-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.member-card .member-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.member-card .member-total {
  font-size: 24px;
  font-weight: 800;
  color: var(--accent-green);
}

.member-card .member-total span {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 4px;
}

/* ===== CHART ===== */
.chart-container {
  position: relative;
  width: 100%;
  height: 300px;
  margin: 20px 0;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ===== BACK BUTTON ===== */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.back-btn:hover {
  background: var(--accent-light);
  color: var(--accent-2);
  border-color: var(--accent-3);
}

/* ===== LOADING ===== */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  gap: 16px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-1);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading p {
  color: var(--text-muted);
  font-size: 14px;
}

/* ===== ADMIN PANEL ===== */
.admin-badge {
  background: rgba(225,29,72,0.08);
  color: var(--accent-rose);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== HIDDEN ===== */
.hidden { display: none !important; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .container { padding: 12px; }
  .login-card { padding: 32px 24px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 16px; }
  .stat-card .stat-value { font-size: 22px; }
  .app-header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .members-grid { grid-template-columns: 1fr; }
  .tabs { gap: 2px; }
  .tab-btn { padding: 8px 14px; font-size: 13px; }
  .card-header { flex-direction: column; gap: 12px; align-items: flex-start; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}
