:root {
  --bg: #f6f8f5;
  --card: #ffffff;
  --text: #102017;
  --muted: #66736a;
  --line: #dfe7df;
  --strong: #166534;
  --warn: #92400e;
  --bad: #991b1b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background 0.3s ease, color 0.3s ease;
}

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.25rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.eyebrow {
  margin: 0 0 0.2rem;
  color: #1f7a4d;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
}

h1, h2 {
  margin: 0;
}

.actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.actions a,
button {
  border: 1px solid #1f7a4d;
  border-radius: 999px;
  background: #1f7a4d;
  color: #fff;
  padding: 0.55rem 0.8rem;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 500;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.actions a:hover,
button:hover {
  background: #145536;
  border-color: #145536;
}

.card,
.metric {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 0.9rem;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

.metric strong {
  display: block;
  font-size: 1.45rem;
  margin-top: 0.25rem;
}

.card {
  margin-bottom: 0.9rem;
}

#deploymentMeta,
.section-header p,
#statusText {
  color: var(--muted);
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 0.75rem 0.55rem;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
}

.progress-line {
  color: var(--muted);
  font-size: 0.85rem;
}

.flag {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.flag.warn {
  color: var(--warn);
  border-color: rgba(146, 64, 14, 0.35);
}

.flag.bad {
  color: var(--bad);
  border-color: rgba(153, 27, 27, 0.35);
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}


/* Dashboard login */
body.login-mode {
  background-image: 
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E"),
    radial-gradient(circle, #383a39 0%, #111312 100%);
  background-image: 
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E"),
    radial-gradient(circle in oklab, #383a39 0%, #111312 100%);
  color: #eef5f0;
}

body.login-mode h1 {
  color: #ffffff;
}

body.login-mode .login-card {
  max-width: 520px;
  background: #ffffff;
  color: #102017;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  margin: 6rem auto;
}

body.login-mode .login-card h2 {
  color: #102017;
}

body.login-mode .login-card p {
  color: #66736a;
}

body.login-mode .login-card label {
  color: #66736a;
}

.login-card {
  max-width: 520px;
}

.login-form {
  display: grid;
  gap: 0.85rem;
  margin-top: 1rem;
}

.login-form label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-form input,
.login-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  padding: 0.7rem 0.8rem;
  color: var(--text);
  background: #fff;
  font: inherit;
}

.login-form button {
  justify-self: start;
  background: #1f7a4d;
  color: #fff;
  border-color: #1f7a4d;
}

.login-form button:hover {
  background: #145536;
  border-color: #145536;
}

.error {
  margin: 0;
  color: var(--bad);
}


.user-badge {
  display: inline-flex;
  align-items: center;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.85rem;
}


/* Deployment selector */
.deployment-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.deployment-picker {
  display: grid;
  gap: 0.35rem;
  min-width: 260px;
  color: var(--muted);
  font-size: 0.85rem;
}

.deployment-picker select {
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  padding: 0.6rem 0.75rem;
  background: #fff;
  color: var(--text);
  font: inherit;
}

@media (max-width: 760px) {
  .deployment-header {
    flex-direction: column;
  }

  .deployment-picker {
    width: 100%;
  }
}


/* Users panel */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.admin-form {
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  padding: 0.9rem;
  display: grid;
  gap: 0.75rem;
}

.admin-form h3 {
  margin: 0;
}

.admin-form label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.admin-form input,
.admin-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  padding: 0.65rem 0.75rem;
  color: var(--text);
  background: #fff;
  font: inherit;
}

.admin-form button,
#reloadUsersButton {
  justify-self: start;
}

.result {
  margin: 0;
  white-space: pre-wrap;
  color: var(--strong);
  font-size: 0.9rem;
}

.result.error {
  color: var(--bad);
}

.users-table-wrap {
  margin-top: 0.8rem;
}

.role-pill,
.enrollment-pill {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
  margin: 0.1rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.temp-password {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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


.bulk-form {
  grid-column: 1 / -1;
}

.admin-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  padding: 0.65rem 0.75rem;
  color: var(--text);
  background: #fff;
  font: inherit;
  resize: vertical;
}

.form-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}


.download-link {
  justify-self: start;
  color: var(--strong);
  font-size: 0.9rem;
  text-decoration: none;
  border-bottom: 1px solid rgba(22, 101, 52, 0.35);
}

.download-link:hover {
  border-bottom-color: var(--strong);
}


/* Assessment review panel */
.assessment-table {
  min-width: 980px;
}

.status-pill,
.score-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.18rem 0.5rem;
  font-size: 0.78rem;
  white-space: nowrap;
}

.score-pill.good {
  color: var(--strong);
  border-color: rgba(22, 101, 52, 0.35);
}

.score-pill.warn {
  color: var(--warn);
  border-color: rgba(146, 64, 14, 0.35);
}

.score-pill.bad {
  color: var(--bad);
  border-color: rgba(153, 27, 27, 0.35);
}

.muted,
.muted-cell {
  color: var(--muted);
}

.assessment-detail-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.65rem;
}

.assessment-detail-item {
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0.7rem;
  background: #f8fbf8;
}

.assessment-detail-item p {
  margin: 0.35rem 0 0;
  max-width: 760px;
}

.download-link {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  padding: 0.55rem 0.8rem;
  text-decoration: none;
}

.modal {
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal[hidden] {
  display: none;
}

.modal-content {
  background-color: var(--card);
  padding: 2rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  width: 100%;
  max-width: 400px;
  position: relative;
}

.close-modal {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  color: var(--muted);
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
}

.close-modal:hover,
.close-modal:focus {
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

/* ---------- Students Grid & Cards ---------- */

.students-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 1.5rem;
}

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

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

.student-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  background: #fff;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.student-card:hover {
  border-color: #1f7a4d;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transform: translateY(-2px);
}

.student-card .student-header {
  display: flex;
  flex-direction: column;
}

.student-card .student-name {
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
  margin: 0;
}

.student-card .student-email {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
}

.student-card .student-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* ---------- Pagination Controls ---------- */
.pagination-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.pagination-controls .page-info {
  font-size: 0.9rem;
  color: var(--muted);
}

.pagination-buttons {
  display: flex;
  gap: 0.5rem;
}

.pagination-btn {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

.pagination-btn:hover:not(:disabled) {
  background: #f0fdf4;
  border-color: #1f7a4d;
}

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

/* ---------- Student Details Overlay ---------- */

.student-details-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 1000;
  padding: 2rem;
  overflow-y: auto;
}

@media (max-width: 800px) {
  .student-details-overlay {
    padding: 1rem;
  }
}

.student-details-overlay[hidden] {
  display: none !important;
}

.details-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  background: #fff;
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.details-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.details-header p {
  margin: 0.25rem 0 0 0;
  color: var(--muted);
}

.back-button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}

.back-button:hover {
  background: var(--line);
}

.details-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.5rem;
}

.details-summary .metric {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.details-summary .metric span {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.details-summary .metric strong {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.details-pages-card {
  margin-top: 2rem;
}

/* Assessment Card specific styles */
.assessment-detail-list {
  margin-top: 0.75rem;
  padding: 0.5rem;
  background: var(--surface);
  border-radius: 6px;
  font-size: 0.85rem;
  max-height: 300px;
  overflow-y: auto;
}

.assessment-detail-item {
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.assessment-detail-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.assessment-detail-item p {
  margin: 0.25rem 0;
  color: var(--text);
}

/* AI Diagnosis Modal */
#studentDiagnosisModal .modal-content,
#classDiagnosisModal .modal-content {
  background: #111827;
  color: #f3f4f6;
  border: 1px solid #374151;
}

#studentDiagnosisModal h3,
#studentDiagnosisModal h4,
#classDiagnosisModal h3,
#classDiagnosisModal h4 {
  color: #f9fafb;
}

#studentDiagnosisModal .close-modal,
#classDiagnosisModal .close-modal {
  color: #9ca3af;
}

#studentDiagnosisModal .close-modal:hover,
#classDiagnosisModal .close-modal:hover {
  color: white;
}

#viewDetailedBreakdownBtn {
  background: #1f7a4d;
  color: white;
  border: none;
}

#viewDetailedBreakdownBtn:hover {
  background: #145536;
}

/* Lecturer Copilot */
.copilot-toggle {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #1f7a4d;
  color: white;
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  transition: transform 0.2s ease;
}

.copilot-toggle:hover {
  transform: translateY(-2px);
  background: #145536;
}

.copilot-panel {
  position: fixed;
  bottom: 5rem;
  right: 2rem;
  width: 400px;
  height: 500px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
  border: 1px solid var(--line);
}

.copilot-header {
  background: #1f7a4d;
  color: white;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.copilot-chat {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: #f8faf9;
}

.copilot-message {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  line-height: 1.4;
  font-size: 0.9rem;
}

.copilot-message.system {
  align-self: flex-start;
  background: white;
  border: 1px solid var(--line);
  color: var(--text);
  border-bottom-left-radius: 2px;
}

.copilot-message.user {
  align-self: flex-end;
  background: #1f7a4d;
  color: white;
  border-bottom-right-radius: 2px;
}

.copilot-form {
  display: flex;
  padding: 1rem;
  border-top: 1px solid var(--line);
  background: white;
  gap: 0.5rem;
}

.copilot-form input {
  flex: 1;
  padding: 0.5rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: inherit;
}

.copilot-form button {
  padding: 0.5rem 1rem;
}

/* Scorecard Traffic Lights */
.score-green {
  color: #166534;
  font-weight: 600;
}
.score-yellow {
  color: #b45309;
  font-weight: 600;
}
.score-red {
  color: #991b1b;
  font-weight: 600;
}

