/* public/css/app.css
   Оформление «как MS Word»: белый лист, Calibri, синие кнопки, плоские блоки,
   таблицы с тонкими серыми рамками и заливкой шапки. Без внешних ресурсов. */

:root {
  --w-ink: #1a1a1a;
  --w-blue: #2b579a;
  --w-blue-dark: #1f4e79;
  --w-border: #d0d0d0;
  --w-border-strong: #b8b8b8;
  --w-head: #d9e2f3;
  --w-muted: #666666;
  --w-panel: #f3f3f3;
  --w-red: #a4262c;
  --w-green: #2f5b25;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #ffffff;
  color: var(--w-ink);
}

body {
  font-family: Calibri, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--w-blue); text-decoration: underline; }
a:hover { color: var(--w-blue-dark); }

h1, h2, h3 { font-weight: 600; margin: 0 0 10px; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 15px; }

.muted { color: var(--w-muted); }
.small { font-size: 12.5px; }
.spacer { flex: 1 1 auto; }
.nowrap { white-space: nowrap; }

/* ---------- Верхняя панель: строка заголовка окна + вкладки ---------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #ffffff;
  border-bottom: 1px solid var(--w-border);
}

.masthead-static { position: static; }

.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 20px;
  background: var(--w-panel);
  border-bottom: 1px solid var(--w-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--w-ink);
  min-width: 0;
}

.brand-mark {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  background: var(--w-blue);
  color: #ffffff;
  font: 700 12px/20px Calibri, Arial, sans-serif;
  text-align: center;
  border-radius: 2px;
}

.brand-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.titlebar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #333333;
  min-width: 0;
}

.user-name {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  padding: 0 20px;
  background: #ffffff;
}

.tab {
  display: block;
  padding: 9px 14px;
  color: var(--w-ink);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  white-space: nowrap;
}

.tab:hover { background: #eef2f9; color: var(--w-blue); }

.tab.is-active {
  color: var(--w-blue);
  border-bottom-color: var(--w-blue);
  font-weight: 600;
}

/* ---------- Страница контента: «лист документа» ---------- */

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 40px 64px;
  font-size: 15px;
}

.page-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid #e5e5e5;
  margin-bottom: 18px;
}

.page-title {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  color: var(--w-ink);
}

.toolbar-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

/* ---------- Кнопки ---------- */

.btn {
  appearance: none;
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--w-blue);
  border-radius: 3px;
  background: var(--w-blue);
  color: #ffffff;
  font: inherit;
  font-size: 14px;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover { background: var(--w-blue-dark); border-color: var(--w-blue-dark); color: #ffffff; }
.btn:active { background: #173d5e; border-color: #173d5e; }
.btn:focus-visible { outline: 2px solid #8fb1e0; outline-offset: 1px; }

.btn-secondary {
  background: #ffffff;
  color: var(--w-blue);
  border-color: var(--w-blue);
}

.btn-secondary:hover {
  background: #eef2f9;
  color: var(--w-blue-dark);
  border-color: var(--w-blue-dark);
}

.btn-danger {
  background: #ffffff;
  color: var(--w-red);
  border-color: var(--w-red);
}

.btn-danger:hover { background: #fbe9ea; color: var(--w-red); border-color: var(--w-red); }

.btn-sm { padding: 2px 8px; font-size: 13px; }

.btn[disabled], .btn:disabled {
  background: #f3f3f3;
  border-color: var(--w-border);
  color: #9a9a9a;
  cursor: not-allowed;
}

.btn[disabled]:hover, .btn:disabled:hover {
  background: #f3f3f3;
  border-color: var(--w-border);
  color: #9a9a9a;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

/* ---------- Таблицы «как в Word» ---------- */

.table-wrap { overflow-x: auto; }

table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: #ffffff;
}

table.grid th,
table.grid td {
  border: 1px solid var(--w-border);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}

table.grid thead th {
  background: var(--w-head);
  font-weight: 600;
  white-space: nowrap;
}

table.grid tbody tr:nth-child(even) { background: #fafbfd; }
table.grid tbody tr:hover { background: #f2f6fc; }

table.grid th.num, table.grid td.num { text-align: center; }
table.grid th.center, table.grid td.center { text-align: center; }
table.grid th.actions, table.grid td.actions { white-space: nowrap; }

td.state {
  border: 0;
  padding: 24px;
  text-align: center;
  color: var(--w-muted);
  background: #ffffff;
}

.meta-table {
  border-collapse: collapse;
  margin: 6px 0 14px;
  font-size: 14px;
}

.meta-table th,
.meta-table td {
  border: 1px solid var(--w-border);
  padding: 5px 10px;
  text-align: left;
  vertical-align: top;
}

.meta-table th {
  background: var(--w-panel);
  font-weight: 600;
  white-space: nowrap;
  width: 200px;
}

/* ---------- Плоские блоки-«страницы» ---------- */

.panel {
  border: 1px solid var(--w-border);
  background: #ffffff;
  padding: 16px 18px;
  margin-bottom: 18px;
}

.panel-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e5e5e5;
}

.profile { padding: 12px 16px; }
.profile-line { margin-bottom: 2px; }

/* ---------- Формы ---------- */

.form { margin: 0; }

.field { margin-bottom: 12px; min-width: 0; }

.field:last-child { margin-bottom: 0; }

.lbl {
  display: block;
  font-size: 13px;
  color: #333333;
  margin-bottom: 4px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="search"],
select,
textarea {
  font: inherit;
  font-size: 14px;
  color: var(--w-ink);
  background: #ffffff;
  padding: 5px 8px;
  border: 1px solid var(--w-border-strong);
  border-radius: 2px;
  max-width: 100%;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--w-blue);
  box-shadow: 0 0 0 1px var(--w-blue);
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--w-blue);
  vertical-align: middle;
  margin: 0 4px 0 0;
}

textarea { width: 100%; min-height: 84px; resize: vertical; }

select[multiple] { width: 100%; min-height: 150px; }

.field > input[type="text"],
.field > input[type="password"],
.field > input[type="email"],
.field > input[type="number"],
.field > input[type="date"],
.field > input[type="datetime-local"],
.field > input[type="search"],
.field > select { width: 100%; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.checks { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 6px; }

.check-line {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 14px;
  line-height: 1.35;
  padding: 2px 0;
  cursor: pointer;
}

.check-line input { margin-top: 3px; }

fieldset.fieldset {
  border: 1px solid var(--w-border);
  padding: 10px 12px;
  margin: 0 0 12px;
}

fieldset.fieldset legend {
  font-size: 13px;
  color: #333333;
  padding: 0 4px;
}

.form-error {
  border-left: 3px solid var(--w-red);
  background: #fde7e9;
  color: #8a2226;
  padding: 8px 10px;
  margin: 10px 0 0;
  font-size: 14px;
}

.hint { font-size: 13px; margin-top: 14px; }

.sample {
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--w-border);
  background: #fbfbfb;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12.5px;
  white-space: pre-wrap;
  color: #333333;
  overflow-x: auto;
}

.error-list {
  margin: 8px 0 0;
  padding-left: 20px;
  color: #8a2226;
  font-size: 13px;
}

/* Фильтры над таблицей */

.filters { padding: 12px 14px; }

.filters-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.filters-row .field { margin-bottom: 0; flex: 1 1 170px; }
.filters-row .field-buttons { flex: 0 0 auto; display: flex; gap: 8px; }

/* ---------- Плитки сводки ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.tile {
  border: 1px solid var(--w-border);
  border-left: 4px solid var(--w-blue);
  padding: 10px 14px;
  background: #ffffff;
}

.tile-value { font-size: 26px; font-weight: 600; color: var(--w-blue); line-height: 1.15; }
.tile-label { font-size: 13px; color: #555555; }

/* ---------- Метки состояния ---------- */

.tag {
  display: inline-block;
  padding: 1px 7px;
  border: 1px solid #c9d3e5;
  border-radius: 2px;
  font-size: 12px;
  line-height: 1.5;
  background: #eef2f9;
  color: #1f3b68;
  white-space: nowrap;
}

.tag-info { background: #eef2f9; border-color: #c9d3e5; color: #1f3b68; }
.tag-ok { background: #e6f2e2; border-color: #b7d7ae; color: var(--w-green); }
.tag-bad { background: #fbe9ea; border-color: #e3b5b8; color: #8a2226; }
.tag-muted { background: #f3f3f3; border-color: var(--w-border); color: #555555; }

/* ---------- Уведомления: тонкая строка сверху ---------- */

.notice-host {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 20px;
  border-bottom: 1px solid;
  font-size: 14px;
}

.notice-info { background: var(--w-head); border-color: #9ab3dd; color: #173a63; }
.notice-error { background: #fde7e9; border-color: #e3a0a5; color: #8a2226; }
.notice-success { background: #e2f0d9; border-color: #b3d0a2; color: var(--w-green); }

.notice button {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  padding: 0 2px;
}

/* ---------- Модальные окна (диалог Word) ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(26, 26, 26, 0.35);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
  overflow: auto;
}

.modal {
  width: 560px;
  max-width: 100%;
  background: #ffffff;
  border: 1px solid #9a9a9a;
  border-radius: 2px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  background: var(--w-panel);
  border-bottom: 1px solid #cfcfcf;
  font-weight: 600;
  font-size: 14px;
}

.modal-close {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 15px;
  color: #444444;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
}

.modal-close:hover { color: #000000; }

.modal-body {
  padding: 16px;
  max-height: calc(100vh - 220px);
  overflow: auto;
  font-size: 14px;
}

.modal-body p { margin: 0 0 10px; }
.modal-body p:last-child { margin-bottom: 0; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid #cfcfcf;
  background: #ffffff;
}

.confirm-text { font-size: 14px; }

/* ---------- Состояния загрузки и пустые ---------- */

.state {
  padding: 22px;
  text-align: center;
  color: var(--w-muted);
  font-size: 14px;
  border: 1px dashed #cfcfcf;
  background: #ffffff;
}

.state-error {
  border-style: solid;
  border-color: #e3b5b8;
  background: #fdf3f3;
  color: #8a2226;
}

/* ---------- Вход ---------- */

.login-page { max-width: 460px; margin: 0 auto; padding: 56px 20px 40px; }

.login-box { border: 1px solid var(--w-border); padding: 26px 30px 22px; }

.login-title { font-size: 21px; margin-bottom: 4px; }

.login-submit { width: 100%; }

/* ---------- Прохождение теста ---------- */

.test-page { max-width: 980px; }

.test-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  background: #ffffff;
  border-bottom: 1px solid var(--w-border);
  margin-bottom: 8px;
}

.test-name { font-weight: 600; font-size: 15px; }

.save-status { font-size: 13px; margin-left: 4px; }
.save-status.is-error { color: var(--w-red); }

.timer {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 15px;
  color: var(--w-blue);
  white-space: nowrap;
}

.timer.is-warn { color: var(--w-red); }

.test-intro {
  padding: 8px 0 12px;
  border-bottom: 1px solid var(--w-border);
  font-size: 13px;
}

.question {
  padding: 14px 0 16px;
  border-top: 1px solid #e0e0e0;
}

.question:first-of-type { border-top: 0; }

.q-head { display: flex; gap: 6px; font-weight: 600; }
.q-num { flex: 0 0 auto; }
.q-meta { font-size: 13px; margin: 2px 0 8px 22px; }
.q-options { margin-left: 22px; }

.option {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 4px 0;
  font-size: 14px;
  line-height: 1.4;
  cursor: pointer;
}

.option input { margin-top: 3px; }
.option:hover { background: #f7f9fd; }

/* ---------- Результат ---------- */

.result-banner {
  border: 1px solid;
  padding: 16px;
  text-align: center;
  margin: 4px 0 18px;
}

.result-banner.is-pass { border-color: #b7d7ae; background: #f1f8ee; color: var(--w-green); }
.result-banner.is-fail { border-color: #e3b5b8; background: #fdf3f3; color: #8a2226; }

.result-verdict {
  font-size: 38px;
  font-weight: 700;
  letter-spacing: 3px;
  line-height: 1.1;
  margin-bottom: 6px;
}

.result-summary { font-size: 15px; color: var(--w-ink); }

.mark-ok { color: #2f7d31; font-weight: 700; }
.mark-bad { color: var(--w-red); font-weight: 700; }

/* ---------- Редактор теста ---------- */

.editor-title { font-size: 19px; margin: 0 0 4px; }
.editor-meta { font-size: 13px; color: #555555; margin-bottom: 14px; }

.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  border-bottom: 1px solid var(--w-border);
  margin-bottom: 18px;
}

.subtab {
  border: 1px solid transparent;
  border-bottom: 0;
  background: transparent;
  padding: 7px 14px;
  font: inherit;
  font-size: 14px;
  color: #333333;
  cursor: pointer;
  border-radius: 2px 2px 0 0;
}

.subtab:hover { background: #eef2f9; }

.subtab.is-active {
  background: #ffffff;
  border-color: var(--w-border);
  border-bottom-color: #ffffff;
  margin-bottom: -1px;
  font-weight: 600;
  color: var(--w-blue);
}

.opt-preview { margin-top: 4px; font-size: 13px; }
.opt-line { color: #555555; }
.opt-line.is-correct { color: var(--w-green); }

.q-options-edit { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }

.option-edit { display: flex; align-items: center; gap: 8px; }
.option-edit .opt-text { flex: 1 1 auto; }
.option-edit .opt-correct { width: 16px; height: 16px; }

.scale {
  padding: 8px 10px;
  border: 1px solid var(--w-border);
  background: #fbfbfb;
  font-size: 13.5px;
  margin-bottom: 12px;
}

.level-input-number { width: 84px; }
.level-input-percent { width: 96px; }

/* ---------- Выбор состава группы ---------- */

.pick {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: start;
}

.pick-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }

.pick-list {
  border: 1px solid var(--w-border-strong);
  height: 250px;
  overflow: auto;
  margin: 0;
  padding: 0;
  list-style: none;
  background: #ffffff;
}

.pick-list li {
  padding: 4px 8px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}

.pick-list li:hover { background: #eef2f9; }
.pick-list li.is-selected { background: var(--w-head); }
.pick-list li.muted-li { cursor: default; color: var(--w-muted); }

.pick-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 24px;
}

/* ---------- Адаптивность ---------- */

@media (max-width: 900px) {
  .titlebar { padding: 6px 12px; }

  .tabs {
    flex-direction: column;
    padding: 0;
    border-top: 1px solid #e5e5e5;
  }

  .tab {
    padding: 9px 14px;
    border-bottom: 1px solid #eeeeee;
    border-left: 3px solid transparent;
  }

  .tab.is-active {
    border-left-color: var(--w-blue);
    background: #f5f8fd;
  }

  .page { padding: 16px 16px 48px; }

  .page-toolbar { padding: 8px 0; }

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

  .filters-row .field { flex: 1 1 100%; }

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

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

  .pick-actions { flex-direction: row; padding-top: 0; justify-content: center; }

  .pick-list { height: 180px; }

  .test-topbar { padding: 8px 0; }

  .timer { margin-left: 0; }

  .user-name { max-width: 140px; }

  .login-page { padding-top: 24px; }

  .modal-overlay { padding: 16px 10px; }

  .modal-body { max-height: calc(100vh - 200px); }
}

@media (max-width: 520px) {
  .tiles { grid-template-columns: 1fr; }
  .result-verdict { font-size: 30px; letter-spacing: 2px; }
}
