.portal-hero {
  padding-top: 85px;
  padding-bottom: 48px;
}

.portal-hero h1 {
  max-width: 850px;
  margin: 20px 0 14px;
  font-size: clamp(48px, 7vw, 82px);
}

.portal-hero > p:not(.eyebrow) {
  max-width: 660px;
  color: #686862;
  font-size: 13px;
  line-height: 1.8;
}

.portal-safety-note {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  max-width: 900px;
  margin-top: 23px;
  padding: 16px 18px;
  border-left: 3px solid #047857;
  background: #ecfdf5;
  color: #065f46;
  font-size: 10px;
  line-height: 1.75;
}

.portal-safety-note strong {
  flex: 0 0 auto;
  color: var(--ink);
}

.portal-workspace {
  padding-bottom: 105px;
}

.role-tabs {
  display: flex;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f1e9;
}

.role-tab {
  min-height: 43px;
  flex: 1;
  padding: 0 15px;
  border: 1px solid transparent;
  color: #64645d;
  background: transparent;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.role-tab.is-active {
  border-color: #047857;
  color: var(--white);
  background: #047857;
}

.role-panel {
  padding: 35px 0 0;
}

.role-panel[hidden] {
  display: none;
}

.dashboard-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.dashboard-heading h2 {
  margin: 12px 0 0;
  font-family: var(--font-display);
  font-size: clamp(26px, 3.5vw, 40px);
  font-weight: 600;
  letter-spacing: -0.06em;
}

.demo-id {
  color: #77776f;
  font-size: 10px;
}

.portal-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 13px;
  margin-bottom: 14px;
}

.portal-stat {
  display: grid;
  min-height: 125px;
  align-content: space-between;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 1px 3px rgba(6, 78, 59, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
}

.portal-stat > span,
.portal-stat small {
  color: #74746d;
  font-size: 10px;
}

.portal-stat strong {
  font-family: var(--font-display);
  font-size: 31px;
  font-weight: 600;
}

.portal-content-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.portal-card {
  padding: 21px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 1px 3px rgba(6, 78, 59, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
}

.portal-card h3 {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
}

.portal-card > p {
  color: #70706a;
  font-size: 11px;
  line-height: 1.8;
}

.responsive-table {
  width: 100%;
  overflow-x: auto;
}

.responsive-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
  text-align: left;
}

.responsive-table th,
.responsive-table td {
  padding: 10px 7px;
  border-bottom: 1px solid #e3e3de;
}

.responsive-table tbody tr:nth-child(even) {
  background: #faf8f5;
}

.responsive-table th {
  color: #696962;
  font-weight: 600;
}

.portal-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.portal-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #e3e3de;
  color: #555550;
  font-size: 10px;
  line-height: 1.55;
}

.portal-list li:last-child {
  border-bottom: 0;
}

.portal-list small {
  flex: 0 0 auto;
  color: #85857d;
}

.teacher-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
  margin-top: 18px;
}

.teacher-form {
  display: grid;
  align-content: start;
  gap: 13px;
}

.teacher-form h3 {
  margin-bottom: 2px;
}

.teacher-form .button {
  justify-self: start;
  margin-top: 2px;
}

.teacher-status {
  min-height: 24px;
  margin: 16px 0 0;
  color: #42604c;
  font-size: 11px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
}

.admin-summary {
  align-content: start;
}

.admin-summary .button {
  margin-top: 12px;
}

.print-section {
  padding-top: 95px;
  padding-bottom: 115px;
  border-top: 1px solid var(--line);
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.template-card {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  background: #efefeb;
}

.template-card > .button {
  justify-self: start;
}

.template-preview {
  min-height: 290px;
  padding: 22px;
  border: 1px solid #d5d5ce;
  background: #fff;
  color: #22221f;
  font-family: var(--font-body);
  font-size: 10px;
  line-height: 1.55;
}

.template-school {
  display: grid;
  min-height: 120px;
  place-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid #d8d8d2;
}

.template-school img {
  width: 116px;
  height: 108px;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.template-stamp {
  margin: 11px 0 4px;
  color: #77776e;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: right;
}

.template-preview h3 {
  margin: 9px 0 13px;
  font-size: 13px;
  text-align: center;
}

.template-preview h3 small {
  color: #77776f;
  font-size: 9px;
}

.template-preview > p:not(.template-stamp):not(.template-foot) {
  margin: 7px 0;
}

.template-preview table {
  font-size: 9px;
}

.template-preview .template-foot {
  margin: 16px 0 0;
  padding-top: 9px;
  border-top: 1px solid #deded8;
  color: #77776f;
  font-size: 8px;
  font-weight: 700;
  text-align: center;
}

.id-card-body {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 20px 0;
  line-height: 2;
}

.id-photo {
  display: grid;
  width: 76px;
  height: 92px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #d3d3cc;
  color: #74746c;
  background: #efefeb;
  font-size: 9px;
}

@media (max-width: 1000px) {
  .portal-hero,
  .portal-workspace,
  .print-section {
    width: calc(100% - 64px);
  }
}

@media (max-width: 767px) {
  .portal-hero,
  .portal-workspace,
  .print-section {
    width: calc(100% - 40px);
  }

  .portal-hero {
    padding-top: 65px;
    padding-bottom: 32px;
  }

  .portal-hero h1 {
    font-size: 48px;
    letter-spacing: 0;
  }

  .portal-safety-note {
    flex-direction: column;
    gap: 5px;
  }

  .role-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .role-panel {
    padding-top: 25px;
  }

  .dashboard-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .portal-stat-grid {
    grid-template-columns: 1fr;
  }

  .portal-stat {
    min-height: 95px;
  }

  .portal-content-grid,
  .teacher-form-grid,
  .admin-grid,
  .template-grid {
    grid-template-columns: 1fr;
  }

  .portal-card {
    padding: 17px;
  }

  .print-section {
    padding-top: 75px;
    padding-bottom: 85px;
  }

  .template-preview {
    padding: 17px;
  }
}

@media print {
  @page {
    size: A4;
    margin: 16mm;
  }

  body[data-printing="true"] > * {
    visibility: hidden !important;
  }

  body[data-printing="true"] .template-preview.print-active,
  body[data-printing="true"] .template-preview.print-active * {
    visibility: visible !important;
  }

  body[data-printing="true"] .template-preview.print-active {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 0;
    border: 1px solid #222;
    box-shadow: none;
  }
}

.portal-safety-note {
  border-left-color: #047857;
  background: #ecfdf5;
  color: #065f46;
}

.role-tabs,
.admin-nav {
  border-radius: 8px;
  background: #f5f1e9;
}

.role-tab,
.auth-tab,
.admin-nav a {
  border-radius: 4px;
}

.role-tab.is-active,
.auth-tab.is-active,
.admin-nav a:hover,
.admin-nav a:focus-visible {
  border-color: #047857;
  color: #ffffff;
  background: #047857;
}

.role-badge {
  border-radius: 4px;
  background: #047857;
}

.portal-stat,
.portal-card,
.auth-shell,
.authenticated-view,
.template-card,
.template-preview {
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(6, 78, 59, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
}

.portal-card,
.auth-shell,
.authenticated-view {
  border-top: 2px solid #d97706;
  background: #ffffff;
}

.template-card {
  background: #f5f1e9;
}

.admission-status {
  border-radius: 4px;
}

.auth-form input,
.auth-form select,
.auth-form textarea,
.invite-result input,
.admin-filter-form input,
.admin-filter-form select {
  border: 1px solid #d1d5db;
  border-radius: 4px;
}

.auth-form input:focus,
.auth-form select:focus,
.auth-form textarea:focus,
.invite-result input:focus,
.admin-filter-form input:focus,
.admin-filter-form select:focus {
  outline: none;
  border-color: #047857;
  box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.15);
}

.auth-form input[type="checkbox"],
.auth-form input[type="radio"],
.admin-filter-form input[type="checkbox"] {
  accent-color: #047857;
}

.responsive-table tbody tr:nth-child(even) {
  background: #faf8f5;
}

.auth-page {
  min-height: calc(100vh - 200px);
  padding-bottom: 100px;
}

.auth-page .portal-hero {
  padding-bottom: 32px;
}

.auth-shell,
.authenticated-view {
  max-width: 860px;
  margin: 0 auto;
  padding: 26px;
  border: 1px solid var(--line);
  border-top: 2px solid #d97706;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(6, 78, 59, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid #d8d8d2;
}

.auth-tabs[hidden],
.auth-panel[hidden],
.authenticated-view[hidden],
.admin-tools[hidden],
#grade-field[hidden],
#relationship-field[hidden] {
  display: none;
}

.auth-tab {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  color: #686862;
  background: transparent;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.auth-tab.is-active {
  border-color: #047857;
  color: var(--white);
  background: #047857;
}

.auth-panel {
  max-width: 590px;
  margin: 0 auto;
}

.auth-panel h2 {
  margin-bottom: 8px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
}

.auth-panel > p,
.admin-grid .portal-card > p {
  color: #686862;
  font-size: 11px;
  line-height: 1.8;
}

.auth-form {
  display: grid;
  gap: 15px;
  margin-top: 21px;
}

.auth-form label {
  display: grid;
  gap: 8px;
  color: #555550;
  font-size: 11px;
  font-weight: 500;
}

.auth-form input,
.auth-form select,
.invite-result input {
  width: 100%;
  min-height: 45px;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  color: var(--ink);
  background: var(--white);
  font: inherit;
  font-size: 12px;
}

.auth-form input:focus,
.auth-form select:focus,
.invite-result input:focus {
  outline: none;
  border-color: #047857;
  box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.15);
}

.auth-form .button {
  justify-self: start;
  margin-top: 4px;
}

.auth-status,
.admin-status,
.invite-result {
  min-height: 22px;
  margin: 15px 0 0;
  color: #42604c;
  font-size: 11px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.auth-status.is-error,
.admin-status.is-error,
.invite-result.is-error {
  color: #a13d33;
}

.authenticated-view .dashboard-heading {
  align-items: center;
}

.role-badge {
  display: inline-flex;
  margin: 0 0 16px;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--white);
  background: var(--ink);
  font-size: 10px;
}

.authenticated-message {
  margin: 0;
  color: #5d5d57;
  font-size: 12px;
  line-height: 1.8;
}

.admin-tools {
  margin-top: 34px;
  padding-top: 25px;
  border-top: 1px solid #d8d8d2;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.admin-grid .portal-card h3 {
  margin-bottom: 12px;
  font-family: var(--font-display);
  font-size: 17px;
}

.account-request-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.account-request {
  display: grid;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #e3e3de;
}

.account-request > div:first-child {
  display: grid;
  gap: 4px;
  overflow-wrap: anywhere;
}

.account-request strong {
  font-size: 12px;
}

.account-request span,
.account-request small,
.account-empty {
  color: #686862;
  font-size: 10px;
  line-height: 1.6;
}

.admission-request > div:first-child {
  display: grid;
  gap: 5px;
}

.admission-status {
  justify-self: start;
  padding: 4px 8px;
  border: 1px solid #d5d5ce;
  color: #555550 !important;
  background: #f0f0ec;
  font-size: 9px !important;
}

.admission-status-approved,
.admission-status-enrolled {
  border-color: #b7c8b7;
  color: #065f46 !important;
  background: #ecfdf5;
}

.admission-status-rejected {
  border-color: #d7b8b2;
  color: #8c3d34 !important;
  background: #f8efed;
}

.admission-status-incomplete {
  border-color: #d9c8a9;
  color: #795b27 !important;
  background: #f8f3e8;
}

.admission-detail {
  display: grid;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid #e3e3de;
}

.admission-detail[hidden] {
  display: none;
}

.admission-detail h4 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
}

.admission-photo-download {
  justify-self: start;
  text-decoration: none;
}

.admission-photo-download[aria-disabled="true"] {
  opacity: 0.6;
  pointer-events: none;
}

.admission-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  background: #e3e3de;
}

.admission-detail-grid > div {
  min-width: 0;
  padding: 9px;
  background: #fafaf8;
  overflow-wrap: anywhere;
}

.admission-detail-grid dt {
  color: #77776f;
  font-size: 9px;
}

.admission-detail-grid dd {
  margin: 4px 0 0;
  color: #383833;
  font-size: 10px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.admission-review-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 0;
}

.admission-review-form label:nth-child(2),
.admission-review-form label:nth-child(3) {
  grid-column: 1 / -1;
}

.admission-review-form .button {
  grid-column: 1 / -1;
}

.account-actions {
  display: flex;
  gap: 8px;
}

.account-actions .button {
  min-height: 34px;
  padding: 0 11px;
  font-size: 10px;
}

.invite-result input {
  margin-top: 8px;
}

.admin-single-note {
  margin: 18px 0 0;
  color: #77776f;
  font-size: 10px;
}

.admin-dashboard-heading h2 {
  margin: 10px 0 7px;
  font-family: var(--font-display);
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 600;
}

.admin-dashboard-heading > p:last-child {
  margin: 0;
  color: #686862;
  font-size: 11px;
  line-height: 1.7;
}

.admin-stat-grid {
  margin: 21px 0;
}

.admin-stat-grid .portal-stat {
  min-height: 105px;
  background: var(--white);
}

.auth-form textarea {
  width: 100%;
  min-height: 110px;
  padding: 10px 12px;
  border: 1px solid #d2d2cb;
  border-radius: 0;
  color: var(--ink);
  background: var(--white);
  font: inherit;
  font-size: 12px;
  line-height: 1.7;
  resize: vertical;
}

.auth-form textarea:focus {
  outline: 2px solid #7e8872;
  outline-offset: 1px;
}

.security-settings {
  margin-top: 24px;
}

.security-settings > p {
  color: #686862;
  font-size: 11px;
  line-height: 1.8;
}

.security-settings h3 {
  margin-bottom: 8px;
  font-family: var(--font-display);
  font-size: 18px;
}

.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 24px 0 17px;
}

.admin-nav {
  display: flex;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  padding: 5px;
  border: 1px solid var(--line);
  background: #efefeb;
  scrollbar-width: thin;
}

.admin-nav a {
  flex: 0 0 auto;
  padding: 9px 11px;
  color: #5d5d57;
  font-size: 10px;
  text-decoration: none;
}

.admin-nav a:hover,
.admin-nav a:focus-visible {
  color: var(--white);
  background: var(--ink);
}

.admin-toolbar > .button {
  flex: 0 0 auto;
}

.admin-filter-form {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) minmax(120px, 1fr) minmax(120px, 1fr) auto;
  align-items: end;
  gap: 10px;
  margin: 18px 0;
}

.admin-filter-form label {
  display: grid;
  gap: 7px;
  color: #555550;
  font-size: 10px;
  font-weight: 500;
}

.admin-filter-form input,
.admin-filter-form select {
  width: 100%;
  min-height: 41px;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  color: var(--ink);
  background: var(--white);
  font: inherit;
  font-size: 11px;
}

.admin-filter-form input:focus,
.admin-filter-form select:focus {
  outline: none;
  border-color: #047857;
  box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.15);
}

.admin-filter-form > .button {
  min-height: 41px;
}

.account-count {
  margin: 12px 0 0;
  color: #686862;
  font-size: 10px;
}

.account-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 15px;
  color: #686862;
  font-size: 10px;
}

.account-pagination .button {
  min-height: 34px;
  padding: 0 11px;
  font-size: 10px;
}

.account-pagination .button:disabled,
.account-actions .button:disabled,
.account-request > .button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.audit-event {
  grid-template-columns: 1fr;
  gap: 0;
}

@media (max-width: 767px) {
  .auth-page {
    padding-bottom: 75px;
  }

  .auth-shell,
  .authenticated-view {
    padding: 18px;
  }

  .auth-tabs {
    align-items: stretch;
    flex-direction: column;
  }

  .auth-tab {
    text-align: left;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .admission-detail-grid,
  .admission-review-form {
    grid-template-columns: 1fr;
  }

  .admission-review-form label:nth-child(2),
  .admission-review-form label:nth-child(3) {
    grid-column: auto;
  }

  .admin-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-toolbar > .button {
    align-self: flex-start;
  }

  .admin-filter-form {
    grid-template-columns: 1fr;
  }

  .account-pagination .button {
    padding: 0 8px;
  }

  .authenticated-view .dashboard-heading {
    align-items: flex-start;
  }
}
