:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #17211d;
  --muted: #66736d;
  --line: #dbe1dc;
  --accent: #007f73;
  --accent-dark: #005f55;
  --warn: #a55f00;
  --soft: #e8f4ef;
  --shadow: 0 10px 30px rgba(16, 24, 20, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  min-height: 44px;
  padding: 0 18px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.primary {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

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

.secondary,
.link-button {
  background: #e5ebe7;
  color: var(--ink);
  text-decoration: none;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  font-weight: 700;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #1f2a24;
  color: #fff;
  padding: 16px clamp(16px, 4vw, 42px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: clamp(24px, 4vw, 36px);
  line-height: 1;
}

.eyebrow {
  margin: 0;
  color: #718078;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar .eyebrow {
  color: #bdd5cb;
}

.timer {
  min-width: 104px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  padding: 10px 14px;
  text-align: center;
  font-size: 24px;
  font-weight: 800;
  color: #ffe6b3;
  background: rgba(255, 255, 255, 0.08);
}

.shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 42px);
}

.admin-shell {
  width: min(1280px, 100%);
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.admin-shell > .panel:not(.active) {
  display: none;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(22px, 5vw, 36px);
}

.narrow {
  width: min(520px, 100%);
  margin: clamp(26px, 7vw, 80px) auto;
}

.centered {
  text-align: center;
}

.panel h2,
.exam-head h2,
.admin-head h2 {
  margin: 6px 0 0;
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1.12;
}

.form {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #c8d2cc;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 127, 115, 0.16);
}

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

.exam-head,
.admin-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.admin-head.compact {
  margin-top: 34px;
}

.admin-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}

.admin-tab {
  min-height: 42px;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.admin-tab.active {
  background: var(--panel);
  color: var(--accent-dark);
  box-shadow: inset 0 -3px 0 var(--accent);
}

.admin-tab-panel {
  display: none;
}

.admin-tab-panel.active {
  display: block;
}

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

.section-heading h2 {
  margin: 6px 0 0;
}

.question-import-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1.3fr) minmax(210px, 1fr) minmax(210px, 1fr) auto auto;
  gap: 12px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  margin-bottom: 18px;
  padding: 16px;
}

.question-import-panel p {
  margin: 5px 0 0;
}

.question-import-panel > .muted {
  grid-column: 1 / -1;
}

.progressbox {
  width: min(300px, 44vw);
  color: var(--muted);
  font-weight: 700;
}

.progressbar {
  height: 10px;
  border-radius: 8px;
  background: #dfe6e1;
  overflow: hidden;
  margin-top: 8px;
}

.progressbar span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--accent);
}

.notice {
  border: 1px solid #f0c36d;
  border-left: 6px solid var(--warn);
  border-radius: 8px;
  background: #fff7e8;
  color: #5e3b00;
  padding: 14px 16px;
  margin-bottom: 18px;
  font-weight: 700;
}

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

.question {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(18px, 4vw, 28px);
}

.question-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.tag,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 8px;
  padding: 0 10px;
  background: var(--soft);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}

.topic {
  margin: 16px 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.question h3 {
  margin: 0 0 16px;
  font-size: clamp(18px, 2.4vw, 22px);
  line-height: 1.35;
}

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

.option {
  display: grid;
  grid-template-columns: 22px 34px 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid #d6ded8;
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfb;
}

.option input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.option-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  min-height: 24px;
  border-radius: 6px;
  background: #e1e8e3;
  color: var(--ink);
  font-weight: 800;
}

.submitbar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  background: rgba(255, 255, 255, 0.96);
  margin-top: 20px;
  padding: 14px;
  box-shadow: 0 -10px 28px rgba(16, 24, 20, 0.08);
}

.muted {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.link-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 18px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.metrics div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.metrics strong {
  display: block;
  margin-top: 6px;
  color: var(--accent-dark);
  font-size: clamp(24px, 4vw, 34px);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

th,
td {
  border-bottom: 1px solid #e5eae6;
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef3ef;
  color: #3e4b45;
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.status.submitted {
  background: #e5f5e7;
  color: #1d6b2f;
}

.status.in_progress {
  background: #fff2dc;
  color: #8a5300;
}

.small-button {
  min-height: 34px;
  padding: 0 12px;
  white-space: nowrap;
}

.editor-dialog {
  width: min(920px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.3);
}

.editor-dialog::backdrop {
  background: rgba(15, 24, 20, 0.62);
}

.editor-dialog form {
  display: grid;
  gap: 20px;
  padding: clamp(20px, 4vw, 32px);
}

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

.editor-head h2 {
  margin: 6px 0 0;
}

.icon-button {
  width: 42px;
  min-width: 42px;
  padding: 0;
  background: #e8ece9;
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(180px, 1fr);
  gap: 16px;
}

.field-title {
  display: block;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.editor-section-head p {
  margin: 5px 0 0;
}

.option-editor-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.option-editor-row {
  display: grid;
  grid-template-columns: 58px minmax(240px, 1fr) 92px 84px;
  gap: 10px;
  align-items: center;
}

.editor-option-id {
  text-align: center;
  font-weight: 800;
  background: #eef3ef;
}

.correct-option {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
}

.correct-option input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.correct-option span {
  margin: 0;
  color: var(--ink);
}

.editor-actions {
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.editor-actions > div {
  display: flex;
  gap: 10px;
}

.hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
  }

  .shell {
    padding: 16px;
  }

  .exam-head,
  .admin-head,
  .submitbar {
    align-items: stretch;
    flex-direction: column;
  }

  .progressbox {
    width: 100%;
  }

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

  .option {
    grid-template-columns: 22px 30px 1fr;
    padding: 11px;
  }

  .admin-tabs {
    overflow-x: auto;
  }

  .admin-tab {
    flex: 0 0 auto;
  }

  .editor-grid,
  .option-editor-row,
  .question-import-panel {
    grid-template-columns: 1fr;
  }

  .question-import-panel > .muted {
    grid-column: auto;
  }

  .option-editor-row {
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
  }

  .editor-section-head,
  .editor-actions {
    flex-direction: column;
  }

  .editor-actions > div {
    width: 100%;
  }

  .editor-actions button {
    flex: 1;
  }
}

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

  .timer {
    min-width: 92px;
    font-size: 20px;
  }
}
