:root {
  --pukaray-red: #c3262d;
  --pukaray-green: #155b2b;
  --pukaray-yellow: #f4c542;
  --ink: #17324d;
  --muted: #5c6b78;
  --line: #dce3ea;
  --surface: #ffffff;
  --soft: #f6f8fb;
}

* {
  box-sizing: border-box;
}

html {
  font-family: "Montserrat", Arial, Helvetica, sans-serif;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--soft);
  font-family: "Montserrat", Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  padding: 14px 32px;
  background: var(--surface);
  border-top: 6px solid var(--pukaray-green);
  border-bottom: 1px solid var(--line);
}

.brand {
  grid-column: 2;
  display: grid;
  grid-template-columns: 88px minmax(260px, auto) 88px;
  align-items: center;
  justify-content: center;
  gap: 36px;
  min-width: 0;
  text-align: center;
}

.brand-logo-pair {
  display: flex;
  align-items: center;
  gap: 34px;
  flex: 0 0 auto;
}

.brand-logo {
  width: 78px;
  height: 78px;
  object-fit: contain;
}

.brand-logo.wide-logo {
  width: 78px;
  height: 78px;
  object-fit: contain;
}

.brand-logo-left {
  justify-self: end;
}

.brand-logo-right {
  justify-self: start;
}

.brand-text {
  min-width: 0;
}

.brand strong {
  display: block;
  line-height: 1.2;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

nav {
  grid-column: 3;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

nav a,
.button {
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.button.small {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 0.9rem;
}

.page {
  width: min(1360px, calc(100% - 32px));
  margin: 28px auto;
}

.panel,
.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 14px 35px rgba(23, 50, 77, 0.08);
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(280px, 460px);
  justify-content: center;
  gap: 20px;
}

.login-shell.guardian-only {
  grid-template-columns: minmax(320px, 760px);
}

.login-panel {
  border-left: 8px solid var(--pukaray-green);
}

.login-shell.guardian-only .login-panel {
  padding: 32px 36px;
}

.login-panel.muted {
  border-left-color: var(--pukaray-yellow);
}

.login-logo {
  display: block;
  width: 110px;
  height: 110px;
  object-fit: contain;
  margin: 0 0 16px;
}

.login-logo-pair {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 14px;
}

.login-shell.guardian-only .login-logo-pair {
  justify-content: center;
  gap: 58px;
}

.login-logo-pair .login-logo {
  margin: 0;
  flex: 0 0 auto;
}

.login-logo-pair .wide-logo {
  width: 230px;
  height: 110px;
  object-fit: contain;
}

.login-shell.guardian-only .login-logo-pair .login-logo {
  width: 96px;
  height: 96px;
}

.login-shell.guardian-only .login-logo-pair .wide-logo {
  width: 132px;
  height: 96px;
}

.corporate-name {
  margin: 0 0 12px;
  color: var(--pukaray-green);
  font-weight: 800;
  line-height: 1.25;
}

.data-consent {
  display: grid;
  gap: 10px;
  margin: 18px 0;
  padding: 18px;
  border: 1px solid #cfe0d5;
  border-left: 5px solid var(--pukaray-green);
  border-radius: 8px;
  background: #f7fbf8;
}

.data-consent h2 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--pukaray-green);
}

.data-consent p {
  margin: 0;
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.5;
}

.data-consent a {
  color: var(--pukaray-green);
  font-weight: 800;
}

.consent-check {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: start;
  gap: 10px;
  margin-top: 4px;
  font-weight: 800;
  color: var(--ink);
}

.consent-check input {
  margin-top: 3px;
}

.guardian-rut-step {
  display: grid;
  gap: 14px;
}

.policy-panel {
  max-width: 980px;
  margin: 0 auto;
}

.policy-header {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}

.policy-header p {
  margin: 4px 0;
}

.policy-content {
  display: grid;
  gap: 12px;
}

.policy-content h2 {
  margin: 20px 0 2px;
  padding-top: 14px;
  border-top: 1px solid #e4ece7;
  color: var(--pukaray-green);
}

.policy-content h3 {
  margin: 12px 0 0;
  color: var(--ink);
}

.policy-content p,
.policy-content li {
  line-height: 1.65;
}

.policy-content ul {
  margin: 0;
  padding-left: 22px;
}

.policy-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin-top: 0;
  line-height: 1.2;
  letter-spacing: 0;
}

h1 {
  font-size: 1.75rem;
  margin-bottom: 10px;
}

.login-title {
  text-align: center;
  margin-bottom: 20px;
}

h2 {
  font-size: 1.25rem;
}

h3 {
  font-size: 1rem;
}

.stack,
.form-grid,
.toolbar {
  display: grid;
  gap: 14px;
}

fieldset {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0 0 18px;
  padding: 22px;
  background: #fff;
}

legend {
  max-width: 100%;
  padding: 0 8px;
  color: var(--pukaray-green);
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
  margin-bottom: 14px;
  color: var(--ink);
  font-weight: 700;
  line-height: 1.35;
}

label span {
  overflow-wrap: anywhere;
}

label small {
  color: var(--muted);
  font-weight: 500;
  line-height: 1.45;
}

.check {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.check span {
  grid-column: 2;
  grid-row: 1;
}

.check input[type="checkbox"] {
  grid-column: 1;
  grid-row: 1;
  margin-top: 2px;
}

.check small {
  grid-column: 2;
}

input,
select,
textarea,
button {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 11px 12px;
  font: inherit;
  line-height: 1.35;
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
}

.locked-input,
input[readonly].locked-input {
  color: var(--ink);
  background: #eef5f0;
  border-color: #c6dacd;
  font-weight: 800;
  cursor: not-allowed;
}

.parent-info-skipped {
  opacity: 0.55;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

button,
.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: auto;
  border: 0;
  background: var(--pukaray-green);
  color: #fff;
  border-radius: 8px;
  padding: 11px 18px;
  cursor: pointer;
  font-weight: 800;
  white-space: normal;
}

button.ghost {
  background: transparent;
  color: var(--pukaray-green);
  border: 1px solid var(--pukaray-green);
}

.alert {
  border-left: 4px solid var(--pukaray-red);
  background: #fff4f4;
  padding: 12px;
}

.alert.ok {
  border-left-color: var(--pukaray-green);
  background: #eef8f3;
}

.hint,
.step-counter,
.upload-card p,
.builder-section header p {
  color: var(--muted);
}

.notice-box {
  border: 1px solid var(--line);
  border-left: 5px solid var(--pukaray-green);
  border-radius: 8px;
  background: #f8fbf9;
  padding: 16px;
  margin: 16px 0 18px;
}

.notice-box h2 {
  margin-bottom: 8px;
  color: var(--pukaray-green);
}

.notice-box p {
  margin-top: 0;
}

.notice-box ul {
  margin: 10px 0 0;
  padding-left: 20px;
}

.notice-box li {
  margin: 8px 0;
  overflow-wrap: anywhere;
}

.toolbar {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: end;
  margin-bottom: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

th,
td {
  padding: 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: normal;
}

.table-wrap {
  width: 100%;
  overflow-x: visible;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.students-table {
  width: 100%;
  min-width: 0;
  margin-bottom: 0;
  table-layout: fixed;
}

.students-table th {
  white-space: normal;
  line-height: 1.25;
  font-size: 0.88rem;
}

.students-table td {
  line-height: 1.4;
  font-size: 0.88rem;
}

.col-course {
  width: 7%;
}

.col-student {
  width: 22%;
}

.col-rut {
  width: 8%;
}

.col-status,
.col-auth {
  width: 11%;
}

.col-date {
  width: 14%;
}

.col-email {
  width: 17%;
  overflow-wrap: anywhere;
}

.col-actions {
  width: 10%;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.table-actions .button {
  flex: 1 1 62px;
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.82rem;
}

.success {
  text-align: center;
}

.enrollment-panel {
  max-width: 920px;
  margin-inline: auto;
}

.wizard-progress {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  margin: 24px 0;
}

.wizard-dot {
  min-height: 64px;
  width: 100%;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 9px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  text-align: left;
  font-size: 0.85rem;
  line-height: 1.25;
  padding: 12px;
  overflow-wrap: anywhere;
}

.wizard-dot span {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eef2f7;
  font-size: 0.8rem;
}

.wizard-dot.active {
  border-color: var(--pukaray-green);
  box-shadow: 0 0 0 3px rgba(21, 91, 43, 0.12);
}

.wizard-dot.active span,
.wizard-dot.done span {
  background: var(--pukaray-green);
  color: #fff;
}

.wizard-step {
  display: none;
}

.wizard-step.active {
  display: block;
}

.wizard-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line);
  background: rgba(246, 248, 251, 0.96);
  padding: 14px 0 0;
  margin-top: 10px;
}

.wizard-actions button {
  min-width: 150px;
}

.wizard-actions button[hidden] {
  display: none;
}

.wizard-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.admin-tabs a {
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background: #fff;
  font-weight: 700;
}

.admin-tabs a.active {
  border-color: var(--pukaray-green);
  background: #eef8f3;
  color: var(--pukaray-green);
}

.institution-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}

.institution-tabs a {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 13px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.institution-tabs a.active {
  border-color: var(--pukaray-green);
  background: #eef8f3;
  color: var(--pukaray-green);
}

.admin-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
  min-width: 0;
}

.heading-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
}

.admin-action-row {
  display: flex;
  justify-content: flex-end;
  margin: 12px 0 18px;
}

.role-pill,
.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 800;
  font-size: 0.85rem;
  white-space: nowrap;
}

.role-pill {
  background: #eef2f7;
  color: var(--muted);
}

.form-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin: 14px 0;
}

.builder-tools {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(420px, 1.2fr);
  gap: 14px;
  margin-bottom: 22px;
}

.compact-tool {
  margin: 0;
}

.compact-tool h2 {
  margin-bottom: 12px;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}

.section-stack {
  display: grid;
  gap: 18px;
}

.builder-section {
  border: 1px solid var(--line);
  border-left: 5px solid var(--pukaray-green);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 18px;
  cursor: pointer;
  list-style: none;
}

.section-head::-webkit-details-marker {
  display: none;
}

.section-head::after {
  content: "+";
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #eef8f3;
  color: var(--pukaray-green);
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1;
}

.builder-section[open] .section-head::after {
  content: "-";
}

.builder-section[open] .section-head {
  border-bottom: 1px solid var(--line);
  background: #fbfdfc;
}

.section-head h2 {
  margin-bottom: 6px;
}

.section-head p {
  margin: 0;
  color: var(--muted);
}

.section-kicker {
  display: inline-flex;
  margin-bottom: 6px;
  color: var(--pukaray-green);
  font-weight: 800;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.section-count {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  margin-left: auto;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
  padding: 6px 10px;
  font-weight: 800;
  font-size: 0.8rem;
  white-space: nowrap;
}

.section-body {
  display: grid;
  gap: 14px;
  padding: 16px 18px 18px;
}

.section-body > .button {
  justify-self: end;
}

.section-edit-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 1.2fr) minmax(90px, 120px) minmax(130px, auto);
  gap: 12px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf9;
  padding: 14px;
}

.builder-table-wrap {
  width: 100%;
  overflow-x: visible;
}

.builder-table {
  table-layout: fixed;
  margin-bottom: 0;
}

.builder-table th,
.builder-table td {
  font-size: 0.9rem;
}

.builder-table th:nth-child(1),
.builder-table td:nth-child(1) {
  width: 70px;
}

.builder-table th:nth-child(2),
.builder-table td:nth-child(2) {
  width: 38%;
}

.builder-table th:nth-child(3),
.builder-table td:nth-child(3) {
  width: 150px;
}

.builder-table th:nth-child(4),
.builder-table td:nth-child(4) {
  width: 100px;
}

.builder-table th:nth-child(5),
.builder-table td:nth-child(5) {
  width: 115px;
}

.builder-table th:nth-child(6),
.builder-table td:nth-child(6) {
  width: 180px;
}

.builder-table small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 500;
}

.question-grid,
.form-row,
.manual-student-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(180px, 240px) minmax(110px, 130px);
  gap: 12px;
  align-items: end;
}

.manual-student-grid {
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  align-items: end;
}

.user-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(190px, 1fr));
  gap: 12px;
  align-items: end;
}

.users-table {
  table-layout: fixed;
  margin-bottom: 0;
}

.users-table small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-weight: 600;
}

.password-modal {
  width: min(560px, calc(100% - 28px));
}

.manual-student-grid button {
  min-height: 58px;
}

.manual-block-reason {
  grid-column: span 2;
}

.student-edit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.student-auth-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.question-editor-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 240px) minmax(100px, 130px);
  gap: 12px;
  align-items: end;
}

.wide-field {
  grid-column: 1 / -1;
}

.row-actions {
  min-width: 220px;
  margin-top: 8px;
}

.row-actions summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--pukaray-green);
  white-space: nowrap;
}

button.danger {
  background: var(--pukaray-red);
  margin-top: 10px;
}

button.small,
.button.small {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 0.86rem;
}

.table-actions form {
  margin: 0;
}

.table-actions button.danger {
  margin-top: 0;
}

.admin-modal {
  width: min(980px, calc(100% - 28px));
  max-height: min(84vh, 760px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(23, 50, 77, 0.24);
}

.admin-modal::backdrop {
  background: rgba(15, 32, 48, 0.52);
}

.modal-form,
.modal-delete-form {
  padding: 22px;
}

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

.modal-header h2 {
  margin-bottom: 4px;
}

.modal-header p {
  margin: 0;
  color: var(--muted);
}

.icon-close {
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 50%;
  background: #eef2f7;
  color: var(--ink);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line);
  margin-top: 8px;
  padding-top: 14px;
}

.modal-delete-form {
  padding-top: 0;
}

.modal-delete-form .danger {
  width: 100%;
  margin-top: 0;
}

.modal-state {
  display: grid;
  place-items: center;
  min-height: 52vh;
}

.modal-card {
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-left: 6px solid var(--pukaray-red);
  border-radius: 8px;
  padding: 24px;
  background: #fff;
  box-shadow: 0 14px 35px rgba(23, 50, 77, 0.08);
}

.modal-card h2 {
  color: var(--pukaray-red);
  margin-bottom: 6px;
}

.question-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.stat strong {
  display: block;
  font-size: 2rem;
}

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

.stat.ok strong,
.status.submitted {
  color: var(--pukaray-green);
}

.stat.warn strong,
.status.pending {
  color: var(--pukaray-red);
}

.status.submitted {
  background: #eef8f3;
}

.status.pending {
  background: #fff4f4;
}

@media (max-width: 760px) {
  .site-header {
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 14px 16px;
  }

  .brand,
  nav {
    grid-column: 1;
  }

  .brand {
    flex-direction: column;
    grid-template-columns: 1fr;
    gap: 10px;
    text-align: center;
  }

  .brand-logo-left,
  .brand-logo-right {
    justify-self: center;
  }

  nav {
    justify-content: center;
  }

  .brand-logo-pair,
  .login-logo-pair {
    flex-wrap: wrap;
    justify-content: center;
  }

  .brand-logo.wide-logo {
    width: 84px;
  }

  .login-logo-pair .wide-logo {
    width: min(230px, 100%);
  }

  .page {
    width: min(100% - 20px, 1120px);
    margin: 16px auto;
  }

  .panel,
  .login-panel {
    padding: 18px;
  }

  .login-shell,
  .login-shell.guardian-only {
    grid-template-columns: minmax(0, 1fr);
  }

  .login-shell.guardian-only .login-panel {
    padding: 18px;
  }

  .login-shell.guardian-only .login-logo-pair {
    gap: 18px;
  }

  .login-shell.guardian-only .login-logo-pair .login-logo {
    width: 88px;
    height: 88px;
  }

  .login-shell.guardian-only .login-logo-pair .wide-logo {
    width: min(150px, 100%);
    height: 88px;
  }

  .data-consent {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .wizard-progress,
  .builder-tools,
  .section-edit-form,
  .question-editor-grid,
  .question-grid,
  .form-row,
  .user-form-grid,
  .manual-student-grid {
    grid-template-columns: 1fr;
  }

  .section-head {
    flex-direction: column;
    align-items: stretch;
  }

  .section-head::after {
    position: absolute;
    right: 14px;
    top: 14px;
  }

  .builder-section {
    position: relative;
  }

  .section-count {
    margin-left: 0;
    width: fit-content;
  }

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

  .builder-table {
    min-width: 760px;
  }

  .manual-block-reason {
    grid-column: auto;
  }

  .wizard-actions,
  .admin-heading,
  .question-actions {
    position: static;
    flex-direction: column;
    align-items: stretch;
  }

  .wizard-actions button,
  button {
    width: 100%;
    min-width: 0;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  th {
    display: none;
  }
}
