/* BeforeTheRank: student dashboard, admin panel, login */

body.app {
  font-size: 0.95rem;
  min-height: 100vh;
}

.loading {
  color: var(--ink-faint);
  padding: 24px 0;
}

.empty {
  color: var(--ink-faint);
  padding: 8px 0;
}

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.demo-banner {
  padding: 8px 20px;
  background: var(--ochre-tint);
  color: #6b4d12;
  font-size: 0.85rem;
  text-align: center;
}

/* Top bar */
.app-top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.app-user {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.app-user-name {
  font-weight: 500;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Shell */
.app-shell {
  display: grid;
  grid-template-columns: 1fr;
}

.app-nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}

.app-nav::-webkit-scrollbar {
  display: none;
}

.app-nav a {
  flex: none;
  padding: 8px 12px;
  border-radius: var(--r-md);
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}

.app-nav a:hover {
  background: var(--line-soft);
  color: var(--ink);
}

.app-nav a[aria-current="page"] {
  background: var(--teal-tint);
  color: var(--teal);
  font-weight: 600;
}

.app-main,
.admin-main {
  padding: 28px 20px 64px;
  min-width: 0;
  outline: none;
}

.admin-main {
  max-width: 1200px;
  margin: 0 auto;
}

@media (min-width: 900px) {
  .app-shell {
    grid-template-columns: 210px 1fr;
  }
  .app-nav {
    flex-direction: column;
    position: sticky;
    top: 58px;
    height: calc(100vh - 58px);
    padding: 20px 12px;
    border-bottom: 0;
    border-right: 1px solid var(--line);
  }
  .app-nav a:nth-child(5) {
    margin-top: 12px;
    padding-top: 20px;
    border-top: 1px solid var(--line-soft);
    border-radius: 0 0 var(--r-md) var(--r-md);
  }
  .app-main {
    padding: 36px 40px 80px;
    max-width: 1180px;
  }
}

/* View header */
.view-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 24px;
}

.view-head h1 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
}

.view-head .sub,
.drawer-head .sub {
  margin-top: 4px;
  color: var(--ink-soft);
  max-width: 44em;
}

.countdown {
  color: var(--ink-soft);
}

.countdown .num {
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--clay);
  margin-right: 4px;
}

.save-status {
  min-height: 1.4em;
  font-size: 0.85rem;
  color: var(--ink-faint);
}

.save-status[data-state="saved"] {
  color: var(--sage);
}

.save-status[data-state="error"] {
  color: #9a3b22;
}

.notice {
  margin-bottom: 20px;
  padding: 12px 16px;
  border-left: 3px solid var(--clay);
  background: var(--clay-tint);
  border-radius: 0 var(--r-md) var(--r-md) 0;
}

/* Panels */
.panel {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.panel h2 {
  font-size: 1.15rem;
  margin-bottom: 12px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}

.panel-head h2 {
  margin: 0;
}

.panel-meta {
  font-size: 0.85rem;
  color: var(--ink-faint);
  margin-bottom: 8px;
}

.panel-link {
  display: inline-block;
  margin-top: 14px;
  font-weight: 600;
  font-size: 0.9rem;
}

.overall .num {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.5rem;
}

.overall {
  color: var(--ink-soft);
}

/* Overview grid */
.ov-grid {
  display: grid;
  gap: 16px;
}

@media (min-width: 900px) {
  .ov-grid {
    grid-template-columns: 1.4fr 1fr;
  }
  .ov-progress {
    grid-row: span 3;
    align-self: start;
  }
}

.subject-rows {
  display: grid;
}

.subject-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink);
  text-decoration: none;
}

.subject-row:hover .subject-name {
  color: var(--teal);
  text-decoration: underline;
}

.subject-name {
  font-weight: 600;
}

.subject-pct {
  font-weight: 600;
}

.subject-row .bar {
  grid-column: 1 / -1;
}

.subject-meta {
  grid-column: 1 / -1;
  font-size: 0.85rem;
  color: var(--ink-faint);
}

.ov-progress .hint {
  margin-top: 14px;
}

/* Progress bar */
.bar {
  height: 8px;
  background: var(--line-soft);
  border-radius: 999px;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--teal);
  border-radius: inherit;
}

/* Tasks */
.task-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.task-list li {
  position: relative;
  padding-left: 22px;
}

.task-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.35em;
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--teal);
  border-radius: 3px;
}

.note-text {
  margin-top: 12px;
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-soft);
  line-height: 1.55;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-ok {
  background: var(--sage-tint);
  color: #3f6046;
}

.badge-warn {
  background: var(--ochre-tint);
  color: #7a5713;
}

.badge-bad {
  background: var(--clay-tint);
  color: #93421f;
}

.sev-counts {
  display: flex;
  gap: 24px;
}

.sev-counts div {
  display: grid;
  gap: 4px;
  justify-items: start;
}

.sev-counts .num {
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1;
}

.mock-total {
  font-size: 1rem;
  color: var(--ink-soft);
}

.mock-total .total {
  font-family: var(--serif);
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--ink);
}

.delta {
  margin-left: 8px;
  font-size: 0.85rem;
  font-weight: 600;
}

.delta.up {
  color: var(--sage);
}

.delta.down {
  color: #9a3b22;
}

.mock-split {
  margin-top: 4px;
  font-size: 0.88rem;
  color: var(--ink-faint);
}

/* Stat row */
.stat-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.stat-row > div {
  display: grid;
  gap: 2px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.stat-row > div:nth-child(odd) {
  border-right: 1px solid var(--line-soft);
}

.stat-row > div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.stat-label {
  font-size: 0.82rem;
  color: var(--ink-faint);
}

.stat-value {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
}

@media (min-width: 760px) {
  .stat-row {
    grid-template-columns: repeat(4, 1fr);
  }
  .stat-row > div {
    border-bottom: 0;
    border-right: 1px solid var(--line-soft);
  }
  .stat-row > div:last-child {
    border-right: 0;
  }
}

/* Filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.chip {
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  font: 500 0.875rem var(--sans);
  cursor: pointer;
}

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

.chip[aria-pressed="true"] {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

/* Tables */
.table-scroll {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.tracker,
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.tracker th,
.tracker td,
.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

.tracker thead th,
.data-table thead th {
  position: sticky;
  top: 0;
  background: #fbfaf7;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

.tracker tbody tr:last-child > *,
.data-table tbody tr:last-child > * {
  border-bottom: 0;
}

.tracker tbody tr:hover,
.data-table tbody tr:hover {
  background: #fbfaf7;
}

.tracker tbody th {
  font-weight: 500;
  min-width: 200px;
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 1;
}

.tracker tbody tr:hover th {
  background: #fbfaf7;
}

.ch-name {
  display: block;
}

.ch-bar {
  display: block;
  height: 3px;
  margin-top: 6px;
  background: var(--line-soft);
  border-radius: 2px;
  overflow: hidden;
  max-width: 160px;
}

.ch-bar span {
  display: block;
  height: 100%;
  background: var(--sage);
  transition: width 0.25s;
}

.c {
  text-align: center !important;
}

.r {
  text-align: right !important;
}

.strong {
  font-weight: 600;
}

.check {
  width: 20px;
  height: 20px;
  accent-color: var(--teal);
  cursor: pointer;
}

.cell-input {
  width: 84px;
  min-height: 36px;
  padding: 6px 8px;
}

.cell-select {
  width: 104px;
  min-height: 36px;
  padding: 6px 8px;
}

.conf {
  display: inline-flex;
  gap: 4px;
}

.conf button {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1.5px solid var(--teal);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.conf button.on {
  background: var(--teal);
}

.conf button:hover {
  box-shadow: 0 0 0 3px var(--teal-tint);
}

.table-foot {
  margin-top: 12px;
}

.note-cell {
  min-width: 180px;
  color: var(--ink-soft);
}

.data-table.compact th,
.data-table.compact td {
  padding: 7px 10px;
  font-size: 0.875rem;
}

.data-table tr.muted > * {
  color: var(--ink-faint);
}

.overdue {
  color: #9a3b22;
  font-weight: 600;
}

.soon {
  color: #7a5713;
  font-weight: 600;
}

/* Forms in panels */
.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
  margin-bottom: 24px;
}

@media (min-width: 640px) {
  .form-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .form-grid .span-2,
  .form-grid .span-3 {
    grid-column: span 2;
  }
}

@media (min-width: 980px) {
  .app-main .form-grid,
  .drawer .form-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .app-main .form-grid .span-3,
  .drawer .form-grid .span-3 {
    grid-column: span 3;
  }
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

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

/* Item lists (backlog) */
.list-section {
  margin-top: 8px;
  margin-bottom: 24px;
}

.list-section h2 {
  font-size: 1.2rem;
  margin-bottom: 12px;
}

.list-section.cleared summary {
  cursor: pointer;
  list-style: none;
}

.list-section.cleared summary h2 {
  display: inline;
}

.count {
  margin-left: 6px;
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-faint);
}

.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.item {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.item:last-child {
  border-bottom: 0;
}

.item-title {
  font-weight: 600;
}

.item-sub {
  margin-left: 6px;
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--ink-faint);
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.item-note {
  margin-top: 6px;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Chart */
.chart-panel {
  margin-bottom: 20px;
}

.chart {
  width: 100%;
  height: auto;
  max-height: 200px;
}

.chart-grid {
  stroke: var(--line-soft);
  stroke-width: 1;
}

.chart-axis {
  font: 11px var(--sans);
  fill: var(--ink-faint);
}

.chart-line {
  fill: none;
  stroke: var(--teal);
  stroke-width: 2.5;
  stroke-linejoin: round;
}

.chart-dot {
  fill: var(--surface);
  stroke: var(--teal);
  stroke-width: 2.5;
}

.chart-label {
  font: 600 11px var(--sans);
  fill: var(--ink);
}

/* Notes */
.notes {
  display: grid;
  gap: 16px;
  max-width: 760px;
}

.note h2 {
  font-size: 1.1rem;
}

.note h3 {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 16px 0 8px;
}

.note .note-text {
  margin-top: 0;
}

/* Locked screen */
.locked {
  max-width: 520px;
  margin: 40px auto;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  display: grid;
  gap: 14px;
  justify-items: start;
}

.locked h1 {
  font-size: 1.6rem;
}

.locked p {
  color: var(--ink-soft);
}

/* Admin list */
.list-tools {
  margin: 20px 0 12px;
}

.search {
  max-width: 340px;
}

.students-table th[scope="row"] {
  font-weight: 400;
  min-width: 200px;
}

.row-open {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  font: 600 0.95rem var(--sans);
  color: var(--teal);
  text-align: left;
  cursor: pointer;
}

.row-open:hover {
  text-decoration: underline;
}

.row-sub {
  display: block;
  font-size: 0.82rem;
  color: var(--ink-faint);
}

.pct-cell {
  min-width: 120px;
}

.pct-cell .num {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.renewals {
  margin-bottom: 8px;
  border-left: 3px solid var(--clay);
}

.renew-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.renew-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 10px 0;
  border-top: 1px solid var(--line-soft);
}

.renew-list li > span {
  flex: 1;
  color: var(--ink-soft);
}

/* Dialogs */
dialog {
  padding: 0;
  border: 0;
  color: var(--ink);
  background: var(--paper);
}

dialog::backdrop {
  background: rgba(23, 46, 43, 0.38);
}

.drawer {
  margin: 0 0 0 auto;
  width: min(760px, 100vw);
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  border-left: 1px solid var(--line);
}

.drawer-inner {
  padding: 24px 20px 48px;
}

@media (min-width: 700px) {
  .drawer-inner {
    padding: 28px 32px 56px;
  }
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1.5px solid var(--ink);
}

.drawer-head h2 {
  font-size: 1.6rem;
}

.drawer-head-actions {
  display: flex;
  gap: 6px;
  flex: none;
}

.drawer-section {
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.drawer-section h3 {
  font-size: 1.1rem;
  margin-bottom: 14px;
}

.drawer-section h3 .num {
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin-left: 6px;
}

.drawer-section .form-grid {
  margin-bottom: 10px;
}

.subject-detail {
  border-top: 1px solid var(--line-soft);
}

.subject-detail summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  padding: 12px 0;
  cursor: pointer;
  list-style: none;
}

.subject-detail summary::-webkit-details-marker {
  display: none;
}

.subject-detail summary .bar {
  grid-column: 1 / -1;
}

.subject-detail summary .subject-name::after {
  content: " (show chapters)";
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--teal);
}

.subject-detail[open] summary .subject-name::after {
  content: " (hide chapters)";
}

.subject-detail .table-scroll {
  margin-bottom: 14px;
}

.mini-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.mini-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
}

.mini-list .row-sub {
  display: inline;
}

.notes-admin {
  display: grid;
  gap: 12px;
}

.note-admin {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.note-admin-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.note-admin p {
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.modal {
  width: min(620px, calc(100vw - 24px));
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
}

.modal-inner {
  padding: 24px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.modal-head h2 {
  font-size: 1.4rem;
}

.modal .form-grid {
  margin: 18px 0 8px;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.credentials {
  margin-top: 12px;
  font-size: 0.9rem;
}

/* Login */
.login-page {
  min-height: 100vh;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px;
}

.login-wrap {
  display: grid;
  justify-items: center;
  gap: 24px;
  padding: 64px 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  display: grid;
  gap: 16px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: 0 18px 40px -28px rgba(23, 46, 43, 0.4);
}

.login-card h1 {
  font-size: 1.5rem;
}

.login-card .btn {
  width: 100%;
  margin-top: 4px;
}

.demo-box {
  max-width: 400px;
  width: 100%;
  padding: 14px 18px;
  background: var(--ochre-tint);
  border-radius: var(--r-md);
  font-size: 0.88rem;
  color: #6b4d12;
}

/* Enquiries inbox */
.enquiries {
  margin: 8px 0 32px;
}

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

.enq-head h2,
.students-heading {
  font-size: 1.3rem;
}

.students-heading {
  margin-top: 8px;
}

.enq-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--ink-soft);
  cursor: pointer;
}

.enq-toggle input {
  accent-color: var(--teal);
}

.enq {
  display: grid;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.enq:last-child {
  border-bottom: 0;
}

.enq-challenge {
  font-family: var(--serif);
  font-style: italic;
}

.enq-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.enq-status {
  width: auto;
  min-height: 34px;
  padding: 5px 10px;
  font-size: 0.875rem;
}

@media (min-width: 900px) {
  .enq {
    grid-template-columns: 1fr auto;
    align-items: start;
  }
}

.badge-info {
  background: var(--teal-tint);
  color: var(--teal);
}

.badge-muted {
  background: var(--line-soft);
  color: var(--ink-soft);
}
