:root {
  --ink: #0f2c38;
  --muted: #5d7681;
  --teal: #0a7082;
  --teal-dark: #075665;
  --teal-soft: #e5f3f4;
  --cream: #fdf9f1;
  --amber: #f2a541;
  --danger: #b4402f;
  --line: #d9e7e9;
  --line-strong: #c2d9dd;
  --shadow: 0 12px 30px rgba(16, 56, 68, 0.08);
  --radius: 18px;
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1100px 500px at 12% -10%, #dff1f1 0%, rgba(223, 241, 241, 0) 60%),
    radial-gradient(900px 480px at 92% 0%, #fdefd8 0%, rgba(253, 239, 216, 0) 55%),
    #f7fbfa;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--teal);
}

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

p {
  margin: 0;
}

.boot {
  display: grid;
  place-items: center;
  min-height: 100vh;
  color: var(--muted);
  font-weight: 600;
}

/* ---------------------------------------------------------------- shell */

.page {
  width: min(1180px, 100% - 32px);
  margin: 0 auto;
  padding: 26px 0 64px;
  display: grid;
  gap: 22px;
}

.site-head {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 17px;
  color: var(--ink);
  text-decoration: none;
  margin-right: auto;
}

.brand .mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--teal);
  color: #fff;
  font-size: 16px;
}

.brand small {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.nav a {
  padding: 8px 13px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 650;
  color: var(--muted);
  text-decoration: none;
}

.nav a:hover {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.nav a.active {
  background: var(--teal);
  color: #fff;
}

.head-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
}

.head-user strong {
  color: var(--ink);
  font-size: 14px;
}

.badge-role {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ---------------------------------------------------------------- atoms */

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.card-head h2 {
  font-size: 19px;
}

.muted {
  color: var(--muted);
  font-size: 13.5px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.btn:hover {
  background: var(--teal-soft);
  border-color: var(--teal);
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.btn.primary:hover {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn.ghost:hover {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.btn.small {
  padding: 6px 11px;
  font-size: 12.5px;
  border-radius: 9px;
}

.btn.danger {
  color: var(--danger);
  border-color: #e9c8c2;
}

.btn.danger:hover {
  background: #fbeeeb;
  border-color: var(--danger);
}

.btn:disabled {
  opacity: 0.5;
  cursor: progress;
}

label.field {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
}

input[type='text'],
input[type='password'],
input[type='search'],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #fbfefd;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(10, 112, 130, 0.35);
  outline-offset: 1px;
  border-color: var(--teal);
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

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

.selector-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-top: 14px;
}

/* ---------------------------------------------------------------- student picker modal */

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 44, 56, 0.45);
  backdrop-filter: blur(2px);
}

.modal-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(520px, 100%);
  max-height: min(80vh, 720px);
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(16, 56, 68, 0.28);
  padding: 20px;
  gap: 14px;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h2 {
  font-size: 18px;
}

.modal-head p {
  margin-top: 4px;
  font-size: 13px;
}

.picker-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.picker-tools input[type='search'] {
  flex: 1 1 200px;
}

.picker-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  white-space: nowrap;
}

.picker-toggle input[type='checkbox'] {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.picker-list {
  overflow-y: auto;
  display: grid;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfefd;
  min-height: 120px;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.inline-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
}

.inline-form .grow {
  flex: 1 1 220px;
}

.error-text {
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}

/* ---------------------------------------------------------------- hero */

.hero {
  padding: clamp(24px, 4vw, 44px);
  border-radius: 26px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, #ffffff 0%, #eef8f7 55%, #fdf4e6 100%);
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}

.hero h1 {
  font-size: clamp(27px, 4.6vw, 44px);
  letter-spacing: -0.02em;
}

.hero p {
  color: var(--muted);
  font-size: 15.5px;
  max-width: 62ch;
  line-height: 1.6;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.pill {
  padding: 8px 15px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: #fff;
  font: inherit;
  font-size: 13.5px;
  font-weight: 650;
  color: var(--muted);
  cursor: pointer;
}

.pill:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.pill.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

/* ---------------------------------------------------------------- tables */

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

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  text-align: left;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: 13px 12px;
  border-bottom: 1px solid #eef5f5;
  vertical-align: middle;
}

.table tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: #fbfdfd;
}

.rank {
  width: 44px;
  font-weight: 800;
  color: var(--muted);
}

.rank.top {
  color: var(--teal);
}

.medal {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eef5f5;
  font-size: 13px;
  font-weight: 800;
}

.medal.gold {
  background: #fdf0d6;
  color: #9a6410;
}

.medal.silver {
  background: #eef1f4;
  color: #5c6b75;
}

.medal.bronze {
  background: #f8e8dc;
  color: #925536;
}

.student-name {
  font-weight: 700;
}

.bar-cell {
  min-width: 140px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.bar {
  flex: 1;
  height: 8px;
  min-width: 70px;
  border-radius: 999px;
  background: #edf4f4;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #0a7082, #23a6a4);
  transition: width 0.25s ease;
}

.points {
  font-weight: 800;
  color: var(--teal-dark);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.empty {
  padding: 26px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  background: #fbfefd;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
}

/* ---------------------------------------------------------------- login */

.auth-wrap {
  min-height: calc(100vh - 70px);
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 30px;
  display: grid;
  gap: 16px;
}

.auth-card h1 {
  font-size: 24px;
}

.demo-hint {
  font-size: 12.5px;
  color: var(--muted);
  background: var(--cream);
  border: 1px dashed #e8d8b6;
  border-radius: 12px;
  padding: 11px 13px;
  line-height: 1.6;
}

.demo-hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
  color: var(--ink);
}

/* ---------------------------------------------------------------- layout */

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr);
  gap: 20px;
  align-items: start;
}

.mark-grid {
  display: grid;
  grid-template-columns: minmax(220px, 290px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.stack {
  display: grid;
  gap: 14px;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------- lists */

.student-list {
  max-height: 66vh;
  overflow: auto;
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding-right: 4px;
}

.student-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: #f7fbfb;
  font: inherit;
  font-size: 14px;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
}

.student-item:hover {
  border-color: var(--line-strong);
  background: #fff;
}

.student-item.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.student-item .score {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}

.student-item.active .score {
  color: #d9f1f1;
}

/* ---------------------------------------------------------------- topics */

.subject-stack {
  display: grid;
  gap: 14px;
}

.subject-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
}

.subject-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: #f8fdfc;
  border-bottom: 1px solid var(--line);
}

.subject-card-head h3 {
  font-size: 15px;
  margin-bottom: 2px;
}

.subject-card-head .muted {
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.subject-card-head .points {
  font-size: 14px;
}

.next-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 9px 16px;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
  color: var(--muted);
  background: #fffdf7;
}

.topic-grid {
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
}

.topic-list {
  list-style: none;
  margin: 0;
  padding: 8px 12px 14px;
  display: grid;
  gap: 2px;
}

.topic-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 14px;
  line-height: 1.45;
  cursor: pointer;
}

.topic-row:hover {
  background: #f4fbfa;
}

.topic-row input[type='checkbox'] {
  width: 17px;
  height: 17px;
  margin-top: 1px;
  accent-color: var(--teal);
  flex: none;
  cursor: pointer;
}

.topic-row.done span.topic-title {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: #9fc4c4;
}

.nextup {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-size: 13px;
}

.nextup-topic {
  color: var(--ink);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 32ch;
}

.nextup-cell {
  min-width: 210px;
  max-width: 340px;
}

.chip {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.all-done {
  font-size: 13px;
  font-weight: 650;
  color: #2f7a52;
}

.nextup-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 13px 16px;
  margin-bottom: 16px;
  border: 1px solid #e6d9b8;
  border-left: 4px solid var(--amber);
  border-radius: 13px;
  background: #fffaf0;
  font-size: 14px;
}

.nextup-banner.done {
  border-color: #cfe8d8;
  border-left-color: #2f7a52;
  background: #f2fbf5;
  color: #1f5c3c;
}

.page-title {
  font-size: clamp(22px, 3vw, 30px);
}

.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
}

.segmented button {
  border: none;
  background: none;
  padding: 8px 14px;
  border-radius: 9px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 650;
  color: var(--muted);
  cursor: pointer;
}

.segmented button:hover {
  color: var(--teal-dark);
  background: var(--teal-soft);
}

.segmented button.active {
  background: var(--teal);
  color: #fff;
}

.class-topics {
  display: grid;
  gap: 8px;
}

.class-topic {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfefd;
}

.class-topic-main {
  display: grid;
  gap: 7px;
  min-width: 240px;
  flex: 1;
  font-size: 14px;
}

.class-topic-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.section-split {
  margin-top: 20px;
  padding-top: 4px;
  border-top: 1px dashed var(--line);
}

.nextup-banner + .subject-stack {
  margin-top: 2px;
}

/* ---------------------------------------------------------------- admin curriculum */

.series-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.series-row {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px 8px 12px;
  background: #fbfefd;
}

.series-row.active {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.series-row button.pick {
  flex: 1;
  text-align: left;
  background: none;
  border: none;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  color: var(--ink);
  cursor: pointer;
  padding: 2px 0;
}

.series-row .meta {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

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

.series-admin + .series-admin {
  margin-top: 12px;
}

.series-admin-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.series-admin-head h3 {
  font-size: 15px;
  margin-right: auto;
}

.topic-admin-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.topic-admin-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 9px;
  background: #f8fcfb;
  font-size: 13.5px;
  line-height: 1.4;
}

.topic-admin-list li span {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.topic-admin-list li .index {
  width: 22px;
  flex: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

details.add-topics {
  margin-top: 12px;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}

details.add-topics > summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--teal);
  list-style: none;
}

details.add-topics > summary::-webkit-details-marker {
  display: none;
}

details.add-topics > summary::before {
  content: '+ ';
}

details.add-topics form {
  margin-top: 10px;
  display: grid;
  gap: 10px;
  justify-items: start;
}

/* ---------------------------------------------------------------- misc */

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

.stat {
  background: #f8fdfc;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 15px;
}

.stat .label {
  font-size: 11.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 750;
}

.stat .value {
  font-size: 24px;
  font-weight: 800;
  color: var(--teal-dark);
  font-variant-numeric: tabular-nums;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(10px);
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 16px 34px rgba(15, 44, 56, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 100;
  max-width: min(520px, calc(100% - 32px));
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.err {
  background: var(--danger);
}

@media (max-width: 900px) {
  .two-col,
  .mark-grid {
    grid-template-columns: 1fr;
  }

  .student-list {
    max-height: 240px;
  }
}

@media (max-width: 640px) {
  .site-head {
    padding: 12px 16px;
    gap: 10px;
  }

  .brand small {
    display: none;
  }

  .page {
    width: calc(100% - 22px);
    padding-top: 16px;
  }

  .card {
    padding: 16px;
  }

  .hide-sm {
    display: none;
  }

  .modal {
    padding: 12px;
  }

  .modal-card {
    max-height: 88vh;
    padding: 16px;
  }
}
