:root {
  --bg: #f5f7f2;
  --surface: #ffffff;
  --surface-soft: #eef4ef;
  --ink: #18252b;
  --muted: #637078;
  --brand: #116b7b;
  --brand-strong: #0a4f5d;
  --accent: #7a8f39;
  --warning: #b37a22;
  --danger: #a33a32;
  --success: #27724c;
  --line: #d8dfd7;
  --shadow: 0 18px 42px rgba(24, 37, 43, 0.1);
  --radius: 8px;
  --max: 1180px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #11181b;
  --surface: #1a2428;
  --surface-soft: #202f34;
  --ink: #edf4f1;
  --muted: #a8b7ba;
  --brand: #5fb9c7;
  --brand-strong: #91d5df;
  --accent: #c2d56f;
  --warning: #e1b45a;
  --danger: #ee7b71;
  --success: #77d49c;
  --line: #314247;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.26);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.portal-shell {
  width: min(var(--max), calc(100% - 24px));
  margin: 0 auto;
}

.auth-view {
  min-height: 100svh;
  display: grid;
  gap: 24px;
  align-content: center;
  padding: 24px 0;
}

.mini-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
}

.mini-brand img {
  width: 58px;
  height: 44px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.mini-brand strong,
.mini-brand small {
  display: block;
  line-height: 1.1;
}

.mini-brand strong {
  font-size: 1rem;
}

.mini-brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

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

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand-strong);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 18px;
  color: var(--brand-strong);
  font-size: clamp(2rem, 12vw, 3.8rem);
  line-height: 0.98;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(1.2rem, 6vw, 1.7rem);
  line-height: 1.08;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 850;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  background: var(--surface);
  color: var(--ink);
  outline: 0;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 20%, transparent);
}

.auth-card label + label,
.compact-form label + label,
.student-form label + label,
.field-set + label,
.compact-form .form-row,
.student-form .form-row {
  margin-top: 13px;
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 14px;
  font-weight: 900;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

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

.button--primary:hover {
  background: var(--brand-strong);
}

.button--dark {
  background: var(--ink);
  color: var(--surface);
}

:root[data-theme="dark"] .button--dark {
  background: var(--surface-soft);
  color: var(--ink);
  border-color: var(--line);
}

.button--quiet {
  background: var(--surface-soft);
  border-color: var(--line);
  color: var(--brand-strong);
}

.form-message {
  min-height: 22px;
  margin: 14px 0 10px;
  color: var(--muted);
  font-weight: 850;
  line-height: 1.45;
}

.form-message.is-error {
  color: var(--danger);
}

.form-message.is-success {
  color: var(--success);
}

.auth-note,
.muted-copy {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.dashboard-view {
  padding: 12px 0 64px;
}

.is-hidden {
  display: none !important;
}

.portal-header {
  position: sticky;
  top: 8px;
  z-index: 10;
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: 0 12px 28px rgba(24, 37, 43, 0.08);
  backdrop-filter: blur(16px);
}

.portal-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.page-heading {
  margin-bottom: 16px;
}

.page-heading h1,
.page-heading h2 {
  margin-bottom: 0;
}

.page-heading--compact {
  margin: 28px 0 14px;
}

.admin-grid,
.student-info-grid {
  display: grid;
  gap: 14px;
}

.stat-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stat-panel div {
  min-height: 84px;
  display: grid;
  align-content: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.stat-panel span {
  color: var(--brand-strong);
  font-size: clamp(1.8rem, 11vw, 2.8rem);
  line-height: 1;
  font-weight: 950;
}

.stat-panel p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.panel-header h2 {
  margin: 0;
}

.form-row {
  display: grid;
  gap: 12px;
}

.field-set {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 13px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.field-set legend {
  padding: 0 5px;
  color: var(--muted);
  font-weight: 900;
}

.check-line {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.check-line--standalone {
  margin-top: 14px;
}

.check-line input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--brand);
}

.group-list,
.student-table {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.group-item,
.student-row,
.media-item {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.group-item {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.group-item strong,
.student-row strong {
  display: block;
  color: var(--brand-strong);
}

.group-item small,
.student-row small {
  color: var(--muted);
  font-weight: 800;
}

.meta-list,
.student-row__meta,
.group-links,
.link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.meta-list span,
.pill,
.group-links a,
.link-list a {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: var(--radius);
  padding: 0 9px;
  background: var(--surface-soft);
  color: var(--brand-strong);
  font-size: 0.82rem;
  font-weight: 900;
}

.group-links a,
.link-list a {
  border: 1px solid var(--line);
}

.icon-action {
  min-width: 40px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--brand-strong);
  font-weight: 950;
}

.student-table {
  max-height: 640px;
  overflow: auto;
  padding-right: 2px;
}

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

.pill--paid {
  background: color-mix(in srgb, var(--success) 16%, transparent);
  color: var(--success);
}

.pill--unpaid {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--danger);
}

.mini-progress,
.progress-track {
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 18%, transparent);
}

.mini-progress {
  height: 7px;
  margin-top: 10px;
}

.mini-progress span,
.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--accent));
}

.student-row__progress {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.35;
}

.row-actions {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 8px;
}

.student-hero {
  display: grid;
  gap: 14px;
}

.student-hero h1 {
  margin-bottom: 8px;
}

.student-meta {
  margin: 0;
  color: var(--muted);
  font-weight: 820;
  line-height: 1.5;
}

.payment-badge {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--danger);
  font-weight: 950;
}

.payment-badge.is-paid {
  background: color-mix(in srgb, var(--success) 16%, transparent);
  color: var(--success);
}

.progress-panel {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.progress-panel p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 820;
  line-height: 1.5;
}

.progress-wrap {
  display: grid;
  align-content: center;
  gap: 8px;
}

.progress-label {
  color: var(--brand-strong);
  font-size: 1.7rem;
  font-weight: 950;
  line-height: 1;
}

.progress-track {
  height: 13px;
}

.student-info-grid {
  margin-top: 14px;
}

.info-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  white-space: pre-line;
}

.links-panel {
  margin-top: 14px;
}

.links-panel h2 {
  margin-bottom: 10px;
}

.materials-shell {
  margin-top: 4px;
}

.materials-widget {
  display: grid;
  gap: 12px;
}

.materials-toolbar {
  display: grid;
  gap: 10px;
}

.category-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.category-tab {
  flex: 0 0 auto;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  background: var(--surface);
  color: var(--brand-strong);
  font-weight: 950;
}

.category-tab.is-active {
  background: var(--brand-strong);
  color: var(--surface);
}

.search-box {
  position: relative;
}

.search-box input {
  padding-left: 36px;
}

.search-box::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 50%;
  width: 12px;
  height: 12px;
  border: 2px solid var(--muted);
  border-radius: 99px;
  transform: translateY(-54%);
}

.search-box::after {
  content: "";
  position: absolute;
  left: 25px;
  top: 28px;
  width: 8px;
  height: 2px;
  background: var(--muted);
  transform: rotate(45deg);
}

.category-summary {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-weight: 800;
}

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

.lesson-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.lesson-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  padding: 14px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.lesson-header strong {
  color: var(--brand-strong);
  font-size: 1.05rem;
}

.lesson-header span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 900;
}

.media-list {
  display: grid;
  gap: 10px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.media-item {
  background: var(--surface);
}

.media-item strong {
  display: block;
  color: var(--ink);
  line-height: 1.25;
}

.media-item small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-weight: 800;
}

.media-item audio {
  width: 100%;
  min-width: 0;
}

.download-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  color: var(--brand-strong);
  font-weight: 950;
  background: var(--surface-soft);
}

.empty-state {
  padding: 16px;
  border: 1px dashed color-mix(in srgb, var(--brand) 36%, var(--line));
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-weight: 820;
}

@media (min-width: 720px) {
  .portal-shell {
    width: min(var(--max), calc(100% - 36px));
  }

  .auth-view {
    grid-template-columns: minmax(0, 0.8fr) minmax(340px, 430px);
    align-items: center;
    gap: clamp(28px, 6vw, 80px);
  }

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

  .portal-header {
    min-height: 72px;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .portal-actions {
    display: flex;
  }

  .form-row,
  .student-info-grid,
  .materials-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field-set {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .field-set legend {
    grid-column: 1 / -1;
  }

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

  .row-actions {
    display: flex;
  }

  .student-hero,
  .progress-panel {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .progress-wrap {
    min-width: 230px;
  }

  .media-item {
    grid-template-columns: minmax(180px, 0.35fr) minmax(0, 1fr) auto;
    align-items: center;
  }
}

@media (min-width: 1040px) {
  .dashboard-view {
    padding-top: 18px;
  }

  .admin-grid {
    grid-template-columns: 0.86fr 1.14fr;
    align-items: start;
  }

  .student-editor {
    grid-row: span 2;
  }
}
