:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --card: #fff;
  --text: #1d2330;
  --muted: #6b7280;
  --border: #e3e6eb;
  --accent: #2f6fde;
  --series-1: #2a78d6; /* данные на диаграммах */
  --ok: #1f8f4e;
  --ok-bg: #e5f5ec;
  --bad: #c2410c;
  --bad-bg: #fdeee5;
  --warn: #a16207;
  --warn-bg: #fef6dc;
}

/* Тёмная тема: по настройке системы (если не выбрана светлая) или явно выбранная. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14171c;
    --card: #1d2128;
    --text: #e6e8ec;
    --muted: #9aa1ad;
    --border: #2d323b;
    --accent: #6c9cf0;
    --series-1: #3987e5;
    --ok: #5cc98a;
    --ok-bg: #173324;
    --bad: #f0915c;
    --bad-bg: #3a2318;
    --warn: #e5c15c;
    --warn-bg: #352c12;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14171c;
  --card: #1d2128;
  --text: #e6e8ec;
  --muted: #9aa1ad;
  --border: #2d323b;
  --accent: #6c9cf0;
  --series-1: #3987e5;
  --ok: #5cc98a;
  --ok-bg: #173324;
  --bad: #f0915c;
  --bad-bg: #3a2318;
  --warn: #e5c15c;
  --warn-bg: #352c12;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.topbar > strong { flex: 1; }
/* Меню отдельной строкой под заголовком: пунктов у администратора много. */
#nav { display: flex; flex-wrap: wrap; gap: 4px; order: 3; flex-basis: 100%; margin-left: -8px; }
#nav:empty { display: none; }
#who { color: var(--muted); font-size: 14px; }
#theme { font-size: 14px; color: var(--muted); }

/* Телефон: заголовок отдельной строкой, меню в одну строку с прокруткой. */
@media (max-width: 600px) {
  .topbar { gap: 2px 12px; padding: 10px 12px 6px; }
  .topbar > strong { flex-basis: 100%; }
  #nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-top: 4px; }
  #nav::-webkit-scrollbar { display: none; }
  #nav button { white-space: nowrap; flex-shrink: 0; }
  main { padding-top: 16px; }
}

main { max-width: 960px; margin: 0 auto; padding: 20px 16px 48px; }

h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 24px 0 8px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}

label { display: block; margin: 12px 0 4px; font-weight: 500; }

input, select, button, a.button {
  font: inherit;
  color: inherit;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--card);
}

input[type="text"], input[type="password"], input[type="number"], input[type="search"], select { width: 100%; max-width: 420px; }
textarea {
  font: inherit;
  color: inherit;
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--card);
  resize: vertical;
}
input[type="checkbox"], input[type="radio"] { width: auto; margin-right: 6px; }

button { cursor: pointer; }
a.button { display: inline-block; text-decoration: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.link { border: none; background: none; color: var(--accent); padding: 6px 8px; }
button.link.active { font-weight: 600; text-decoration: underline; text-underline-offset: 4px; }
button:disabled { opacity: .5; cursor: default; }
button.link.danger { color: var(--bad); }
button.danger:not(.link) { color: var(--bad); border-color: var(--bad); }

.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.muted { color: var(--muted); }
.error { color: var(--bad); margin-top: 10px; }
.success { color: var(--ok); margin-top: 10px; }

.check-list label { font-weight: 400; margin: 6px 0; }
.check-grid { display: flex; flex-wrap: wrap; gap: 0 18px; }

.subnav { display: flex; flex-wrap: wrap; gap: 2px; margin: -6px 0 12px -8px; }

/* Колонка с текстом забирает свободное место; короткие колонки – по содержимому. */
td.wrap { white-space: normal; min-width: 160px; }
td.main { width: 60%; }
td.actions { text-align: right; }

.option-row { display: flex; align-items: center; gap: 6px; margin: 6px 0; }
.option-row input[type="text"] { max-width: none; flex: 1; min-width: 0; }
.options.numbered { counter-reset: seq; }
.options.numbered .seq-num::before { counter-increment: seq; content: counter(seq) "."; display: inline-block; min-width: 1.6em; }
@media (max-width: 600px) { .pair-row { flex-wrap: wrap; } .pair-row input[type="text"] { flex-basis: 100%; } }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-weight: 600; font-size: 13px; color: var(--muted); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 13px; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }

.question { margin-bottom: 18px; }
.question p { margin: 0 0 6px; font-weight: 500; }
.question label { font-weight: 400; margin: 4px 0; }
.question .hint { font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.seq-list { list-style: none; padding: 0; margin: 0; counter-reset: seq; }
.seq-list li { display: flex; align-items: center; gap: 6px; padding: 6px 8px; margin: 4px 0;
  border: 1px solid var(--border); border-radius: 7px; background: var(--card); }
.seq-list li::before { counter-increment: seq; content: counter(seq) "."; min-width: 1.6em; color: var(--muted); }
.seq-list li span { flex: 1; }
.match-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 12px; align-items: center; }
.match-grid select { max-width: none; }
@media (max-width: 600px) { .match-grid { grid-template-columns: 1fr; } }

.score { font-size: 32px; font-weight: 700; }

.login { max-width: 360px; margin: 60px auto; }


.small { font-size: 13px; }
label.inline { display: flex; align-items: center; font-weight: 400; margin-top: 14px; }
td.import-desc { min-width: 280px; }
ul.indicators { margin: 0; padding-left: 18px; }
ul.indicators li { margin: 3px 0; }
.mapping-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 12px; }
details summary { cursor: pointer; font-weight: 500; }
tr.muted td { color: var(--muted); }
.notice { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--warn-bg); }
code { font: 14px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; padding: 1px 5px; border-radius: 4px; background: var(--bg); }

/* «Роза ветров» */
.radar-grid { display: flex; flex-wrap: wrap; gap: 16px; }
.radar-grid > .card { flex: 1 1 380px; min-width: 0; }
.radar-wrap { position: relative; max-width: 460px; margin: 0 auto 8px; }
.radar-wrap svg { display: block; width: 100%; height: auto; }
.radar-tip {
  position: absolute; transform: translate(-50%, calc(-100% - 12px)); pointer-events: none;
  background: var(--text); color: var(--card); padding: 6px 10px; border-radius: 6px;
  font-size: 13px; max-width: 260px; width: max-content;
}

/* Квоты вопросов по компетенциям (учебный план) */
.quota-grid { display: grid; gap: 6px; }
.quota-row { display: flex; align-items: center; gap: 10px; font-weight: 400; margin: 0; }
.quota-row span { flex: 1; }
.quota-row input { max-width: 90px; }

/* Прогресс преподавателя */
.progress-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
progress { width: 100%; max-width: 420px; height: 10px; accent-color: var(--accent); }

/* Печать одной карточки «розы»: остальная страница скрыта (PDF – «Сохранить как PDF»). */
@media print {
  body.print-one * { visibility: hidden; }
  body.print-one .print-target, body.print-one .print-target * { visibility: visible; }
  body.print-one .print-target { position: absolute; left: 0; top: 0; width: 100%; border: none; box-shadow: none; }
  body.print-one .print-target .no-print, body.print-one .print-target .no-print * { display: none; }
}

/* Вывод студенту по компетенциям */
.verdict { display: grid; gap: 10px; }
.verdict-item { display: flex; gap: 12px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--border); }
.verdict-item:first-child { border-top: none; }
.verdict-item .what { flex: 1 1 320px; min-width: 0; }

/* Отступы и раскладка – классами, а не inline-стилями в JS */
.card > h2:first-child { margin-top: 0; }
.mt-0 { margin-top: 0; }
.mt-xs { margin-top: 4px; }
.mt-s { margin-top: 8px; }
.mt-m { margin-top: 12px; }
.mt-l { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-s { margin-bottom: 8px; }
.m-0 { margin: 0; }
.ml-xs { margin-left: 6px; }
.pad-bottom { padding-bottom: 8px; }
.grow { flex: 1; min-width: 220px; }
input.narrow { max-width: 110px; }
button.link.bare { padding: 0; }
.button-row { gap: 8px; flex-wrap: wrap; }
.spaced-list > li { margin: 8px 0; }
.mode-switch { margin: 14px 0 4px; }
.mode-switch label.inline { margin: 0; }
td.wrap-text, .wrap-text { white-space: normal; }

details.card .card { border: none; padding: 0; margin: 12px 0 0; }

/* Главная администратора */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.tile-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.tile-label { font-weight: 500; margin: 2px 0 4px; }
.attention { list-style: none; margin: 0; padding: 0; }
.attention li { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--border); }
.attention li:first-child { border-top: none; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 0 16px; }
.text-left { text-align: left; }
.home-grid > * { min-width: 0; } /* таблицы прокручиваются внутри карточки, а не растягивают страницу */
.bar { height: 6px; border-radius: 3px; background: var(--border); margin-top: 4px; min-width: 80px; }
.bar-fill { height: 100%; border-radius: 3px; background: var(--accent); }
.bar-fill.full { background: var(--ok); }
