:root {
  --bg: #f4f6f7;
  --bg-soft: #eef2f4;
  --panel: #ffffff;
  --text: #12364a;
  --heading: #004b73;
  --muted: #667987;
  --line: #d8d9db;
  --line-strong: #bcc4ca;
  --accent: #36a0de;
  --accent-dark: #008dc6;
  --accent-deep: #006f9d;
  --accent-soft: #eaf7fd;
  --gray-brand: #d8d9db;
  --danger: #b42318;
  --success: #067647;
  --warning: #9a6700;
  --shadow: 0 18px 42px rgba(0, 76, 116, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(0, 141, 198, 0.07) 0, rgba(0, 141, 198, 0.07) 4px, transparent 4px) 0 0 / 96px 96px,
    linear-gradient(180deg, #ffffff 0, var(--bg) 280px, var(--bg-soft) 100%);
  color: var(--text);
  font-family: "Univia Pro", "Segoe UI", Arial, sans-serif;
  line-height: 1.55;
}

a {
  color: var(--accent-deep);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 10px 32px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

.topbar::before {
  content: "";
  position: fixed;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--accent-dark);
  pointer-events: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  color: var(--heading);
  text-decoration: none;
}

.brand-mark {
  width: 76px;
  height: auto;
  display: block;
  flex: 0 0 auto;
}

.brand-copy {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.brand-copy strong {
  color: var(--accent-dark);
  font-size: 20px;
  line-height: 1.05;
}

.brand-copy small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.code-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #fff;
  font-size: 14px;
  font-weight: 700;
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 32px auto 64px;
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

.message {
  padding: 12px 14px;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 76, 116, 0.05);
}

.message-error {
  color: var(--danger);
  border-color: #f0b8b8;
}

.message-success {
  color: var(--success);
  border-color: #a9d6bd;
}

.login-panel,
.exam-head,
.task-card,
.admin-card {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 32px;
  padding: 34px;
  align-items: center;
  overflow: hidden;
}

.login-panel::before,
.exam-head::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
}

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

h1 {
  color: var(--heading);
  font-size: 34px;
  line-height: 1.15;
  margin-bottom: 8px;
}

h2 {
  color: var(--heading);
  font-size: 22px;
  line-height: 1.25;
  margin-bottom: 10px;
}

h3 {
  color: var(--text);
  font-size: 16px;
  margin-bottom: 12px;
}

.login-panel p,
.exam-head p,
.muted {
  color: var(--muted);
}

.candidate-line {
  margin-bottom: 8px;
}

.login-form,
.upload-form,
.admin-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: #284b5f;
  font-size: 14px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  font: inherit;
  background: #fff;
}

input:focus,
textarea:focus {
  border-color: var(--accent-dark);
  box-shadow: 0 0 0 3px rgba(54, 160, 222, 0.16);
  outline: none;
}

textarea {
  resize: vertical;
}

button,
.primary-action,
.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

button,
.primary-action {
  color: #fff;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  border-color: var(--accent-dark);
}

.secondary-button {
  min-height: 34px;
  padding: 6px 10px;
  color: var(--accent-deep);
  background: var(--accent-soft);
  border-color: #b9dfef;
}

button:hover,
.primary-action:hover {
  background: linear-gradient(135deg, var(--accent-deep), var(--accent-dark));
}

.secondary-button:hover {
  color: #fff;
  background: var(--accent-dark);
}

button:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.download-link {
  color: var(--accent-deep);
  background: var(--accent-soft);
  border-color: #b9dfef;
}

.download-link:hover {
  color: #fff;
  background: var(--accent-dark);
}

.task-materials-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.task-materials-list h3 {
  flex-basis: 100%;
  margin-bottom: 0;
}

.exam-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 28px 26px 32px;
  margin-bottom: 20px;
  overflow: hidden;
}

.timer {
  min-width: 150px;
  padding: 12px 14px;
  border: 1px solid #b9dfef;
  border-radius: 8px;
  text-align: center;
  background: linear-gradient(180deg, #ffffff, var(--accent-soft));
}

.timer-label,
.timer-expired {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.timer strong {
  display: block;
  color: var(--accent-deep);
  font-size: 28px;
  line-height: 1.2;
}

.timer-expired {
  color: var(--danger);
  font-weight: 800;
}

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

.task-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  gap: 28px;
  padding: 24px;
}

.task-main p {
  white-space: pre-line;
}

.inline-task {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}

.inline-section {
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--gray-brand);
  border-radius: 8px;
  background: #fbfcfd;
}

.inline-section h3 {
  margin-bottom: 8px;
  color: var(--accent-deep);
}

.inline-section p:last-child,
.inline-section ol:last-child {
  margin-bottom: 0;
}

.inline-section ol {
  padding-left: 22px;
}

.inline-section li + li {
  margin-top: 6px;
}

.inline-section-accent {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.inline-section-question {
  border-left-color: #d69e2e;
  background: #fff8e6;
}

.inline-section-compact {
  border-left-color: #42b883;
  background: #eefaf3;
}

.answer-panel {
  border-left: 1px solid var(--line);
  padding-left: 28px;
}

.answer-hint {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 14px;
}

.current-answer {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  font-size: 14px;
}

pre {
  overflow: auto;
  margin: 8px 0 0;
  padding: 10px;
  border-radius: 6px;
  background: #eef2f4;
  white-space: pre-wrap;
}

.admin-list {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
  gap: 16px;
}

.admin-card {
  padding: 20px;
}

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

.status {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.status.active {
  color: var(--success);
  background: #e9f8ef;
}

.status.expired {
  color: var(--warning);
  background: #fff4d6;
}

.admin-submissions {
  display: grid;
  gap: 10px;
}

.admin-submissions > div {
  display: grid;
  grid-template-columns: 110px 170px 1fr;
  gap: 12px;
  align-items: start;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.compact-form {
  grid-template-columns: 1fr;
  align-items: end;
}

.compact-form button {
  grid-column: 1 / -1;
  justify-self: start;
}

.task-file-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin: 14px 0 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.task-materials {
  margin: 14px 0 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.task-materials .task-file-form {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.material-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.material-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.material-row span {
  overflow-wrap: anywhere;
}

.task-edit-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.task-edit-form label:nth-child(2),
.task-edit-form label:nth-child(4),
.task-edit-form button {
  grid-column: 1 / -1;
}

.candidate-table {
  display: grid;
  gap: 8px;
}

.candidate-row {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) 160px 100px 70px 100px;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.candidate-row-head {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  border-top: 0;
  padding-top: 0;
}

.candidate-row code {
  word-break: break-word;
}

.inline-candidate-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

@media (max-width: 840px) {
  .topbar {
    padding: 10px 16px;
  }

  .brand {
    gap: 10px;
  }

  .brand-mark {
    width: 58px;
  }

  .brand-copy strong {
    font-size: 17px;
  }

  .brand-copy small {
    font-size: 10px;
  }

  .login-panel,
  .task-card,
  .exam-head {
    grid-template-columns: 1fr;
  }

  .exam-head {
    display: grid;
  }

  .answer-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 20px;
  }

  .admin-submissions > div {
    grid-template-columns: 1fr;
  }

  .admin-grid,
  .compact-form,
  .task-file-form,
  .material-row,
  .task-edit-form,
  .candidate-row,
  .inline-candidate-form {
    grid-template-columns: 1fr;
  }
}
