:root {
  --ink: #101418;
  --ink-soft: #5b6673;
  --paper: #ffffff;
  --field: #e6ebf1;
  --line: #c9d2dc;
  --pen: #1c4fd8;
  --bad: #c0392f;
  --mid: #b07908;
  --good: #0d7a4f;
  --radius: 4px;
}

* { box-sizing: border-box; }

/* display у .group и .points перебивает браузерное [hidden] — возвращаем скрытие */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--field);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 760px; margin: 0 auto; padding: 20px 16px 64px; }
.wrap.wide { max-width: 1180px; }

header.bar {
  background: var(--ink);
  color: #fff;
  padding: 12px 16px;
}
header.bar .inner {
  max-width: 1180px; margin: 0 auto;
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
}
header.bar a { color: #b9c6d6; text-decoration: none; }
header.bar a:hover, header.bar a:focus { color: #fff; text-decoration: underline; }
header.bar .name { font-weight: 700; letter-spacing: -0.01em; margin-right: auto; color: #fff; }

h1 { font-size: 26px; line-height: 1.15; letter-spacing: -0.02em; margin: 24px 0 6px; }
h2 { font-size: 18px; margin: 28px 0 10px; }
p.lead { color: var(--ink-soft); margin: 0 0 20px; max-width: 60ch; }

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

label { display: block; font-weight: 600; margin: 0 0 6px; }
.hint { color: var(--ink-soft); font-weight: 400; font-size: 14px; }

input[type=text], input[type=password], textarea, select {
  width: 100%;
  padding: 12px;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--pen);
  outline-offset: 2px;
}
textarea { min-height: 120px; resize: vertical; }

button, .btn {
  display: inline-block;
  padding: 13px 20px;
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}
button:hover, .btn:hover { background: #263140; }
.btn.ghost, button.ghost { background: #fff; color: var(--ink); }
.btn.ghost:hover { background: var(--field); }
.btn.wide { display: block; width: 100%; text-align: center; padding: 18px; font-size: 18px; }
button.link {
  background: none; border: none; color: var(--bad); padding: 4px;
  font-size: 14px; text-decoration: underline; cursor: pointer;
}

.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* Номер группы — главный элемент экрана */
.code {
  font-size: clamp(40px, 13vw, 64px);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  margin: 6px 0 2px;
}
.code.small { font-size: 22px; }

/* Три кнопки балла */
.points { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.points button {
  background: #fff; color: var(--ink); border: 2px solid var(--line);
  padding: 16px 6px; border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.points button .n { font-size: 30px; font-weight: 700; line-height: 1; }
.points button .t { font-size: 13px; color: var(--ink-soft); }
.points button[data-p="1"].on { border-color: var(--bad); background: #fdf0ee; }
.points button[data-p="2"].on { border-color: var(--mid); background: #fdf6e6; }
.points button[data-p="3"].on { border-color: var(--good); background: #eaf6f0; }
.points button.on .t { color: var(--ink); }

.p1 { color: var(--bad); } .p2 { color: var(--mid); } .p3 { color: var(--good); }

#reader { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #000; }
#reader video { display: block; width: 100% !important; }

.note {
  border-left: 3px solid var(--pen);
  background: #fff;
  padding: 12px 14px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 16px;
}
.note.warn { border-left-color: var(--mid); }
.note.err { border-left-color: var(--bad); }
.note.ok { border-left-color: var(--good); }

table { width: 100%; border-collapse: collapse; background: #fff; font-size: 15px; }
th, td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
th { background: var(--field); font-size: 13px; font-weight: 600; }
td.num, th.num { text-align: center; }
.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.scroll table { border: none; }
.matrix th.vert { writing-mode: vertical-rl; transform: rotate(180deg); height: 190px; white-space: nowrap; font-weight: 500; }
.matrix td.empty { background: #f6f8fa; color: #b3bcc7; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { border: 1px solid var(--line); border-radius: 100px; padding: 3px 11px; font-size: 13px; background: #fff; }

.checks { display: grid; gap: 6px; }
.checks label { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; padding: 5px 0; }
.checks input { margin-top: 3px; width: 18px; height: 18px; flex: none; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat b { display: block; font-size: 28px; line-height: 1.1; }
.stat span { color: var(--ink-soft); font-size: 14px; }

.muted { color: var(--ink-soft); font-size: 14px; }

/* Список групп на странице оценки */
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.group {
  background: #fff; color: var(--ink); border: 1px solid var(--line);
  padding: 14px 8px; display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.group:hover { background: var(--field); }
.group .gc { font-size: 19px; font-weight: 700; letter-spacing: 0.01em; }
.group .gb { font-size: 12px; font-weight: 600; min-height: 16px; color: var(--ink-soft); }
.group.done { border-color: var(--ink-soft); background: #f4f7fa; }
.group.done .gc { font-weight: 600; color: var(--ink-soft); }
.group .gb.p1::before, .group .gb.p2::before, .group .gb.p3::before { content: "балл "; font-weight: 400; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Телефон: админка тоже должна открываться с точки, а не только с ноутбука */
.matrix th:first-child, .matrix td:first-child {
  position: sticky; left: 0; z-index: 1; background: #fff;
}
.matrix th:first-child { background: var(--field); }

@media (max-width: 560px) {
  .wrap { padding: 16px 12px 56px; }
  .card { padding: 14px; }
  h1 { font-size: 23px; margin-top: 18px; }
  header.bar .inner { gap: 10px 14px; }
  header.bar .name { flex-basis: 100%; margin-bottom: 2px; }
  .points button { padding: 20px 4px; }
  .points button .n { font-size: 34px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat b { font-size: 24px; }
  th, td { padding: 7px 8px; }
  .matrix th.vert { height: 150px; }
  .sheet { grid-template-columns: 1fr; }
}

/* Печать листов с QR */
@media print {
  body { background: #fff; }
  .noprint { display: none !important; }
  .sheet { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
  .qr-card { break-inside: avoid; border: 1px dashed #888; }
}
.sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.qr-card { background: #fff; border: 1px solid var(--line); padding: 16px; text-align: center; }
.qr-card img { width: 100%; max-width: 210px; height: auto; display: block; margin: 0 auto 8px; }
.qr-card .c { font-size: 30px; font-weight: 700; letter-spacing: 0.02em; }
.qr-card .s { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
