:root {
  --paper: #edf1f2;
  --surface: #ffffff;
  --ink: #12262c;
  --muted: #566b72;
  --line: #c9d5d9;
  --petrol: #0e4a57;
  --petrol-deep: #093640;
  --amber: #f2b01e;
  --ok: #1a7449;
  --ok-bg: #e2f2ea;
  --bad: #b3261e;
  --bad-bg: #fbe9e7;
  --display: "Bahnschrift", "DIN Alternate", "Arial Narrow", "Segoe UI", sans-serif;
  --body: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--body); line-height: 1.5; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.0625rem; }
p { margin: 0; }
a { color: var(--petrol); }
.boot { padding: 48px 16px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }

/* шапка */
.topbar { background: var(--petrol); color: #fff; }
.topbar-in { max-width: 1120px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 24px; min-height: 56px; flex-wrap: wrap; }
.brand { font-family: var(--display); font-size: 1.125rem; font-weight: 600; color: #fff; text-decoration: none; padding: 14px 0; }
.brand span { color: var(--amber); }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a { color: #d6e6ea; text-decoration: none; padding: 16px 12px 13px; border-bottom: 3px solid transparent; }
.nav a:hover { color: #fff; }
.nav a.on { color: #fff; border-bottom-color: var(--amber); }
.who { display: flex; align-items: center; gap: 12px; font-size: 0.875rem; color: #d6e6ea; padding: 8px 0; }
.who button { background: none; border: 1px solid #5c8792; color: #fff; }
.who button:hover { background: var(--petrol-deep); }

.page { max-width: 1120px; margin: 0 auto; padding: 32px 20px 72px; }
.page.narrow { max-width: 780px; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.head p { margin-top: 6px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 24px; }
.panel + .panel { margin-top: 16px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }

/* кнопки и поля */
button, .btn { font: inherit; font-weight: 600; border-radius: 4px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-block; line-height: 1.3; }
button:hover, .btn:hover { border-color: var(--petrol); }
button.primary, .btn.primary { background: var(--petrol); border-color: var(--petrol); color: #fff; }
button.primary:hover, .btn.primary:hover { background: var(--petrol-deep); }
button.danger { color: var(--bad); border-color: #e2b4b0; }
button.danger:hover { background: var(--bad-bg); border-color: var(--bad); }
button.link { border: 0; background: none; padding: 0; color: var(--petrol); font-weight: 400; text-decoration: underline; }
button.mini { padding: 4px 9px; font-size: 0.875rem; font-weight: 400; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
label.field { display: block; }
label.field > span { display: block; font-size: 0.875rem; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  font: inherit; color: var(--ink); width: 100%; padding: 8px 10px; border: 1px solid #9fb1b7; border-radius: 4px; background: #fff; }
textarea { resize: vertical; min-height: 64px; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--petrol); flex: none; margin: 0; }
label.check { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.error { color: var(--bad); background: var(--bad-bg); border-left: 4px solid var(--bad); padding: 10px 14px; border-radius: 2px; }
.notice { background: #fff6dc; border-left: 4px solid var(--amber); padding: 10px 14px; border-radius: 2px; }

/* вход */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.login-side { background: var(--petrol); color: #fff; padding: 64px 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-side h1 { font-size: 3.25rem; max-width: 9em; }
.login-side p { color: #c6dbe0; max-width: 30em; margin-top: 20px; font-size: 1.0625rem; }
.login-side .mark { font-family: var(--display); font-size: 1.125rem; font-weight: 600; }
.login-side .mark span { color: var(--amber); }
.login-form { padding: 64px 56px; display: flex; flex-direction: column; justify-content: center; background: var(--surface); }
.login-form form { max-width: 340px; width: 100%; }
.login-form h2 { margin-bottom: 24px; }

/* таблицы */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
table { border-collapse: collapse; width: 100%; font-size: 0.9375rem; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 0.8125rem; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #f6f9fa; }
td { padding: 10px 14px; border-bottom: 1px solid #e3eaec; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: #f3f8f9; }
td.r, th.r { text-align: right; }
.empty { padding: 40px 24px; text-align: center; color: var(--muted); }
.tag { display: inline-block; font-size: 0.8125rem; font-weight: 600; padding: 2px 9px; border-radius: 3px; white-space: nowrap; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.tag.wait { background: #fff1c9; color: #6b4a00; }
.tag.off { background: #e6ecee; color: var(--muted); }

/* список тестов сотрудника */
.tests { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.tests li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 24px; padding: 22px 24px; border-bottom: 1px solid #e3eaec; align-items: center; }
.tests li:last-child { border-bottom: 0; }
.tests .terms { margin-top: 8px; display: flex; gap: 18px; flex-wrap: wrap; font-size: 0.875rem; color: var(--muted); }
.tests .side { text-align: right; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }

/* прохождение */
.exam-bar { position: sticky; top: 0; z-index: 5; background: var(--petrol); color: #fff; }
.exam-bar-in { max-width: 880px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 16px; }
.exam-bar h1 { font-size: 1.0625rem; flex: 1; font-weight: 600; }
.timer { font-family: var(--display); font-size: 1.75rem; font-variant-numeric: tabular-nums; font-weight: 600; min-width: 4.2ch; text-align: right; }
.timer.low { color: var(--amber); }
.timer small { display: block; font: 400 0.6875rem var(--body); color: #c6dbe0; text-align: right; }
.sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; margin-bottom: 24px; }
.sheet button { padding: 0; height: 40px; font-family: var(--display); font-size: 1rem; font-variant-numeric: tabular-nums; background: var(--surface); border: 1px solid #9fb1b7; border-radius: 3px; color: var(--muted); }
.sheet button.done { background: var(--petrol); border-color: var(--petrol); color: #fff; }
.sheet button.cur { box-shadow: 0 0 0 3px var(--amber); border-color: var(--ink); }
.question { border: 0; padding: 0; margin: 0; min-width: 0; }
.question legend { padding: 0; font-family: var(--display); font-size: 1.5rem; font-weight: 600; line-height: 1.25; white-space: pre-wrap; }
.q-meta { margin: 0 0 10px; font-size: 0.875rem; color: var(--muted); }
.q-hint { margin: 10px 0 16px; font-size: 0.875rem; color: var(--muted); }
.opt { display: flex; gap: 12px; align-items: flex-start; padding: 13px 14px; border: 1px solid var(--line); border-radius: 4px; margin-top: 8px; cursor: pointer; background: #fff; }
.opt:hover { border-color: var(--petrol); }
.opt input { margin-top: 3px; }
.opt.sel { border-color: var(--petrol); background: #eef6f7; box-shadow: inset 3px 0 0 var(--petrol); }
.exam-foot { display: flex; gap: 12px; align-items: center; margin-top: 24px; flex-wrap: wrap; }
.save-state { font-size: 0.875rem; color: var(--muted); }
.save-state.fail { color: var(--bad); font-weight: 600; }

/* результат */
.verdict { border-radius: 6px; padding: 28px; color: #fff; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px 32px; align-items: end; }
.verdict.ok { background: var(--ok); }
.verdict.bad { background: var(--bad); }
.verdict h1 { font-size: 2.25rem; }
.verdict p { opacity: 0.9; margin-top: 8px; }
.verdict .pct { font-family: var(--display); font-size: 4rem; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; margin: 16px 0 0; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.facts div { padding: 14px 18px; border-right: 1px solid #e3eaec; }
.facts div:last-child { border-right: 0; }
.facts dt { font-size: 0.8125rem; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 600; }
.review { list-style: none; counter-reset: q; margin: 0; padding: 0; }
.review > li { counter-increment: q; background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--ok); border-radius: 4px; padding: 18px 20px; margin-top: 10px; }
.review > li.wrong { border-left-color: var(--bad); }
.review h3 { white-space: pre-wrap; }
.review h3::before { content: counter(q) ". "; color: var(--muted); }
.review ul { list-style: none; margin: 12px 0 0; padding: 0; }
.review ul li { padding: 5px 0 5px 28px; position: relative; }
.review ul li::before { content: "○"; position: absolute; left: 4px; color: #9fb1b7; }
.review ul li.picked::before { content: "●"; color: var(--ink); }
.review ul li.right { color: var(--ok); font-weight: 600; }
.review ul li.picked.miss { color: var(--bad); text-decoration: line-through; }
.review .why { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 0.9375rem; color: var(--muted); }
.review .mark { float: right; margin-left: 12px; }

/* редактор */
.q-edit { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 20px; margin-top: 12px; }
.q-edit-head { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.q-edit-head h3 { flex: 1; }
.o-edit { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; margin-top: 8px; }
.q-edit .two { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 12px; margin-top: 12px; }
.sticky-save { position: sticky; bottom: 0; background: var(--paper); padding: 14px 0; margin-top: 20px; border-top: 1px solid var(--line); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; align-items: end; }
.summary { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 14px; }
.summary b { font-family: var(--display); font-size: 1.5rem; font-variant-numeric: tabular-nums; display: block; line-height: 1.1; }
.creds { font-family: Consolas, "Courier New", monospace; font-size: 0.9375rem; }

dialog { border: 0; border-radius: 6px; padding: 24px; max-width: 460px; width: calc(100% - 32px); color: var(--ink); box-shadow: 0 12px 40px rgba(9, 54, 64, 0.3); }
dialog::backdrop { background: rgba(9, 54, 64, 0.55); }
dialog h2 { margin-bottom: 10px; }
dialog .row { margin-top: 20px; justify-content: flex-end; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 4px; opacity: 0; pointer-events: none; transition: opacity 0.2s; max-width: calc(100% - 32px); z-index: 20; }
#toast.show { opacity: 1; }

@media (max-width: 760px) {
  h1 { font-size: 1.625rem; }
  .login { grid-template-columns: 1fr; }
  .login-side { padding: 32px 20px; }
  .login-side h1 { font-size: 2.125rem; }
  .login-side p { display: none; }
  .login-form { padding: 32px 20px; justify-content: flex-start; }
  .page { padding: 20px 16px 56px; }
  .panel { padding: 18px; }
  .tests li { grid-template-columns: 1fr; padding: 18px; }
  .tests .side { text-align: left; align-items: flex-start; }
  .verdict { grid-template-columns: 1fr; padding: 22px; }
  .verdict h1 { font-size: 1.75rem; }
  .verdict .pct { font-size: 3rem; }
  .question legend { font-size: 1.25rem; }
  .facts div { border-right: 0; border-bottom: 1px solid #e3eaec; }
  .q-edit .two { grid-template-columns: 1fr; }
  .who .name { display: none; }
}
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
@media print {
  .topbar, .no-print, #toast { display: none !important; }
  body { background: #fff; }
  .verdict { color: #000; background: none !important; border: 2px solid #000; }
}

.gap-top { margin-top: 12px; }
.stack .head { margin-bottom: 0; }
.qs-head { margin: 32px 0 0; align-items: baseline; justify-content: flex-start; }
.who a { color: #d6e6ea; }
.who a:hover { color: #fff; }
td .row { flex-wrap: nowrap; gap: 6px; }
.tests .terms { row-gap: 2px; }
@media (max-width: 760px) {
  .topbar-in { gap: 0 12px; padding: 0 16px; }
  .brand { padding: 12px 0 0; flex-basis: 100%; }
  .nav a { padding: 10px 10px 8px; white-space: nowrap; }
  .nav a:first-child { padding-left: 0; }
}

.qs-head { align-items: center; }
.skipped { margin: 8px 0 0; padding-left: 20px; max-height: 180px; overflow: auto; }
dialog { max-height: calc(100vh - 32px); overflow: auto; }
#toast { bottom: 84px; }

.sec-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px auto auto; gap: 10px; align-items: center; margin-top: 8px; }
.total b { font-family: var(--display); font-size: 1.125rem; }
.role-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px 20px; }

.q-section { display: inline-block; margin: 0 0 10px; padding: 3px 10px; border-left: 4px solid var(--amber); background: #dfe9ec; color: var(--petrol-deep); font-weight: 600; border-radius: 0 3px 3px 0; }
.review .q-section { margin-bottom: 8px; }

.role-input { max-width: 320px; }
