:root {
  --primary: #2563eb;
  --secondary: #38bdf8;
  --background: #f8fafc;
  --sidebar: #0f172a;
  --card: #ffffff;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text: #1e293b;
  --text-muted: #64748b;
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
}

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

body.theme {
  font-family: "Poppins", "Segoe UI", sans-serif;
  background: radial-gradient(circle at top right, rgba(56, 189, 248, 0.2), transparent 45%),
    var(--background);
  color: var(--text);
  min-height: 100vh;
}

h1,
h2,
h3 {
  font-family: "Space Grotesk", "Poppins", sans-serif;
}

a {
  color: inherit;
}

.auth {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 48px;
  padding: 64px;
}

.auth-card {
  background: var(--card);
  padding: 40px;
  border-radius: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-card h1 {
  font-size: 32px;
}

.auth-visual {
  position: relative;
  border-radius: 24px;
  background: linear-gradient(145deg, var(--primary), var(--secondary));
  padding: 40px;
  display: flex;
  align-items: flex-start;
  color: white;
  overflow: hidden;
}

.auth-visual-card {
  background: rgba(255, 255, 255, 0.06);
  padding: 28px;
  border-radius: 20px;
  backdrop-filter: blur(6px);
  color: rgba(255,255,255,0.98);
  border: 1px solid rgba(255,255,255,0.07);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
  max-width: 480px;
}

.card-glow {
  position: absolute;
  width: 280px;
  height: 280px;
  top: -120px;
  right: -80px;
  background: rgba(255, 255, 255, 0.14);
  filter: blur(20px);
  border-radius: 999px;
}

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

.brand-dot {
  width: 16px;
  height: 16px;
  background: var(--secondary);
  border-radius: 50%;
}

.brand-title {
  font-weight: 600;
  font-size: 18px;
}

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

.auth-visual-card h2,
.auth-visual-card h3 {
  color: #ffffff;
}

.auth-visual-card p.muted {
  color: rgba(255,255,255,0.85);
}

.auth-visual-card ul {
  margin: 8px 0 16px 18px;
  color: rgba(255,255,255,0.95);
  line-height: 1.5;
}

.auth-visual-card ul li {
  margin-bottom: 8px;
}

.auth-visual-card pre,
.auth-visual-card code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono", "Courier New", monospace;
  font-size: 13px;
}

.auth-visual-card pre {
  background: rgba(0,0,0,0.22);
  padding: 12px;
  border-radius: 8px;
  overflow: auto;
  color: #ffffff;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 8px;
}

.auth-visual-card a {
  color: #cfe9ff;
  text-decoration: underline;
}

.brand.compact .brand-subtitle {
  color: rgba(255, 255, 255, 0.7);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

.field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.small-btn {
  padding: 6px 10px;
  font-size: 12px;
}

.test-marks-list {
  display: grid;
  gap: 10px;
}

.inline-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.field input,
.field select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  font-size: 14px;
}

.btn {
  padding: 10px 16px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

.btn.primary {
  background: var(--primary);
  color: white;
}

.btn.ghost {
  background: transparent;
  border: 1px solid #cbd5f5;
  color: var(--text);
}

.btn.success {
  background: var(--success);
  color: white;
}

.btn.danger {
  background: var(--danger);
  color: white;
}

.btn:hover {
  opacity: 0.9;
}

/* hide mobile hamburger by default; shown in mobile media queries */
.hamburger { display: none; }

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 12px;
}

.error {
  color: var(--danger);
  font-size: 13px;
  min-height: 16px;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  color: white;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.menu-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  padding: 12px 14px;
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
  font-weight: 600;
}

.menu-btn.active,
.menu-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.content {
  padding: 32px 36px 64px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}

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

.topbar input {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  min-width: 220px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

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

.section {
  margin-top: 32px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

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

.table-wrap {
  background: var(--card);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
  overflow-x: auto;
}

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

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.report-table th {
  text-align: left;
  padding: 8px 10px;
  background: rgba(0,0,0,0.04);
  font-weight: 700;
}
.report-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.report-table tbody tr:nth-child(odd) td {
  background: rgba(0,0,0,0.02);
}

.table-wrap th,
.table-wrap td {
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid #eef2f6;
}

.table-wrap th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.pagination {
  margin-top: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.activity {
  list-style: none;
  display: grid;
  gap: 12px;
}

.activity li {
  background: var(--card);
  padding: 12px 16px;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.report-output {
  background: var(--card);
  padding: 16px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  min-height: 160px;
}

.settings-grid {
  display: grid;
  gap: 16px;
  max-width: 420px;
}

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

.attendance-panel {
  display: grid;
  gap: 16px;
}

.calendar-card {
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.calendar-header {
  margin-bottom: 12px;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.calendar-weekdays {
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.calendar-day {
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  color: var(--text);
  font-weight: 600;
}

.calendar-day.empty {
  background: transparent;
}

.calendar-day.today {
  background: var(--primary);
  color: #fff;
}

.attendance-table-wrap {
  margin-top: 0;
}

.attendance-footer-actions {
  display: flex;
  justify-content: flex-end;
}

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

.attendance-status {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: #e2e8f0;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}

.attendance-status.locked {
  background: #dbeafe;
  color: #1d4ed8;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  padding: 24px;
  overflow-y: auto;
}

.modal-card {
  background: var(--card);
  border-radius: 20px;
  padding: 24px;
  width: min(880px, 100%);
  max-height: calc(100vh - 48px);
  overflow: hidden;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

#student-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: flex-start;
  max-height: calc(100vh - 170px);
  overflow-y: scroll;
  scrollbar-gutter: stable both-edges;
  scroll-behavior: smooth;
  padding-right: 6px;
}

#student-form > label.field {
  flex: 1 1 calc(50% - 8px);
  min-width: 280px;
}

#student-form > div.field,
#student-form > #save-student,
#student-form > #form-error {
  width: 100%;
  flex: 1 1 100%;
}

.hidden {
  display: none;
}

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

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .menu {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .modal-card {
    max-height: calc(100vh - 24px);
    padding: 16px;
  }

  #student-form {
    max-height: calc(100vh - 140px);
  }

  #student-form > label.field {
    min-width: 100%;
    flex-basis: 100%;
  }

  .calendar-day {
    height: 32px;
    font-size: 13px;
  }
}

/* Responsive improvements: off-canvas sidebar, tighter tables, modal tweaks */
@media (max-width: 960px) {
  .auth {
    grid-template-columns: 1fr;
  }

  .layout {
    position: relative;
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: -320px; /* off-canvas */
    height: 100vh;
    width: 260px;
    z-index: 60;
    transition: left 240ms ease, transform 240ms ease;
    padding-top: 24px;
    padding-bottom: 24px;
    box-shadow: 0 8px 30px rgba(2,6,23,0.35);
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  body.sidebar-open .sidebar {
    left: 0;
  }

  .hamburger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    font-size: 18px;
    margin-right: 8px;
  }

  .content {
    padding: 20px 18px 64px;
  }

  .table-wrap {
    padding: 12px;
  }

  .report-output, .table-wrap table, .report-table {
    font-size: 13px;
  }

  /* ensure logout button anchors to bottom of sidebar */
  .sidebar #logout {
    margin-top: auto;
    align-self: stretch;
  }
}

@media (max-width: 600px) {
  .topbar input { min-width: 120px; }
  .table-wrap th, .table-wrap td, .report-table th, .report-table td {
    padding: 8px 6px;
    font-size: 13px;
  }

  .modal-card {
    width: 95%;
    padding: 12px;
  }

  #student-form > label.field {
    min-width: 100%;
    flex-basis: 100%;
  }

  .calendar-weekdays, .calendar-grid {
    gap: 6px;
  }

  .report-output { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Students section mobile layout */
  #students-section .section-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  #students-section .section-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  #students-section .section-actions select,
  #students-section .section-actions input,
  #students-section .section-actions button {
    width: 100%;
  }

  #students-section .table-wrap {
    padding: 10px;
    border-radius: 14px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #students-section table {
    min-width: 760px;
    font-size: 12px;
  }

  #students-section th,
  #students-section td {
    padding: 8px 6px;
    white-space: nowrap;
  }

  #students-section .actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
  }

  #students-section .actions .btn {
    padding: 8px 10px;
    font-size: 12px;
  }

  .pagination {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .pagination .btn,
  .pagination span {
    width: 100%;
    text-align: center;
  }

  /* Make stat cards display as single-row items with label and value side-by-side */
  .cards {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-radius: 12px;
  }

  .stat-card p {
    margin: 0;
    font-size: 14px;
    color: var(--text-muted);
  }

  .stat-card h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
  }
}
