/* ==========================================================
   TOKENS
   ========================================================== */
:root {
  --bg: #f7f5ef;
  --surface: #ffffff;
  --primary: #1b2a4a;
  --primary-light: #2f4373;
  --accent: #f2a93b;
  --rust: #b8562e;
  --text: #22252b;
  --text-muted: #6b6f76;
  --border: #e5e1d6;
  --success: #3f8f5d;
  --success-bg: #e7f3ec;
  --danger: #c4472c;
  --danger-bg: #fbeae5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(27, 42, 74, 0.06), 0 4px 16px rgba(27, 42, 74, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

h1, h2, h3, .brand, .nav-item, .stat-value {
  font-family: "Poppins", sans-serif;
}

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

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-size: 14px;
}

/* ==========================================================
   LOGIN PAGE
   ========================================================== */
.login-wrap {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  min-height: 100vh;
}

.login-brand {
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 64px;
  position: relative;
  overflow: hidden;
}

.login-brand::after {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  border: 1px solid rgba(242, 169, 59, 0.25);
  top: -120px;
  right: -140px;
}

.login-brand::before {
  content: "";
  position: absolute;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  border: 1px solid rgba(242, 169, 59, 0.18);
  bottom: -100px;
  right: -60px;
}

.login-brand .eyebrow {
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 18px;
}

.login-brand h1 {
  font-size: 38px;
  font-weight: 600;
  margin: 0 0 14px;
  max-width: 420px;
}

.login-brand p {
  color: rgba(255, 255, 255, 0.72);
  max-width: 380px;
  font-size: 15px;
}

.login-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.login-card {
  width: 100%;
  max-width: 360px;
}

.login-card h2 {
  font-size: 22px;
  margin: 0 0 6px;
}

.login-card .sub {
  color: var(--text-muted);
  margin: 0 0 28px;
  font-size: 14px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.field input, .field select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}

.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(47, 67, 115, 0.12);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.btn-primary:hover { background: var(--primary-light); }
.btn-primary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.form-msg {
  margin-top: 14px;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 8px;
  display: none;
}

.form-msg.error { display: block; background: var(--danger-bg); color: var(--danger); }
.form-msg.success { display: block; background: var(--success-bg); color: var(--success); }

/* ==========================================================
   APP SHELL
   ========================================================== */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--primary);
  color: #fff;
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
}

.brand {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 4px;
}

.brand-sub {
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  margin-bottom: 36px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
}

.nav-item .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }

.nav-item.active {
  background: rgba(242, 169, 59, 0.14);
  color: var(--accent);
}
.nav-item.active .dot { background: var(--accent); opacity: 1; }

.sidebar-footer {
  margin-top: auto;
}

.logout-btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.85);
  padding: 10px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
}
.logout-btn:hover { background: rgba(255, 255, 255, 0.14); }

.main {
  padding: 32px 40px;
  max-width: 1180px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: 24px;
  margin: 0 0 4px;
}

.page-header .sub {
  color: var(--text-muted);
  font-size: 14px;
}

/* ==========================================================
   STAT CARDS
   ========================================================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 10px;
}

.stat-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--primary);
}

.stat-value.accent { color: var(--rust); }
.stat-value.success { color: var(--success); }

/* ==========================================================
   CARD / TABLE
   ========================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.card-header h3 { margin: 0; font-size: 15px; }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar input, .toolbar select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
  background: var(--bg);
}

.btn-accent {
  background: var(--primary);
  color: #fff;
  padding: 9px 16px;
  font-weight: 600;
  font-size: 13px;
  border-radius: 7px;
}
.btn-accent:hover { background: var(--primary-light); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 7px;
}
.btn-ghost:hover { border-color: var(--primary-light); }

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: #fbfaf6;
}

tbody td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fbfaf6; }

.student-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.roll-chip {
  display: inline-block;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.status-pill.present { background: var(--success-bg); color: var(--success); }
.status-pill.absent { background: var(--danger-bg); color: var(--danger); }

.row-actions { display: flex; gap: 8px; }

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.icon-btn:hover { border-color: var(--primary-light); color: var(--primary); }
.icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

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

/* ==========================================================
   MODAL
   ========================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(27, 42, 74, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 26px 28px;
}

.modal h3 { margin: 0 0 20px; font-size: 17px; }

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.modal-grid .field.full { grid-column: 1 / -1; }

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

/* ==========================================================
   ATTENDANCE
   ========================================================== */
.attendance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.attendance-row:last-child { border-bottom: none; }

.toggle-group {
  display: flex;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}

.toggle-btn {
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
}

.toggle-btn.active.present { background: var(--success); color: #fff; }
.toggle-btn.active.absent { background: var(--danger); color: #fff; }

/* ==========================================================
   MISC
   ========================================================== */
.loading { padding: 40px; text-align: center; color: var(--text-muted); }

@media (max-width: 880px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: flex; flex-direction: row; align-items: center; padding: 14px 18px; overflow-x: auto; }
  .sidebar-footer { margin-top: 0; margin-left: auto; }
  .brand-sub { display: none; }
  .brand { margin-bottom: 0; margin-right: 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .main { padding: 20px; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .modal-grid { grid-template-columns: 1fr; }
}
