:root {
  --primary: #0d6efd;
  --primary-dark: #0b5ed7;
  --accent: #17c666;
  --warning: #ffa21d;
  --danger: #ea4d4d;
  --info: #3ec9d6;
  --ink: #1d2630;
  --muted: #6b7785;
  --line: #dbe0e5;
  --page: #eef3fb;
  --panel: #ffffff;
  --side: #111827;
  --violet: #7952b3;
  --pink: #d63384;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(13, 110, 253, .14), transparent 34%),
    radial-gradient(circle at top right, rgba(25, 135, 84, .13), transparent 30%),
    var(--page);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

a { color: inherit; text-decoration: none; }
a:hover { color: inherit; }

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 15%, rgba(13, 110, 253, .22), transparent 30%),
    radial-gradient(circle at 85% 20%, rgba(255, 193, 7, .24), transparent 24%),
    linear-gradient(135deg, #eff2ff, #eefcf8);
}

.auth-card {
  width: 100%;
  max-width: 430px;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 12px;
  box-shadow: 0 18px 55px rgba(19, 25, 32, .16);
  padding: 34px;
}

.auth-card-wide { max-width: 560px; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 20px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--pink));
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(13, 110, 253, .28);
}

.brand-logo {
  width: 46px;
  max-height: 42px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 4px;
}

.auth-card .brand-logo {
  width: 58px;
  max-height: 52px;
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.detail-list-clean .detail-item {
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(219, 224, 229, .75);
}

.detail-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #fbfdff;
}

.detail-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.installment-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr 1fr;
  gap: 10px;
  align-items: end;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
}

.check-grid label {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 700;
  margin: 0;
}

.check-grid input {
  width: auto;
}

.filter-bar {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 1fr) auto auto auto auto;
  gap: 10px;
  align-items: center;
}

.signature-preview {
  display: block;
  width: 160px;
  max-height: 70px;
  object-fit: contain;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 6px;
}

.student-photo-preview {
  display: block;
  width: 112px;
  height: 140px;
  object-fit: cover;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 4px;
}

.student-avatar {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 5px 14px rgba(15, 23, 42, .15);
  flex: 0 0 44px;
}

.student-avatar-lg {
  width: 92px;
  height: 112px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 4px;
  flex: 0 0 92px;
}

.student-cell,
.profile-strip,
.section-heading {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-strip,
.section-heading {
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

.profile-strip { justify-content: flex-start; }
.profile-strip h2,
.section-heading h2 { margin: 0 0 4px; font-size: 22px; font-weight: 850; }
.section-title { margin: 22px 0 4px; font-size: 16px; font-weight: 850; }

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(13, 110, 253, .18), transparent 32%),
    var(--side);
  color: #dbe0e5;
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  box-shadow: 14px 0 34px rgba(17, 24, 39, .18);
}

.sidebar-admin { border-right: 4px solid var(--primary); }
.sidebar-student { border-right: 4px solid var(--accent); }
.sidebar .brand { color: #fff; margin-bottom: 28px; }
.nav-label { color: #9ba8b7; font-size: 11px; font-weight: 800; margin: 20px 12px 8px; text-transform: uppercase; letter-spacing: .08em; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 10px;
  color: #c8d0d8;
  margin-bottom: 4px;
  border: 1px solid transparent;
  transition: background .18s ease, transform .18s ease, border-color .18s ease;
}
.nav-link:hover, .nav-link.active {
  background: rgba(255, 255, 255, .11);
  border-color: rgba(255, 255, 255, .12);
  color: #fff;
  transform: translateX(2px);
}
.nav-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 12px;
  font-weight: 900;
  flex: 0 0 28px;
}

.main { min-width: 0; }
.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(10px);
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.content { padding: 26px; }
.page-title { margin: 0; font-size: 25px; font-weight: 800; }
.muted { color: var(--muted); }
.user-pill {
  border-radius: 999px;
  font-weight: 800;
  padding: 9px 14px;
  white-space: nowrap;
}
.user-pill-photo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}
.user-pill-photo img {
  width: 30px;
  height: 30px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid #fff;
}

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card {
  background: var(--panel);
  border: 0;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(19, 25, 32, .08);
  overflow: hidden;
  position: relative;
}
.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--info), var(--accent));
}
.card-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}
.card-title { margin: 0; font-size: 17px; font-weight: 800; }
.card-body { padding: 20px; }
.stat { display: flex; align-items: center; justify-content: space-between; }
.stat strong { font-size: 28px; display: block; margin-top: 6px; color: var(--ink); }
.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--info));
  color: #fff;
  font-weight: 900;
  box-shadow: 0 12px 26px rgba(13, 110, 253, .26);
}
.grid > .card:nth-child(2) .stat-icon { background: linear-gradient(135deg, #198754, #20c997); }
.grid > .card:nth-child(3) .stat-icon { background: linear-gradient(135deg, #fd7e14, #ffc107); }
.grid > .card:nth-child(4) .stat-icon { background: linear-gradient(135deg, #dc3545, #d63384); }

.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { margin-bottom: 14px; }
label { display: block; font-weight: 800; margin-bottom: 7px; color: #344054; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  transition: border-color .18s ease, box-shadow .18s ease;
}
input[type="file"] { padding: 9px; }
label:has(+ input[required])::after,
label:has(+ select[required])::after,
label:has(+ textarea[required])::after {
  content: " *";
  color: var(--danger);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 .22rem rgba(13, 110, 253, .15);
  outline: 0;
}
textarea { min-height: 100px; resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(17, 24, 39, .08);
}
.btn:disabled { opacity: .7; cursor: not-allowed; box-shadow: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-light { background: #eef1f5; color: var(--ink); }
.btn-light:hover { background: #dde5ef; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 10px; font-size: 12px; }

.table-wrap {
  overflow-x: auto;
  padding: 12px;
}
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 10px;
}
thead tr {
  background: transparent;
}
tbody tr {
  background: #fff;
  box-shadow: 0 5px 18px rgba(15, 23, 42, .06);
  transition: transform .18s ease, box-shadow .18s ease;
}
tbody tr:nth-child(4n + 1) td:first-child { border-left: 5px solid var(--primary); }
tbody tr:nth-child(4n + 2) td:first-child { border-left: 5px solid var(--accent); }
tbody tr:nth-child(4n + 3) td:first-child { border-left: 5px solid var(--warning); }
tbody tr:nth-child(4n + 4) td:first-child { border-left: 5px solid var(--danger); }
tbody tr:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(15, 23, 42, .11);
}
th, td {
  padding: 14px 16px;
  border-bottom: 0;
  text-align: left;
  vertical-align: middle;
}
th {
  color: #667085;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: #f3f7ff;
}
tbody td:first-child, thead th:first-child {
  border-top-left-radius: 12px;
  border-bottom-left-radius: 12px;
}
tbody td:last-child, thead th:last-child {
  border-top-right-radius: 12px;
  border-bottom-right-radius: 12px;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}
.badge-success { background: #d1e7dd; color: #0f5132; }
.badge-warning { background: #fff3cd; color: #664d03; }
.badge-danger { background: #f8d7da; color: #842029; }
.badge-info { background: #cff4fc; color: #055160; }

.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; border: 0; font-weight: 700; }
.alert-success { background: #e8fbf0; color: #128a49; }
.alert-danger { background: #fde9e9; color: #b62424; }
.alert-info { background: #e8fbfd; color: #087b86; }

.content > .card,
.content > .grid {
  animation: panel-in .24s ease-out;
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .grid-2, .grid-3, .grid-4, .form-row, .detail-list, .installment-row, .check-grid, .filter-bar { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; gap: 10px; padding: 18px; }
  .content { padding: 18px; }
  .section-heading, .profile-strip { flex-direction: column; }
  .student-cell { align-items: flex-start; }
}

@media print {
  .sidebar, .topbar, .filter-bar, .actions, .btn { display: none !important; }
  .layout { display: block; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
}
