/* «Журнал уроків» — стилі.
   Токени → база → компоненти (кнопки, поля, картки, чипи) → каркас (шапка, навігація) → сторінки. */

/* ---------- Токени ---------- */
:root {
  --bg: #f3f5f8; --surface: #ffffff; --surface-2: #eef1f5; --raise: #ffffff;
  --line: #e2e6ec; --line-strong: #cdd4dd;
  --text: #17202b; --muted: #636d7a;
  --primary: #2f5d8a; --primary-hover: #264d74; --primary-soft: #e5eef8; --primary-text: #ffffff;
  --ok: #217744; --ok-bg: #e1f3e7; --bad: #b3412e; --bad-bg: #fbe8e4; --warn: #8a5d00; --warn-bg: #fff2d1;
  --planned: #3c78d8;
  --ring: color-mix(in srgb, var(--primary) 35%, transparent);
  --shadow-1: 0 1px 2px rgb(16 24 40 / .06), 0 0 0 1px rgb(16 24 40 / .02);
  --shadow-2: 0 6px 24px rgb(16 24 40 / .10);
  --radius: 14px; --radius-sm: 10px; --tabs-h: 62px;
  --card: var(--surface); --info-bg: var(--primary-soft);
  --s1: #2a78d6; --s2: #eb6834;   /* індивідуальні / групові уроки на графіках */
  color-scheme: light;
}
/* Темна тема: за налаштуванням системи, якщо людина не вибрала іншу в «Ще» → «Вигляд» (data-theme) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1115; --surface: #171b21; --surface-2: #20252d; --raise: #2b323c;
    --line: #262c35; --line-strong: #363e4a;
    --text: #e8ebf0; --muted: #98a2b0;
    --primary: #7ba8de; --primary-hover: #93b9e6; --primary-soft: #1b2939; --primary-text: #0b1420;
    --ok: #6cc591; --ok-bg: #15291c; --bad: #f08a76; --bad-bg: #33201b; --warn: #e2b54a; --warn-bg: #2e2610;
    --planned: #8db2ee; --s1: #3987e5; --s2: #d95926;
    --shadow-1: 0 1px 0 rgb(0 0 0 / .25); --shadow-2: 0 8px 30px rgb(0 0 0 / .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #0e1115; --surface: #171b21; --surface-2: #20252d; --raise: #2b323c;
    --line: #262c35; --line-strong: #363e4a;
    --text: #e8ebf0; --muted: #98a2b0;
    --primary: #7ba8de; --primary-hover: #93b9e6; --primary-soft: #1b2939; --primary-text: #0b1420;
    --ok: #6cc591; --ok-bg: #15291c; --bad: #f08a76; --bad-bg: #33201b; --warn: #e2b54a; --warn-bg: #2e2610;
    --planned: #8db2ee; --s1: #3987e5; --s2: #d95926;
    --shadow-1: 0 1px 0 rgb(0 0 0 / .25); --shadow-2: 0 8px 30px rgb(0 0 0 / .45);
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hx-cell.k1 { color: var(--primary-text); } }
:root[data-theme="dark"] .hx-cell.k1 { color: var(--primary-text); }

/* ---------- База ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tabs-h) + 14px + env(safe-area-inset-bottom)); }
main { max-width: 780px; margin: 0 auto; padding: 14px 16px 28px; }
main.wide { max-width: 1280px; }   /* сторінки-таблиці на весь місяць */
a { color: var(--primary); text-underline-offset: 2px; }
h1 { font-size: 1.45rem; letter-spacing: -.01em; margin: .4em 0 .5em; }
h2 { font-size: 1.12rem; letter-spacing: -.005em; margin: 1.3em 0 .5em; }
h3 { font-size: 1rem; margin: 0 0 .4em; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.grow { flex: 1 1 auto; min-width: 0; } .r { text-align: right; } .pre { white-space: pre-wrap; }
.inline { display: inline; }
.ic { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; }
a, button, summary, label, select { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.err { color: var(--bad); } .warn-text { color: var(--warn); } .ok-text { color: var(--ok); }
.planned { color: var(--planned); font-style: italic; }

/* ---------- Кнопки ----------
   .btn — вторинна (заливка + рамка), .primary — головна дія, .ok — «Проведено»,
   .ghost — на поверхні картки, .danger — руйнівна. .link — лише текст. */
.btn { --b-bg: var(--surface-2); --b-fg: var(--text); --b-bd: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 8px 15px;
  border: 1px solid var(--b-bd); border-radius: var(--radius-sm); background: var(--b-bg); color: var(--b-fg);
  font: inherit; font-weight: 600; line-height: 1.2; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color .15s, border-color .15s, box-shadow .15s, transform .06s; }
.btn:hover { background: color-mix(in srgb, var(--b-bg), var(--text) 7%); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn .ic { width: 18px; height: 18px; }
.btn.primary { --b-bg: var(--primary); --b-fg: var(--primary-text); --b-bd: transparent; box-shadow: var(--shadow-1); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ok { --b-bg: var(--ok-bg); --b-fg: var(--ok); --b-bd: color-mix(in srgb, var(--ok) 28%, transparent); }
.btn.ghost { --b-bg: var(--surface); }
.btn.danger { --b-bg: var(--bad-bg); --b-fg: var(--bad); --b-bd: color-mix(in srgb, var(--bad) 28%, transparent); }
.btn.small { min-height: 34px; padding: 5px 11px; font-size: .88rem; gap: 6px; border-radius: 9px; }
.btn.small .ic { width: 16px; height: 16px; }
.btn.icon { width: 40px; padding: 0; } .btn.small.icon { width: 34px; }
.btn.big { min-height: 50px; padding: 12px 22px; font-size: 1.05rem; border-radius: 12px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.link { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px; display: inline-flex; align-items: center; gap: 4px; }
.link.bad { color: var(--bad); }
.back { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; text-decoration: none; margin: 2px 0 6px; }

/* ---------- Поля ---------- */
input, textarea, select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 8px 11px; min-height: 40px; max-width: 100%;
  transition: border-color .15s, box-shadow .15s; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
input[type=color] { width: 44px; padding: 3px; cursor: pointer; }
input[type=checkbox], input[type=radio] { min-height: 0; width: 18px; height: 18px; accent-color: var(--primary); }
input[type=checkbox]:focus, input[type=radio]:focus { box-shadow: none; }
.label { font-weight: 600; margin: 6px 0 4px; font-size: .9rem; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: .9rem; font-weight: 600; }
.num { width: 90px; }
.check, .radio-row { display: flex; align-items: center; gap: 9px; font-weight: 400; padding: 5px 0; }

/* Сегменти: вкладки-перемикачі й групи прапорців */
.seg { display: inline-flex; gap: 2px; padding: 3px; margin: 0; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-2); }
.seg a, .seg label { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 13px;
  border-radius: 9px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .9rem; cursor: pointer;
  transition: background-color .15s, color .15s; }
.seg a:hover, .seg label:hover { color: var(--text); }
.seg a.on, .seg label:has(input:checked) { background: var(--raise); color: var(--primary); box-shadow: var(--shadow-1); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--primary); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
/* кілька прапорців (місяці для оновлення): вибране — з галочкою й тлом, щоб відрізнялося від невибраного */
.seg label:has(input[type=checkbox]:checked) { background: var(--primary-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 40%, transparent); }
.seg label:has(input[type=checkbox]:checked)::before { content: ""; width: 14px; height: 14px; flex: none; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat; }
.seg.wide { display: flex; } .seg.wide label { flex: 1; text-align: center; }
.seg label .ic, .seg a .ic { width: 16px; height: 16px; }

/* ---------- Картки, банери, чипи ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  margin: 10px 0; box-shadow: var(--shadow-1); }
.card > h2:first-child { margin-top: 0; }
.card.inner { background: var(--bg); box-shadow: none; margin-top: 12px; }
.banner { border-radius: var(--radius); padding: 11px 14px; margin: 8px 0; border: 1px solid transparent; }
.banner.info { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 18%, transparent); }
.banner.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 22%, transparent); }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; font-weight: 600; line-height: 1.5;
  padding: 1px 9px; border-radius: 99px; background: var(--surface-2); color: var(--text); vertical-align: middle;
  border: 1px solid var(--line); }
.chip .ic { width: 13px; height: 13px; }
.chip.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.chip.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.chip.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.chip.grp, .chip.auto, .chip.fmt.online { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.chip.fmt.offline { background: var(--surface-2); }
.chip.pay-paid { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.chip.pay-partial { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.chip.pay-unpaid { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.plain { list-style: none; padding: 0; } .plain li { padding: 7px 0; border-bottom: 1px solid var(--line); }

/* Розгортання: власна стрілка замість трикутника браузера */
details > summary { cursor: pointer; color: var(--primary); margin-top: 6px; list-style: none; font-weight: 600; }
details > summary::-webkit-details-marker { display: none; }
details:not(.more) > summary::before { content: ""; display: inline-block; width: 15px; height: 15px; margin-right: 4px;
  vertical-align: -2px; background: currentColor; transition: transform .15s;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.5 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.5 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat; }
details[open]:not(.more) > summary::before { transform: rotate(90deg); }

/* ---------- Шапка ---------- */
.top { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top); }
.top-in { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; gap: 16px; padding: 9px 16px; min-height: 58px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.02rem; letter-spacing: -.01em;
  text-decoration: none; color: var(--text); white-space: nowrap; }
.brand .logo { border-radius: 8px; flex: none; }
.account { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.account form { margin: 0; }
.avatar { --av: #4F7CAC; display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%;
  background: var(--av); color: #fff; font-size: .8rem; font-weight: 700; letter-spacing: .02em; user-select: none;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px color-mix(in srgb, var(--av) 40%, transparent); }
.avatar.sm { width: 26px; height: 26px; font-size: .68rem; box-shadow: none; }

/* Навігація: на телефоні — панель знизу, на широкому екрані — у шапці */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding: 0 4px env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 600; }
.tab-ic { display: grid; place-items: center; width: 54px; height: 30px; border-radius: 99px; transition: background-color .15s; }
.tab-ic .ic { width: 22px; height: 22px; }
.tabs a.on { color: var(--primary); }
.tabs a.on .tab-ic { background: var(--primary-soft); }
.tabs a:hover .tab-ic { background: var(--surface-2); }
.tabs a.on:hover .tab-ic { background: var(--primary-soft); }

/* Контекст адміністратора: чий журнал відкрито */
.ctx { border-top: 1px solid var(--line); background: var(--surface); }
.ctx.other { background: var(--primary-soft); border-top-color: color-mix(in srgb, var(--primary) 15%, transparent); }
.ctx-in { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 7px 16px; }
.ctx-label { font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.jpick { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 4px 10px 4px 5px;
  border: 1px solid var(--line-strong); border-radius: 99px; background: var(--surface); font-weight: 650; cursor: pointer;
  box-shadow: var(--shadow-1); max-width: 100%; transition: border-color .15s, box-shadow .15s; }
.jpick:hover { border-color: var(--primary); }
.jpick:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.jpick-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jpick-arrows { color: var(--muted); width: 16px; height: 16px; }
.jpick select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; }
.ctx-badge { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 600; color: var(--primary); }
.ctx-badge .ic { width: 17px; height: 17px; }
.demo-strip { background: var(--warn-bg); color: var(--warn); text-align: center; font-size: .85rem; font-weight: 600; padding: 6px 12px; }

@media (min-width: 900px) {
  body { padding-bottom: 32px; }
  .tabs { position: static; height: auto; padding: 0; margin: 0 auto; background: none; border: 0; gap: 2px; flex: none; }
  .tabs a { flex-direction: row; gap: 7px; padding: 7px 13px; border-radius: 10px; font-size: .92rem; }
  .tab-ic { width: auto; height: auto; background: none !important; }
  .tab-ic .ic { width: 19px; height: 19px; }
  .tabs a:hover { background: var(--surface-2); color: var(--text); }
  .tabs a.on { background: var(--primary-soft); color: var(--primary); }
  .account { margin-left: 0; }
}
@media (max-width: 899px) {
  .account .logout span { display: none; }
  .account .logout { width: 34px; padding: 0; }
}
@media (max-width: 380px) { .brand span { font-size: .95rem; } }

/* ---------- Розклад ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 14px 0 6px; flex-wrap: wrap; }
.toolbar .nav { display: flex; gap: 6px; }
.period { margin-top: 10px; display: flex; align-items: center; gap: 8px; }
.icon-link { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; color: var(--muted); }
.icon-link:hover { background: var(--surface-2); color: var(--primary); }
.icon-link .ic { width: 17px; height: 17px; }
.first { margin-top: 4px; }
.first-label { font-weight: 700; color: var(--primary); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
@media (min-width: 761px) { .first { display: none; } }
.day { margin: 18px 0; }
.day h3 { display: flex; align-items: baseline; gap: 8px; font-size: .95rem; }
.day.today h3 { color: var(--primary); }
.day .empty { margin: 0 0 0 4px; }
.lesson { position: relative; display: grid; grid-template-columns: 54px 1fr; gap: 4px 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 12px 16px; margin: 8px 0;
  box-shadow: var(--shadow-1); overflow: hidden; }
.lesson::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, var(--primary)); }
.lesson .time { font-weight: 700; font-variant-numeric: tabular-nums; }
.lesson .time small { display: block; color: var(--muted); font-weight: 500; }
.lesson .name { font-weight: 650; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.lesson .members, .lesson .topic { font-size: .9rem; }
.lesson .members .absent { text-decoration: line-through; color: var(--muted); }
.lesson .members .late { color: var(--warn); }
.lesson .loc { display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.lesson .loc .ic { width: 15px; height: 15px; }
.lesson .topic::before { content: "Тема: "; color: var(--muted); }
.lesson .hw, .hist .hw { font-size: .9rem; } .lesson .hw::before, .hist .hw::before { content: "ДЗ: "; color: var(--muted); }
.hist .topic::before { content: "Тема: "; color: var(--muted); }
.lesson .state { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.lesson .links { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.lesson .prep { font-size: .85rem; margin-top: 4px; }
.lesson .prep summary { margin-top: 2px; font-size: .85rem; }
.lesson .actions { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
  margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.lesson.cancelled { opacity: .72; } .lesson.cancelled .name { text-decoration: line-through; }
.lesson.todo:not(.overdue) .name { font-style: italic; }
.lesson.queued { outline: 2px dashed var(--warn); }
.prep-box { background: var(--primary-soft); border-radius: var(--radius-sm); padding: 9px 12px; font-size: .9rem; }
.offline-banner { position: sticky; top: calc(var(--hdr, 58px) + 8px); z-index: 4; }

/* Місяць у розкладі: компактні рядки, дотик розгортає картку */
.compact .lesson { padding: 9px 14px 9px 16px; margin: 6px 0; cursor: pointer; gap: 2px 12px; }
.compact .lesson:not(.expanded) :is(.members, .loc, .topic, .hw, .prep, .links, .actions, .time small) { display: none; }
.compact .lesson:not(.expanded) .state { margin-top: 2px; }
.compact .lesson.expanded { box-shadow: 0 0 0 2px var(--primary) inset; }
.hint { margin: 6px 0 0; }

/* Вікно уроку */
dialog { border: 0; border-radius: 18px; padding: 0; width: min(540px, calc(100vw - 24px)); background: var(--surface);
  color: var(--text); box-shadow: var(--shadow-2); }
dialog::backdrop { background: rgb(8 12 18 / .5); }
dialog form { padding: 18px; display: flex; flex-direction: column; gap: 11px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.attend-row { padding: 5px 0; border-bottom: 1px solid var(--line); }
.attend-row select { max-width: 60%; }

/* ---------- Учні, зіставлення ---------- */
.title-card { border-left: 4px solid var(--c); } .title-card .name { font-weight: 650; }
.hidden-item { opacity: .55; }
.members-edit .member { padding: 5px 0; border-bottom: 1px solid var(--line); }
.month-kids { border-left: 4px solid var(--ok); }
.card.match.todo { border-left: 4px solid var(--warn); }
.card.match.auto { border-left: 4px solid var(--primary); }
.card.suspicious { border-left: 4px solid var(--muted); }
.match-fields { margin-top: 6px; }
.match-fields select { min-width: 0; flex: 1 1 200px; }
.match .pibx { width: 100%; margin: 6px 0; }
.sticky-actions { position: sticky; bottom: calc(var(--tabs-h) + 4px + env(safe-area-inset-bottom)); display: flex; gap: 8px;
  justify-content: flex-end; padding: 10px 0; background: linear-gradient(transparent, var(--bg) 30%); }
@media (min-width: 900px) { .sticky-actions { bottom: 0; } }

/* ---------- Місяць, ЗП, звіти ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow-1); }
.stat span { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); }
.stat b { display: block; font-size: 1.2rem; letter-spacing: -.01em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat small { display: block; font-size: .75rem; color: var(--muted); margin-top: 2px; }
.stat small.planned { color: var(--planned); }
.stats.wide { grid-template-columns: repeat(4, 1fr); margin-bottom: 10px; }
@media (max-width: 600px) { .stats.wide { grid-template-columns: repeat(2, 1fr); } }
.payroll { border-left: 4px solid var(--primary); }
.table-wrap { overflow-x: auto; }
table.month { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-1); overflow: hidden; }
table.month th { font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  background: var(--surface-2); }
table.month th, table.month td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
table.month tbody tr:last-child td { border-bottom: 0; }
table.month th.r, table.month td.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.month tr.sub td { border-bottom: 2px solid var(--line); padding-top: 0; }
table.month .part { margin-bottom: 4px; }
table.month .part .chip { margin-right: 4px; }
table.month td > .chip { white-space: nowrap; }
table.month .copy-col { width: 1%; padding-right: 0; }
.copy-row { margin: 14px 0 8px; }
.copy-child { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid var(--line-strong);
  border-radius: 9px; background: var(--surface); color: var(--muted); cursor: pointer; transition: color .15s, border-color .15s, background-color .15s; }
.copy-child .ic { width: 16px; height: 16px; }
.copy-child:hover, .copy-child:focus-visible { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }
.report { border-radius: var(--radius); padding: 12px 16px; margin: 10px 0; background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--ok); box-shadow: var(--shadow-1); }
.report.bad { border-left-color: var(--bad); }
.report-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.report-month { margin-top: 6px; }
details.more > summary { list-style: none; margin: 4px 0 6px; }
details.more .if-open, details.more[open] .if-closed { display: none; }
details.more[open] .if-open { display: inline; }

/* Статистика школи */
.subnav { display: flex; gap: 4px; margin: 4px 0 12px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.subnav::-webkit-scrollbar { display: none; }
.subnav a { flex: none; white-space: nowrap; }
.subnav a { padding: 9px 12px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subnav a:hover { color: var(--text); }
.subnav a.on { color: var(--primary); border-bottom-color: var(--primary); }
/* Карта «Коли зайнятий центр»: сітка, що на телефоні повертається (дні — стовпці, години — рядки) */
.heat-lead { font-weight: 600; margin: 4px 0 6px; }
.heat2 { display: grid; gap: 3px; margin: 12px 0 8px; max-width: 900px; font-variant-numeric: tabular-nums;
  grid-template-columns: 92px repeat(14, minmax(0, 1fr)) 58px; grid-auto-rows: 34px; }
.heat2 > * { grid-row: var(--row); grid-column: var(--col); display: grid; place-items: center; min-width: 0; }
.hx-hour { font-size: .7rem; font-weight: 600; color: var(--muted); align-self: end; padding-bottom: 2px; }
.hx-day { justify-items: start; font-size: .85rem; font-weight: 600; color: var(--muted); padding-right: 6px; }
.hx-day .short { display: none; }
.hx-tot-h { color: var(--text); }
.hx-tot { font-size: .85rem; font-weight: 700; border-left: 1px solid var(--line); }
.hx-cell { position: relative; border-radius: 7px; font-size: .8rem; font-weight: 700; color: var(--text);
  background: color-mix(in oklab, var(--primary) calc(var(--a) * 100%), var(--surface-2)); transition: box-shadow .12s; }
.hx-cell.k2 { color: var(--primary-text); }
.hx-cell[tabindex] { cursor: pointer; }   /* iPhone показує підказку по дотику лише «клікабельним» елементам */
.hx-cell[tabindex]:hover, .hx-cell:focus-visible { box-shadow: inset 0 0 0 2px var(--text); outline: none; z-index: 2; }
/* підказка: значення першим рядком; біля країв прив'язана до краю */
.hx-cell[tabindex]:hover::after, .hx-cell[tabindex]:focus::after { content: attr(data-tip); position: absolute; z-index: 6;
  bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); width: max-content; max-width: 240px; white-space: pre-line;
  text-align: left; background: var(--text); color: var(--bg); font-size: .78rem; font-weight: 500; line-height: 1.4;
  padding: 7px 10px; border-radius: 9px; box-shadow: var(--shadow-2); pointer-events: none; }
.hx-cell.l::after { left: 0 !important; transform: none !important; }
.hx-cell.r::after { left: auto !important; right: 0; transform: none !important; }
.heat-legend { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.heat-legend i { width: 22px; height: 14px; border-radius: 4px; background: color-mix(in oklab, var(--primary) calc(var(--a) * 100%), var(--surface-2)); }
.heat-legend span:first-child { margin-right: 2px; } .heat-legend i + span { margin-left: 2px; }
@media (max-width: 600px) {
  .heat2 { grid-template-columns: 48px repeat(7, minmax(0, 1fr)); grid-auto-rows: 30px; }
  .heat2 > * { grid-row: var(--prow); grid-column: var(--pcol); }
  .hx-hour { align-self: center; justify-items: start; padding: 0; }
  .hx-day { justify-items: center; padding: 0; align-self: end; }
  .hx-day .long { display: none; } .hx-day .short { display: inline; }
  .hx-tot { border-left: 0; border-top: 1px solid var(--line); }
  .hx-cell.l::after, .hx-cell.r::after { left: 50% !important; right: auto; transform: translateX(-50%) !important; }
  .hx-cell.pl::after { left: 0 !important; right: auto; transform: none !important; }
  .hx-cell.pr::after { left: auto !important; right: 0 !important; transform: none !important; }
}
.trend { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow-1); }
.trend-row { display: grid; grid-template-columns: 56px 1fr; gap: 2px 8px; align-items: center; margin: 6px 0; }
.trend-label { font-size: .8rem; color: var(--muted); }
.trend-bars { display: flex; flex-direction: column; gap: 2px; }
.bar { height: 8px; border-radius: 4px; min-width: 2px; }
.bar.revenue, .legend.revenue { background: var(--primary); }
.bar.earned, .legend.earned { background: var(--ok); }
.trend-val { grid-column: 2; color: var(--muted); }
.legend { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; }
.rates-form .field { flex: 1 1 140px; }

/* Навантаження вчителя: вибір вчителя й сітка «як у таблиці» */
.tpick { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; margin: 4px 0 6px; scrollbar-width: thin; }
.tpick a { display: inline-flex; align-items: center; gap: 7px; flex: none; padding: 4px 12px 4px 4px; border-radius: 99px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); text-decoration: none; font-weight: 600; font-size: .9rem; }
.tpick a:hover { border-color: var(--primary); }
.tpick a.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.tpick a:not(:has(.avatar)) { padding: 7px 14px; }
.lg-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .82rem; color: var(--muted); margin: 6px 0 4px; }
.lg-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg-legend .c { font-style: normal; }
.lg-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-1); margin: 8px 0; }
table.lgrid { border-collapse: separate; border-spacing: 0; font-size: .8rem; font-variant-numeric: tabular-nums; min-width: 100%; }
.lgrid th, .lgrid td { padding: 0; height: 34px; text-align: center; border-bottom: 1px solid var(--line); }
.lgrid tbody tr:last-child > * { border-bottom: 0; }
.lgrid thead th { background: var(--surface-2); color: var(--muted); font-size: .72rem; font-weight: 700; line-height: 1.1; padding: 5px 0; }
.lgrid thead small { display: block; font-weight: 500; font-size: .64rem; }
.lgrid .dc { min-width: 30px; }
.lgrid .we { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.lgrid thead .we { background: color-mix(in oklab, var(--surface-2), var(--text) 5%); }
.lgrid thead .now { color: var(--primary); box-shadow: inset 0 -3px 0 var(--primary); }
.lgrid .nm { position: sticky; left: 0; z-index: 1; background: var(--surface); text-align: left; padding: 0 10px; min-width: 180px;
  max-width: 230px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-right: 1px solid var(--line); font-weight: 600; }
.lgrid thead .nm { background: var(--surface-2); z-index: 2; }
.lgrid .nm a { color: var(--text); text-decoration: none; } .lgrid .nm a:hover { color: var(--primary); text-decoration: underline; }
.lgrid .tot { padding: 0 10px; text-align: right; white-space: nowrap; font-weight: 700; border-left: 1px solid var(--line); }
.lgrid .tot small { display: block; font-size: .7rem; font-weight: 600; line-height: 1; }
.lgrid tfoot > * { background: var(--surface-2); color: var(--muted); font-weight: 700; border-top: 1px solid var(--line-strong); border-bottom: 0; }
.lgrid tfoot .tot { color: var(--text); }
/* клітинка з годинами: колір = тип уроку (+ крапка в групових), пунктир = ще не позначено, штрих = пізнє скасування */
.lgrid .c, .lg-legend .c { --k: var(--s1); position: relative; display: inline-grid; place-items: center; width: 27px; height: 25px;
  border-radius: 6px; font-weight: 700; color: var(--text); cursor: pointer; border: 1.5px solid transparent;
  background: color-mix(in oklab, var(--k) 30%, var(--surface)); }
.c.grp { --k: var(--s2); }
.c.grp::after { content: ""; position: absolute; top: 2px; right: 2px; width: 5px; height: 5px; border-radius: 50%; background: var(--k); }
.c.planned { background: color-mix(in oklab, var(--k) 8%, var(--surface)); border: 1.5px dashed var(--k); font-style: italic; font-weight: 600; }
.c.late { background-image: repeating-linear-gradient(135deg, transparent 0 3px, color-mix(in oklab, var(--k) 45%, transparent) 3px 5px); }
.lgrid .c:hover, .lgrid .c:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }
.lg-tip { position: fixed; z-index: 30; max-width: 280px; white-space: pre-line; background: var(--text); color: var(--bg);
  font-size: .8rem; line-height: 1.4; padding: 8px 11px; border-radius: 10px; box-shadow: var(--shadow-2); pointer-events: none; }
@media (max-width: 600px) { .lgrid .nm { min-width: 128px; max-width: 150px; padding: 0 8px; } }

/* «Потребує уваги» */
.attn { display: grid; grid-template-columns: 1fr; gap: 10px; }
.attn-card { margin: 0; display: flex; flex-direction: column; }
.attn-card h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.attn-card h3 .ic { width: 19px; height: 19px; color: var(--primary); }
.attn-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.attn-row:first-of-type { border-top: 0; }
.attn-row form { margin: 0; }
.attn-ok { display: flex; align-items: center; gap: 6px; color: var(--ok); font-weight: 600; font-size: .9rem; margin: 6px 0; }
.attn-note { margin: 8px 0 0; padding-top: 8px; border-top: 1px dashed var(--line); }
.h2-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 1.3em; }
.h2-row h2 { margin: 0; }

/* Журнал змін */
.log-day { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 4px; }
.log-row { display: flex; gap: 12px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); margin: 6px 0; }
.log-time { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); min-width: 44px; }

/* Великий центр: вибір вчителя, пошук і згортання довгих списків */
.tsel { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 12px; }
.tsel .jpick { min-width: 0; max-width: min(100%, 360px); }
.ttools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 6px 0 8px; }
.ttools input[type=search] { flex: 1 1 220px; }
.ttools-sort { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--muted); font-weight: 600; }
table.teachers.folded tr.t-more { display: none; }
.attn-sum { color: var(--muted); margin: 0 0 4px; }
.attn-more > summary { margin: 8px 0 2px; }
.attn-more[open] > summary { margin-bottom: 6px; }
h2 .muted { font-weight: 600; }

/* ---------- Налаштування, пристрої ---------- */
.cal-row { padding: 9px 0; border-bottom: 1px solid var(--line); }
.cal-row:last-of-type { border-bottom: 0; }
.other-cals { margin-top: 8px; }
.sess-h { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 20px 4px 6px; }
.sess-list { padding: 2px 16px; }
.sess { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.sess + .sess { border-top: 1px solid var(--line); }
.sess-icon { flex: none; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); }
.sess-icon .ic { width: 21px; height: 21px; }
.sess-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; }
.sess-side form, .sess-list form { margin: 0; }
.sess-online { color: var(--primary); font-size: .85rem; font-weight: 600; }
.sess-danger { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: 0;
  border-top: 1px solid var(--line); padding: 12px 0; color: var(--bad); font: inherit; font-weight: 600; cursor: pointer; }
.sess-note { margin: 4px 4px 0; }

/* ---------- Вхід ---------- */
.login { max-width: 440px; margin: 0 auto; padding-top: 10vh; text-align: center; }
.login .logo { border-radius: 18px; box-shadow: var(--shadow-2); }
.login h1 { margin: 18px 0 6px; font-size: 1.7rem; }
.login .card { text-align: left; }
.login .btn.big { width: 100%; margin: 16px 0 10px; }
.demo-note { border: 2px dashed var(--warn); }

/* ---------- Тестова таблиця (демо) ---------- */
.sheet-wrap { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
table.sheet { border-collapse: collapse; font-size: .75rem; }
table.sheet th, table.sheet td { border: 1px solid var(--line); padding: 2px 4px; white-space: nowrap; min-width: 28px; text-align: center; }
table.sheet td:first-of-type { text-align: left; }
table.sheet thead th { position: sticky; top: 0; background: var(--bg); z-index: 1; }
table.sheet tbody th { position: sticky; left: 0; background: var(--bg); }
table.sheet td.f { color: var(--muted); }

/* ---------- Сповіщення ---------- */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 12px; z-index: 20; max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-2); font-weight: 500; }
@media (min-width: 900px) { .toast { bottom: 28px; } }
.toast.busy::before { content: ""; display: inline-block; width: .9em; height: .9em; margin-right: .5em; vertical-align: -0.1em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: tl-spin .8s linear infinite; }
@keyframes tl-spin { to { transform: rotate(360deg); } }

a.strong { font-weight: 600; }

/* ---------- Телефон ---------- */
@media (max-width: 600px) {
  main { padding: 10px 12px 24px; }
  h1 { font-size: 1.3rem; }
  /* iOS не збільшує сторінку при фокусі, якщо шрифт поля ≥ 16px */
  input, select, textarea { font-size: 16px; }
  .top-in { padding: 8px 12px; min-height: 54px; gap: 10px; }
  .ctx-in { padding: 6px 12px; gap: 8px; }
  .ctx-badge span { font-size: .8rem; }
  .toolbar { gap: 6px; }
  .toolbar .seg a { padding: 6px 11px; }
  .card { padding: 12px 14px; }
  .stats { gap: 6px; }
  .stat { padding: 9px 11px; }
  .stat b { font-size: 1.05rem; }
  .lesson .actions { flex-wrap: nowrap; }
  .lesson .actions .btn:not(.icon) { flex: 1 1 0; min-width: 0; padding-inline: 8px; }

  /* таблиці → картки */
  table.stack, table.stack tbody { display: block; background: none; border: 0; box-shadow: none; overflow: visible; }
  table.stack thead { display: none; }
  table.stack tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; padding: 11px 13px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 8px 0; box-shadow: var(--shadow-1); }
  table.stack tr.sub { margin-top: -8px; border-top: 0; border-radius: 0 0 var(--radius) var(--radius); padding-top: 4px; }
  table.stack td { display: block; border: 0; padding: 0; text-align: left; }
  table.stack td.c-copy { order: 0; width: auto; padding: 0; }
  table.stack td.c-name { flex: 1 1 0; min-width: 0; font-weight: 600; }
  table.stack td.c-full { flex: 1 1 100%; }
  table.stack td.c-status { margin-left: auto; }
  table.stack td[data-label]::before { content: attr(data-label) " "; color: var(--muted); font-size: .8rem; }
  table.stack td[data-label] > div { display: inline; margin-left: 4px; }
  table.month .part .chip { border-radius: 6px; white-space: normal; }


  /* вікно уроку — панель знизу екрана */
  dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 18px 18px 0 0; max-height: 92vh; }
  dialog form { padding: 16px 16px 0; }
  .dialog-actions { position: sticky; bottom: 0; background: var(--surface); margin: 0 -16px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line); }
  .dialog-actions .btn { flex: 1; }
  dialog h3 { margin-bottom: 0; }
  dialog #mark-when { margin-top: 0; }
  .attend-row select { max-width: 62%; }
  .seg.wide label { padding: 8px 4px; font-size: .85rem; line-height: 1.2; }
  /* текстові кнопки («прибрати» тощо) — більша зона дотику */
  button.link { min-height: 36px; padding: 6px 4px; }
}

table.teachers tr[hidden] { display: none !important; }   /* пошук ховає рядки й на телефоні, де рядки — flex */
