:root {
  color-scheme: light;
  --background: #f7f8fa;
  --surface: #ffffff;
  --surface-muted: #f1f3f6;
  --text: #111827;
  --muted: #606b7c;
  --border: #d7dce4;
  --border-strong: #bcc4d0;
  --accent: #075f3b;
  --accent-soft: #e8f4ed;
  --link: #0645ad;
  --visited-link: #551a8b;
  --success: #16803b;
  --danger: #c62828;
  --shadow: 0 8px 24px rgba(17, 24, 39, 0.07);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #11151c;
  --surface: #1b212b;
  --surface-muted: #252d39;
  --text: #f3f5f7;
  --muted: #b7c0ce;
  --border: #394351;
  --border-strong: #526071;
  --accent: #7cd5a8;
  --accent-soft: #18372a;
  --link: #9fc0ff;
  --visited-link: #c5a7ff;
  --success: #79d99a;
  --danger: #ff8585;
  --shadow: none;
}

* { box-sizing: border-box; }

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

button,
input,
select { font: inherit; }

.site-header,
main {
  width: min(1180px, calc(100% - 28px));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 0 16px;
}


h1 {
  margin: 0;
  font-size: clamp(1.65rem, 3.2vw, 2.55rem);
  line-height: 1.08;
}

.subtitle {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.site-title-block { min-width: 0; }

.formula-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 2px;
}

.formula-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
  min-height: 38px;
  padding: 8px 12px;
  white-space: nowrap;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--link);
  font-size: 0.88rem;
  font-weight: 650;
  text-decoration: none;
  box-shadow: var(--shadow);
}

.formula-button-label {
  text-decoration: underline;
  text-decoration-thickness: from-font;
  text-underline-offset: 0.13em;
}

.formula-button > .availability-icon {
  width: 1.25rem;
  text-align: center;
}

.formula-button:visited { color: var(--visited-link); }

.formula-button:hover {
  border-color: var(--link);
  background: var(--accent-soft);
  color: var(--link);
}

.dialog-close,
.details-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}


.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1.7fr) minmax(190px, 0.8fr);
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.sort-control {
  min-width: 0;
}

.controls label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.controls input,
.controls select {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.controls input:focus,
.controls select:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 30%, transparent);
  outline-offset: 2px;
}



.session-shortcuts {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 4px;
  align-items: center;
  width: 100%;
  min-height: 48px;
  margin-top: 10px;
  padding: 7px 8px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  scrollbar-width: thin;
}

.session-shortcut {
  flex: 1 1 34px;
  min-width: 48px;
  min-height: 32px;
  padding: 5px 4px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--link);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 750;
  white-space: nowrap;
}

.session-shortcut:hover {
  border-color: var(--link);
  background: var(--accent-soft);
}

.session-shortcut:active { transform: translateY(1px); }

.session-shortcut.collection-shortcut {
  flex-grow: 2;
  min-width: 104px;
  padding-inline: 7px;
}

.session-shortcut.specimen-sample-shortcut {
  flex-grow: 2.65;
  min-width: 132px;
}

.session-shortcut.mock-sets-shortcut {
  min-width: 106px;
}

.catalogue {
  display: grid;
  gap: 14px;
  margin-top: 14px;
  padding-bottom: 40px;
}

.session-section {
  scroll-margin-top: 60px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.session-heading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 42px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
}

.session-heading h2 {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 650;
}


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

.papers-table {
  width: 100%;
  min-width: 650px;
  border-collapse: collapse;
  table-layout: fixed;
}

.papers-table th,
.papers-table td {
  height: 44px;
  padding: 5px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
}

.papers-table tr > :last-child { border-right: 0; }
.papers-table tbody tr:last-child td { border-bottom: 0; }

.papers-table thead th {
  height: 46px;
  background: var(--surface-muted);
  font-size: 1rem;
  font-weight: 600;
}

.table-link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 32px;
  padding-inline: 1.75rem;
  border-radius: 6px;
  color: var(--link);
  font-size: 0.98rem;
  font-weight: 560;
  text-decoration: none;
}

.table-link:visited { color: var(--visited-link); }

.table-link-label {
  text-decoration: underline;
  text-decoration-thickness: from-font;
  text-underline-offset: 0.13em;
}

.table-link:hover {
  background: var(--accent-soft);
  color: var(--link);
}

.availability-icon {
  flex: 0 0 auto;
  text-decoration: none;
}

.table-link > .availability-icon,
.missing-link > .availability-icon {
  position: absolute;
  top: 50%;
  right: 0.38rem;
  width: 1.3rem;
  transform: translateY(-50%);
  text-align: center;
  line-height: 1;
}

.availability-icon.placeholder {
  visibility: hidden;
}

.modal-link .availability-icon.placeholder {
  display: none;
}

.missing-link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 32px;
  padding-inline: 1.75rem;
  color: var(--text);
  font-size: 0.98rem;
  font-weight: 560;
}

.missing-link .table-link-label {
  text-decoration: none;
}

.details-row td { height: 38px; }

.details-button {
  width: 100%;
  min-height: 28px;
  padding: 0 5px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 1.35rem;
  line-height: 1;
}

.details-button:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.empty-paper-cell { background: color-mix(in srgb, var(--surface-muted) 45%, transparent); }

.empty-state {
  padding: 30px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.paper-dialog {
  width: min(640px, calc(100% - 28px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.paper-dialog::backdrop { background: rgba(10, 15, 25, 0.55); }

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 20px 15px;
  border-bottom: 1px solid var(--border);
}

.dialog-meta {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.3rem;
}

.dialog-close {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.5rem;
  line-height: 1;
}

.dialog-content {
  display: grid;
  gap: 20px;
  padding: 18px 20px 22px;
  overflow-y: auto;
}


.paper-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 2px;
}

.paper-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 750;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
}

.paper-action-button:visited { color: var(--accent); }
.paper-action-button:hover,
.paper-action-button:focus-visible { background: var(--accent-soft); }

.dialog-group h3 {
  margin: 0 0 9px;
  font-size: 0.94rem;
}

.modal-links { display: grid; gap: 8px; }

.modal-link {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 48px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-muted);
  color: var(--link);
  text-decoration: none;
}

.modal-link:visited { color: var(--visited-link); }

.modal-link:hover {
  border-color: var(--link);
  color: var(--link);
}

.modal-link-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 750;
}

.modal-link-text {
  text-decoration: underline;
  text-decoration-thickness: from-font;
  text-underline-offset: 0.13em;
}

.modal-action-button {
  width: 100%;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.dialog-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.login-dialog {
  width: min(430px, calc(100% - 28px));
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
}

.login-dialog::backdrop {
  background: rgba(10, 15, 25, 0.58);
  backdrop-filter: blur(2px);
}

.login-form {
  display: grid;
  gap: 14px;
  padding: 24px;
}

.login-lock {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent-soft);
  font-size: 1.35rem;
}

.login-form h2 {
  margin: 0;
  font-size: 1.35rem;
}

.login-description {
  margin: -5px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.login-password-field {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 700;
}

.login-password-field input {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.login-error {
  min-height: 1.25rem;
  margin: -4px 0 0;
  color: var(--danger);
  font-size: 0.84rem;
}

.login-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

.primary-button,
.secondary-button {
  min-height: 40px;
  padding: 8px 15px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

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

.primary-button:hover:not(:disabled),
.secondary-button:hover {
  filter: brightness(0.97);
}


@media (max-width: 900px) {
  .session-shortcut {
    flex: 0 0 auto;
    min-width: 44px;
    padding-inline: 8px;
  }

  .session-shortcut.collection-shortcut {
    min-width: max-content;
    padding-inline: 12px;
  }
}

@media (max-width: 680px) {
  .site-header {
    align-items: stretch;
    padding-top: 18px;
  }
  .formula-links { max-width: 58%; }
  .formula-button { flex: 0 0 auto; }
  .controls { grid-template-columns: 1fr; }
  .search-control { grid-column: auto; }
}

@media (max-width: 460px) {
  .site-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .formula-links {
    max-width: none;
    justify-content: stretch;
  }
  .formula-button { flex: 1 1 0; }
  .controls { grid-template-columns: 1fr; }
  .search-control { grid-column: auto; }
  .modal-link { grid-template-columns: 1fr; gap: 2px; }
}

.tier-heading-content {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  padding-inline: 0.4rem;
}

.tier-heading-label {
  width: 100%;
  text-align: center;
}

.grade-boundary-badge {
  position: absolute;
  border: 1px solid #9bb4da;
  border-radius: 999px;
  background: #eef5ff;
  color: #003f94;
  padding: 0.25rem 0.55rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.1;
  cursor: pointer;
  white-space: nowrap;
}

.grade-boundary-badge-left {
  left: 0.35rem;
}

.grade-boundary-badge-right {
  right: 0.35rem;
}

.grade-boundary-badge:hover,
.grade-boundary-badge:focus-visible {
  background: #dceaff;
  border-color: #5d86c5;
}

.grade-boundary-dialog {
  width: min(32rem, calc(100vw - 2rem));
}

.grade-boundary-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.grade-boundary-table th,
.grade-boundary-table td {
  border-bottom: 1px solid #d8dee8;
  padding: 0.55rem 0.7rem;
  text-align: right;
}

.grade-boundary-table th:first-child,
.grade-boundary-table td:first-child {
  text-align: left;
}

.grade-boundary-table thead th {
  color: #405069;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.grade-boundary-source {
  margin-top: 1rem;
}

@media (max-width: 700px) {
  .grade-boundary-badge {
    font-size: 0.7rem;
    padding-inline: 0.4rem;
  }

  .grade-boundary-badge-left {
    left: 0.2rem;
  }

  .grade-boundary-badge-right {
    right: 0.2rem;
  }
}

.grade-boundary-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}


/* Stage 7E: show notional component boundaries directly in each paper dialog. */
.notional-boundary-group {
  display: grid;
  gap: 0.75rem;
}

.notional-boundary-group h3 {
  margin-bottom: 0;
}

.grade-boundary-table-inline {
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  background: var(--surface-muted);
}

.grade-boundary-table-inline th,
.grade-boundary-table-inline td {
  padding-block: 0.48rem;
}

.grade-boundary-source-inline {
  margin-top: 0;
}

/* Stage 7J: question-level analysis modal and balanced tier actions. */
.qla-badge {
  text-decoration: none;
  min-width: 7.8rem;
}

.qla-dialog {
  width: min(92vw, 1120px);
  height: min(88vh, 900px);
  max-height: calc(100vh - 24px);
}

.qla-dialog[open] {
  display: flex;
  flex-direction: column;
}

.qla-dialog-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.qla-controls {
  display: grid;
  grid-template-columns: minmax(8rem, 11rem) minmax(8rem, 11rem) minmax(15rem, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.qla-controls label {
  display: grid;
  gap: 5px;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
}

.qla-controls select,
.qla-controls input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
}

.qla-dialog-header {
  gap: 16px;
}

.qla-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

#qla-sparx-link-container {
  display: contents;
}

.qla-header-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
}

.qla-header-button:hover,
.qla-header-button:focus-visible {
  background: var(--accent-soft);
}

.qla-header-button .availability-icon {
  font-size: 0.7rem;
  line-height: 1;
}


.qla-row-count {
  margin: 0 0 0.6rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.qla-table-container {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background: var(--surface);
}

.qla-message {
  margin: 0;
  padding: 24px;
  color: var(--muted);
}

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

.qla-table {
  min-width: 100%;
  width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--text);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.qla-table th,
.qla-table td {
  min-width: 5rem;
  max-width: 15rem;
  padding: 0.48rem 0.58rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
}

.qla-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  min-width: 7rem;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 0.72rem;
  line-height: 1.25;
  white-space: normal;
}

.qla-table tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--surface-muted) 55%, var(--surface));
}

.qla-table tbody tr:hover td {
  background: var(--accent-soft);
}

.qla-table .qla-column-series,
.qla-table .qla-column-paper,
.qla-table .qla-column-question,
.qla-table .qla-column-ao,
.qla-table .qla-column-mean-score,
.qla-table .qla-column-max-score,
.qla-table .qla-column-mean {
  white-space: nowrap;
}

.qla-table .qla-column-skill-tested,
.qla-table .qla-column-sparx-skills {
  min-width: 14rem;
  white-space: normal;
}

.qla-empty-value {
  color: var(--muted);
}

@media (max-width: 760px) {
  .qla-dialog {
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
  }

  .qla-controls {
    grid-template-columns: 1fr;
  }

  .qla-row-count {
    margin: 0;
  }

  .qla-dialog-header {
    align-items: flex-start;
  }

  .qla-header-actions {
    flex-wrap: wrap;
    gap: 6px;
  }
}

/* Stage 7K: visually separate the Foundation and Higher tier tables. */
.papers-table-tier-gap {
  min-width: 820px;
}

.papers-table-tier-gap .tier-table-spacer-column {
  width: clamp(72px, 7vw, 112px);
}

.papers-table-tier-gap .tier-table-spacer {
  height: auto;
  padding: 0;
  border: 0;
  background: var(--surface);
  pointer-events: none;
}

.papers-table-tier-gap thead tr > th:last-child,
.papers-table-tier-gap tbody tr > td:nth-child(5) {
  border-left: 1px solid var(--border);
}

.qla-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.22rem;
}

.qla-badge .availability-icon {
  font-size: 0.72rem;
  line-height: 1;
}

@media (max-width: 760px) {
  .papers-table-tier-gap .tier-table-spacer-column {
    width: 48px;
  }
}
