/* Inter self-hosted (OFL, сабсеты cyrillic+latin, ~14КБ/файл) —
   внешние CDN не нужны, CSP не меняется */
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/static/fonts/inter-cyrillic-400.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/static/fonts/inter-latin-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("/static/fonts/inter-cyrillic-500.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("/static/fonts/inter-latin-500.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/static/fonts/inter-cyrillic-600.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/static/fonts/inter-latin-600.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/static/fonts/inter-cyrillic-700.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/static/fonts/inter-latin-700.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #17202b;
  --muted: #77808c;
  --line: #e6e9ee;
  --accent: #2457d6;
  --accent-soft: #e9effc;
  --header-bg: rgba(255,255,255,.92);
  --track: #e9ecef;
  --hover: #f2f5fa;          /* ховер строк, пилюль, вкладок */
  --chip: #f0f2f5;           /* фон тегов и юзерчипа */
  --ctl-base: #ffffff;       /* база color-mix тега вида контроля */
  --passed-bg: #f1fcf4;      /* предмет «выполнен» по порогу */
  --passed-line: #9fdec0;
  --passed-grad: linear-gradient(180deg, #e9fbeef2, #f1fcf4 70%);
  --asbar-bg: #fdf6ea;       /* плашка «смотрю за другого» */
  --asbar-line: #f2e0bd;
  --fmt-on-ink: #6b46c2;     /* «дистанционно» */
  --fmt-on-line: #ddd2f5;
  --fmt-on-bg: #f6f1fe;
  --fmt-off-ink: #a06a00;    /* «очно» */
  --fmt-off-line: #f2e0bd;
  --fmt-off-bg: #fdf6ea;
  --shadow: 0 1px 2px rgba(23,32,43,.05), 0 4px 16px rgba(23,32,43,.06);
  /* ступени статусов: валидированы dataviz/validate_palette (light, #fff);
     тёмная тема задаёт свои — см. блоки ниже */
  --st-not-started: #8a94a3;
  --st-in-progress: #2457d6;
  --st-attach: #0d9068;
  --st-attached: #0a6ec4;
  --st-needs-defense: #d68b00;
  --st-done: #1a8a4a;
  --st-not-needed: #7a4fd3;
  --ctl-Экзамен: #d23b3b;
  --ctl-Зачёт: #1a8a4a;
  --ctl-Практика: #d68b00;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.45 Inter, -apple-system, "SF Pro Text", "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 0;
}
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
html { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }

/* ---------- шапка ---------- */

header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 28px;
  background: var(--header-bg); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.logo { margin-right: 2px; }
.badge {
  margin-left: 8px; padding: 2px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 12.5px; font-weight: 600;
}
.statusbar { flex: 1; color: var(--muted); font-size: 12.5px; min-width: 180px; text-align: right; }

button {
  font: inherit; cursor: pointer; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); border-radius: 9px; padding: 7px 14px;
  transition: border-color .12s, color .12s, background .12s;
}
button:hover { border-color: var(--accent); color: var(--accent); }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
button.ghost:hover { color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { opacity: .92; }
button.danger:hover { border-color: #d23b3b; color: #d23b3b; }

/* ---------- герой: прогресс + стат-карточки ---------- */

.hero { padding: 26px 28px 4px; max-width: 1060px; margin: 0 auto; }
.hero-top { display: flex; align-items: baseline; gap: 14px; margin-bottom: 10px; }
.hero h1 { margin: 0; font-size: 24px; font-weight: 750; letter-spacing: -.025em; }
.progress-label { color: var(--muted); font-size: 13.5px; }
.progressbar {
  height: 10px; border-radius: 999px; background: var(--track); overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(23,32,43,.06);
}
.progressbar > div {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #33b56e, #1a8a4a);
  transition: width .35s ease;
}
/* статусов 7 — фиксированные 6 колонок роняли «Не требуется» второй строкой;
   auto-fit держит все в одном ряду на десктопе и аккуратно переносит на узких */
.statcards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 10px; margin-top: 16px;
}
.statcard {
  position: relative; overflow: hidden; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px 11px; box-shadow: var(--shadow);
  transition: transform .12s, background-color .25s, border-color .25s, box-shadow .25s;
}
.statcard::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--c);
  transition: height .25s;
}
.statcard .num { font-size: 26px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.01em; transition: color .25s; }
.statcard .lbl { font-size: 11.5px; color: var(--muted); margin-top: 2px; letter-spacing: .02em; }
.statcard:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--c) 55%, var(--line)); }
/* активный фильтр — не заливка, а тонированное стекло: подцветка 13%,
   рамка и кольцо в цвет статуса, цифра принимает цвет статуса */
.statcard.active {
  background: color-mix(in srgb, var(--c) 13%, var(--card));
  border-color: color-mix(in srgb, var(--c) 45%, var(--line));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--c) 22%, transparent), var(--shadow);
}
.statcard.active .num { color: var(--c); }
.statcard.active::before { height: 4px; }
.statcard.pulse { animation: stat-pulse .55s ease-out; }
@keyframes stat-pulse {
  from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 50%, transparent); }
  to { box-shadow: 0 0 0 16px color-mix(in srgb, var(--c) 0%, transparent); }
}

/* ---------- раскладка ---------- */

.layout { max-width: 1060px; margin: 0 auto; padding: 18px 28px 60px; }

.searchwrap { position: relative; margin-bottom: 18px; }
.search-ico {
  position: absolute; left: 14px; top: 50%; transform: translateY(-56%);
  font-size: 17px; color: var(--muted); pointer-events: none;
}
.search {
  width: 100%; font: inherit; font-size: 14.5px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 16px 11px 40px;
  background: var(--card); box-shadow: var(--shadow);
}
.search:focus { outline: none; border-color: var(--accent); }
.search::placeholder { color: #a6aeb9; }

/* ---------- фокус: что в работе ---------- */

.focus { margin-bottom: 18px; }
/* заголовок — кнопка: список свёрнут до клика, caret крутится как у предметов */
.focus-head {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 8px; padding: 0; border: none; background: none;
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--ink);
}
.focus-head:hover { color: var(--accent); }
.focus-head .caret { font-size: 11px; transition: transform .15s; }
.focus-head.open .caret { transform: rotate(90deg); }
.focus-count {
  padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: color-mix(in srgb, var(--st-needs-defense) 15%, transparent);
  text-transform: none; letter-spacing: 0;
}
.focus-row {
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 11px;
  padding: 9px 14px; margin-bottom: 6px; box-shadow: var(--shadow);
}
.focus-row .pill { width: 100%; justify-content: center; }
.focus-row .subj { color: var(--muted); font-size: 12.5px; justify-self: end; text-align: right; }

/* ---------- предметы ---------- */

.subjects { display: grid; gap: 14px; }
/* overflow:hidden убран — он обрезал тултип кнопки «↓ вниз» у свёрнутого
   предмета; скругление фона summary теперь на самом summary */
.subject {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow);
}
/* порог баллов достигнут — предмет «горит» салатовым (в тёмной теме — тёмно-зелёным) */
.subject.passed { background: var(--passed-bg); border-color: var(--passed-line); }
.subject.passed > summary { background: var(--passed-grad); }
.subject.passed > summary::before { background: var(--st-done); }
.subject.passed .mini-bar > div { background: var(--st-done); }
.subject > summary {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 18px 13px 22px; cursor: pointer; list-style: none; user-select: none;
  position: relative; border-radius: 13px 13px 0 0;
}
.subject:not([open]) > summary { border-radius: 13px; }
.subject > summary::-webkit-details-marker { display: none; }
.subject > summary::before {          /* цветная полоска вида контроля */
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--ctl, var(--accent));
}
.subject > summary .caret { color: var(--muted); font-size: 11px; transition: transform .15s; }
.subject[open] > summary .caret { transform: rotate(90deg); }
.subject-name { font-weight: 650; font-size: 16px; overflow-wrap: anywhere; letter-spacing: -.005em; }
.tag {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 999px; background: var(--chip); color: var(--muted);
}
.tag.control { background: color-mix(in srgb, var(--ctl) 12%, var(--ctl-base)); color: var(--ctl); }
.tag.done-badge { background: var(--st-done); color: #fff; font-weight: 700; }
.subject-progress { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.mini-bar {
  width: 84px; height: 6px; border-radius: 999px; background: var(--track); overflow: hidden;
}
.mini-bar > div { height: 100%; background: var(--st-done); border-radius: 999px; }
.mini-label { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.score-pill { color: var(--ink); font-weight: 600; }
.score-pill.hit { color: var(--st-done); }
/* «↓ вниз»/«↑ вверх» у выполненных предметов — рядом с баллами */
.sink-btn { padding: 2px 9px; font-size: 12px; font-weight: 600; border-radius: 999px; }
.subject-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.subject:hover .subject-actions,
.subject > summary:focus-within .subject-actions { opacity: 1; }
.subject-actions .ghost { padding: 4px 8px; font-size: 14px; }

/* тело предмета и «Сейчас в работе»: высоту анимирует animateOpen в app.js */
.subject-body, #focus-list {
  overflow: hidden;
  transition: height .32s cubic-bezier(.4, 0, .2, 1);
}
.subject-body { padding: 2px 14px 12px; }
/* при сворачивании open снимается только в конце анимации —
   каретку возвращаем в исходное положение сразу */
.subject.closing > summary .caret { transform: none; }

/* мягкое появление всплывающих слоёв (диалоги, панели, меню) */
@keyframes pop-in {
  from { opacity: 0; transform: translateY(7px) scale(.985); }
}
@keyframes fade-in { from { opacity: 0; } }
dialog[open] { animation: pop-in .18s ease-out; }
dialog::backdrop { animation: fade-in .18s ease-out; }
.notif-panel:not([hidden]),
.status-menu:not([hidden]) { animation: pop-in .15s ease-out; }

/* смена темы: класс на <html> на ~0.4с — все цвета переезжают плавно */
html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
  transition: background-color .3s ease, background .3s ease, color .3s ease,
              border-color .3s ease, fill .3s ease, stroke .3s ease,
              box-shadow .3s ease !important;
}

@media (prefers-reduced-motion: reduce) {
  .subject-body, #focus-list, #progress-fill { transition: none; }
  dialog[open], dialog::backdrop,
  .notif-panel:not([hidden]), .status-menu:not([hidden]) { animation: none; }
  .statcard.pulse { animation: none; }
  html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
    transition: none !important;
  }
}
.add-task-line { padding: 8px 6px 2px; }
.add-task-line button {
  font-size: 13px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 8px; padding: 3px 10px;
  transition: color .15s, border-color .15s;
}
.add-task-line button:hover { color: var(--ink); border-color: var(--accent); }
.hidden-line { font-size: 13px; }
.hidden-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 3px 6px; color: var(--muted); font-size: 13px;
}
.hidden-row button { font-size: 12.5px; padding: 2px 8px; }

/* ---------- строки задач ---------- */

.task-row {
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr) auto auto;
  align-items: center;
  column-gap: 12px;
  padding: 8px 8px; border-top: 1px solid var(--line); border-radius: 9px;
}
.task-row:first-child { border-top: none; }
.task-row:hover { background: var(--hover); }
.task-row.not-needed { opacity: .5; }
.task-row .pill { width: 100%; justify-content: center; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1.5px solid; border-radius: 999px; padding: 4px 12px;
  font-size: 12px; font-weight: 600; background: var(--card); white-space: nowrap;
  transition: background .12s, transform .05s;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill .chev { font-size: 9px; opacity: .7; margin-left: 1px; }
.pill.syncing { opacity: .55; }            /* изменение ещё не подтверждено сервером */
.pill.syncing .dot { animation: mt-pulse .9s ease-in-out infinite; }
@keyframes mt-pulse { 50% { opacity: .2; } }
.pill.st-not_started { border-color: var(--st-not-started); color: var(--st-not-started); }
.pill.st-in_progress { border-color: var(--st-in-progress); color: var(--st-in-progress); }
.pill.st-attach_sdo { border-color: var(--st-attach); color: var(--st-attach); }
.pill.st-attached { border-color: var(--st-attached); color: var(--st-attached); }
.pill.st-needs_defense { border-color: var(--st-needs-defense); color: var(--st-needs-defense); }
.pill.st-done { border-color: var(--st-done); color: var(--st-done); }
.pill.st-not_needed { border-color: var(--st-not-needed); color: var(--st-not-needed); }
.pill:hover { background: var(--hover); }
.pill:active { transform: scale(.97); }

.task-name { min-width: 0; overflow-wrap: anywhere; }
.fmt {
  font-size: 10.5px; font-weight: 600; padding: 1px 7px; margin-left: 6px;
  border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
}
.fmt.online { color: var(--fmt-on-ink); border-color: var(--fmt-on-line); background: var(--fmt-on-bg); }
.fmt.offline { color: var(--fmt-off-ink); border-color: var(--fmt-off-line); background: var(--fmt-off-bg); }
.auto-tag {
  font-size: 10.5px; color: var(--st-done);
  border: 1px solid color-mix(in srgb, var(--st-done) 35%, transparent);
  background: color-mix(in srgb, var(--st-done) 10%, transparent);
  border-radius: 999px; padding: 0 6px; margin-left: 6px;
}
.score {
  color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums;
  cursor: pointer; white-space: nowrap;
}
.score:hover { color: var(--accent); }
.score b { color: var(--ink); font-size: 13.5px; }
.task-actions { display: flex; gap: 0; opacity: 0; transition: opacity .12s; }
.task-row:hover .task-actions,
.task-row:focus-within .task-actions { opacity: 1; }
.task-actions .ghost { padding: 3px 7px; font-size: 13px; }
@media (hover: none) {
  .task-actions, .subject-actions { opacity: 1; }   /* тач: без ховера */
}

/* ---------- меню статуса ---------- */

.status-menu {
  position: fixed; z-index: 50; min-width: 215px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 34px rgba(23,32,43,.18); padding: 5px;
}
.status-menu button {
  display: flex; width: 100%; align-items: center; gap: 9px;
  border: none; background: none; border-radius: 8px; padding: 8px 11px;
  font-size: 13.5px; font-weight: 500; text-align: left;
}
.status-menu button:hover { background: var(--hover); }
.status-menu button.current { font-weight: 700; }
.status-menu button.current::after { content: "✓"; margin-left: auto; }
.status-menu .dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: none; }
.status-menu .sep { border-top: 1px solid var(--line); margin: 4px 6px; }
.status-menu .reset { color: var(--muted); }

/* ---------- диалоги ---------- */

dialog {
  border: none; border-radius: 16px; padding: 20px 22px; min-width: 360px; max-width: 92vw;
  box-shadow: 0 16px 48px rgba(23,32,43,.24);
}
dialog::backdrop { background: rgba(23,32,43,.38); }
dialog h3 { margin: 0 0 14px; font-size: 16.5px; }
dialog label { display: block; margin-bottom: 11px; font-size: 12.5px; color: var(--muted); }
dialog input, dialog select {
  display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 14px;
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; color: var(--ink);
  background: var(--card);
}
dialog input:focus, dialog select:focus { outline: none; border-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- вкладки ---------- */

.tabs {
  display: flex; gap: 4px; max-width: 1060px; margin: 14px auto 0; padding: 0 28px;
}
.tab {
  border: none; background: none; color: var(--muted); font-weight: 600;
  padding: 8px 14px; border-radius: 9px; font-size: 14px;
}
.tab:hover { color: var(--accent); background: var(--hover); }
.tab.active { color: var(--accent); background: var(--accent-soft); }

/* ---------- вкладка «Графики» ---------- */

.charts { max-width: 1060px; margin: 0 auto; padding: 8px 28px 60px; }
body:not([data-tab="charts"]) .charts { display: none; }
body[data-tab="charts"] .hero, body[data-tab="charts"] .layout { display: none; }

.kpirow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 10px 0 14px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 16px 12px; box-shadow: var(--shadow);
}
.kpi .num { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.kpi .num .of { font-size: 15px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.kpi .lbl { font-size: 12px; color: var(--muted); margin-top: 1px; }
.kpi.accent .num { color: var(--accent); }
.kpi.green .num { color: var(--st-done); }

.legend {
  display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 4px 0 12px;
  font-size: 12.5px; color: var(--ink);
}
.legend .li { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; }
.legend .cnt { color: var(--muted); font-variant-numeric: tabular-nums; }

.chartgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.chart-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 16px 18px 14px; min-width: 0;
  display: flex; flex-direction: column;
}
/* короткий график (типы заданий) центрируем, а не прижимаем к заголовку */
.chart-card .chart { margin: auto 0; }
.chart-card.span2 { grid-column: span 1; }
@media (min-width: 900px) { .chart-card.span2 { grid-column: span 2; } }
.chart-card h3 { margin: 0 0 12px; font-size: 14px; font-weight: 650; color: var(--ink); }
.chart svg { display: block; width: 100%; height: auto; }
.chart .rowlabel {
  font-size: 12px; fill: var(--ink);
}
.chart .rowlabel.dim { fill: var(--muted); }
.chart .valuelabel { font-size: 11.5px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .track { fill: var(--track); }
.chart .threshold-line { stroke: var(--ink); stroke-width: 1.5; opacity: .55; }
.chart .hit { cursor: default; }
.chart .hit:hover { opacity: .82; }

.chart-tip {
  position: fixed; z-index: 60; pointer-events: none;
  background: var(--ink); color: var(--bg); border-radius: 9px;
  padding: 7px 11px; font-size: 12.5px; line-height: 1.5;
  box-shadow: 0 8px 22px rgba(23,32,43,.3); max-width: 260px;
}
.chart-tip b { font-size: 13px; font-variant-numeric: tabular-nums; }
.chart-tip .k { display: inline-flex; align-items: center; gap: 5px; }
.chart-tip .k i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

.empty { text-align: center; color: var(--muted); padding: 48px 0; }

/* ---------- хедер: юзер ---------- */

.userchip {
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  padding: 4px 10px; border-radius: 999px; background: var(--chip);
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- плашка «смотрю за другого» ---------- */

.asbar {
  max-width: 1060px; margin: 12px auto -4px; padding: 8px 14px;
  background: var(--asbar-bg); border: 1px solid var(--asbar-line); border-radius: 10px;
  font-size: 13px; display: flex; align-items: center; gap: 10px;
}
.asbar[hidden] { display: none; }   /* flex перебивал hidden — плашка не исчезала */
.asbar .ghost { padding: 3px 10px; font-size: 12.5px; }
.admin-table td.btns .ghost { font-size: 12px; padding: 3px 8px; }

/* ---------- колокольчик уведомлений ---------- */

.bell { position: relative; font-size: 16px; padding: 6px 10px; margin-left: auto; }
.bell-badge {
  position: absolute; top: -2px; right: -4px; min-width: 18px; height: 18px;
  border-radius: 999px; background: #d23b3b; color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
  padding: 0 4px; box-shadow: 0 0 0 2px var(--card);
}
.notif-panel {
  position: fixed; z-index: 40; width: 360px; max-width: 92vw;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 34px rgba(23,32,43,.18); overflow: hidden;
}
.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px 8px; font-size: 13.5px; font-weight: 650;
  border-bottom: 1px solid var(--line);
}
.notif-head .ghost { font-size: 12px; padding: 3px 8px; }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-row {
  display: flex; gap: 10px; padding: 8px 14px; font-size: 13px;
  border-bottom: 1px solid var(--line); line-height: 1.45;
}
.notif-row:last-child { border-bottom: none; }
.notif-row .when { color: var(--muted); flex: none; font-size: 12px;
                   font-variant-numeric: tabular-nums; padding-top: 1px; }
.notif-row span:last-child { overflow-wrap: anywhere; }
.notif-empty { padding: 22px 14px; color: var(--muted); font-size: 13px; text-align: center; }

/* ---------- админ-панель ---------- */

.admin { max-width: 1060px; margin: 0 auto; padding: 8px 28px 60px; }
.admin-filters { display: flex; gap: 8px; margin: 0 0 12px; }
.admin-filters .search { flex: 0 1 300px; padding: 8px 12px 8px 34px; }
.admin-filters select {
  font: inherit; font-size: 13.5px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px;
  background: var(--card); box-shadow: var(--shadow); max-width: 220px;
}
.admin-filters select:focus { outline: none; border-color: var(--accent); }

/* мобильные карточки пользователей (вместо таблицы <640px) */
.ucard { border-bottom: 1px solid var(--line); padding: 10px 2px; }
.ucard:last-child { border-bottom: none; }
.ucard-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ucard-head b { font-size: 13.5px; overflow-wrap: anywhere; }
.ucard-role { color: var(--accent); font-size: 11.5px; font-weight: 600; }
.ucard-line { color: var(--ink); font-size: 13px; margin-top: 3px;
              font-variant-numeric: tabular-nums; }
.ucard-dates { color: var(--muted); font-size: 12px; margin-top: 2px; }
.ucard-btns { margin-top: 6px; display: flex; gap: 6px; }
.ucard-btns .ghost { font-size: 12.5px; padding: 4px 10px; }
body:not([data-tab="admin"]) .admin { display: none; }
body[data-tab="admin"] .hero, body[data-tab="admin"] .layout,
body[data-tab="admin"] .charts { display: none; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.admin .tablewrap { overflow-x: auto; }
.admin-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.admin-table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line);
}
.admin-table td { padding: 7px 10px 7px 0; border-bottom: 1px solid var(--line);
  white-space: nowrap; }
.admin-table td.em { font-weight: 600; overflow-wrap: anywhere; }
.activity { display: flex; flex-direction: column; gap: 2px; max-height: 420px;
  overflow-y: auto; }
.act { display: flex; gap: 8px; font-size: 12.5px; padding: 4px 0;
  border-bottom: 1px solid var(--line); align-items: baseline; }
.act .when { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.act .who { font-weight: 600; flex: none; }
.act .who.behalf { color: var(--accent); }   // «→ за <email>» после автора
.act span:last-child { overflow-wrap: anywhere; }
@media (max-width: 900px) { .admin-grid { grid-template-columns: 1fr; } }

@media (max-width: 640px) {
  .charts { padding: 8px 16px 60px; }
  .tabs { padding: 0 16px; }
  .kpirow { grid-template-columns: repeat(2, 1fr); }
  .chartgrid { grid-template-columns: 1fr; }
}

/* ---------- адаптив ---------- */

@media (max-width: 640px) {
  header, .hero, .layout { padding-left: 16px; padding-right: 16px; }
  .btn-txt { display: none; }          /* шапка: «Выйти»/«Синк» → иконки */
  header { gap: 4px; }
  .badge { margin-left: 4px; }
  .admin, .charts { padding-left: 16px; padding-right: 16px; }
  .admin-filters { flex-wrap: wrap; }
  .admin-filters .search { flex: 1 1 100%; }
  .statcards { gap: 8px; }
  .statcard .num { font-size: 19px; }
  .statusbar { text-align: left; width: 100%; order: 5; }
  .subject-progress { margin-left: 0; width: 100%; flex-wrap: wrap; row-gap: 4px; }
  .mini-bar { flex: 1; }
  .task-name { min-width: 0; }
  .task-row { grid-template-columns: 148px minmax(0, 1fr); }
  .task-row .score { grid-column: 2; justify-self: end; }
  /* длинные статусы («Прикреплено, не оценено») на телефоне переносятся */
  .task-row .pill, .focus-row .pill { white-space: normal; line-height: 1.25; }
  .task-row .task-actions { grid-column: 1 / -1; justify-self: end; }
  .focus-row { grid-template-columns: 148px minmax(0, 1fr); }
  .focus-row .subj { grid-column: 1 / -1; }
  .act { flex-wrap: wrap; }
  .asbar { flex-wrap: wrap; }
}

/* ---------- тосты ---------- */

.toasts {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px;
  z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  pointer-events: auto; cursor: pointer;
  background: var(--ink); color: var(--card);
  padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow);
  font-size: 14px; max-width: min(520px, 90vw);
  animation: toast-in .18s ease-out;
}
.toast.err { background: #b23131; color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- кнопки удаления/опасного ---------- */

button.danger {
  background: var(--ctl-Экзамен); border-color: var(--ctl-Экзамен); color: #fff;
}
button.danger:hover { opacity: .92; }
button.danger-ghost { color: var(--ctl-Экзамен); }
.dlg-del-name { font-weight: 600; margin: 6px 0; }
.dlg-del-hint { color: var(--muted); font-size: 13px; margin: 0 0 4px; }

/* ---------- активные сессии ---------- */

.sessions-list { display: flex; flex-direction: column; gap: 6px; min-width: 300px; }
.sess-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
.sess-row .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sess-row.current { border-color: var(--st-done); }
.sess-row.current .dot { background: var(--st-done); }
.sess-ua { font-weight: 600; font-size: 14px; }
.sess-meta { color: var(--muted); font-size: 12.5px; }
.sess-cur { margin-left: auto; color: var(--st-done); font-size: 12.5px; font-weight: 600; }

/* ---------- вкладка «Решения» ---------- */

.solutions { padding: 18px 28px; max-width: 1100px; margin: 0 auto; }
.sol-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.sol-hint { flex: 1; color: var(--muted); font-size: 13px; min-width: 200px; }
.sol-zone-title {
  margin: 18px 0 8px; font-size: 15px; color: var(--muted);
  text-transform: none; letter-spacing: 0;
}
.sol-subject { margin-bottom: 8px; }
.sol-task { margin-bottom: 10px; }
.sol-task-name {
  font-weight: 600; font-size: 14px; margin: 8px 0 6px;
  display: flex; align-items: center; gap: 8px;
}
.sol-count {
  padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
}
.sol-card {
  border: 1px solid var(--line); border-radius: 12px; background: var(--card);
  box-shadow: var(--shadow); padding: 10px 14px; margin-bottom: 8px;
}
.sol-card.mine { border-left: 3px solid var(--accent); }
.sol-card-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.sol-card-head b { font-size: 14px; }
.sol-when { color: var(--muted); font-size: 12.5px; }
.sol-actions { margin-left: auto; display: flex; gap: 2px; }
.sol-actions .ghost { padding: 3px 8px; font-size: 13px; }
.sol-files { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.sol-file {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  border: 1px solid var(--line); border-radius: 9px; padding: 5px 10px;
  font-size: 13px; color: var(--ink); text-decoration: none;
  transition: border-color .12s, color .12s;
}
.sol-file:hover { border-color: var(--accent); color: var(--accent); }
.sol-file span:nth-child(2) {
  max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sol-size { color: var(--muted); font-size: 12px; }
.sol-comments { border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 6px; }
.sol-comment-list { display: flex; flex-direction: column; gap: 4px; }
.sol-comment { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sol-comment-head {
  color: var(--muted); font-size: 12px; white-space: nowrap; min-width: 90px;
}
.sol-comment-text { flex: 1; font-size: 13.5px; white-space: pre-wrap; }
.sol-comment-del { padding: 0 4px; font-size: 12px; }
.sol-comment-form { display: flex; gap: 6px; margin-top: 6px; }
.sol-comment-form input {
  flex: 1; font: inherit; font-size: 13.5px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink);
}
.sol-comment-form input:focus { outline: none; border-color: var(--accent); }
.sol-comment-form .ghost { padding: 4px 10px; }
.sol-empty-zone { color: var(--muted); font-size: 13.5px; }
.sol-unattached {
  margin-top: 22px; border-top: 2px solid var(--line); padding-top: 2px;
}
.sol-files-label { font-size: 13px; color: var(--muted); margin: 6px 0 0; }

/* чеклист не торчит под вкладкой — как у «Графиков» и «Админа» */
body:not([data-tab="solutions"]) .solutions { display: none; }
body[data-tab="solutions"] .hero, body[data-tab="solutions"] .layout { display: none; }

/* зона перетаскивания в диалоге */
.sol-drop {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 90px; padding: 14px;
  border: 2px dashed var(--line); border-radius: 12px;
  color: var(--muted); cursor: pointer; user-select: none;
  transition: border-color .12s, background .12s, color .12s;
}
.sol-drop:hover, .sol-drop.hover {
  border-color: var(--accent); color: var(--accent); background: var(--accent-soft);
}
.sol-drop small { font-size: 12px; }
.sol-filelist { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.sol-filerow {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; font-size: 13px;
}
.sol-filerow-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sol-filerow .ghost { padding: 0 6px; font-size: 12px; }

/* прогресс загрузки файлов */
.sol-progress { margin-top: 10px; display: flex; align-items: center; gap: 10px; }
.sol-progress-bar {
  flex: 1; height: 8px; border-radius: 999px; overflow: hidden;
  background: var(--line); min-width: 120px;
}
.sol-progress-bar > div {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), #6d95ec);
  background-size: 200% 100%;
  animation: solShimmer 1.2s linear infinite;
  transition: width .15s ease;
}
.sol-progress > span { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
@keyframes solShimmer {
  from { background-position: 0 0; } to { background-position: 200% 0; }
}

/* появление только что загруженной карточки */
.sol-card.just-added { animation: solIn .35s ease; }
@keyframes solIn {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
  to { opacity: 1; transform: none; }
}

/* теги в комментариях */
.sol-mention {
  background: var(--accent-soft); color: var(--accent);
  border-radius: 6px; padding: 0 4px; font-weight: 600;
}
.sol-cf-wrap { position: relative; flex: 1; }
.sol-cf-wrap input { width: 100%; }
.sol-mention-list {
  position: absolute; left: 0; bottom: calc(100% + 4px); z-index: 30;
  min-width: 180px; max-height: 180px; overflow: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); padding: 4px;
}
.sol-mention-item {
  padding: 6px 10px; border-radius: 7px; cursor: pointer; font-size: 13.5px;
}
.sol-mention-item:hover { background: var(--accent-soft); color: var(--accent); }
.sol-cf-status { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* инлайн-правка комментария */
.sol-comment-actions { display: flex; gap: 2px; }
.sol-comment-actions .ghost { padding: 0 4px; font-size: 12px; }
.sol-edit { display: flex; align-items: flex-start; gap: 6px; flex-basis: 100%; }
.sol-edit-ta {
  flex: 1; font: inherit; font-size: 13.5px; padding: 6px 10px;
  border: 1px solid var(--accent); border-radius: 8px; resize: vertical;
  background: var(--card); color: var(--ink);
}
.sol-edit-ta:focus { outline: none; }
.sol-comment .sol-files { margin: 2px 0 0 0; }

@media (max-width: 640px) {
  .solutions { padding: 12px 14px; }
  .sol-file span:nth-child(2) { max-width: 170px; }
  .sol-comment-head { min-width: 0; }
}

/* ---------- тёмная тема: авто по системе + ручной переключатель ---------- */
/* Выбор кнопкой: data-theme="dark"/"light" на <html>, хранится в localStorage
   (mt_theme). Нет атрибута — тема следует за системой. Оба блока палитры
   ниже — синхронные копии, править вместе. */

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10151c;
  --card: #1a222c;
  --ink: #e8edf3;
  --muted: #8b95a3;
  --line: #2a3440;
  --accent: #6d95ec;
  --accent-soft: #22304a;
  --header-bg: rgba(16,21,28,.92);
  --track: #2a3440;
  --hover: #232d3a;
  --chip: #232d3a;
  --ctl-base: #1a222c;
  --passed-bg: #152019;
  --passed-line: #2f5a43;
  --passed-grad: linear-gradient(180deg, rgba(76,217,134,.09), #152019 70%);
  --asbar-bg: #2a2517;
  --asbar-line: #4a4025;
  --fmt-on-ink: #b8a3e8;
  --fmt-on-line: #3b3358;
  --fmt-on-bg: #242038;
  --fmt-off-ink: #dfb45c;
  --fmt-off-line: #4a4025;
  --fmt-off-bg: #2a2517;
  /* статусы на тёмном: свои ступени (валидированы на #1a222c), не автоповорот */
  --st-not-started: #8a94a3;
  --st-in-progress: #4a7ef0;
  --st-attach: #27ab7c;
  --st-attached: #5493ea;
  --st-needs-defense: #cc8300;
  --st-done: #2bab6d;
  --st-not-needed: #9d7fe8;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.35);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #10151c;
    --card: #1a222c;
    --ink: #e8edf3;
    --muted: #8b95a3;
    --line: #2a3440;
    --accent: #6d95ec;
    --accent-soft: #22304a;
    --header-bg: rgba(16,21,28,.92);
    --track: #2a3440;
    --hover: #232d3a;
    --chip: #232d3a;
    --ctl-base: #1a222c;
    --passed-bg: #152019;
    --passed-line: #2f5a43;
    --passed-grad: linear-gradient(180deg, rgba(76,217,134,.09), #152019 70%);
    --asbar-bg: #2a2517;
    --asbar-line: #4a4025;
    --fmt-on-ink: #b8a3e8;
    --fmt-on-line: #3b3358;
    --fmt-on-bg: #242038;
    --fmt-off-ink: #dfb45c;
    --fmt-off-line: #4a4025;
    --fmt-off-bg: #2a2517;
    --st-not-started: #8a94a3;
    --st-in-progress: #4a7ef0;
    --st-attach: #27ab7c;
    --st-attached: #5493ea;
    --st-needs-defense: #cc8300;
    --st-done: #2bab6d;
    --st-not-needed: #9d7fe8;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.35);
  }
}

/* кнопка 🌙/☀️ в шапке */
.theme-toggle { font-size: 16px; padding: 6px 10px; }

/* ---------- тултипы кнопок шапки (data-tip) ---------- */

[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; top: calc(100% + 7px); right: -2px; z-index: 70;
  background: var(--ink); color: var(--bg);
  padding: 5px 10px; border-radius: 8px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(23,32,43,.25);
  pointer-events: none; opacity: 0; transform: translateY(-3px);
  transition: opacity .12s ease, transform .12s ease;
}
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  opacity: 1; transform: none;
  transition: opacity .12s ease .25s, transform .12s ease .25s;
}
@media (hover: none) { [data-tip]::after { display: none; } }
