:root {
  --uji-blue: #003865;
  --uji-blue-2: #00558c;
  --uji-red: #d71920;
  --uji-green: #66b32e;
  --uji-cyan: #009fe3;
  --uji-yellow: #ffd200;
  --bg: #eef2f5;
  --bg-soft: #f7f9fb;
  --panel: #ffffff;
  --line: #d8e0e7;
  --line-strong: #b8c8d6;
  --text: #172331;
  --muted: #5b6a78;
  --accent: var(--uji-blue);
  --accent-dark: #002642;
  --accent-soft: #e6f2f8;
  --success: #2f7d32;
  --error: #b4232b;
  --error-soft: #fff0f1;
  --shadow: 0 16px 36px rgba(0, 35, 65, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background:
    linear-gradient(90deg, var(--uji-red) 0 25%, var(--uji-green) 25% 50%, var(--uji-cyan) 50% 75%, var(--uji-yellow) 75% 100%) top / 100% 8px no-repeat,
    linear-gradient(180deg, #ffffff 0, var(--bg-soft) 185px, var(--bg) 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  font-weight: 700;
}

[hidden] {
  display: none !important;
}

.page-shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.55fr);
  gap: 22px;
  margin-bottom: 22px;
  overflow: hidden;
  padding: 28px 30px 28px 36px;
}

.hero,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 8px;
  background: linear-gradient(180deg, var(--uji-red), var(--uji-green), var(--uji-cyan), var(--uji-yellow));
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--uji-blue-2);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: var(--uji-blue);
  letter-spacing: 0;
}

h1 {
  max-width: 980px;
  margin-bottom: 12px;
  font-size: clamp(2rem, 3.4vw, 3.15rem);
  line-height: 1.05;
  font-weight: 800;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(1.35rem, 2vw, 1.85rem);
  line-height: 1.18;
}

.hero-copy,
.summary-copy,
.auth-copy {
  color: var(--muted);
  line-height: 1.55;
}

.hero-copy {
  max-width: 760px;
  margin-bottom: 0;
  font-size: 1.03rem;
}

.hero-status {
  align-self: stretch;
  display: grid;
  align-content: center;
  padding: 20px 22px;
  border-left: 4px solid var(--uji-cyan);
  background: linear-gradient(180deg, #f4f9fc 0%, #ffffff 100%);
}

.summary-label {
  margin-bottom: 8px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.summary-value {
  margin-bottom: 8px;
  font-size: clamp(2rem, 3.6vw, 3rem);
  font-weight: 800;
  color: var(--uji-blue);
}

.summary-copy {
  margin-bottom: 0;
}

.workspace {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.auth-gate {
  display: grid;
  min-height: 42vh;
  place-items: center;
}

.panel {
  padding: 22px;
}

.auth-panel {
  width: min(560px, 100%);
  display: grid;
  gap: 18px;
  border-top: 5px solid var(--uji-blue);
}

.auth-panel p {
  margin-bottom: 0;
}

.google-signin-button {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: var(--uji-blue);
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 8px 18px rgba(0, 35, 65, 0.08);
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-top: 5px solid var(--uji-blue);
}

.content-column {
  display: grid;
  gap: 22px;
}

.session-form,
.add-student-form {
  display: grid;
  gap: 14px;
}

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

.account-header h2 {
  margin-bottom: 0;
}

.account-email {
  margin: 6px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 44px;
  padding: 11px 13px;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
}

.field input[readonly] {
  background: #f3f6f8;
  color: #415365;
}

.field input:focus,
.field select:focus {
  outline: 3px solid rgba(0, 159, 227, 0.18);
  border-color: var(--uji-blue-2);
}

.primary-button,
.secondary-button {
  min-height: 44px;
  border-radius: 4px;
  padding: 11px 18px;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease, border-color 0.14s ease;
}

.primary-button {
  border: 1px solid var(--uji-blue);
  background: var(--uji-blue);
  color: #fff;
  box-shadow: 0 10px 18px rgba(0, 56, 101, 0.18);
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--uji-blue);
}

.compact-button {
  min-height: 38px;
  padding: 8px 14px;
}

.primary-button:hover,
.secondary-button:hover,
.google-signin-button:hover {
  transform: translateY(-1px);
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button:hover,
.google-signin-button:hover {
  border-color: var(--uji-blue-2);
  background: var(--accent-soft);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.status-box {
  min-height: 52px;
  padding: 14px 16px;
  border-radius: 4px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--uji-cyan);
  background: #f8fbfd;
  color: var(--muted);
  line-height: 1.45;
}

.status-box.success {
  border-left-color: var(--success);
  color: var(--success);
  background: #f2faf3;
}

.status-box.error {
  border-left-color: var(--error);
  color: #8a1f25;
  background: var(--error-soft);
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.session-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  padding: 0;
  overflow: hidden;
  background: var(--line);
}

.session-strip > div {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 18px 20px;
  background: #fff;
}

.metric-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.session-strip strong {
  color: var(--uji-blue);
  overflow-wrap: anywhere;
}

.table-panel {
  display: grid;
  gap: 18px;
}

.empty-state {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
  background: #f8fbfd;
  border: 1px dashed var(--line-strong);
  border-radius: 4px;
}

.table-shell {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  background: #f8fbfd;
  color: var(--uji-blue);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.student-name {
  font-weight: 800;
}

.grade-cell {
  color: var(--uji-blue);
  font-weight: 800;
}

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

.origin-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.origin-badge.registered {
  color: var(--success);
  background: #f2faf3;
}

.origin-badge.extra {
  color: var(--accent-dark);
  background: #fffbe2;
}

.attendance-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 32px;
  font-weight: 800;
}

.attendance-toggle input {
  width: 20px;
  height: 20px;
  accent-color: var(--uji-blue);
}

.add-student-form {
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
  padding: 16px;
  background: #f8fbfd;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.table-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.correction-workspace {
  display: grid;
  gap: 22px;
}

.correction-header-panel {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  border-top: 5px solid var(--uji-yellow);
}

.correction-subtitle {
  margin: 0;
  color: var(--muted);
}

.correction-actions {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.correction-grade-field {
  width: 110px;
}

.correction-content {
  display: grid;
  gap: 18px;
}

.correction-section-panel {
  border-top: 5px solid var(--uji-cyan);
}

.section-description,
.apartado-description {
  color: var(--muted);
  line-height: 1.55;
}

.section-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.question-group {
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--uji-cyan);
  border-radius: 4px;
  background: #fff;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.section-header h3 {
  margin-bottom: 6px;
}

.correction-question-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.correction-question {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f8fbfd;
}

.correction-question-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.correction-question-header strong,
.correction-question-header span {
  display: block;
}

.correction-question-header span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.86rem;
}

.correction-badge {
  flex: 0 0 auto;
  min-width: 108px;
  padding: 5px 9px;
  border-radius: 999px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 800;
}

.correction-badge.correct {
  color: var(--success);
  background: #f2faf3;
}

.correction-badge.incorrect {
  color: var(--error);
  background: var(--error-soft);
}

.correction-badge.pending {
  color: var(--accent-dark);
  background: #fffbe2;
}

.correction-answer {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  overflow-wrap: anywhere;
}

.correction-answer img {
  display: block;
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
}

.correction-expected {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.correction-toggle {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.correction-toggle .active {
  border-color: var(--uji-blue);
  background: var(--accent-soft);
  color: var(--uji-blue);
}

.print-sheet {
  display: none;
}

@media (max-width: 900px) {
  .page-shell {
    width: min(100vw - 20px, 720px);
    padding-top: 18px;
  }

  .hero {
    grid-template-columns: 1fr;
    padding: 24px 22px 24px 30px;
  }

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

  .session-strip {
    grid-template-columns: 1fr;
  }

  .panel-heading,
  .account-header,
  .correction-header-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .add-student-form {
    grid-template-columns: 1fr;
  }

  .correction-actions {
    justify-content: flex-start;
  }

  .correction-question-grid {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    size: A4;
    margin: 14mm;
  }

  body {
    background: #fff;
    color: #000;
  }

  .page-shell {
    display: none !important;
  }

  .print-sheet {
    display: block;
    font-family: Arial, Helvetica, sans-serif;
  }

  .print-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding-bottom: 12px;
    border-bottom: 3px solid #003865;
  }

  .print-kicker {
    margin: 0 0 6px;
    color: #003865;
    font-size: 10pt;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .print-header h1 {
    margin: 0;
    color: #003865;
    font-size: 22pt;
    line-height: 1.1;
  }

  .print-course {
    color: #003865;
    font-size: 12pt;
    font-weight: 700;
    white-space: nowrap;
  }

  .print-meta {
    display: grid;
    grid-template-columns: 1.4fr 0.7fr 1fr;
    gap: 10px;
    margin: 14px 0 16px;
  }

  .print-meta div {
    min-height: 48px;
    padding: 8px 10px;
    border: 1px solid #7c8b99;
  }

  .print-meta span {
    display: block;
    margin-bottom: 5px;
    color: #44515f;
    font-size: 8pt;
    font-weight: 700;
    text-transform: uppercase;
  }

  .print-meta strong {
    color: #000;
    font-size: 11pt;
  }

  .print-table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
    font-size: 9.5pt;
  }

  .print-table th,
  .print-table td {
    padding: 7px 8px;
    border: 1px solid #7c8b99;
    text-align: left;
  }

  .print-table th {
    position: static;
    color: #003865;
    background: #eef2f5;
    font-size: 8.5pt;
    letter-spacing: 0;
  }

  .print-table td {
    height: 32px;
  }

  .print-number-column {
    width: 32px;
    text-align: center !important;
  }

  .print-signature-column {
    width: 34%;
  }
}
