:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --primary: #1d4ed8;
  --primary-dark: #1e3a8a;
  --primary-soft: #dbeafe;
  --accent: #059669;
  --accent-soft: #d1fae5;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  padding-bottom: 84px;
}

.hidden {
  display: none !important;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  box-shadow: 0 2px 12px rgba(30, 58, 138, 0.25);
}

.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.brand-badge {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.brand h1 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand p {
  margin: 0;
  font-size: 0.76rem;
  opacity: 0.88;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-back,
.btn-icon {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

/* Layout */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px;
}

.section-head h2 {
  margin: 0 0 4px;
  font-size: 1.25rem;
}

.section-head p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Grid de Turmas */
.classes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 640px) {
  .classes-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.class-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 0.12s ease, border-color 0.12s ease;
  text-align: left;
}

.class-card:active {
  transform: scale(0.97);
}

.class-card:hover {
  border-color: var(--primary);
}

.class-code {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--primary-dark);
}

.class-label {
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 600;
}

.class-stats {
  margin-top: 4px;
  font-size: 0.76rem;
  color: var(--accent);
  font-weight: 700;
  background: var(--accent-soft);
  padding: 4px 8px;
  border-radius: 999px;
  align-self: flex-start;
}

/* Disciplinas */
.class-banner {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.class-banner h2 {
  margin: 6px 0 0;
  font-size: 1.15rem;
}

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

.subjects-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 640px) {
  .subjects-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.subject-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-align: left;
}

.subject-card:active {
  transform: scale(0.98);
}

.subject-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.subject-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}

.subject-status {
  font-size: 0.76rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  white-space: nowrap;
}

.subject-status.done {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Cards e Formulários */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.meta-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 600px) {
  .meta-row {
    grid-template-columns: 1fr 1fr;
  }
}

.meta-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.meta-row input {
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  color: var(--text);
}

.card-header-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  gap: 10px;
}

.card-header-toggle h3,
.students-header h3 {
  margin: 0;
  font-size: 1rem;
}

.muted {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 3px 0 0;
}

.mini-badge {
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
}

.mini-badge.ok {
  background: var(--accent-soft);
  color: var(--accent);
}

.gabarito-body {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.question-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

@media (min-width: 600px) {
  .question-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

.q-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}

.q-num {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--primary-dark);
  min-width: 36px;
}

.opt-group {
  display: flex;
  gap: 8px;
}

.opt-btn {
  width: 38px;
  height: 36px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}

.opt-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.opt-btn.correct {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.opt-btn.wrong {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

/* Lista de Alunos para Lançamento */
.students-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

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

.students-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.student-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 12px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
}

.student-row:active {
  background: #f8fafc;
  transform: scale(0.99);
}

.student-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.student-num {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 0.84rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.student-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.student-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.score-pill {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--muted);
}

.score-pill.filled {
  background: var(--accent-soft);
  color: var(--accent);
}

.search-box {
  margin-bottom: 10px;
}

.search-box input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  background: #f8fafc;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}

.student-row.is-done {
  border-color: #86efac;
  background: #f0fdf4;
}

.student-row.is-done .student-num {
  background: var(--accent);
  color: #fff;
}

.status-tag {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
}

.status-tag.done {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-tag.pending {
  background: #f1f5f9;
  color: var(--muted);
}

.student-bottom-bar.single-action {
  grid-template-columns: 1fr;
}

/* TELA 4: Lançamento Individual do Aluno (Full Screen Mobile) */
.student-sticky-header {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  position: sticky;
  top: 64px;
  z-index: 30;
  border: 1.5px solid var(--border);
}

.student-id-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.student-name-input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  background: #f8fafc;
}

.student-name-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}

.score-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.score-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  text-align: center;
}

.score-box.highlight {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.score-label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
}

.score-box strong {
  font-size: 1.2rem;
  color: var(--text);
}

.student-questions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.student-q-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
}

.student-q-label {
  display: flex;
  flex-direction: column;
}

.student-q-label strong {
  font-size: 0.98rem;
  color: var(--primary-dark);
}

.student-q-label span {
  font-size: 0.72rem;
  color: var(--muted);
}

.student-q-row .opt-btn {
  width: 48px;
  height: 44px;
  font-size: 1.05rem;
  font-weight: 800;
  border-radius: 10px;
}

.student-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
  z-index: 40;
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.08);
}

/* Botões */
.btn-primary,
.btn-secondary {
  border: none;
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

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

.btn-secondary {
  background: #e2e8f0;
  color: var(--text);
}

.btn-sm {
  padding: 8px 11px;
  font-size: 0.8rem;
}

.full-width {
  width: 100%;
}

.pill {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 0.82rem;
  padding: 5px 11px;
  border-radius: 999px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

@media (min-width: 640px) {
  .modal {
    align-items: center;
  }
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}

.modal-sheet {
  position: relative;
  width: 100%;
  max-width: 540px;
  max-height: 92vh;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.2);
}

@media (min-width: 640px) {
  .modal-sheet {
    border-radius: 18px;
  }
}

.modal-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.btn-close {
  background: #f1f5f9;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
}

.modal-body-pad {
  padding: 16px;
  overflow-y: auto;
}

.modal-body-pad textarea {
  width: 100%;
  margin: 10px 0 14px;
  padding: 10px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.92rem;
}

.toast {
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 200;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
