:root {
  --portal-violet: #4f2b62;
  --portal-gold: #b58a42;
  --portal-paper: #fbf8f4;
  --portal-line: #dfd4e2;
  --portal-muted: #6d6371;
}

.portal-body {
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(135deg, #f1e9f3, #fffaf6 55%, #efe5f2);
  color: #2e2531;
}

.portal-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 74px;
  padding: 0.5rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid rgba(255,255,255,.18);
  background: var(--portal-violet);
  color: white;
}

.portal-brand img { width: 105px; max-height: 60px; object-fit: contain; }
.portal-header nav { display: flex; gap: 1rem; align-items: center; }
.portal-header a { color: white; font-weight: 800; text-decoration: none; }
.portal-header nav span { opacity: .75; }
.portal-main { width: min(1180px, calc(100% - 2rem)); min-height: calc(100vh - 150px); margin: 0 auto; padding: 2rem 0 4rem; }
.portal-footer { padding: 1.5rem; background: var(--portal-violet); color: white; text-align: center; }

.portal-card {
  border: 1px solid var(--portal-line);
  border-radius: .75rem;
  padding: clamp(1.25rem, 4vw, 2.25rem);
  background: rgba(255,255,255,.94);
  box-shadow: 0 20px 60px rgba(44,22,54,.12);
}

.portal-card h1, .portal-card h2, .portal-heading h1 { margin: .3rem 0 .6rem; color: var(--portal-violet); font-family: Georgia, serif; font-weight: 400; }
.auth-card { width: min(520px, 100%); margin: 5vh auto; }
.auth-help { margin: 1.2rem 0 0; color: var(--portal-muted); font-size: .88rem; }
.portal-form { display: grid; gap: 1rem; margin-top: 1.4rem; }
.portal-form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; }
.portal-form label { display: grid; gap: .4rem; color: var(--portal-violet); font-size: .82rem; font-weight: 900; }
.portal-form input, .portal-form select, .portal-form textarea {
  min-width: 0; border: 1px solid var(--portal-line); border-radius: .4rem; padding: .78rem; background: white; color: #2e2531; font: inherit;
}
.portal-form input:focus, .portal-form select:focus, .portal-form textarea:focus { outline: 3px solid rgba(79,43,98,.14); border-color: var(--portal-violet); }
.portal-checkbox { display: flex !important; grid-column: 1/-1; flex-direction: row; align-items: center; }
.portal-checkbox input { min-width: auto; }
.portal-actions { display: flex; flex-wrap: wrap; gap: .65rem; align-items: center; }
.portal-alert { margin-bottom: 1rem; border-radius: .45rem; padding: .85rem 1rem; background: #e5f4ea; color: #185d33; font-weight: 800; }
.portal-alert.error { background: #fde9e7; color: #8a2922; }
.portal-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: end; margin-bottom: 1.5rem; }
.portal-heading p { margin: 0; color: var(--portal-muted); }
.portal-tabs { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.portal-tabs a { border-radius: 999px; padding: .6rem 1rem; background: white; color: var(--portal-violet); font-weight: 900; text-decoration: none; }
.portal-tabs a.active { background: var(--portal-violet); color: white; }
.table-wrap { overflow-x: auto; border: 1px solid var(--portal-line); border-radius: .6rem; background: white; }
.portal-table { width: 100%; border-collapse: collapse; }
.portal-table th, .portal-table td { padding: .78rem; border-bottom: 1px solid var(--portal-line); text-align: left; vertical-align: top; }
.portal-table th { background: #f0e9f2; color: var(--portal-violet); font-size: .76rem; text-transform: uppercase; }
.portal-table tr:last-child td { border-bottom: 0; }
.status-pill { display: inline-block; border-radius: 999px; padding: .25rem .55rem; background: #e6f4eb; color: #1e6338; font-size: .74rem; font-weight: 900; }
.status-pill.expired, .status-pill.inactive { background: #f8e4e2; color: #8d2b25; }
.status-pill.pending { background: #fff2cf; color: #785b15; }
.link-button { border: 0; padding: 0; background: transparent; color: #8d2b25; cursor: pointer; font: inherit; font-weight: 800; }
.course-library { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; }
.course-library article { display: grid; gap: .7rem; }
.course-library p { margin: 0; color: var(--portal-muted); }
.lesson-list { display: grid; gap: 1.25rem; }
.lesson-card { display: grid; grid-template-columns: minmax(280px,1.2fr) minmax(240px,.8fr); gap: 1.25rem; }
.lesson-video { position: relative; aspect-ratio: 16/9; overflow: hidden; border-radius: .55rem; background: #160f19; }
.lesson-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.lesson-number { color: var(--portal-gold); font-weight: 900; text-transform: uppercase; }
.empty-state { padding: 2rem; color: var(--portal-muted); text-align: center; }

@media (max-width: 760px) {
  .portal-header { align-items: flex-start; }
  .portal-header nav { flex-direction: column; gap: .35rem; align-items: flex-end; font-size: .82rem; }
  .portal-header nav span { display: none; }
  .portal-form-grid, .course-library, .lesson-card { grid-template-columns: 1fr; }
  .portal-heading { align-items: flex-start; flex-direction: column; }
}
