:root {
  --primary: #012970;
  --accent: #4154f1;
  --accent-hover: #2f3fd0;
  --bg: #f6f9ff;
  --card: #ffffff;
  --text: #1a1a2e;
  --muted: #6c757d;
  --border: #dee2e6;
  --success: #198754;
  --warning: #ffc107;
  --danger: #dc3545;
  --shadow: 0 4px 20px rgba(1, 41, 112, 0.08);
  --radius: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Header */
.site-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand h1 {
  font-size: 1.35rem;
  font-weight: 700;
}

.brand p {
  font-size: 0.85rem;
  opacity: 0.9;
  margin-top: 0.15rem;
}

.header-meta {
  font-size: 0.8rem;
  opacity: 0.85;
  text-align: right;
}

/* Main */
.main-wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.stat-card .label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-card .value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 0.25rem;
}

/* Toolbar */
.toolbar {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.toolbar input,
.toolbar select {
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.92rem;
  min-width: 200px;
}

.toolbar input:focus,
.toolbar select:focus {
  outline: 2px solid rgba(65, 84, 241, 0.35);
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-outline {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background: var(--bg);
}

.btn-outline:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.toolbar-spacer {
  flex: 1;
}

/* Grid */
.students-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.15rem;
}

.student-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.student-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(1, 41, 112, 0.12);
}

.card-photo-wrap {
  height: 200px;
  background: linear-gradient(180deg, #e8eeff 0%, #f6f9ff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.card-photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-fallback {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-size: 1.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.status-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  text-transform: uppercase;
}

.status-active {
  background: #d1e7dd;
  color: #0f5132;
}

.status-inactive {
  background: #f8d7da;
  color: #842029;
}

.status-other {
  background: #fff3cd;
  color: #664d03;
}

.card-body {
  padding: 1rem;
}

.card-body h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.35rem;
}

.card-meta {
  font-size: 0.82rem;
  color: var(--muted);
}

.card-meta div {
  margin-top: 0.2rem;
}

.card-meta strong {
  color: var(--text);
}

/* States */
.loading-box,
.error-box,
.empty-box {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  color: var(--muted);
}

.error-box {
  color: var(--danger);
  border-color: #f5c2c7;
  background: #fff5f5;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Pagination */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.75rem;
}

.page-info {
  font-size: 0.88rem;
  color: var(--muted);
  padding: 0 0.75rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
  overflow-y: auto;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--card);
  border-radius: var(--radius);
  max-width: 820px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.modal-header h2 {
  font-size: 1.15rem;
  color: var(--primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0.15rem 0.4rem;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 1.5rem;
}

.detail-top {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.detail-photo {
  width: 160px;
  flex-shrink: 0;
}

.detail-photo img,
.detail-photo .avatar-fallback {
  width: 160px;
  height: 160px;
  border-radius: var(--radius);
  object-fit: cover;
}

.detail-photo .avatar-fallback {
  font-size: 2.5rem;
}

.detail-signature {
  margin-top: 0.75rem;
}

.detail-signature img {
  max-width: 140px;
  max-height: 60px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.detail-signature span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem 1.25rem;
  flex: 1;
}

.detail-item label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

.detail-item span {
  font-size: 0.92rem;
  font-weight: 500;
  word-break: break-word;
}

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
  margin: 1.25rem 0 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--bg);
}

.enroll-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.enroll-table th,
.enroll-table td {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  text-align: left;
}

.enroll-table th {
  background: var(--bg);
  color: var(--primary);
  font-weight: 600;
}

.site-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

@media (max-width: 600px) {
  .toolbar input,
  .toolbar select {
    min-width: 100%;
    flex: 1 1 100%;
  }

  .header-meta {
    text-align: left;
  }
}
