.quiz-tracker-page,
.quiz-tracker-page * {
  box-sizing: border-box;
}

.quiz-tracker-page {
  display: grid;
  gap: 16px;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.quiz-tracker-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
}

.quiz-tracker-head h2 {
  margin: 0;
  color: var(--rd-ink);
}

.quiz-tracker-head p {
  margin: 4px 0 0;
  color: var(--rd-muted);
}

/* ── KPI stat strip (click-to-filter) ───────────────────────────────────── */
.qt-kpi-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}

.qt-kpi {
  appearance: none;
  border: 1px solid var(--rd-line);
  background: var(--rd-card);
  border-radius: 12px;
  padding: 12px 13px;
  display: grid;
  gap: 5px;
  text-align: left;
  cursor: pointer;
  min-width: 0;
  font: inherit;
  transition: border-color .12s ease, box-shadow .12s ease, transform .08s ease;
}

.qt-kpi:not(.is-static):hover {
  border-color: var(--rd-accent-line);
}

.qt-kpi.is-active {
  border-color: var(--rd-accent);
  box-shadow: 0 0 0 3px var(--rd-accent-soft);
}

.qt-kpi.is-static {
  cursor: default;
  background: var(--rd-card-2);
}

.qt-kpi-value {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--rd-ink);
  font-variant-numeric: tabular-nums;
}

.qt-kpi-label {
  font-size: 0.63rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--rd-muted);
}

.qt-kpi.is-danger {
  background: linear-gradient(180deg, color-mix(in srgb,var(--rd-red),transparent 93%), color-mix(in srgb,var(--rd-red),transparent 98%));
  border-color: color-mix(in srgb,var(--rd-red),transparent 76%);
}
.qt-kpi.is-danger .qt-kpi-value { color: var(--rd-red); }
.qt-kpi.is-danger .qt-kpi-label { color: var(--rd-red); }

.qt-kpi.is-success {
  background: linear-gradient(180deg, color-mix(in srgb,var(--rd-green),transparent 92%), color-mix(in srgb,var(--rd-green),transparent 98%));
  border-color: color-mix(in srgb,var(--rd-green),transparent 74%);
}
.qt-kpi.is-success .qt-kpi-value { color: var(--rd-green); }
.qt-kpi.is-success .qt-kpi-label { color: var(--rd-green); }

.qt-kpi.is-danger.is-active { box-shadow: 0 0 0 3px color-mix(in srgb,var(--rd-red),transparent 82%); }
.qt-kpi.is-success.is-active { box-shadow: 0 0 0 3px color-mix(in srgb,var(--rd-green),transparent 82%); }

/* ── Filter chips ───────────────────────────────────────────────────────── */
.qt-chip-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.qt-filter-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--rd-line);
  background: #fff;
  color: var(--rd-ink);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 0.77rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.qt-filter-chip:hover { border-color: var(--rd-accent-line); }

.qt-filter-chip.is-active {
  background: var(--rd-chrome);
  border-color: var(--rd-chrome);
  color: var(--rd-accent-hi);
}

.qt-filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  padding: 0 4px;
  border-radius: 999px;
  color: var(--rd-muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.qt-filter-chip.is-active .qt-filter-count {
  color: var(--rd-on-chrome-muted);
}

/* ── Section color key ──────────────────────────────────────────────────── */
.quiz-tracker-key {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.quiz-tracker-key {
  background: var(--rd-card-2);
  border: 1px solid var(--rd-line);
  border-radius: 10px;
  padding: 9px 13px;
}
.quiz-key-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  font-size: 0.73rem;
  white-space: nowrap;
  color: var(--rd-muted);
}

.quiz-key-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--quiz-key-color, #5E5B54);
  flex: 0 0 auto;
}

/* ── The list ───────────────────────────────────────────────────────────── */
.quiz-tracker-list {
  display: grid;
  gap: 14px;
  width: 100%;
  max-width: 100%;
}

/* ── Readiness card (one roomy card per student) ────────────────────────── */
.qt-card {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 14px 15px;
  border-radius: 13px;
  background: var(--rd-card);
  border: 1px solid var(--rd-line);
  box-shadow: 0 1px 2px rgba(14,15,16,.04);
  /* Ribbon = ONLY red (stalled) or green (ready). Everyone else has no colored
     ribbon (the named status tag still labels their state). */
  border-left: 3px solid var(--rd-line);
  display: grid;
  gap: 12px;
  overflow: hidden;
}

.qt-card.qt-bucket-stalled { border-left-color: var(--rd-red); }
.qt-card.qt-bucket-ready { border-left-color: var(--rd-green); }
.qt-card.qt-bucket-inprogress { border-left-color: var(--rd-line); }
.qt-card.qt-bucket-notstarted { border-left-color: var(--rd-line); }

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

.qt-card-name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
  color: var(--rd-ink);
}

.lm-cardname {
  cursor: pointer;
  font-weight: 700;
  color: var(--rd-ink);
}
.lm-cardname:hover { color: var(--rd-accent-deep); text-decoration: underline; }

.qt-stage-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--rd-chrome);
  color: var(--rd-accent-hi);
  font-size: 0.64rem;
  font-weight: 700;
  white-space: nowrap;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qt-card-metaline {
  color: var(--rd-muted);
  font-size: 0.74rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

/* ── Tag row ─────────────────────────────────────────────────────────────── */
.qt-tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.qt-tag,
.qt-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.67rem;
  font-weight: 700;
  white-space: nowrap;
}

.qt-tag.is-neutral,
.qt-chip.is-neutral {
  background: var(--rd-card-3);
  color: var(--rd-muted);
}
.qt-tag.is-inprogress {
  background: color-mix(in srgb,var(--rd-amber),transparent 88%);
  color: var(--rd-amber);
}
.qt-tag.is-ready {
  background: color-mix(in srgb,var(--rd-green),transparent 88%);
  color: var(--rd-green);
}
.qt-tag.is-danger,
.qt-chip.is-danger {
  background: color-mix(in srgb,var(--rd-red),transparent 90%);
  color: var(--rd-red);
}
.qt-tag.is-warn {
  background: color-mix(in srgb,var(--rd-amber),transparent 84%);
  color: var(--rd-amber);
}
.qt-chip.is-good {
  background: color-mix(in srgb,var(--rd-green),transparent 86%);
  color: var(--rd-green);
}
.qt-chip.is-watch {
  background: var(--rd-accent-soft);
  color: var(--rd-accent-deep);
}

/* ── Completion bars (full width, labelled) ─────────────────────────────── */
.qt-bar-block {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.qt-bar-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.qt-bar-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--rd-muted);
}

.qt-bar-nums {
  font-size: 0.72rem;
  color: var(--rd-muted);
  white-space: nowrap;
}
.qt-bar-nums strong { color: var(--rd-ink); }

.quiz-progress-bar {
  width: 100%;
  height: 7px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--rd-card-3);
  display: flex;
  min-width: 0;
}

.quiz-progress-segment {
  height: 100%;
  min-width: 0;
  background: var(--rd-card-3);
  border-right: 1px solid rgba(255, 255, 255, 0.85);
  position: relative;
  overflow: hidden;
}

.quiz-progress-segment:last-child { border-right: 0; }

.quiz-progress-segment > span {
  display: block;
  height: 100%;
  width: var(--quiz-segment-fill, 0%);
  background: var(--quiz-segment-color, #5E5B54);
}

.quiz-progress-fill {
  height: 100%;
  width: var(--quiz-fill, 0%);
  background: var(--rd-grey);
}

/* ── Card footer + primary action ───────────────────────────────────────── */
.qt-card-footer {
  display: grid;
  gap: 10px;
}

.qt-primary-btn {
  appearance: none;
  justify-self: start;
  border: 0;
  background: linear-gradient(180deg, var(--rd-accent-hi), var(--rd-accent));
  color: var(--rd-on-accent);
  border-radius: 9px;
  padding: 9px 14px;
  min-height: 38px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 3px 10px color-mix(in srgb,var(--rd-accent),transparent 78%);
}
.qt-primary-btn:hover { filter: brightness(1.05); }
.qt-primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.qt-nudge-btn {
  appearance: none;
  justify-self: start;
  border: 1.5px solid var(--rd-accent);
  background: #fff;
  color: var(--rd-accent-deep);
  border-radius: 9px;
  padding: 9px 14px;
  min-height: 38px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.qt-nudge-btn:hover { background: var(--rd-accent-soft); }

/* ── Expand: section breakdown & scores ─────────────────────────────────── */
.qt-details > summary {
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--rd-accent-deep);
  padding: 4px 0;
  list-style: none;
}
.qt-details > summary::-webkit-details-marker { display: none; }
.qt-details > summary::before {
  content: '▸ ';
  color: var(--rd-muted);
}
.qt-details[open] > summary::before { content: '▾ '; }

.qt-details-body {
  display: grid;
  gap: 14px;
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(15, 51, 39, 0.03);
  border: 1px solid rgba(15, 51, 39, 0.08);
}

.qt-detail-title {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--rd-ink);
  margin-bottom: 6px;
}
.qt-detail-hint {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--rd-muted);
}
.qt-detail-empty {
  font-size: 0.9rem;
  color: var(--rd-muted);
  font-style: italic;
}

.qt-weak-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.qt-weak-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(178, 58, 43, 0.12);
  color: var(--rd-red);
  font-size: 0.86rem;
  font-weight: 700;
}

.qt-section-rows { display: grid; gap: 7px; }
.qt-section-row {
  display: grid;
  grid-template-columns: minmax(0, 160px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}
.qt-section-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--rd-ink);
}
.qt-section-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--quiz-key-color, #5E5B54);
  flex: 0 0 auto;
}
.qt-section-track {
  height: 9px;
  border-radius: 999px;
  background: rgba(15, 51, 39, 0.08);
  overflow: hidden;
  min-width: 0;
}
.qt-section-fill { display: block; height: 100%; }
.qt-section-count {
  color: var(--rd-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.qt-score-list { display: grid; gap: 8px; }
.qt-score-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(15, 51, 39, 0.07);
}
.qt-score-row:last-child { border-bottom: 0; padding-bottom: 0; }
.qt-score-row strong { color: var(--rd-ink); font-size: 1rem; }
.qt-score-meta {
  color: var(--rd-muted);
  font-size: 0.86rem;
}

/* ── Empty / error ──────────────────────────────────────────────────────── */
.quiz-empty,
.quiz-error {
  padding: 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(15, 51, 39, 0.10);
  color: var(--rd-muted);
}

.quiz-error {
  color: var(--rd-red);
  background: rgba(254, 226, 226, 0.72);
}

/* ── Header actions + search ────────────────────────────────────────────── */
.quiz-refresh-btn {
  appearance: none;
  border: 1px solid rgba(15, 51, 39, 0.14);
  background: rgba(255, 255, 255, 0.72);
  color: var(--rd-ink);
  border-radius: 999px;
  padding: 9px 16px;
  min-height: 38px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.quiz-refresh-btn:hover { border-color: var(--rd-accent-deep); }

.quiz-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.quiz-search-field {
  display: grid;
  gap: 6px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--rd-ink);
}

.quiz-search-field input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid rgba(15, 51, 39, 0.14);
  border-radius: 12px;
  padding: 13px 14px;
  min-height: 44px;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.86);
  color: var(--rd-ink);
  outline: none;
}

.quiz-search-field input:focus {
  border-color: var(--rd-accent-deep);
  box-shadow: 0 0 0 3px var(--rd-accent-soft);
}

.quiz-student-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--rd-muted);
  font-size: 0.9rem;
  min-width: 0;
}

/* ── Settings / automation dialogs (preserved) ──────────────────────────── */
.quiz-results-dialog {
  width: min(560px, calc(100vw - 28px));
  border: 0;
  border-radius: 20px;
  padding: 0;
  background: transparent;
}

.quiz-results-dialog::backdrop {
  background: rgba(15, 51, 39, 0.36);
}

.quiz-results-card {
  padding: 16px;
  border-radius: 20px;
  background: #fff;
  color: var(--rd-ink);
  display: grid;
  gap: 12px;
}

.quiz-results-card h3 { margin: 0; }

.quiz-settings-card select,
.quiz-settings-card input {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(15, 51, 39, 0.14);
  border-radius: 12px;
  padding: 10px 11px;
  font: inherit;
  background: #fff;
  color: var(--rd-ink);
}

.quiz-settings-card input:disabled {
  background: rgba(15, 51, 39, 0.04);
  color: var(--rd-muted);
}

.quiz-settings-note {
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(15, 51, 39, 0.05);
  color: var(--rd-muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

/* ── Mobile (≤760px) ────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .quiz-tracker-page { gap: 12px; }

  .qt-kpi-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .qt-kpi:last-child { grid-column: span 2; }

  .qt-kpi-value { font-size: 1.3rem; }

  .qt-card { padding: 14px; }

  .qt-card-head { flex-wrap: wrap; }
  .qt-stage-pill { max-width: 100%; }

  /* Completion sub-text may collapse to just the % on narrow screens. */
  .qt-bar-sub { display: none; }

  .qt-section-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .qt-section-track { display: none; }

  .quiz-header-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .quiz-header-actions .quiz-refresh-btn {
    max-width: 100%;
    white-space: normal;
    text-align: left;
  }
}
