@font-face {
  font-family: "Montserrat";
  src: url("fonts/Montserrat-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Montserrat";
  src: url("fonts/Montserrat-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Montserrat";
  src: url("fonts/Montserrat-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Montserrat";
  src: url("fonts/Montserrat-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Forum";
  src: url("fonts/Forum-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --basis-red: #960000;
  --basis-red-dark: #600006;
  --basis-red-bright: #c80c16;
  --basis-orange: #ff8112;
  --basis-navy: #0e1940;
  --basis-plum: #380104;
  --bg: #f7f5f4;
  --bg-soft: #f1eeee;
  --panel: #ffffff;
  --text: #211e1e;
  --muted: #6c6b6b;
  --line: #e3dddd;
  --line-strong: #cabebe;
  --danger: #b42318;
  --success: #067647;
  --warning: #9a6700;
  --shadow: 0 24px 70px rgba(56, 1, 4, 0.09);
  --shadow-soft: 0 12px 34px rgba(56, 1, 4, 0.07);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 92% 12%, rgba(150, 0, 0, 0.09) 0 1px, transparent 2px) 0 0 / 24px 24px,
    radial-gradient(circle at 8% 90%, rgba(14, 25, 64, 0.06), transparent 28rem),
    linear-gradient(180deg, #fff 0, var(--bg) 24rem, var(--bg-soft) 100%);
  color: var(--text);
  font-family: "Montserrat", "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

a {
  color: var(--basis-red);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

a:hover {
  color: var(--basis-red-bright);
}

.topbar {
  position: relative;
  z-index: 10;
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 14px max(28px, calc((100vw - 1240px) / 2));
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid rgba(150, 0, 0, 0.13);
  box-shadow: 0 7px 30px rgba(56, 1, 4, 0.04);
  backdrop-filter: blur(18px);
}

.topbar::after {
  content: "";
  position: absolute;
  inset: auto 0 -1px 0;
  height: 2px;
  background: linear-gradient(90deg, var(--basis-red) 0 8%, var(--basis-orange) 8% 10%, transparent 10%);
}

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

.brand-mark {
  width: 138px;
  height: 43px;
  display: block;
  flex: 0 0 auto;
  object-fit: contain;
}

.brand-copy {
  position: relative;
  display: grid;
  gap: 0;
  padding-left: 22px;
  min-width: 0;
}

.brand-copy::before {
  content: "";
  position: absolute;
  inset: 3px auto 3px 0;
  width: 1px;
  background: var(--line-strong);
}

.brand-copy strong {
  color: var(--basis-navy);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.25;
}

.brand-copy small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.17em;
  line-height: 1.4;
  text-transform: uppercase;
}

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

.topnav > a {
  font-size: 13px;
  font-weight: 600;
}

.code-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid rgba(150, 0, 0, 0.18);
  border-radius: 999px;
  color: var(--basis-red);
  background: #fff8f7;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.page {
  width: min(1240px, calc(100% - 40px));
  margin: 42px auto 72px;
}

.messages {
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
}

.message {
  padding: 13px 16px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--basis-navy);
  box-shadow: var(--shadow-soft);
}

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

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

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

.login-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(360px, 0.88fr);
  min-height: 420px;
  border-radius: 24px;
  overflow: hidden;
}

.login-panel > div:first-child {
  position: relative;
  z-index: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(36px, 6vw, 76px);
  color: #fff;
  background:
    radial-gradient(circle at 82% 18%, rgba(255, 129, 18, 0.88) 0 5px, transparent 6px),
    radial-gradient(circle at 78% 24%, rgba(255, 255, 255, 0.2) 0 34px, transparent 36px),
    radial-gradient(circle at 95% 78%, rgba(255, 255, 255, 0.12) 0 92px, transparent 94px),
    linear-gradient(135deg, var(--basis-plum), var(--basis-red) 66%, #c30b15);
  isolation: isolate;
}

.login-panel > div:first-child::after {
  content: "";
  position: absolute;
  z-index: -1;
  width: 230px;
  height: 230px;
  right: -90px;
  bottom: -105px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 50%;
  box-shadow: 0 0 0 34px rgba(255, 255, 255, 0.04), 0 0 0 68px rgba(255, 255, 255, 0.03);
}

.login-panel > div:only-child {
  grid-column: 1 / -1;
  min-height: 360px;
}

.login-panel > .login-form {
  align-content: center;
  padding: clamp(32px, 5vw, 64px);
  background: #fff;
}

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

h1 {
  color: var(--basis-plum);
  font-family: "Forum", Georgia, serif;
  font-size: clamp(38px, 5vw, 52px);
  font-weight: 400;
  line-height: 1.04;
  margin-bottom: 12px;
}

.login-panel > div:first-child h1 {
  max-width: 580px;
  color: #fff;
  font-size: clamp(46px, 6vw, 66px);
}

.login-panel > div:first-child p {
  max-width: 610px;
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.84);
  font-size: 16px;
}

h2 {
  color: var(--basis-plum);
  font-size: 21px;
  line-height: 1.32;
  margin-bottom: 10px;
}

h3 {
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  margin-bottom: 12px;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--basis-red);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  display: inline-block;
  width: 28px;
  height: 2px;
  margin: 0 10px 3px 0;
  background: var(--basis-orange);
}

.login-panel .eyebrow {
  color: #fff;
}

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

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

.test-intro {
  max-width: 760px;
  color: var(--muted);
  white-space: pre-line;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--basis-navy);
  font-size: 13px;
  font-weight: 600;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 11px 13px;
  color: var(--text);
  font: inherit;
  background: #fff;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--basis-red);
  box-shadow: 0 0 0 4px rgba(150, 0, 0, 0.1);
  outline: none;
}

textarea {
  resize: vertical;
}

button,
.primary-action,
.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 43px;
  padding: 10px 17px;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

button,
.primary-action {
  color: #fff;
  background: linear-gradient(135deg, var(--basis-red-dark), var(--basis-red) 58%, var(--basis-red-bright));
  border-color: var(--basis-red);
  box-shadow: 0 10px 24px rgba(150, 0, 0, 0.18);
}

button:hover,
.primary-action:hover {
  color: #fff;
  background: linear-gradient(135deg, var(--basis-red), var(--basis-red-bright));
  box-shadow: 0 12px 28px rgba(150, 0, 0, 0.25);
  transform: translateY(-1px);
}

.secondary-button,
.download-link {
  color: var(--basis-red);
  background: #fff8f7;
  border-color: rgba(150, 0, 0, 0.22);
  box-shadow: none;
}

.secondary-button:hover,
.download-link:hover {
  color: #fff;
  background: var(--basis-red);
  border-color: var(--basis-red);
}

.danger-button {
  min-height: 36px;
  padding: 7px 12px;
  color: var(--danger);
  background: #fff;
  border-color: rgba(180, 35, 24, 0.35);
  box-shadow: none;
}

.danger-button:hover {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
  box-shadow: 0 8px 18px rgba(180, 35, 24, 0.2);
}

button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

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

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

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

.exam-head::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--basis-red) 0 78%, var(--basis-orange) 78% 86%, var(--basis-navy) 86%);
}

.exam-head h1 {
  font-size: clamp(38px, 4vw, 48px);
}

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

.timer {
  min-width: 168px;
  padding: 14px 18px;
  border: 1px solid rgba(150, 0, 0, 0.2);
  border-radius: 14px;
  text-align: center;
  background: linear-gradient(180deg, #fff, #fff5f3);
}

.timer-label,
.timer-expired {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.timer strong {
  display: block;
  color: var(--basis-red);
  font-size: 29px;
  line-height: 1.25;
}

.timer-expired {
  color: var(--danger);
  letter-spacing: 0.04em;
}

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

.task-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 400px);
  gap: 0;
  border-radius: 20px;
  overflow: hidden;
}

.task-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--basis-red);
}

.task-main,
.answer-panel {
  padding: 28px;
}

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

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

.inline-section {
  padding: 17px;
  border: 1px solid var(--line);
  border-left: 4px solid #b6a9a9;
  border-radius: 10px;
  background: #fbfafa;
}

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

.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(--basis-red);
  background: #fff6f5;
}

.inline-section-question {
  border-left-color: var(--basis-orange);
  background: #fff8ef;
}

.inline-section-compact {
  border-left-color: var(--basis-navy);
  background: #f4f6fb;
}

.answer-panel {
  border-left: 1px solid var(--line);
  background: #fbf9f9;
}

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

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

pre {
  overflow: auto;
  margin: 8px 0 0;
  padding: 12px;
  border-radius: 9px;
  color: var(--basis-navy);
  background: #f0eeee;
  white-space: pre-wrap;
}

.admin-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-soft);
}

.admin-nav a {
  padding: 9px 14px;
  border-radius: 9px;
  color: var(--basis-navy);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.admin-nav a:hover,
.admin-nav a.active {
  color: #fff;
  background: var(--basis-red);
}

.admin-nav .admin-nav-logout {
  margin-left: auto;
  color: var(--muted);
}

.admin-page-head {
  margin-bottom: 18px;
}

.admin-breadcrumbs {
  display: flex;
  gap: 9px;
  align-items: center;
  margin: 4px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.test-catalog {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.test-catalog-card {
  display: grid;
  gap: 18px;
  min-height: 250px;
  padding: 24px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--basis-red);
  border-radius: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-soft);
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.test-catalog-card:hover {
  transform: translateY(-3px);
  border-color: rgba(150, 0, 0, 0.35);
  box-shadow: var(--shadow);
}

.test-catalog-card h2 {
  margin: 7px 0 4px;
}

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

.test-catalog-card dl {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0;
}

.test-catalog-card dl > div {
  padding: 10px;
  border-radius: 10px;
  background: var(--bg-soft);
}

.test-catalog-card dt {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.test-catalog-card dd {
  margin: 3px 0 0;
  color: var(--basis-navy);
  font-size: 20px;
  font-weight: 700;
}

.test-catalog-link {
  align-self: end;
  color: var(--basis-red);
  font-size: 13px;
  font-weight: 700;
}

.section-heading {
  padding: 8px 4px 0;
}

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

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

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

.admin-card {
  padding: 23px;
  border-radius: 16px;
  box-shadow: var(--shadow-soft);
}

.task-create-card {
  border-top: 3px solid var(--basis-orange);
}

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

.admin-card-head > h2 {
  margin-bottom: 0;
}

.admin-card-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.status {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.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: 11px;
  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: 15px 0 19px;
  padding-bottom: 19px;
  border-bottom: 1px solid var(--line);
}

.task-materials {
  margin: 15px 0 19px;
  padding-bottom: 19px;
  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: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfafa;
}

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

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

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

.test-settings-card {
  border-top: 3px solid var(--basis-red);
}

.test-settings-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 18px;
}

.test-settings-form label:nth-of-type(5),
.test-settings-form label:nth-of-type(6),
.test-settings-form button {
  grid-column: 1 / -1;
}

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

.candidate-row {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) 125px 165px 80px 52px 102px 92px;
  gap: 10px;
  align-items: center;
  min-width: 850px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}

.candidate-row-head {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-top: 0;
  padding-top: 0;
}

.candidate-row code {
  color: var(--basis-red);
  word-break: break-word;
}

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

.candidate-test-form {
  display: grid;
  gap: 6px;
}

.candidate-test-form select,
.candidate-test-form button {
  width: 100%;
}

.site-footer {
  width: min(1240px, calc(100% - 40px));
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto;
  padding: 22px 0 30px;
  border-top: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 900px) {
  .topbar {
    padding: 13px 20px;
  }

  .brand-copy {
    display: none;
  }

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

  .login-panel {
    min-height: 0;
  }

  .exam-head {
    display: grid;
  }

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

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

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

  .candidate-row {
    min-width: 0;
  }

  .admin-card-head {
    align-items: flex-start;
  }

  .admin-card-head-actions {
    align-items: flex-end;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .admin-nav {
    flex-wrap: wrap;
  }

  .admin-nav a {
    flex: 1 1 auto;
    text-align: center;
  }

  .admin-nav .admin-nav-logout {
    margin-left: 0;
  }

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

  .topbar {
    min-height: 76px;
    gap: 12px;
  }

  .brand-mark {
    width: 108px;
    height: auto;
  }

  .topnav {
    gap: 10px;
  }

  .code-chip {
    max-width: 135px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .page {
    width: min(100% - 24px, 1240px);
    margin-top: 24px;
    margin-bottom: 46px;
  }

  .login-panel {
    border-radius: 18px;
  }

  .login-panel > div:first-child,
  .login-panel > .login-form,
  .task-main,
  .answer-panel,
  .exam-head,
  .admin-card {
    padding: 22px;
  }

  .login-panel > div:first-child {
    min-height: 300px;
  }

  .site-footer {
    width: min(100% - 24px, 1240px);
    flex-direction: column;
    gap: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
