:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef4ff;
  --surface-3: #f8fbff;
  --text: #1f1f1f;
  --muted: #5b6780;
  --border: #d7e0ef;
  --accent: #0056d2;
  --accent-2: #00419e;
  --accent-soft: #e8f0fe;
  --success: #1f7a4d;
  --danger: #b3261e;
  --warning: #8a5a00;
  --player: #101418;
  --shadow: 0 12px 32px rgba(31, 45, 70, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

a {
  color: var(--accent-2);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
textarea {
  font: inherit;
}

button,
input,
textarea,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 68px;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(31, 45, 70, 0.05);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  color: var(--text);
  letter-spacing: 0;
}

.brand:hover {
  text-decoration: none;
}

.brand-title {
  color: var(--accent);
  font-size: 1.08rem;
  font-weight: 850;
}

.brand-byline {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.nav a,
.nav button {
  font-weight: 700;
}

.page {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.auth-shell {
  min-height: calc(100vh - 130px);
  display: grid;
  place-items: center;
}

.auth-panel,
.panel,
.course-card,
.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel {
  width: min(420px, 100%);
  padding: 28px;
}

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

h1 {
  margin-bottom: 16px;
  font-size: clamp(2rem, 4vw, 2.75rem);
  line-height: 1.06;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 18px;
  font-size: 1.12rem;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 4px;
  font-size: 1rem;
}

h4 {
  margin: 0 0 4px;
  font-size: 0.95rem;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 650;
}

input,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 86, 210, 0.14);
}

.primary-button,
.secondary-button,
.small-button,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.66;
}

.primary-button {
  width: 100%;
  background: var(--accent);
  color: #fff;
}

.primary-button:hover,
.primary-link:hover {
  background: var(--accent-2);
  text-decoration: none;
}

.secondary-button,
.small-button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.secondary-button:hover,
.small-button:hover {
  border-color: #b9c8dd;
  background: var(--surface-3);
  text-decoration: none;
}

.small-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.86rem;
}

.small-button.danger {
  color: var(--danger);
}

.link-button {
  min-height: auto;
  padding: 0;
  background: transparent;
  color: var(--accent-2);
}

.primary-link {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.form-message,
.muted {
  color: var(--muted);
}

.form-message,
.error-text {
  min-height: 22px;
  margin: 10px 0 0;
  font-size: 0.92rem;
}

.error-text {
  color: var(--danger);
}

.page-title,
.panel-header,
.course-block-header,
.watch-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-title {
  margin-bottom: 24px;
}

.eyebrow {
  margin-bottom: 7px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.dashboard,
.student-home {
  display: grid;
  gap: 22px;
}

.tab-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  width: max-content;
  max-width: 100%;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.tab-button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.tab-button.active {
  background: var(--accent);
  color: #fff;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric {
  display: grid;
  gap: 10px;
  min-height: 98px;
  padding: 18px;
  border-top: 3px solid var(--accent);
}

.metric span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.metric strong {
  color: var(--accent-2);
  font-size: 1.55rem;
}

.panel {
  padding: 20px;
}

.panel h2 {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.75fr) minmax(0, 1.35fr);
  gap: 22px;
  align-items: start;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

.status {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  width: max-content;
  max-width: 100%;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: #e9ece8;
  color: #37423d;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status.approved,
.status.ready,
.status.enrolled {
  background: #e6f4ea;
  color: var(--success);
}

.status.pending,
.status.processing {
  background: #fff4d6;
  color: var(--warning);
}

.status.rejected,
.status.failed {
  background: #fce8e6;
  color: var(--danger);
}

.status.none,
.status.locked,
.status.archived {
  background: var(--accent-soft);
  color: var(--accent-2);
}

.course-block {
  padding: 16px 0;
  border-top: 1px solid var(--border);
}

.course-block h3 {
  color: #10233f;
  font-size: 1.08rem;
}

.course-block:first-child {
  padding-top: 0;
  border-top: 0;
}

.course-block.archived,
.module-row.archived {
  opacity: 0.68;
  background: #f8fafc;
}

.course-block-header {
  align-items: flex-start;
  gap: 12px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(130px, 1fr) auto;
  gap: 10px;
  margin: 14px 0;
}

.edit-form,
.module-edit-form {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(130px, 1fr) auto;
  gap: 10px;
  align-items: start;
  margin: 12px 0 14px;
}

.edit-form .form-message,
.module-edit-form .form-message {
  align-self: center;
  margin: 0;
}

.module-edit-form {
  margin: 8px 0 0;
}

.module-list {
  display: grid;
  gap: 10px;
}

.course-access {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 12px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.course-access p {
  margin-bottom: 0;
}

.access-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 2px;
}

.student-grant-form {
  display: grid;
  gap: 10px;
}

.student-search-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.student-search-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 9px 10px;
  color: var(--text);
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.student-search-option:hover {
  border-color: #9dbcf4;
  background: var(--accent-soft);
}

.student-search-option[hidden] {
  display: none;
}

.student-search-option span:first-child {
  display: grid;
  min-width: 0;
}

.student-search-option strong,
.student-search-option small {
  overflow-wrap: anywhere;
}

.student-search-option small {
  color: var(--muted);
}

.access-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  margin: 0;
  padding: 9px 10px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.access-option:has(input:checked) {
  border-color: #9dbcf4;
  background: var(--accent-soft);
}

.access-option input {
  width: 18px;
  height: 18px;
}

.access-option span {
  display: grid;
  min-width: 0;
}

.access-option strong,
.access-option small {
  overflow-wrap: anywhere;
}

.access-option small {
  color: var(--muted);
}

.module-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 76px;
  padding: 12px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.module-row.ready {
  border-color: #c4d6f2;
  background: #fbfdff;
}

.module-row.student {
  grid-template-columns: minmax(0, 1fr) auto;
}

.module-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.module-main strong,
.module-main span {
  overflow-wrap: anywhere;
}

.upload-form {
  display: grid;
  grid-template-columns: minmax(160px, 220px) auto minmax(70px, auto);
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.course-card {
  display: grid;
  gap: 12px;
  padding: 22px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.course-card:hover {
  border-color: #a9c3ef;
  box-shadow: 0 16px 34px rgba(31, 45, 70, 0.12);
  transform: translateY(-1px);
}

.course-card-top {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.course-provider {
  color: var(--accent);
}

.progress {
  width: 100%;
  height: 8px;
  overflow: hidden;
  background: #dfe6e2;
  border-radius: 999px;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.progress.large {
  height: 12px;
}

.watch-page {
  display: grid;
  gap: 16px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  color: var(--accent);
  font-weight: 800;
}

.watch-status {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.learning-player {
  overflow: hidden;
  background: var(--player);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(14, 23, 38, 0.24);
  --plyr-color-main: var(--accent);
  --plyr-video-background: var(--player);
  --plyr-control-radius: 6px;
  --plyr-menu-radius: 8px;
  --plyr-range-thumb-height: 14px;
  --plyr-range-track-height: 5px;
}

.video-shell {
  overflow: hidden;
  background: var(--player);
}

.learning-player .plyr {
  min-width: 0;
  border-radius: 8px;
}

.learning-player .plyr--video {
  background: var(--player);
}

.learning-player .plyr__video-wrapper {
  background: var(--player);
}

.video-player {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--player);
}

.watch-meta {
  box-shadow: var(--shadow);
}

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

.watch-stats div {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.watch-stats dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.watch-stats dd {
  margin: 6px 0 0;
  font-size: 1.15rem;
  font-weight: 850;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 160px);
  text-align: center;
}

@media (max-width: 860px) {
  .app-header {
    flex-wrap: wrap;
    gap: 10px;
    min-height: auto;
    padding: 14px 16px;
  }

  .brand {
    flex-wrap: wrap;
    row-gap: 0;
  }

  .nav {
    gap: 12px;
    width: 100%;
  }

  .page-title,
  .panel-header,
  .course-block-header,
  .watch-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-grid,
  .split-layout,
  .access-list,
  .student-search-list,
  .course-grid,
  .watch-stats {
    grid-template-columns: 1fr;
  }

  .inline-form,
  .edit-form,
  .module-edit-form,
  .module-row,
  .upload-form {
    grid-template-columns: 1fr;
  }

  .page {
    width: min(100vw - 24px, 1180px);
    padding-top: 22px;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 15px;
  }

  .page {
    width: min(100vw - 20px, 1180px);
    padding: 18px 0 32px;
  }

  .auth-shell {
    min-height: calc(100vh - 118px);
    align-items: start;
  }

  .auth-panel,
  .panel,
  .course-card {
    padding: 16px;
  }

  .panel h2 {
    margin-bottom: 14px;
  }

  h1 {
    font-size: 2rem;
  }

  .metric {
    min-height: 78px;
    padding: 14px;
  }

  .metric strong {
    font-size: 1.35rem;
  }

  .secondary-button,
  .small-button {
    min-height: 42px;
  }

  .table-wrap {
    overflow-x: visible;
  }

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

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tr {
    display: grid;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
  }

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

  td {
    display: grid;
    grid-template-columns: minmax(82px, 0.35fr) minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    padding: 0;
    border-bottom: 0;
    overflow-wrap: anywhere;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
  }

  td:not([data-label]) {
    grid-template-columns: 1fr;
  }

  td:not([data-label])::before {
    display: none;
  }

  td:empty {
    display: none;
  }

  .row-actions {
    align-items: stretch;
  }

  .row-actions .small-button {
    flex: 1 1 120px;
  }

  .course-block {
    padding: 18px 0;
  }

  .course-card {
    gap: 10px;
  }

  .module-row {
    gap: 12px;
  }

  .upload-form input[type="file"] {
    padding: 9px;
  }

  .access-option {
    min-height: 54px;
    padding: 10px;
  }

  .watch-header {
    gap: 10px;
  }
}

@media (max-width: 420px) {
  .app-header {
    padding-inline: 12px;
  }

  .nav {
    justify-content: space-between;
  }

  .nav a,
  .nav button {
    min-height: 36px;
  }

  .tab-list {
    width: 100%;
  }

  .tab-button {
    flex: 1;
  }

  td {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .module-row.student .small-button {
    width: 100%;
  }
}
