:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1c2024;
  --muted: #6b7280;
  --line: #e2e5ea;
  --accent: #2563eb;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.45 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px;
  flex: 0 0 230px;
  background: #14181d;
  color: #d7dbe0;
  padding: 18px 0;
}
.sidebar .brand { font-weight: 700; font-size: 17px; padding: 0 18px 14px; color: #fff; }
.sidebar a { display: block; padding: 8px 18px; color: #cbd2d9; }
.sidebar a:hover { background: #1e242b; text-decoration: none; }
.sidebar a.active { background: var(--accent); color: #fff; }
.sidebar .who { padding: 14px 18px 0; font-size: 13px; color: #8b949e; border-top: 1px solid #262c33; margin-top: 14px; }

.content { flex: 1; padding: 22px 26px 60px; min-width: 0; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 26px 0 10px; }
.sub { color: var(--muted); margin: 0 0 18px; font-size: 14px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card .value { font-size: 26px; font-weight: 700; }
.card .label { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card.bad .value { color: var(--bad); }
.card.warn .value { color: var(--warn); }
.card.ok .value { color: var(--ok); }

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

table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tbody tr:hover { background: #fafbfc; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }

.tag {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  font-size: 12px; background: #eef1f5; color: #3c4450;
}
.tag.ok { background: #dcfce7; color: var(--ok); }
.tag.warn { background: #fef3c7; color: var(--warn); }
.tag.bad { background: #fee2e2; color: var(--bad); }
.tag.high { background: #fee2e2; color: var(--bad); }
.tag.low { background: #eef1f5; color: var(--muted); }

form.inline { display: inline; }
input, select, textarea {
  font: inherit; padding: 6px 8px; border: 1px solid var(--line);
  border-radius: 6px; background: #fff; color: var(--ink);
}
textarea { width: 100%; min-height: 90px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
label > input, label > select, label > textarea { display: block; margin-top: 3px; width: 100%; }

.btn {
  display: inline-block; padding: 7px 13px; border-radius: 6px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; cursor: pointer; font: inherit;
}
.btn:hover { text-decoration: none; opacity: .92; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.small { padding: 4px 9px; font-size: 13px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters label { margin-bottom: 0; }

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; }
.flash.ok { background: #dcfce7; color: #14532d; }
.flash.err { background: #fee2e2; color: #7f1d1d; }

.masked { color: var(--muted); }
.muted { color: var(--muted); font-size: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 900px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.login {
  max-width: 340px; margin: 12vh auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 26px;
}
.login h1 { font-size: 19px; margin-bottom: 16px; }

.media-preview {
  width: 160px; height: 120px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line);
  background: #eef1f5;
}
/* Превью в ленте — кликабельное: за ним открывается галерея. Курсор и
   подсветка говорят об этом раньше, чем подпись под таблицей. */
a > .media-preview { cursor: zoom-in; transition: border-color .12s, box-shadow .12s; }
a:hover > .media-preview { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(37, 99, 235, .18); }

/* Альбом: три кадра одного отчёта стоят рядом и открываются как галерея. */
.media-set { display: flex; flex-wrap: wrap; gap: 6px; max-width: 340px; }
.media-set a { position: relative; display: block; line-height: 0; }
.media-set.many .media-preview { width: 104px; height: 78px; }
/* Кружок и в ленте круглый: квадратное окно читается как чужое видео. */
.media-preview.round { border-radius: 50%; }
/* Видео в ленте — кадр, а не проигрыватель: значок говорит, что за ним есть
   что смотреть. */
.media-play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 22px; text-shadow: 0 1px 6px rgba(0, 0, 0, .6); pointer-events: none;
}
.media-count { font-size: 12px; color: var(--muted); margin-top: 4px; }
/* Отзыв балла прямо из строки ленты: поле причины и кнопка в одну колонку. */
.cancel-point { display: flex; flex-direction: column; gap: 5px; min-width: 170px; }
.cancel-point input { margin: 0; font-size: 13px; padding: 4px 7px; }
.media-missing {
  width: 160px; height: 120px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; border: 1px dashed var(--line); color: var(--muted); font-size: 12px;
}
/* In the flag card the video is the thing being judged, so it gets room. */
.flag-card video.media-preview { width: 100%; height: auto; max-height: 320px; object-fit: contain; }
.media-links {
  display: flex; gap: 8px; margin-top: 4px; font-size: 12px;
}
code { background: #eef1f5; padding: 1px 5px; border-radius: 4px; font-size: 13px; }

/* --- Галерея медиа (app/admin/static/gallery.js) -------------------------- */

body.gallery-open { overflow: hidden; }
.gallery {
  position: fixed; inset: 0; z-index: 100; display: none;
  align-items: center; justify-content: center;
  background: rgba(12, 14, 18, .92); padding: 56px 64px 64px;
}
.gallery.is-open { display: flex; }
.gallery-stage {
  display: flex; align-items: center; justify-content: center;
  max-width: 100%; max-height: 100%;
}
.gallery-stage img,
.gallery-stage video {
  max-width: min(1100px, 92vw); max-height: 82vh;
  border-radius: 8px; background: #000; display: block;
}
/* Кружок остаётся кружком и на весь экран. */
.gallery-stage video.round { border-radius: 50%; max-height: 74vh; aspect-ratio: 1 / 1; }
.gallery-close, .gallery-nav {
  position: absolute; background: rgba(255, 255, 255, .12); color: #fff;
  border: 0; border-radius: 999px; cursor: pointer; line-height: 1;
}
.gallery-close { top: 14px; right: 18px; width: 38px; height: 38px; font-size: 24px; }
.gallery-nav { top: 50%; transform: translateY(-50%); width: 44px; height: 64px; font-size: 30px; }
.gallery-nav.prev { left: 12px; }
.gallery-nav.next { right: 12px; }
.gallery-close:hover, .gallery-nav:hover { background: rgba(255, 255, 255, .24); }
.gallery-caption {
  position: absolute; left: 0; right: 0; bottom: 18px; text-align: center;
  color: #d7dbe2; font-size: 13px;
}
.gallery-caption a { color: #fff; }

/* --- Подсказка у цифры на дашборде --------------------------------------- */

/* Кружок с вопросом вместо строки под каждой карточкой: объяснение нужно
   один раз, а место на дашборде — всё время. Открывается и по наведению, и
   по фокусу, поэтому работает с клавиатуры и по касанию. */
.help {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px;
  border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); background: var(--panel);
  font-size: 10px; font-weight: 700; line-height: 1; cursor: help; position: relative;
}
.help:hover, .help:focus-visible { border-color: var(--accent); color: var(--accent); outline: none; }
.help::after {
  content: attr(data-tip);
  /* Вправо подсказка не растёт: у крайней правой карточки она уходила за
     край экрана и обрезалась ровно на том слове, ради которого её открыли. */
  position: absolute; bottom: calc(100% + 8px); right: -6px;
  width: max-content; max-width: 260px; padding: 8px 10px;
  background: var(--ink); color: #fff; border-radius: 6px;
  font-size: 12px; font-weight: 400; line-height: 1.35; text-align: left;
  white-space: normal; opacity: 0; visibility: hidden; transition: opacity .12s;
  z-index: 20; pointer-events: none; box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
}
.help:hover::after, .help:focus-visible::after { opacity: 1; visibility: visible; }
/* На карточке знак стоит в углу, а не в строке подписи: длинная подпись
   иначе переносит его на вторую строку, и он висит там один. */
.card { position: relative; overflow: visible; }
.card .help { position: absolute; top: 11px; right: 12px; }
.card .label { padding-right: 22px; }
