:root {
  --ink: #16263b;
  --ink-2: #314052;
  --paper: #f3efe5;
  --surface: #fffdf8;
  --surface-2: #e9e4d8;
  --accent: #e66b3c;
  --accent-dark: #b94622;
  --green: #2f7d61;
  --red: #b84943;
  --line: #cfc7b8;
  --muted: #716f69;
  --shadow: 4px 4px 0 rgba(22, 38, 59, .14);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Manrope", system-ui, sans-serif;
  background:
    linear-gradient(rgba(22,38,59,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22,38,59,.035) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(230,107,60,.4); outline-offset: 3px; }
a { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, .serif { font-family: "PT Serif", Georgia, serif; }

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(420px, 560px);
}
.login-story {
  padding: clamp(40px, 7vw, 100px);
  background: var(--ink);
  color: var(--paper);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}
.login-story::after {
  content: "";
  position: absolute;
  width: 330px;
  height: 330px;
  right: -90px;
  bottom: 80px;
  border: 55px solid var(--accent);
  border-radius: 50%;
  opacity: .92;
}
.brand { display: inline-flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: .02em; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; background: var(--accent); color: white; border-radius: 10px; font-weight: 800; }
.login-copy { max-width: 680px; position: relative; z-index: 1; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 800; }
.login-copy h1 { font-size: clamp(44px, 6vw, 78px); line-height: .98; margin: 18px 0 24px; max-width: 760px; }
.login-copy p { color: #c8d0d8; font-size: 18px; line-height: 1.65; max-width: 590px; }
.login-panel { display: grid; place-items: center; padding: 40px; background: var(--surface); }
.login-card { width: 100%; max-width: 390px; }
.login-card h2 { font-size: 38px; margin-bottom: 10px; }
.muted { color: var(--muted); }

.field { display: grid; gap: 7px; margin-bottom: 17px; }
.field label, .field-label { font-size: 13px; font-weight: 800; color: var(--ink-2); }
input, textarea, select {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
  transition: border .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(230,107,60,.14); }
textarea { min-height: 120px; resize: vertical; line-height: 1.55; }

.btn {
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  padding: 11px 16px;
  background: white;
  color: var(--ink);
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  box-shadow: 2px 2px 0 rgba(22,38,59,.12);
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); border-color: var(--accent-dark); color: white; }
.btn-dark { background: var(--ink); color: white; }
.btn-ghost { border-color: transparent; box-shadow: none; background: transparent; }
.btn-danger { color: var(--red); border-color: #d9aaa6; background: #fff8f6; }
.btn-small { min-height: 34px; padding: 7px 10px; font-size: 13px; box-shadow: none; }
.btn-full { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px 1fr; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 26px 18px;
  background: var(--ink);
  color: white;
  display: flex;
  flex-direction: column;
}
.sidebar .brand { padding: 0 8px 28px; }
.nav { display: grid; gap: 6px; }
.nav button {
  appearance: none;
  border: 0;
  background: transparent;
  color: #bbc6d0;
  text-align: left;
  padding: 12px 14px;
  border-radius: 9px;
  font-weight: 700;
}
.nav button:hover, .nav button.active { color: white; background: rgba(255,255,255,.09); }
.nav .badge { float: right; background: var(--accent); color: white; min-width: 22px; padding: 2px 6px; border-radius: 999px; text-align: center; font-size: 11px; }
.sidebar-user { margin-top: auto; padding: 18px 8px 0; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-user strong, .sidebar-user span { display: block; }
.sidebar-user span { font-size: 12px; color: #9da9b5; margin-top: 4px; }
.sidebar-user button { color: #cbd3da; padding-left: 0; margin-top: 8px; }

.main { min-width: 0; padding: 34px clamp(22px, 4vw, 56px) 70px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.page-head h1 { font-size: clamp(32px, 4vw, 52px); margin-bottom: 6px; }
.page-head p { margin: 0; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 30px; }
.stat, .card {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat { padding: 20px; }
.stat span { display: block; color: var(--muted); font-size: 13px; font-weight: 700; }
.stat strong { display: block; font-family: "PT Serif", Georgia, serif; font-size: 38px; margin-top: 7px; }
.stat.accent { background: var(--accent); border-color: var(--accent-dark); color: white; }
.stat.accent span { color: #ffe5dc; }
.card { padding: 22px; }
.card + .card { margin-top: 16px; }
.card h3 { margin-bottom: 7px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 18px; }
.card-head p { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.list { display: grid; gap: 12px; }
.notification { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 0; border-bottom: 1px solid var(--surface-2); }
.notification:last-child { border: 0; }
.notification.unread::before { content: ""; width: 9px; height: 9px; flex: 0 0 auto; background: var(--accent); border-radius: 50%; }
.notification.unread .notification-body { margin-left: -4px; }
.notification-body { flex: 1; }
.notification time, .meta { color: var(--muted); font-size: 12px; }
.empty { padding: 34px; border: 1.5px dashed var(--line); border-radius: var(--radius); text-align: center; color: var(--muted); }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 13px 10px; border-bottom: 1px solid var(--surface-2); vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
tr:last-child td { border-bottom: 0; }
.status { display: inline-flex; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.status-green { background: #dcefe7; color: #24634d; }
.status-orange { background: #fbe1d7; color: #9a3d1f; }
.status-gray { background: #e9e7e1; color: #5d5c58; }
.status-red { background: #f5deda; color: #943a35; }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(13,25,40,.62); display: grid; place-items: center; padding: 24px; }
.modal { width: min(720px, 100%); max-height: calc(100vh - 48px); overflow: auto; background: var(--surface); border-radius: 16px; border: 1.5px solid var(--ink); box-shadow: 8px 8px 0 rgba(0,0,0,.22); padding: 24px; }
.modal-wide { width: min(1120px, 100%); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.modal-head h2 { font-size: 30px; margin-bottom: 4px; }
.test-confirm { width: min(520px, 100%); text-align: center; padding: 34px; }
.test-confirm h2 { font-size: 34px; margin: 10px 0 15px; }
.test-confirm p { color: var(--ink-2); line-height: 1.6; }
.test-confirm .card-actions { justify-content: center; margin-top: 24px; }
.confirm-note { margin-top: 20px; padding: 16px 18px; display: grid; gap: 7px; text-align: left; background: var(--paper); border: 1.5px solid var(--line); border-radius: 10px; color: var(--ink-2); font-size: 14px; }
.confirm-note span::before { content: "•"; margin-right: 9px; color: var(--accent); font-weight: 800; }
.confirm-clock { width: 70px; height: 70px; margin: 0 auto 18px; display: grid; place-items: center; border: 3px solid var(--accent); border-radius: 50%; color: var(--accent); font-family: "PT Serif", Georgia, serif; font-size: 28px; position: relative; }
.confirm-clock::after { content: "мин"; position: absolute; bottom: 8px; font-family: "Manrope", sans-serif; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.icon-btn { width: 38px; height: 38px; border: 0; background: var(--surface-2); border-radius: 50%; font-size: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.checkbox-grid { display: grid; gap: 9px; padding: 12px; background: var(--paper); border-radius: 10px; }
.check { display: flex; gap: 9px; align-items: center; font-size: 14px; }
.check input { width: auto; }

.editor-stage { border: 1.5px solid var(--line); background: white; border-radius: 12px; padding: 18px; margin-top: 14px; }
.editor-stage-head { display: grid; grid-template-columns: 1fr 150px 130px auto; gap: 12px; align-items: end; }
.question-editor, .round-editor { margin-top: 12px; padding: 15px; background: var(--paper); border-radius: 10px; }
.options-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.inline-row { display: flex; align-items: center; gap: 10px; }
.inline-row > * { flex: 1; }
.editor-footer { position: sticky; bottom: -24px; display: flex; justify-content: flex-end; gap: 10px; padding: 16px 0 2px; background: var(--surface); border-top: 1px solid var(--line); margin-top: 20px; }
.modal-layer { z-index: 60; }
.test-folder-list { display: grid; gap: 18px; }
.test-folder-card { position: relative; padding-top: 28px; overflow: visible; }
.test-folder-card .folder-tab { position: absolute; width: 150px; height: 18px; left: 20px; top: -12px; border: 1.5px solid var(--line); border-bottom: 0; border-radius: 10px 10px 0 0; background: var(--surface); }
.test-folder-card h2 { margin: 12px 0 5px; font-size: 30px; }
.folder-meta { display: flex; gap: 22px; padding-top: 16px; border-top: 1px solid var(--surface-2); color: var(--muted); font-size: 13px; }
.folder-meta strong { color: var(--ink); }
.test-settings { padding: 18px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--paper); }
.test-active-check { min-height: 44px; padding: 0 4px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin: 30px 0 14px; }
.section-heading h3 { margin: 5px 0 0; font-family: "PT Serif", Georgia, serif; font-size: 28px; }
.stage-file-list { display: grid; gap: 10px; }
.stage-file { display: grid; grid-template-columns: 62px minmax(0, 1fr) auto; align-items: center; gap: 18px; min-height: 124px; padding: 18px; border: 1.5px solid var(--line); border-radius: 12px; background: white; }
.stage-file-number { align-self: stretch; display: grid; place-items: center; border-right: 1px solid var(--surface-2); color: var(--accent); font-family: "PT Serif", Georgia, serif; font-size: 25px; font-weight: 700; }
.stage-file-body { min-width: 0; }
.stage-file-body h3 { margin: 7px 0 5px; font-family: "PT Serif", Georgia, serif; font-size: 23px; }
.stage-file-body p { margin: 0; color: var(--muted); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stage-file-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; flex-wrap: wrap; max-width: 300px; }
.stage-file-actions .icon-btn { border: 1px solid var(--line); background: var(--surface); }
.stage-file-actions .icon-btn:disabled { opacity: .3; cursor: default; }

.candidate-shell { min-height: 100vh; }
.candidate-topbar { height: 74px; padding: 0 clamp(20px, 5vw, 70px); background: var(--ink); color: white; display: flex; align-items: center; justify-content: space-between; }
.candidate-main { width: min(1040px, calc(100% - 40px)); margin: 0 auto; padding: 48px 0 80px; }
.test-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 28px; }
.test-card { min-height: 250px; display: flex; flex-direction: column; }
.test-card h2 { font-size: 31px; }
.test-card .btn { margin-top: auto; align-self: flex-start; }
.stage-overview { width: min(920px, calc(100% - 40px)); }
.stage-overview > h1 { margin: 10px 0 8px; font-size: clamp(38px, 6vw, 58px); }
.stage-overview-description { max-width: 720px; color: var(--muted); font-size: 17px; line-height: 1.6; }
.stage-overview-progress { display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: 0 8px; margin: 28px 0 20px; }
.stage-overview-progress strong { font-family: "PT Serif", Georgia, serif; font-size: 24px; }
.stage-overview-progress span { color: var(--muted); font-size: 13px; }
.stage-overview-progress div { grid-column: 1 / -1; height: 5px; margin-top: 9px; overflow: hidden; border-radius: 99px; background: var(--surface-2); }
.stage-overview-progress i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .25s ease; }
.candidate-stage-list { display: grid; gap: 12px; }
.candidate-stage { display: grid; grid-template-columns: 68px minmax(0, 1fr) auto; align-items: center; gap: 20px; min-height: 150px; padding: 20px; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 3px 3px 0 rgba(22,38,59,.1); }
.candidate-stage.locked { background: rgba(255,253,248,.55); box-shadow: none; }
.candidate-stage-number { align-self: stretch; display: grid; place-items: center; border-right: 1px solid var(--surface-2); color: var(--accent); font-family: "PT Serif", Georgia, serif; font-size: 27px; font-weight: 700; }
.candidate-stage.completed .candidate-stage-number { color: var(--green); font-family: "Manrope", sans-serif; }
.candidate-stage.locked .candidate-stage-number { color: #9c9a94; }
.candidate-stage-copy h2 { margin: 10px 0 6px; font-size: 27px; }
.candidate-stage-copy p { margin: 0; }
.candidate-stage-action { min-width: 156px; display: flex; justify-content: flex-end; }
.locked-stage-note { margin-top: 8px !important; color: var(--muted); font-size: 13px; }
.between-stages-note { margin: 18px 0 0; padding: 16px 18px; border-left: 4px solid var(--green); background: #e6f0e9; color: var(--ink-2); line-height: 1.55; }

.runner { min-height: 100vh; background: var(--surface); }
.runner-head { position: sticky; top: 0; z-index: 10; min-height: 74px; background: var(--ink); color: white; padding: 12px clamp(18px, 4vw, 52px); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 20px; }
.runner-title { font-size: 13px; color: #c0cad3; }
.runner-title strong { display: block; color: white; font-size: 16px; }
.progress { display: flex; align-items: center; gap: 8px; justify-content: center; }
.progress-dot { width: 30px; height: 6px; background: rgba(255,255,255,.2); border-radius: 5px; }
.progress-dot.done, .progress-dot.current { background: var(--accent); }
.timer { justify-self: end; font-variant-numeric: tabular-nums; padding: 9px 13px; border: 1px solid rgba(255,255,255,.24); border-radius: 9px; font-weight: 800; }
.timer.urgent { color: #ffd1c3; border-color: var(--accent); }
.runner-main { width: min(900px, calc(100% - 36px)); margin: 0 auto; padding: 46px 0 100px; }
.stage-kicker { color: var(--accent); text-transform: uppercase; letter-spacing: .1em; font-size: 12px; font-weight: 800; }
.runner-main h1 { font-size: clamp(34px, 5vw, 54px); margin: 9px 0 14px; }
.instruction { font-size: 17px; line-height: 1.65; color: var(--ink-2); }
.scenario { margin: 28px 0; padding: 24px; background: var(--paper); border-left: 5px solid var(--accent); white-space: pre-wrap; line-height: 1.65; border-radius: 0 12px 12px 0; }
.briefing-label { display: inline-flex; margin-top: 24px; padding: 7px 11px; border-radius: 7px 7px 0 0; background: var(--accent); color: white; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.briefing-label + .scenario { margin-top: 0; }
.answer-box { min-height: 280px; font-size: 16px; }
.runner-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 22px; }
.save-state { color: var(--muted); font-size: 12px; }
.question { padding: 22px 0; border-bottom: 1px solid var(--surface-2); }
.question h3 { font-family: "Manrope", sans-serif; font-size: 17px; line-height: 1.5; }
.option { display: flex; gap: 11px; align-items: flex-start; padding: 12px; border: 1.5px solid var(--line); border-radius: 10px; margin-top: 8px; cursor: pointer; background: white; }
.option:hover { border-color: var(--accent); }
.option input { width: auto; margin-top: 3px; }
.option.locked { cursor: default; opacity: .58; }
.option.locked:hover { border-color: var(--line); }
.option.locked.selected { opacity: 1; border-color: var(--accent); background: #fff3ed; box-shadow: inset 4px 0 0 var(--accent); }
.locked-note { display: inline-block; margin-top: 10px; color: var(--green); font-size: 12px; font-weight: 800; }
.complete-card { text-align: center; padding: 70px 30px; }
.complete-icon { width: 72px; height: 72px; margin: 0 auto 20px; border-radius: 50%; background: var(--green); color: white; display: grid; place-items: center; font-size: 36px; }
.previous-answer { margin: 14px 0; padding: 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); white-space: pre-wrap; }
.prior-block { margin: 26px 0 32px; }
.prior-context { margin-top: 12px; padding: 20px; border: 1.5px solid var(--line); border-radius: 12px; background: #faf8f2; }
.prior-context h3 { margin-bottom: 12px; }
.prior-body { white-space: pre-wrap; line-height: 1.6; color: var(--ink-2); }
.prior-context details { margin-top: 14px; color: var(--muted); }

.result-section { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.answer-view { white-space: pre-wrap; line-height: 1.6; background: var(--paper); border-radius: 10px; padding: 16px; }
.activity { display: grid; gap: 8px; }
.activity-item { display: grid; grid-template-columns: 145px 1fr; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--surface-2); font-size: 13px; }
.toast { position: fixed; z-index: 100; right: 24px; bottom: 24px; background: var(--ink); color: white; padding: 13px 17px; border-radius: 10px; box-shadow: var(--shadow); transform: translateY(100px); opacity: 0; transition: .2s; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--red); }
.loader { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }

@media (max-width: 900px) {
  .login-page { grid-template-columns: 1fr; }
  .login-story { min-height: 360px; padding: 42px 28px; }
  .login-story::after { width: 180px; height: 180px; border-width: 30px; bottom: -40px; }
  .login-copy h1 { font-size: 46px; }
  .login-panel { padding: 46px 24px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 14px 18px; flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar .brand { padding: 0 18px 0 0; }
  .nav { display: flex; }
  .nav button { white-space: nowrap; }
  .sidebar-user { display: none; }
  .stats { grid-template-columns: 1fr 1fr; }
  .editor-stage-head { grid-template-columns: 1fr 1fr; }
  .stage-file { grid-template-columns: 52px minmax(0, 1fr); }
  .stage-file-actions { grid-column: 2; justify-content: flex-start; max-width: none; }
}

@media (max-width: 620px) {
  .main { padding: 26px 16px 60px; }
  .page-head { display: block; }
  .page-head .btn { margin-top: 16px; }
  .stats, .test-grid, .form-grid, .options-editor { grid-template-columns: 1fr; }
  .card-head { display: block; }
  .card-actions { margin-top: 14px; }
  .editor-stage-head { grid-template-columns: 1fr; }
  .folder-meta { display: grid; gap: 5px; }
  .section-heading { display: block; }
  .section-heading .btn { width: 100%; margin-top: 14px; }
  .stage-file { grid-template-columns: 42px minmax(0, 1fr); gap: 12px; padding: 15px 13px; }
  .stage-file-number { font-size: 21px; }
  .stage-file-body h3 { font-size: 21px; }
  .stage-file-actions { grid-column: 1 / -1; }
  .stage-file-actions .btn:not(.btn-small) { flex: 1; }
  .candidate-main, .stage-overview { width: min(100% - 28px, 1040px); padding-top: 34px; }
  .candidate-topbar { padding: 0 14px; }
  .candidate-topbar .brand { gap: 8px; }
  .candidate-stage { grid-template-columns: 44px minmax(0, 1fr); align-items: start; gap: 13px; padding: 16px 14px; }
  .candidate-stage-number { font-size: 21px; }
  .candidate-stage-copy h2 { font-size: 22px; }
  .candidate-stage-action { grid-column: 1 / -1; min-width: 0; }
  .candidate-stage-action .btn { width: 100%; }
  .runner-head { grid-template-columns: 1fr auto; }
  .progress { display: none; }
  .runner-main { padding-top: 28px; }
  .runner-actions { align-items: stretch; flex-direction: column; }
  .runner-actions .btn { width: 100%; }
  .activity-item { grid-template-columns: 1fr; gap: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
