:root {
  --bg-primary: #f6f8fb;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #ffffff;
  --text-main: #172033;
  --text-muted: #64748b;
  --accent-blue: #1d4ed8;
  --accent-purple: #475569;
  --success-green: #15803d;
  --warning-amber: #b45309;
  --danger-red: #b91c1c;
  --border-color: #e2e8f0;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 2px 10px rgba(15,23,42,0.06);
  --transition: all 0.25s cubic-bezier(.4,0,.2,1);
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-main);
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 260px;
  min-height: 100vh;
  background: var(--bg-sidebar);
  padding: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  border-right: 1px solid var(--border-color);
  box-shadow: 1px 0 8px rgba(15,23,42,.03);
}

.sidebar-header {
  padding: 24px 24px 20px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-nav { padding: 12px 0; flex: 1; }

.nav-link {
  padding: 13px 24px;
  color: var(--text-muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.95rem;
  font-weight: 500;
  transition: var(--transition);
  border-left: 3px solid transparent;
}

.nav-link:hover {
  color: var(--text-main);
  background: rgba(67,97,238,0.06);
}

.nav-link.active {
  color: var(--accent-blue);
  background: #eff6ff;
  border-left-color: var(--accent-blue);
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: 260px;
  flex: 1;
  padding: 28px 36px;
  min-height: 100vh;
  overflow-y: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.topbar h1 {
  font-size: 1.5rem;
  font-weight: 600;
}
.page-subtitle { color: var(--text-muted); margin-top: 6px; font-size: .9rem; }
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border-color);
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.card h3 {
  margin-bottom: 16px;
  font-size: 1.1rem;
  font-weight: 600;
}

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent-blue);
}

.stat-card.green::before { background: var(--success-green); }
.stat-card.green { background: var(--bg-card); }
.stat-card.amber::before { background: var(--warning-amber); }
.stat-card.amber { background: var(--bg-card); }
.stat-card.purple::before { background: var(--accent-purple); }
.stat-card.purple { background: var(--bg-card); }

.stat-icon { font-size: 1.8rem; margin-bottom: 12px; }
.stat-value { font-size: 1.6rem; font-weight: 700; margin-bottom: 4px; }
.stat-label { color: var(--text-muted); font-size: 0.85rem; font-weight: 500; }

/* ===== TABLE ===== */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--border-color); }
th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; }
tbody tr { transition: var(--transition); }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

/* ===== BADGES ===== */
.badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-paid { background: #dcfce7; color: var(--success-green); }
.badge-pending { background: #fee2e2; color: var(--danger-red); }

/* ===== BUTTONS ===== */
.btn {
  background: var(--accent-blue);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn:hover { background: #1e40af; transform: translateY(-1px); }
.btn-success { background: var(--success-green); }
.btn-success:hover { background: #166534; }
.btn-danger { background: var(--danger-red); }
.btn-danger:hover { background: #991b1b; }
.btn-ghost { background: #ffffff; border: 1px solid var(--border-color); color: #334155; }
.btn-ghost:hover { background: #f8fafc; color: var(--text-main); }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; }

/* ===== MODAL ===== */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15,23,42,0.42);
  backdrop-filter: blur(6px);
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding-top: 8vh;
  z-index: 200;
  overflow-y: auto;
}

.modal.active { display: flex; }

.modal-content {
  background: #ffffff;
  border: 1px solid var(--border-color);
  padding: 28px;
  border-radius: var(--radius);
  width: 480px;
  max-width: 92%;
  box-shadow: 0 16px 40px rgba(15,23,42,.16);
  animation: modalSlide 0.25s ease;
  margin-bottom: 40px;
}

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

.modal-content h3 {
  font-size: 1.15rem;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: flex-end;
}

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(67,97,238,0.15);
}

.form-control::placeholder { color: var(--text-muted); opacity: 0.6; }
textarea.form-control { min-height: 80px; resize: vertical; }
select.form-control { cursor: pointer; }
select.form-control option { color: var(--text-main); background: #fff; }
.form-help { margin-top: 6px; color: var(--text-muted); font-size: 0.78rem; line-height: 1.45; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ===== PHOTO UPLOAD ===== */
.photo-upload {
  display: flex;
  align-items: center;
  gap: 16px;
}

.photo-preview {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 2px dashed var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  font-size: 2rem;
  color: var(--text-muted);
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-upload-btn {
  display: inline-block;
  padding: 8px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: var(--transition);
}

.photo-upload-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-main);
}

input[type="file"] { display: none; }

/* ===== STUDENT PHOTO IN TABLE ===== */
.student-photo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-input);
  border: 2px solid var(--border-color);
}

.student-photo-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

/* ===== TABS ===== */
.tabs { display: flex; gap: 0; margin-bottom: 24px; border-bottom: 1px solid var(--border-color); }
.tab {
  cursor: pointer;
  padding: 12px 20px;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  margin-bottom: -1px;
}
.tab:hover { color: var(--text-main); }
.tab.active { border-bottom-color: var(--accent-blue); color: var(--accent-blue); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--success-green);
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease;
  font-size: 0.9rem;
}

.toast.error { border-left-color: var(--danger-red); }

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== SEARCH/FILTER BAR ===== */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-bar .form-control { width: auto; flex: 1; min-width: 160px; }
.filter-bar select.form-control { flex: 0 0 180px; }

/* ===== LOGO PREVIEW ===== */
.logo-preview {
  width: 120px;
  height: 120px;
  border-radius: var(--radius);
  background: var(--bg-input);
  border: 2px dashed var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 10px;
}

.logo-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* ===== CHECKBOX GROUP ===== */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition);
}

.checkbox-item:hover { border-color: var(--accent-blue); }
.checkbox-item input[type="checkbox"] { accent-color: var(--accent-blue); }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.95rem; }

/* ===== LOADING SPINNER ===== */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ===== CONFIRM DIALOG ===== */
.confirm-text { font-size: 0.95rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 8px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar .nav-link span { display: none; }
  .sidebar-header h2 span { display: none; }
  .main-content { margin-left: 60px; padding: 20px 16px; }
  .form-row { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; }
  .filter-bar .form-control, .filter-bar select.form-control { flex: 1; width: 100%; }
  .modal-content { width: 95%; }
  .topbar { align-items: flex-start; gap: 14px; flex-direction: column; }
  .topbar .btn { width: 100%; justify-content: center; }
  .card { padding: 16px; }
  th, td { padding: 12px 10px; white-space: nowrap; }
}
