:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #111827;
  --muted: #64748b;
  --line: #d8dee8;
  --nav: #222832;
  --nav-soft: #343b47;
  --primary: #2f7d68;
  --primary-dark: #246351;
  --accent: #e85157;
  --danger: #b83d49;
  --warning: #b7791f;
  --shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

.student-url #teacher-app {
  display: none;
}

.student-url #student-app {
  display: block;
}

.auth-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 28px;
  background:
    radial-gradient(circle at 20% 20%, rgba(37, 99, 235, 0.16), transparent 28rem),
    radial-gradient(circle at 80% 0%, rgba(124, 58, 237, 0.15), transparent 24rem),
    var(--bg);
}

.auth-card {
  width: min(100%, 520px);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.16);
  padding: 28px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

.auth-brand h1 {
  font-size: 30px;
}

.auth-brand p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
  border-radius: 14px;
  background: var(--panel-soft);
  padding: 6px;
}

.auth-tab {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.auth-tab.active {
  background: #fff;
  color: var(--primary);
  box-shadow: var(--soft-shadow);
}

.auth-form {
  display: none;
  gap: 14px;
}

.auth-form.active {
  display: grid;
}

.auth-form .primary-button {
  width: 100%;
  margin-top: 4px;
}

.auth-hint,
.auth-message {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.auth-message {
  min-height: 22px;
  margin-top: 14px;
  color: var(--danger);
  font-weight: 800;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  touch-action: manipulation;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--nav);
  color: #fff;
  padding: 24px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: var(--accent);
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 4px;
  color: #cbd5e1;
}

.nav {
  display: grid;
  gap: 10px;
}

.nav-button {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #eef2f7;
  padding: 12px 14px;
  text-align: left;
  font-weight: 700;
}

.nav-button:hover,
.nav-button.active {
  background: var(--nav-soft);
}

.main {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 124px;
  background: var(--accent);
  color: #fff;
  padding: 26px 36px;
}

.eyebrow {
  margin: 0 0 6px;
  color: inherit;
  opacity: 0.86;
  font-size: 14px;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 0;
  font-size: 34px;
}

h2 {
  margin-bottom: 6px;
  font-size: 24px;
}

h3 {
  margin-bottom: 0;
  font-size: 18px;
}

.topbar-actions,
.section-head,
.panel-head,
.question-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.topbar-actions {
  flex-wrap: wrap;
  align-items: center;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.bottom-editor-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.print-test-row {
  display: grid;
  grid-template-columns: minmax(180px, 260px) repeat(3, minmax(180px, auto));
  align-items: end;
  gap: 12px;
}

.print-test-row button {
  min-height: 52px;
  white-space: nowrap;
}

.print-test-status {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.print-test-status.error {
  color: var(--danger);
}

.editor-switcher-panel {
  padding: 18px 22px;
}

.editor-switcher-panel label {
  max-width: 520px;
}

.view {
  display: none;
  padding: 30px 36px 44px;
}

.view.active {
  display: block;
}

.panel,
.test-card,
.question-card,
.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 24px;
  margin-bottom: 18px;
}

.panel-head {
  margin-bottom: 18px;
}

.section-head {
  margin-bottom: 18px;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.section-head p,
.panel-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.status-line {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  margin-bottom: 14px;
  border: 1px solid #bfd6ca;
  border-radius: 8px;
  background: #eef8f3;
  color: #1e684b;
  padding: 8px 12px;
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-weight: 700;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  align-self: end;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  background: #fff;
  padding: 12px 16px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.04);
}

.checkbox-field input {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.checkbox-field span {
  display: block;
  min-width: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.2;
  white-space: nowrap;
}

input,
textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
}

select {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
  font: inherit;
  font-weight: 800;
}

textarea {
  resize: vertical;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  padding: 10px 15px;
  font-weight: 800;
}

.primary-button {
  background: var(--primary);
  color: #fff;
}

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

.secondary-button {
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.panel .secondary-button,
.test-card .secondary-button,
.question-card .secondary-button {
  border-color: #cbd5e1;
  background: #f1f5f9;
  color: #243041;
}

.test-card .danger-button {
  background: var(--danger);
  color: #fff;
}

.danger-button {
  background: var(--danger);
  color: #fff;
}

.icon-button {
  width: 38px;
  padding: 0;
  background: #edf2f7;
  color: #1f2937;
  font-size: 20px;
}

.file-button {
  display: inline-grid;
  place-items: center;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.test-list,
.question-list,
.results-list {
  display: grid;
  gap: 16px;
}

.test-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 22px;
}

.test-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.link-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 10px;
}

.link-button {
  display: inline-grid;
  place-items: center;
  text-decoration: none;
}

.question-card {
  padding: 22px;
}

.question-card-head {
  align-items: center;
  margin-bottom: 16px;
}

.answer-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.answer-row {
  display: grid;
  grid-template-columns: 26px 1fr;
  align-items: center;
  gap: 10px;
}

.answer-row input[type="radio"] {
  width: 18px;
  height: 18px;
}

.question-meta-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(100px, 0.35fr) minmax(140px, 0.5fr);
  gap: 12px;
  margin: 14px 0;
}

.question-meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.question-meta-pills span,
.review-meta {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  padding: 4px 9px;
  font-size: 13px;
  font-weight: 800;
}

.library-layout {
  display: grid;
  grid-template-columns: minmax(240px, 0.65fr) minmax(360px, 1.35fr);
  gap: 18px;
}

.category-list,
.library-list {
  display: grid;
  gap: 10px;
}

.category-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  color: var(--text);
  padding: 10px 12px;
  font-weight: 800;
}

.category-chip.active,
.category-chip:hover {
  border-color: rgba(47, 125, 104, 0.35);
  background: rgba(47, 125, 104, 0.1);
  color: var(--primary-dark);
}

.library-filter-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 14px;
}

.library-bulk-actions {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  padding: 12px;
}

.library-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.library-summary div {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  padding: 12px;
}

.library-summary span,
.library-performance span,
.question-evaluation-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.library-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.library-question-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  grid-template-areas:
    "header header"
    "meta actions";
  align-items: start;
  gap: 16px 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-soft);
  padding: 18px 20px;
}

.library-question-card.inactive {
  opacity: 0.72;
}

.library-question-header {
  grid-area: header;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.library-select-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.library-select-box input {
  width: 18px;
  height: 18px;
}

.library-question-title strong {
  display: block;
  color: var(--text);
  font-size: 22px;
  line-height: 1.28;
}

.library-question-meta {
  grid-area: meta;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.library-question-meta .question-meta-pills {
  margin-top: 0;
  max-width: 360px;
}

.active-pill {
  background: rgba(16, 185, 129, 0.12) !important;
  color: #047857 !important;
}

.inactive-pill,
.duplicate-pill {
  background: rgba(245, 158, 11, 0.16) !important;
  color: #92400e !important;
}

.library-question-card p {
  margin: 6px 0 0;
  color: var(--muted);
}

.library-performance {
  width: 100%;
  max-width: 360px;
  margin-top: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  padding: 10px;
}

.library-performance > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.library-performance strong {
  font-size: 18px;
}

.library-performance p {
  margin-top: 8px;
  font-size: 13px;
}

.library-performance.danger {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.06);
}

.library-performance.warning {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.08);
}

.library-performance.success,
.library-performance.ok {
  border-color: rgba(16, 185, 129, 0.28);
  background: rgba(16, 185, 129, 0.06);
}

.mini-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
  margin-top: 8px;
}

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

.library-copy-controls {
  grid-area: actions;
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  padding: 12px;
}

.library-copy-controls label {
  margin: 0;
  font-size: 13px;
}

.library-copy-controls select {
  width: 100%;
  min-height: 42px;
}

.library-copy-controls .secondary-button {
  width: 100%;
  min-height: 42px;
  white-space: nowrap;
}

.library-copy-controls .compact-button {
  grid-column: auto;
  width: 100%;
}

.student-tools {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(180px, 280px);
  gap: 14px;
  align-items: end;
  margin-bottom: 18px;
}

.students-search-box {
  width: 100%;
}

.students-list {
  display: grid;
  gap: 14px;
}

.student-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

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

.student-card-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.student-average {
  min-width: 76px;
  border-radius: 999px;
  padding: 8px 12px;
  text-align: center;
  font-weight: 900;
}

.student-average.success {
  background: rgba(16, 185, 129, 0.16);
  color: #047857;
}

.student-average.fail {
  background: rgba(239, 68, 68, 0.14);
  color: #b91c1c;
}

.student-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.student-stats-grid span {
  border-radius: 12px;
  background: var(--panel-soft);
  padding: 12px;
  color: var(--muted);
}

.student-stats-grid strong {
  display: block;
  color: var(--text);
  font-size: 20px;
}

.student-results-detail summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 900;
}

.student-results-detail ul {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.student-results-detail li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.student-results-detail small {
  color: var(--muted);
}

.student-profile-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 18px;
  align-items: start;
}

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

.student-list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  padding: 14px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.student-list-item:hover,
.student-list-item.active {
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: var(--soft-shadow);
  transform: translateY(-1px);
}

.student-list-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.student-list-item b {
  color: var(--primary);
}

.student-profile-detail {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 22px;
}

.student-profile-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.student-profile-hero h2 {
  margin-bottom: 4px;
  font-size: 30px;
}

.student-profile-hero p:not(.eyebrow) {
  color: var(--muted);
}

.student-profile-score {
  min-width: 112px;
  border-radius: 16px;
  padding: 14px;
  text-align: center;
}

.student-profile-score.success {
  background: rgba(16, 185, 129, 0.16);
  color: #047857;
}

.student-profile-score.fail {
  background: rgba(239, 68, 68, 0.14);
  color: #b91c1c;
}

.student-profile-score strong {
  display: block;
  font-size: 28px;
}

.student-profile-score span {
  font-weight: 800;
}

.student-profile-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.student-profile-stats span {
  border-radius: 12px;
  background: var(--panel-soft);
  padding: 12px;
  color: var(--muted);
}

.student-profile-stats strong {
  display: block;
  color: var(--text);
  font-size: 20px;
}

.student-profile-section {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 16px;
}

.catalog-toolbar,
.catalog-merge-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) repeat(3, minmax(180px, 1fr));
  gap: 14px;
  align-items: end;
  margin-bottom: 18px;
}

.catalog-export-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.catalog-merge-panel {
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr) auto;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--soft-shadow);
  padding: 18px;
}

.catalog-merge-panel h3 {
  margin: 0 0 4px;
  font-size: 20px;
}

.catalog-merge-panel p {
  margin: 0;
  color: var(--muted);
}

.catalog-list {
  display: grid;
  gap: 16px;
}

.catalog-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--soft-shadow);
  padding: 20px;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.catalog-card:hover {
  transform: translateY(-2px);
  border-color: rgba(37, 99, 235, 0.24);
  box-shadow: 0 22px 55px rgba(15, 23, 42, 0.11);
}

.catalog-card.is-archived {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.catalog-select {
  display: flex;
  align-items: flex-start;
  padding-top: 4px;
}

.catalog-select input {
  width: 18px;
  height: 18px;
}

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

.catalog-eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-weight: 800;
}

.catalog-card h3 {
  margin: 0;
  font-size: 23px;
  line-height: 1.18;
}

.catalog-badges,
.catalog-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.catalog-status,
.catalog-tags span {
  border-radius: 999px;
  background: var(--panel-soft);
  padding: 7px 11px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.catalog-status.active,
.catalog-status.open {
  background: #d1fae5;
  color: #047857;
}

.catalog-status.draft,
.catalog-status.waiting {
  background: #fef3c7;
  color: #92400e;
}

.catalog-status.archived,
.catalog-status.closed {
  background: #fee2e2;
  color: #b91c1c;
}

.catalog-meta-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(92px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.catalog-meta-grid span {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 800;
  min-height: 68px;
}

.catalog-meta-grid strong {
  display: block;
  color: var(--text);
  font-size: 18px;
}

.catalog-actions {
  display: grid;
  grid-column: 2;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 9px;
  align-content: start;
  min-width: 0;
}

.catalog-actions button,
.catalog-merge-panel button {
  min-height: 42px;
  white-space: nowrap;
}

.subject-tools {
  margin-bottom: 18px;
}

.subjects-search-box {
  max-width: 520px;
}

.subjects-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.subject-stat-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--soft-shadow);
  padding: 18px;
}

.subject-stat-card span {
  display: block;
  color: var(--muted);
  font-weight: 800;
}

.subject-stat-card strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: 28px;
  font-weight: 900;
}

.subjects-list {
  display: grid;
  gap: 18px;
}

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

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

.subject-card h3 {
  margin: 4px 0 0;
  font-size: 26px;
}

.subject-score {
  min-width: 110px;
  border-radius: 16px;
  background: linear-gradient(135deg, #dbeafe, #ede9fe);
  padding: 12px 14px;
  text-align: center;
}

.subject-score strong {
  display: block;
  color: var(--text);
  font-size: 24px;
  font-weight: 900;
}

.subject-score span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.subject-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 14px;
}

.subject-metrics span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  padding: 8px 12px;
  color: var(--muted);
  font-weight: 800;
}

.subject-metrics strong {
  color: var(--text);
}

.subject-progress {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: #e5e7eb;
}

.subject-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
}

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

.subject-test-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
  padding: 12px 14px;
}

.subject-test-list small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 700;
}

.compact-button {
  min-height: 38px;
  padding: 8px 12px;
}

.student-trend-chart {
  display: flex;
  align-items: end;
  gap: 10px;
  min-height: 150px;
  border-radius: 14px;
  background: var(--panel-soft);
  padding: 18px;
}

.student-trend-chart span {
  position: relative;
  flex: 1;
  min-width: 24px;
  max-width: 52px;
  border-radius: 10px 10px 4px 4px;
  background: linear-gradient(180deg, var(--primary), var(--accent));
}

.student-trend-chart b {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--muted);
}

.student-trend-empty {
  display: flex;
  align-items: center;
  gap: 16px;
  border-radius: 14px;
  background: var(--panel-soft);
  padding: 18px;
}

.student-trend-empty strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  height: 84px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-size: 24px;
}

.student-trend-empty span {
  color: var(--muted);
  font-weight: 800;
}

.student-weakness-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.student-weakness-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-radius: 12px;
  background: var(--panel-soft);
  padding: 12px;
}

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

.student-history-table {
  width: 100%;
  border-collapse: collapse;
}

.student-history-table th,
.student-history-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
}

.student-result-status {
  display: inline-flex;
  border-radius: 999px;
  padding: 5px 10px;
  font-weight: 900;
}

.student-result-status.success {
  background: rgba(16, 185, 129, 0.14);
  color: #047857;
}

.student-result-status.fail {
  background: rgba(239, 68, 68, 0.14);
  color: #b91c1c;
}

.student-shell {
  min-height: 100vh;
  background: #edf1f5;
}

.student-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  background: var(--accent);
  color: #fff;
  padding: 30px max(24px, 8vw);
}

.student-header h1 {
  font-size: 36px;
}

.student-header p {
  margin-bottom: 0;
}

.student-timer {
  align-self: center;
  min-width: 130px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
  padding: 12px 14px;
  text-align: center;
  font-weight: 800;
}

.student-header-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px 14px;
  font-weight: 800;
}

.student-header-info span {
  white-space: nowrap;
}

.student-running .student-header {
  align-items: center;
  min-height: 74px;
  padding-top: 16px;
  padding-bottom: 16px;
}

.student-running .student-header .eyebrow,
.student-running #student-test-meta {
  display: none;
}

.student-running .student-header h1 {
  font-size: 28px;
}

.student-main {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 24px 44px;
}

.student-form {
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  margin-bottom: 18px;
}

.student-start-card {
  padding: 0;
  overflow: hidden;
}

.student-start-card h2 {
  margin: 0;
  border-bottom: 1px solid var(--line);
  padding: 18px 22px;
  font-size: 22px;
  font-weight: 500;
}

.student-start-card h2 strong {
  font-weight: 900;
}

.student-start-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(300px, 1.05fr);
  gap: 48px;
  padding: 34px 28px 24px;
}

.student-entry-form {
  display: grid;
  gap: 24px;
}

.student-entry-form label {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(220px, 1fr);
  align-items: center;
  gap: 24px;
  font-size: 20px;
  font-weight: 500;
}

.student-entry-form input {
  min-height: 44px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 9px 12px;
}

.student-start-info {
  font-size: 21px;
  line-height: 1.4;
}

.student-start-info p {
  margin-bottom: 8px;
}

.student-start-info span {
  color: #000;
}

.student-start-rules {
  margin-top: 42px;
}

.student-start-rules p {
  margin-bottom: 6px;
}

.student-start-button {
  margin: 0 28px 28px;
}

.availability-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
  align-items: start;
  padding: 30px;
  border-left: 6px solid var(--primary);
  background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
}

.availability-card.closed {
  border-left-color: var(--danger);
  background: linear-gradient(135deg, #ffffff 0%, #fff7f7 100%);
}

.availability-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 16px;
  background: #eaf1ff;
  color: var(--primary);
  font-size: 28px;
  font-weight: 900;
}

.availability-card.closed .availability-icon {
  background: #fee2e2;
  color: var(--danger);
}

.availability-kicker {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.availability-card h2 {
  margin: 0 0 10px;
  border: 0;
  padding: 0;
  font-size: 30px;
  font-weight: 900;
  line-height: 1.15;
}

.availability-message {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  font-weight: 800;
}

.availability-note {
  max-width: 650px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.student-quiz {
  display: grid;
  gap: 16px;
}

.student-question {
  border: 1px solid var(--line);
  border-left: 5px solid var(--primary);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 22px;
}

.student-question fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

.student-question legend {
  margin-bottom: 14px;
  font-size: 19px;
  font-weight: 800;
}

.student-question-points {
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
}

.student-option {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  font-weight: 400;
}

.student-option:hover {
  border-color: var(--primary);
  background: #f0f9f6;
}

.student-submit {
  display: flex;
  justify-content: flex-end;
}

.student-navigation {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 10px;
}

.required-answer-message {
  grid-column: 1 / -1;
  min-height: 22px;
  color: var(--danger);
  font-weight: 800;
  text-align: right;
}

.required-answer-message:empty {
  display: none;
}

.secondary-nav-button {
  min-height: 42px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  color: #243041;
  padding: 10px 15px;
  font-weight: 800;
}

.secondary-nav-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.question-progress {
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.student-result {
  border-left: 5px solid var(--primary);
}

.result-card {
  padding: 18px;
}

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

.result-card-head p:last-child {
  margin-bottom: 0;
}

.result-card.success {
  border-left: 5px solid var(--primary);
}

.result-card.fail {
  border-left: 5px solid var(--danger);
}

.result-group {
  display: grid;
  gap: 14px;
  margin-bottom: 24px;
}

.result-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 18px 20px;
  box-shadow: var(--soft-shadow);
}

.result-group-head h3 {
  margin: 0 0 4px;
  font-size: 22px;
}

.result-group-head p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.result-group-list {
  display: grid;
  gap: 16px;
}

.question-evaluation-panel {
  margin-bottom: 18px;
}

.question-evaluation-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
}

.question-evaluation-card,
.question-evaluation-summary {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
  padding: 14px;
}

.question-evaluation-card h3 {
  margin: 0;
  font-size: 18px;
}

.question-evaluation-card p,
.question-evaluation-summary p {
  margin: 6px 0 12px;
  color: var(--muted);
}

.question-evaluation-card ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.question-evaluation-card li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  border-radius: 10px;
  background: #ffffff;
  padding: 10px;
}

.question-evaluation-card li strong {
  display: block;
  font-size: 14px;
}

.question-evaluation-card li span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.question-evaluation-card li b {
  white-space: nowrap;
}

.question-evaluation-summary strong {
  display: block;
  margin-top: 8px;
  font-size: 38px;
}

.result-visual {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
  padding: 16px;
}

.score-ring {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background:
    radial-gradient(circle closest-side, #fff 68%, transparent 70%),
    conic-gradient(var(--primary) calc(var(--score) * 1%), #e5e7eb 0);
}

.result-card.fail .score-ring {
  background:
    radial-gradient(circle closest-side, #fff 68%, transparent 70%),
    conic-gradient(var(--danger) calc(var(--score) * 1%), #e5e7eb 0);
}

.score-ring span {
  color: var(--text);
  font-size: 22px;
  font-weight: 900;
}

.score-summary {
  display: grid;
  gap: 10px;
}

.score-row,
.score-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
}

.score-row span,
.score-grid span {
  color: var(--muted);
  font-weight: 800;
}

.score-row strong,
.score-grid strong {
  color: var(--text);
}

.score-bar {
  overflow: hidden;
  height: 12px;
  border-radius: 999px;
  background: #e5e7eb;
}

.score-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.result-card.fail .score-bar span {
  background: linear-gradient(90deg, var(--danger), var(--warning));
}

.result-review {
  margin-top: 14px;
}

.result-review summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 900;
}

.result-review ul {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.result-review li {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 12px;
  background: #fff;
  padding: 12px;
}

.result-review li.correct {
  border-left-color: var(--success);
}

.result-review li.wrong {
  border-left-color: var(--danger);
}

.result-review li span {
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

@media (max-width: 940px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding: 16px;
  }

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

  .nav-button {
    text-align: center;
  }

  .topbar,
  .student-header,
  .section-head,
  .panel-head,
  .test-card,
  .result-card-head {
    flex-direction: column;
    align-items: stretch;
  }

  .test-card {
    grid-template-columns: 1fr;
  }

  .result-visual {
    grid-template-columns: 1fr;
  }

  .score-ring {
    justify-self: center;
  }

  .form-grid,
  .student-form,
  .link-row,
  .library-layout,
  .question-meta-grid,
  .student-start-layout,
  .student-entry-form label,
  .student-navigation {
    grid-template-columns: 1fr;
  }

  .question-progress {
    text-align: left;
  }

  .view {
    padding: 24px;
  }
}

@media (max-width: 560px) {
  .topbar,
  .student-header {
    padding: 22px;
  }

  h1,
  .student-header h1 {
    font-size: 28px;
  }

  .nav {
    grid-template-columns: 1fr;
  }

  .panel,
  .question-card,
  .student-question {
    padding: 18px;
  }
}

/* Modern SaaS redesign */
:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-soft: #f1f5f9;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --nav: #ffffff;
  --nav-soft: #eef4ff;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #7c3aed;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #10b981;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  --soft-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
}

body {
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 28rem),
    var(--bg);
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
}

.app-shell {
  grid-template-columns: 268px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  min-height: 100vh;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  box-shadow: 12px 0 38px rgba(15, 23, 42, 0.04);
}

.brand-mark {
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.28);
}

.brand span {
  color: var(--muted);
}

.nav-button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 10px;
  color: #1f2937;
  font-weight: 750;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.nav-button span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: var(--primary);
}

.nav-button:hover,
.nav-button.active {
  background: var(--nav-soft);
  color: var(--primary);
}

.nav-button.active::before {
  content: "";
  position: absolute;
  left: 0;
  width: 3px;
  height: 28px;
  border-radius: 999px;
  background: var(--primary);
}

.ghost-nav {
  opacity: 0.72;
}

.ghost-nav:disabled {
  cursor: default;
}

.ai-card {
  margin-top: 32px;
  border: 1px solid #dbeafe;
  border-radius: 14px;
  background: linear-gradient(145deg, #ffffff, #eef4ff);
  padding: 18px;
  color: #1f2937;
}

.ai-card p {
  margin: 8px 0 14px;
  color: var(--muted);
  font-size: 14px;
}

.ai-card span {
  display: inline-flex;
  border-radius: 999px;
  background: rgba(124, 58, 237, 0.1);
  color: var(--accent);
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.user-card {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 16px;
}

.user-card strong,
.user-card span {
  display: block;
}

.user-card span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.user-card .secondary-button {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(240px, 0.75fr) minmax(320px, 1.25fr);
  gap: 18px;
}

.account-panel {
  display: flex;
  align-items: center;
  gap: 16px;
}

.account-avatar {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-weight: 900;
}

.settings-form {
  display: grid;
  gap: 14px;
}

.settings-form .primary-button {
  justify-self: start;
}

.settings-message {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

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

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

.plan-overview-panel {
  grid-column: span 1;
}

.plan-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

.plan-card.active {
  border-color: rgba(37, 99, 235, 0.45);
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.08), rgba(255, 255, 255, 0.96));
  box-shadow: 0 18px 38px rgba(37, 99, 235, 0.13);
}

.plan-card-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 18px;
  font-weight: 900;
}

.plan-card p {
  margin: 0 0 10px;
  color: var(--muted);
}

.plan-card ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: var(--text);
  font-weight: 800;
}

.plan-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 900;
}

.plan-badge.free {
  background: rgba(37, 99, 235, 0.11);
  color: #1d4ed8;
}

.plan-badge.pro {
  background: rgba(124, 58, 237, 0.13);
  color: #6d28d9;
}

.plan-usage {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.plan-usage span {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 800;
}

.locked-feature {
  opacity: 0.72;
}

.admin-users-panel {
  grid-column: 1 / -1;
}

.pending-users-list {
  display: grid;
  gap: 12px;
}

.pending-user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
  padding: 14px;
}

.pending-user-card strong,
.pending-user-card span {
  display: block;
}

.pending-user-card span {
  margin-top: 4px;
  color: var(--muted);
}

.pending-user-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.registered-user-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.backup-note {
  margin: 12px 0 0;
}

.user-usage-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.user-usage-stats span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 800;
}

.user-usage-stats strong {
  color: var(--text);
}

.user-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 128px;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 900;
}

.user-status.approved {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}

.user-status.pending {
  background: rgba(245, 158, 11, 0.16);
  color: #92400e;
}

.user-status.blocked {
  background: rgba(239, 68, 68, 0.14);
  color: #b91c1c;
}

.compact-control {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
  padding: 0 10px;
  font-weight: 800;
}

.compact-empty {
  padding: 18px;
  text-align: left;
}

.topbar {
  min-height: 108px;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 250, 252, 0.78);
  color: var(--text);
  backdrop-filter: blur(16px);
}

.topbar h1 {
  font-size: 32px;
  letter-spacing: 0;
}

.topbar-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
}

.topbar-actions {
  display: grid;
  grid-template-columns: minmax(280px, 440px) auto;
  align-items: center;
  gap: 14px;
}

.search-box {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--soft-shadow);
  padding: 0 12px;
  color: var(--muted);
}

.search-box input {
  border: 0;
  border-radius: 0;
  padding: 10px 4px;
  box-shadow: none;
}

.primary-button {
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.24);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.primary-button:hover {
  background: linear-gradient(135deg, var(--primary-dark), #6d28d9);
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.3);
  transform: translateY(-1px);
}

.secondary-button,
.panel .secondary-button,
.test-card .secondary-button,
.question-card .secondary-button,
.secondary-nav-button {
  border-color: var(--line);
  border-radius: 10px;
  background: #fff;
  color: #1f2937;
}

.danger-button,
.test-card .danger-button {
  border-radius: 10px;
  background: var(--danger);
}

.view {
  padding: 28px 36px 48px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--soft-shadow);
  padding: 20px;
}

.stat-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 14px;
  font-size: 22px;
  font-weight: 900;
}

.stat-card strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.stat-card p {
  margin: 7px 0 0;
  color: var(--muted);
}

.stat-card.purple .stat-icon {
  background: #ede9fe;
  color: var(--accent);
}

.stat-card.blue .stat-icon {
  background: #dbeafe;
  color: var(--primary);
}

.stat-card.green .stat-icon {
  background: #d1fae5;
  color: #059669;
}

.stat-card.amber .stat-icon {
  background: #fef3c7;
  color: var(--warning);
}

.section-head {
  align-items: center;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.filter-chip {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #334155;
  padding: 8px 14px;
  font-weight: 750;
}

.filter-chip.active,
.filter-chip:hover {
  border-color: rgba(37, 99, 235, 0.35);
  background: #eef4ff;
  color: var(--primary);
}

.panel,
.test-card,
.question-card,
.result-card {
  border-color: var(--line);
  border-radius: 16px;
  box-shadow: var(--soft-shadow);
}

.test-card {
  grid-template-columns: minmax(0, 1fr) auto;
  border-radius: 16px;
  padding: 20px 22px;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.test-card:hover {
  border-color: rgba(37, 99, 235, 0.24);
  box-shadow: 0 22px 48px rgba(15, 23, 42, 0.1);
  transform: translateY(-2px);
}

.test-card-main {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 16px;
  align-items: center;
  min-width: 0;
}

.test-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: #dbeafe;
  color: var(--primary);
  font-size: 24px;
  font-weight: 900;
}

.test-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.test-course {
  margin: 5px 0 10px;
  color: var(--primary);
  font-weight: 750;
}

.test-meta,
.feature-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.test-meta {
  color: #475569;
  font-size: 14px;
}

.feature-row {
  margin-top: 12px;
}

.status-pill,
.feature-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 13px;
  font-weight: 800;
}

.status-pill {
  background: #d1fae5;
  color: #047857;
}

.feature-pill {
  background: #eef4ff;
  color: var(--primary);
}

.muted-pill {
  background: #f1f5f9;
  color: var(--muted);
}

.card-actions {
  gap: 8px;
}

.icon-action {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: #1f2937;
  font-size: 18px;
  font-weight: 900;
  transition: transform 160ms ease, border-color 160ms ease, color 160ms ease;
}

.icon-action:hover {
  border-color: rgba(37, 99, 235, 0.35);
  color: var(--primary);
  transform: translateY(-1px) scale(1.02);
}

.danger-icon:hover {
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--danger);
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--muted);
  padding: 28px;
  text-align: center;
  font-weight: 750;
}

.status-line {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: var(--primary);
}

input,
textarea,
select,
.checkbox-field {
  border-radius: 10px;
  border-color: #dbe3ef;
}

.checkbox-field {
  border-radius: 14px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(37, 99, 235, 0.55);
  outline: 3px solid rgba(37, 99, 235, 0.14);
}

.student-header {
  background: linear-gradient(135deg, var(--primary), var(--accent));
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --panel: #111827;
    --panel-soft: #1f2937;
    --text: #f8fafc;
    --muted: #94a3b8;
    --line: #273244;
    --nav: #0b1220;
    --nav-soft: #172033;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
    --soft-shadow: 0 10px 26px rgba(0, 0, 0, 0.2);
  }

  body {
    background:
      radial-gradient(circle at top left, rgba(37, 99, 235, 0.18), transparent 28rem),
      var(--bg);
  }

  .sidebar,
  .topbar,
  .panel,
  .test-card,
  .question-card,
  .result-card,
  .stat-card,
  .search-box,
  .auth-card,
  .auth-tab.active,
  .user-card,
  .secondary-button,
  .panel .secondary-button,
  .icon-action,
  input,
  select,
  textarea,
  .checkbox-field {
    background: var(--panel);
    color: var(--text);
  }

  .ai-card {
    background: linear-gradient(145deg, #111827, #172033);
  }
}

@media (max-width: 1100px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .plan-overview-panel {
    grid-column: 1 / -1;
  }

  .plan-cards {
    grid-template-columns: 1fr;
  }

  .student-stats-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

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

  .student-profile-list {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .student-profile-stats {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

  .topbar-actions {
    grid-template-columns: 1fr;
  }

  .library-question-card {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "meta"
      "actions";
  }

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

  .library-question-meta {
    grid-template-columns: 1fr;
  }

  .library-filter-row,
  .library-bulk-actions,
  .library-summary,
  .question-evaluation-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

@media (max-width: 940px) {
  .sidebar {
    position: static;
    min-height: auto;
  }

  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .ai-card {
    display: none;
  }

  .test-card-main {
    grid-template-columns: 48px 1fr;
  }
}

@media (max-width: 640px) {
  .stats-grid,
  .subjects-summary,
  .nav {
    grid-template-columns: 1fr;
  }

  .test-card-main {
    grid-template-columns: 1fr;
  }

  .student-tools,
  .library-filter-row,
  .library-bulk-actions,
  .library-summary,
  .library-copy-controls,
  .question-evaluation-grid,
  .student-stats-grid,
  .student-profile-list,
  .student-profile-stats,
  .student-results-detail li {
    grid-template-columns: 1fr;
  }

  .library-question-header {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .library-copy-controls .secondary-button,
  .library-copy-controls .compact-button {
    grid-column: auto;
    width: 100%;
  }

  .library-copy-controls .secondary-button {
    width: 100%;
  }

  .library-copy-controls .compact-button {
    grid-column: auto;
    width: 100%;
  }

  .student-profile-hero,
  .student-trend-empty,
  .student-weakness-list li,
  .subject-card-head,
  .subject-test-list li {
    flex-direction: column;
  }

  .test-icon {
    width: 48px;
    height: 48px;
  }
}

/* Device optimization: desktop, tablet, Android and iOS */
html {
  -webkit-text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
}

* {
  min-width: 0;
}

img,
svg,
canvas,
video,
iframe {
  max-width: 100%;
  height: auto;
}

button,
input,
select,
textarea {
  max-width: 100%;
}

button,
.nav-button,
.primary-button,
.secondary-button,
.danger-button,
.icon-action,
.compact-button,
.category-chip,
.filter-chip,
.student-option {
  min-height: 44px;
}

.main,
.view,
.panel,
.topbar,
.topbar > div,
.topbar-actions,
.search-box,
.library-question-card,
.library-question-header,
.library-question-title,
.library-copy-controls,
.test-card-main,
.student-shell,
.student-main,
.student-start-card,
.student-question {
  min-width: 0;
}

.topbar {
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
}

.topbar-actions {
  width: min(100%, 720px);
}

.search-box input {
  min-width: 0;
}

.test-title-row,
.test-meta,
.feature-row,
.question-meta-pills,
.student-header-info {
  overflow-wrap: anywhere;
}

.library-question-card {
  overflow: hidden;
}

.library-question-title strong {
  overflow-wrap: anywhere;
}

.library-question-meta .question-meta-pills,
.library-performance {
  max-width: 100%;
}

.library-copy-controls .secondary-button,
.library-copy-controls .compact-button,
.bottom-editor-actions .primary-button,
.bottom-editor-actions .secondary-button,
.panel-actions .primary-button,
.panel-actions .secondary-button {
  white-space: nowrap;
}

.student-entry-form input,
.student-entry-form label,
.student-option,
.student-question legend {
  overflow-wrap: anywhere;
}

.student-history-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 1280px) {
  .library-layout {
    grid-template-columns: 1fr;
  }

  .library-question-card {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: auto;
    padding: 18px;
  }

  .brand {
    margin-bottom: 18px;
  }

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

  .nav-button {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  .user-card {
    max-width: none;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    min-height: auto;
  }

  .topbar-actions {
    width: 100%;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .view {
    padding: 24px;
  }

  .stats-grid,
  .subjects-summary,
  .student-profile-stats,
  .library-summary {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .test-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .card-actions {
    justify-content: flex-start;
  }

  .student-header {
    flex-direction: column;
    align-items: stretch;
  }

  .student-header-info {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .topbar-actions,
  .print-test-row,
  .library-filter-row,
  .library-bulk-actions,
  .question-evaluation-grid,
  .student-tools,
  .student-start-layout,
  .student-entry-form label,
  .student-navigation {
    grid-template-columns: 1fr;
  }

  .library-question-card {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "meta"
      "actions";
  }

  .library-copy-controls {
    max-width: none;
  }

  .library-select-box {
    justify-content: flex-start;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .checkbox-field {
    align-self: stretch;
  }

  .checkbox-field span {
    white-space: normal;
  }

  .student-main {
    padding: 20px 14px 34px;
  }

  .student-start-layout {
    gap: 24px;
    padding: 24px 18px 18px;
  }

  .student-start-button {
    margin: 0 18px 22px;
  }

  .student-entry-form {
    gap: 16px;
  }

  .student-start-info {
    font-size: 17px;
  }

  .student-start-rules {
    margin-top: 24px;
  }

  .student-navigation {
    gap: 12px;
  }

  .required-answer-message {
    text-align: left;
  }
}

@media (max-width: 560px) {
  .sidebar {
    padding: 14px;
  }

  .brand {
    align-items: flex-start;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .nav-button {
    padding: 10px;
    font-size: 14px;
  }

  .topbar {
    padding: 18px;
  }

  .topbar h1,
  h1 {
    font-size: 28px;
    line-height: 1.1;
  }

  .topbar-subtitle {
    font-size: 15px;
  }

  .view {
    padding: 18px 14px 34px;
  }

  .panel,
  .test-card,
  .question-card,
  .result-card,
  .student-question,
  .library-question-card {
    border-radius: 14px;
    padding: 16px;
  }

  .stats-grid,
  .subjects-summary,
  .student-stats-grid,
  .student-profile-list,
  .student-profile-stats,
  .library-summary {
    grid-template-columns: 1fr;
  }

  .test-card-main {
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: start;
  }

  .test-icon {
    width: 44px;
    height: 44px;
  }

  .card-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .card-actions .icon-action {
    width: 100%;
  }

  .section-actions,
  .panel-actions,
  .bottom-editor-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .section-actions button,
  .panel-actions button,
  .bottom-editor-actions button {
    width: 100%;
  }

  .library-question-header {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .library-question-title strong {
    font-size: 19px;
  }

  .library-performance > div:first-child {
    align-items: flex-start;
  }

  .student-header {
    padding: 18px;
  }

  .student-running .student-header h1,
  .student-header h1 {
    font-size: 24px;
  }

  .student-header-info span {
    white-space: normal;
  }

  .student-timer {
    width: 100%;
  }

  .student-start-card h2 {
    padding: 16px;
    font-size: 20px;
  }

  .student-question legend {
    font-size: 18px;
  }

  .student-option {
    grid-template-columns: 28px minmax(0, 1fr);
  }
}

@media (max-width: 380px) {
  .nav {
    grid-template-columns: 1fr;
  }

  .test-card-main {
    grid-template-columns: 1fr;
  }

  .card-actions {
    grid-template-columns: 1fr;
  }
}

/* Editor settings layout */
.editor-settings-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: end;
  gap: 18px 20px;
}

.editor-settings-grid > label:not(.checkbox-field) {
  grid-column: span 3;
}

.editor-settings-grid .checkbox-compact {
  grid-column: span 6;
}

.editor-settings-grid .checkbox-wide {
  grid-column: span 6;
}

.editor-settings-grid > label:nth-child(5),
.editor-settings-grid > label:nth-child(6),
.editor-settings-grid > label:nth-child(7) {
  grid-column: span 4;
}

.editor-settings-grid input:not([type="checkbox"]) {
  min-height: 56px;
  border-radius: 12px;
  padding: 12px 16px;
}

.editor-settings-grid .checkbox-field {
  min-height: 72px;
  justify-content: flex-start;
  gap: 14px;
  border-radius: 16px;
  padding: 16px 20px;
  overflow: hidden;
}

.editor-settings-grid .checkbox-field input {
  width: 22px;
  height: 22px;
}

.editor-settings-grid .checkbox-field span {
  flex: 1 1 auto;
  font-size: 16px;
  line-height: 1.25;
  white-space: nowrap;
}

@media (max-width: 1320px) {
  .editor-settings-grid > label:not(.checkbox-field),
  .editor-settings-grid > label:nth-child(5),
  .editor-settings-grid > label:nth-child(6),
  .editor-settings-grid > label:nth-child(7) {
    grid-column: span 6;
  }

  .editor-settings-grid .checkbox-compact,
  .editor-settings-grid .checkbox-wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .editor-settings-grid > label:not(.checkbox-field),
  .editor-settings-grid .checkbox-compact,
  .editor-settings-grid .checkbox-wide {
    grid-column: 1 / -1;
  }

  .editor-settings-grid .checkbox-field span {
    white-space: normal;
  }
}

/* AI question generator */
.ai-card {
  cursor: pointer;
}

.ai-card:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.25);
  outline-offset: 3px;
}

.ai-generator-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  gap: 24px;
  align-items: start;
}

.ai-generator-panel textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  line-height: 1.55;
}

.ai-upload-box {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  padding: 16px;
  border: 1px dashed #bfdbfe;
  border-radius: 16px;
  background: #f8fbff;
}

.ai-upload-box p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.ai-upload-field {
  display: grid;
  gap: 10px;
  font-weight: 800;
}

.ai-upload-field input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  font-weight: 700;
}

.ai-generator-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.ai-generator-grid > label {
  min-width: 0;
}

.ai-generator-grid select,
.ai-generator-grid input {
  width: 100%;
  min-width: 0;
}

.ai-generator-grid .ai-target-field {
  grid-column: 1 / -1;
}

.ai-target-field select {
  min-height: 58px;
  padding-right: 44px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ai-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.ai-actions button {
  min-height: 52px;
}

.ai-status {
  min-height: 24px;
  margin-top: 14px;
  color: var(--muted);
  font-weight: 700;
}

.ai-status.success {
  color: #047857;
}

.ai-status.error {
  color: #ef4444;
}

.ai-status.loading {
  color: #2563eb;
}

.ai-status.warning {
  color: #b45309;
}

.ai-fill-missing-button:not([hidden]) {
  border-color: #f59e0b;
  color: #92400e;
  background: #fffbeb;
}

.ai-preview-list {
  display: grid;
  gap: 16px;
}

.ai-question-preview {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #f8fafc;
}

.ai-question-select {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-weight: 800;
  color: var(--muted);
}

.ai-question-select input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
}

.ai-question-preview h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
}

.ai-question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.ai-question-meta span {
  padding: 6px 12px;
  border-radius: 999px;
  background: #eef2ff;
  color: #2563eb;
  font-size: 13px;
  font-weight: 800;
}

.ai-question-preview ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ai-question-preview li {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #ffffff;
  color: var(--text);
}

.ai-question-preview li.correct {
  background: #ecfdf5;
  color: #047857;
  font-weight: 800;
}

.advanced-settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 18px;
  margin: 18px 0 24px;
}

.advanced-panel {
  margin: 0;
}

.advanced-panel-wide {
  grid-column: 1 / -1;
}

.grade-scale-list,
.certificate-settings,
.closed-group-settings {
  display: grid;
  gap: 12px;
}

.grade-scale-row {
  display: grid;
  grid-template-columns: minmax(90px, 0.35fr) minmax(220px, 1fr) minmax(150px, 0.42fr) auto;
  gap: 12px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fafc;
}

.grade-scale-row label {
  min-width: 0;
}

.grade-scale-row input[type="text"],
.grade-scale-row input[type="number"] {
  min-height: 46px;
}

.grade-certificate-field {
  min-height: 46px;
  margin: 0;
  white-space: nowrap;
}

.result-card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.result-card-actions .secondary-button,
.result-card-actions .danger-button {
  min-width: 150px;
}

@media (max-width: 1200px) {
  .ai-generator-layout {
    grid-template-columns: 1fr;
  }

  .catalog-actions {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
    min-width: 0;
  }

  .catalog-meta-grid {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }
}

@media (max-width: 1100px) {
  .advanced-settings-grid {
    grid-template-columns: 1fr;
  }

  .catalog-toolbar,
  .catalog-merge-panel {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .catalog-merge-panel button {
    width: 100%;
  }

  .catalog-export-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .ai-generator-grid {
    grid-template-columns: 1fr;
  }

  .ai-actions {
    display: grid;
  }

  .ai-question-preview {
    grid-template-columns: 1fr;
  }

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

  .result-card-actions {
    justify-content: flex-start;
  }

  .result-card-actions .secondary-button,
  .result-card-actions .danger-button {
    width: 100%;
  }

  .catalog-toolbar,
  .catalog-merge-panel,
  .catalog-card,
  .catalog-actions,
  .catalog-meta-grid {
    grid-template-columns: 1fr;
  }

  .catalog-card-head {
    flex-direction: column;
  }

  .catalog-actions {
    grid-column: auto;
  }

  .catalog-export-actions,
  .catalog-export-actions button {
    width: 100%;
  }
}
