/* ─────────── Токени: світла тема за замовчуванням, темна — перемикачем у шапці ─────────── */
:root {
  /* приглушена світла: без чисто білого, щоб не сліпило */
  --bg: #dfe4ec;
  --surface: #eef1f5;
  --surface-2: #e5e9f0;
  --border: #cdd4df;
  --border-strong: #b7c0ce;
  --text: #172238;
  --muted: #5c6880;
  --primary: #243a6b;
  --primary-2: #33598f;
  --primary-soft: #d7e0ee;
  --accent: #0ea5b7;
  --lecture: #2a54c4;
  --lecture-soft: #dbe3f6;
  --practice: #0a805a;
  --practice-soft: #d5eadf;
  --exam: #b95410;
  --exam-soft: #f1dfcd;
  --danger: #c23434;
  --danger-soft: #f1dad8;
  --warn-soft: #f2e7c9;
  --today: #ece5d3;
  --today-line: #f2b33d;
  --shadow-sm: 0 1px 2px rgba(15, 27, 51, .05);
  --shadow: 0 1px 2px rgba(15, 27, 51, .04), 0 8px 24px rgba(15, 27, 51, .06);
  --shadow-lg: 0 20px 60px rgba(15, 27, 51, .22);
  --radius: 14px;
  --radius-sm: 10px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e1526;
  --surface: #151e33;
  --surface-2: #1a2440;
  --border: #27334f;
  --border-strong: #35435f;
  --text: #e7ecf6;
  --muted: #95a2ba;
  --primary: #3f6fb8;
  --primary-2: #8fb2ea;
  --primary-soft: #1d2b4b;
  --lecture: #82a2ff;
  --lecture-soft: #1b2748;
  --practice: #45cf9c;
  --practice-soft: #143229;
  --exam: #ffa35c;
  --exam-soft: #3a2616;
  --danger: #ff7c7c;
  --danger-soft: #3b1c22;
  --warn-soft: #352b15;
  --today: #1d2131;
  --today-line: #e0a53a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .55);
  color-scheme: dark;
}
:root[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2395a2ba' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
.theme-btn .ico svg { width: 18px; height: 18px; }

/* ─────────── База ─────────── */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
h1 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 20px; }
main.container { flex: 1; padding-top: 24px; padding-bottom: 40px; }

/* ─────────── Шапка ─────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-in {
  max-width: 1280px; margin: 0 auto; padding: 0 20px; height: 66px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); min-width: 0; }
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 44px; height: 44px; border-radius: 11px; flex: none;
  object-fit: contain; padding: 3px; background: #fff;
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text b { font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.brand-text small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { display: flex; align-items: center; gap: 6px; }
.nav-link {
  padding: 8px 12px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: 14px;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { color: var(--primary-2); background: var(--primary-soft); }
.user-pill {
  display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px;
  border: 1px solid var(--border); border-radius: 999px; font-size: 13px; font-weight: 600; margin-left: 4px;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary-2); font-size: 12px; font-weight: 800;
}
.role-tag { font-size: 11px; color: var(--muted); font-weight: 600; }

/* ─────────── Кнопки та поля ─────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 700; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .icon-btn:focus-visible, .add-btn:focus-visible, .lesson.editable:focus-visible,
input:focus-visible, select:focus-visible, .tab:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary-2) 40%, transparent); outline-offset: 1px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 30%, transparent); }
.btn.primary:hover { background: var(--primary-2); border-color: var(--primary-2); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn svg, .ico svg { width: 18px; height: 18px; }
.ico { display: inline-flex; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 0; background: transparent; color: var(--muted);
  display: grid; place-items: center; cursor: pointer; font-size: 16px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn svg { width: 17px; height: 17px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 700; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); font-weight: 500; }
input[type=text], input[type=password], input[type=number], input[type=time], input[type=search], select {
  height: 42px; width: 100%; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
select {
  appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364718a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
select:disabled { opacity: .55; cursor: not-allowed; background-color: var(--surface-2); }
input:hover, select:hover:not(:disabled) { border-color: var(--muted); }
input:focus, select:focus { border-color: var(--primary-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-2) 18%, transparent); outline: none; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg label {
  display: flex; align-items: center; justify-content: center; gap: 8px; height: 42px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer; font-weight: 700; font-size: 14px;
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked).k-lecture { border-color: var(--lecture); background: var(--lecture-soft); color: var(--lecture); }
.seg label:has(input:checked).k-practice { border-color: var(--practice); background: var(--practice-soft); color: var(--practice); }
.seg label:has(input:checked).k-exam { border-color: var(--exam); background: var(--exam-soft); color: var(--exam); }
.seg label:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--primary-2) 40%, transparent); }
.seg .dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; opacity: .7; }

/* ─────────── Картки ─────────── */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head p { margin: 4px 0 0; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.crumbs a { color: var(--primary-2); }

/* ─────────── Фільтри ─────────── */
.filters { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) minmax(0, 1.4fr); gap: 14px; }
.filter-card { display: grid; grid-template-columns: 1fr; gap: 16px; }
.search-wrap { position: relative; }
.search-wrap input { padding-left: 40px; }
.search-wrap .ico { position: absolute; left: 12px; top: 12px; color: var(--muted); }
.search-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 10;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 6px; max-height: 300px; overflow: auto;
}
.search-results button {
  display: flex; width: 100%; justify-content: space-between; gap: 12px; padding: 9px 10px; border: 0; background: none;
  border-radius: 8px; font: inherit; color: var(--text); cursor: pointer; text-align: left;
}
.search-results button:hover, .search-results button.active { background: var(--primary-soft); }
.search-results .muted { font-size: 13px; }
.or-line { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.or-line::before, .or-line::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ─────────── Таблиця розкладу ─────────── */
.tt-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 22px 0 12px; }
.tt-head h2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; font-weight: 700; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); font-weight: 600; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.tt-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.tt { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.tt th, .tt td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); }
.tt tr > *:last-child { border-right: 0; }
.tt tbody tr:last-child > * { border-bottom: 0; }
.tt thead th {
  padding: 12px 10px; font-size: 13px; font-weight: 800; text-align: left; color: var(--text);
  background: var(--surface-2); position: relative;
}
.tt thead th.today { background: var(--today); box-shadow: inset 0 3px 0 var(--today-line); }
.today-dot { display: inline-block; margin-left: 8px; font-size: 11px; font-weight: 700; color: #9a6400; background: #fdebc4; padding: 1px 8px; border-radius: 999px; vertical-align: 1px; }
.tt-pair-h { width: 92px; }
.tt th.tt-pair { padding: 10px; background: var(--surface-2); text-align: center; vertical-align: middle; }
.tt th.tt-pair .pn { display: grid; place-items: center; width: 30px; height: 30px; margin: 0 auto 6px; border-radius: 9px; background: var(--primary-soft); color: var(--primary-2); font-size: 15px; font-weight: 800; }
.tt th.tt-pair .pt { display: block; font-size: 12px; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.tt th.tt-pair.now .pn { background: var(--primary); color: #fff; }
.tt td { padding: 6px; vertical-align: top; height: 108px; }
.tt td.today { background: color-mix(in srgb, var(--today) 70%, transparent); }
.tt td > * + * { margin-top: 6px; }
.empty { display: grid; place-items: center; height: 100%; min-height: 60px; color: var(--border-strong); font-weight: 700; }

.lesson {
  display: block; width: 100%; text-align: left; font: inherit; color: var(--text);
  border: 1px solid transparent; border-left: 4px solid var(--lecture); border-radius: var(--radius-sm);
  background: var(--lecture-soft); padding: 8px 10px; font-size: 13px; line-height: 1.35;
}
.lesson.k-practice { border-left-color: var(--practice); background: var(--practice-soft); }
.lesson.k-exam { border-left-color: var(--exam); background: var(--exam-soft); }
.lesson.k-exam.editable:hover { border-left-color: var(--exam); }
.lesson.k-exam .badge { color: var(--exam); }
.lesson.editable { cursor: pointer; transition: box-shadow .15s, transform .1s, border-color .15s; }
.lesson.editable:hover { box-shadow: var(--shadow); border-color: var(--border-strong); border-left-color: inherit; transform: translateY(-1px); }
.lesson.k-lecture.editable:hover { border-left-color: var(--lecture); }
.lesson.k-practice.editable:hover { border-left-color: var(--practice); }
.lesson.dim { opacity: .55; }
.lesson .badge { display: inline-block; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--lecture); margin-bottom: 3px; }
.lesson .sub-tag { display: inline-block; white-space: nowrap; margin-left: 6px; padding: 0 6px; border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 10px; letter-spacing: .02em; }
.lesson.k-practice .badge { color: var(--practice); }
.l-subj { font-weight: 800; font-size: 13.5px; margin-bottom: 4px; overflow-wrap: anywhere; }
.l-meta { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.l-meta svg { width: 13px; height: 13px; flex: none; }
.l-meta b { color: var(--text); font-weight: 700; }

.add-btn {
  display: grid; place-items: center; width: 100%; min-height: 92px; border-radius: var(--radius-sm);
  border: 1.5px dashed var(--border-strong); background: transparent; color: var(--muted);
  font: inherit; font-size: 24px; font-weight: 500; cursor: pointer; transition: all .15s;
}
.add-btn:hover { border-color: var(--primary-2); color: var(--primary-2); background: var(--primary-soft); }
.add-btn.small { min-height: 30px; font-size: 12px; font-weight: 700; }

/* мобільний список */
.tt-list { display: none; gap: 12px; }
.day-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.day-card h4 { padding: 12px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 15px; }
.day-card.today h4 { background: var(--today); box-shadow: inset 4px 0 0 var(--today-line); }
.day-card > p { padding: 14px; margin: 0; }
.day-row { display: grid; grid-template-columns: 62px 1fr; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.day-row:last-child { border-bottom: 0; }
.dr-time { display: flex; flex-direction: column; align-items: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; }
.dr-time b { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-2); font-size: 14px; margin-bottom: 4px; }
.dr-body > * + * { margin-top: 6px; }
.dr-body .add-btn { min-height: 48px; }

/* ─────────── Стан «порожньо» ─────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state .big-ico { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 18px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-2); }
.empty-state .big-ico svg { width: 30px; height: 30px; }
.empty-state h3 { color: var(--text); margin-bottom: 6px; }
.empty-state p { margin: 0 auto; max-width: 420px; }

/* ─────────── Вкладки ─────────── */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; margin-bottom: 18px; box-shadow: var(--shadow-sm); scrollbar-width: thin; }
.tab { flex: none; padding: 9px 14px; border-radius: 9px; color: var(--muted); font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; gap: 7px; }
.tab:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.tab.active { background: var(--primary); color: #fff; }
.tab svg { width: 16px; height: 16px; }
.count { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.tab.active .count { background: rgba(255,255,255,.2); color: #fff; }

/* ─────────── Списки (адмінка) ─────────── */
.list { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--surface); }
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--surface-2); }
.list-row .main { flex: 1; min-width: 0; }
.list-row .title { font-weight: 700; overflow-wrap: anywhere; }
.list-row .sub { font-size: 13px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.list-row .actions { display: flex; gap: 2px; flex: none; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 180px; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.tag { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-2); font-weight: 700; }

/* ─────────── Вибір дисциплін ─────────── */
.sc-selected { display: flex; flex-wrap: wrap; gap: 6px; min-height: 34px; padding: 6px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); margin-bottom: 8px; }
.sc-selected .ph { color: var(--muted); font-size: 13px; padding: 4px 6px; }
.sc-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-2); font-weight: 700; font-size: 13px; }
.sc-chip.new { background: var(--practice-soft); color: var(--practice); }
.sc-chip button { width: 20px; height: 20px; border-radius: 50%; border: 0; background: transparent; color: inherit; cursor: pointer; display: grid; place-items: center; font-size: 13px; }
.sc-chip button:hover { background: rgba(0,0,0,.08); }
.sc-list { max-height: 210px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 8px; }
.sc-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--border); font-size: 14px; }
.sc-item:last-child { border-bottom: 0; }
.sc-item:hover { background: var(--surface-2); }
.sc-item input { width: 17px; height: 17px; accent-color: var(--primary); }
.sc-add { display: flex; width: 100%; align-items: center; gap: 8px; padding: 10px 12px; border: 0; background: var(--practice-soft); color: var(--practice); font: inherit; font-weight: 700; cursor: pointer; text-align: left; }
.sc-empty { padding: 12px; color: var(--muted); font-size: 13px; }

/* ─────────── Форми / авторизація ─────────── */
.form { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-err { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; }
.form-note { background: var(--warn-soft); padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.form-actions .left { margin-right: auto; }

.auth { max-width: 520px; margin: 12px auto 0; }
.auth .card { padding: 26px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; margin-bottom: 20px; }
.auth-tabs a { text-align: center; padding: 9px; border-radius: 9px; font-weight: 700; color: var(--muted); font-size: 14px; }
.auth-tabs a:hover { text-decoration: none; color: var(--text); }
.auth-tabs a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.auth h1 { font-size: 24px; margin-bottom: 4px; }
.auth .lead { color: var(--muted); margin: 0 0 18px; }

.hint-bar { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--text); font-size: 14px; margin-bottom: 14px; }
.hint-bar .ico { color: var(--primary-2); margin-top: 1px; }

/* ─────────── Модалка ─────────── */
.modal-wrap {
  position: fixed; inset: 0; z-index: 50; background: rgba(10, 18, 36, .48); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 16px; animation: fade .15s ease;
}
.modal {
  width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto;
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  animation: pop .18s ease;
}
.modal.wide { max-width: 640px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.modal-body { padding: 16px 20px 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ─────────── Тости ─────────── */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: grid; gap: 8px; }
.toast {
  background: var(--text); color: var(--surface); padding: 11px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow-lg); animation: pop .18s ease; max-width: 360px;
}
.toast.err { background: var(--danger); color: #fff; }

.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--primary-2); animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 18px; padding-bottom: 24px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--border); }

.times-grid { display: grid; gap: 10px; max-width: 520px; }
.times-row { display: grid; grid-template-columns: 90px 1fr 1fr; gap: 10px; align-items: center; font-weight: 700; }

/* ─────────── Перемикач тижнів ─────────── */
.weekbar {
  display: grid; grid-template-columns: 44px 1fr 44px auto; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 8px; margin-bottom: 12px;
}
.wk-arrow {
  width: 44px; height: 44px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface-2);
  font: inherit; font-size: 26px; line-height: 1; color: var(--primary); cursor: pointer; display: grid; place-items: center;
  padding-bottom: 3px;
}
.wk-arrow:hover:not(:disabled) { background: var(--primary-soft); border-color: var(--primary-2); }
.wk-arrow:disabled { opacity: .35; cursor: not-allowed; }
.wk-center { text-align: center; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.wk-tag { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.wk-tag.cur { color: var(--practice); }
.wk-label { font-size: 17px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.wk-dots { display: flex; gap: 4px; padding-left: 8px; border-left: 1px solid var(--border); }
.wk-dot {
  height: 36px; min-width: 54px; padding: 0 10px; border-radius: 9px; border: 1px solid transparent; background: transparent;
  font: inherit; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; font-variant-numeric: tabular-nums;
}
.wk-dot:hover { background: var(--surface-2); color: var(--text); }
.wk-dot.active { background: var(--primary); color: #fff; }
.wk-arrow:focus-visible, .wk-dot:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary-2) 40%, transparent); outline-offset: 1px; }

.tt thead th .th-day { display: block; }
.tt thead th .th-date { display: inline-block; margin-top: 2px; font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.dc-date { margin-left: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.print-week { display: none; }

/* ─────────── Адаптив ─────────── */
@media (max-width: 960px) {
  .tt { display: none; }
  .tt-list { display: grid; }
  .tt-wrap { background: none; border: 0; box-shadow: none; overflow: visible; }
  .weekbar { grid-template-columns: 44px 1fr 44px; }
  .wk-dots { grid-column: 1 / -1; border-left: 0; padding: 6px 0 0; border-top: 1px solid var(--border); justify-content: space-between; }
  .wk-dot { flex: 1; min-width: 0; padding: 0 4px; }
}
@media (max-width: 760px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .field:first-child { grid-column: 1 / -1; }
  .brand-text small { display: none; }
  .nav .nav-link.hide-sm, .up-name, .role-tag { display: none; }
  .user-pill { padding: 3px; }
  h1 { font-size: 23px; }
  .page-head { margin-bottom: 14px; }
  .page-head p { font-size: 14px; }
  .tt-head { margin: 18px 0 10px; }
  .tt-head h2 { font-size: 18px; }
  .tt-tools { width: 100%; }
  .tt-tools .print-btn { display: none; }
  .tt-head > .legend { width: 100%; }
  .hint-bar { font-size: 13px; }
  .tt-tools .legend { margin-right: auto; }
  .toolbar .grow { min-width: 100%; }
  .toolbar > .btn.primary { flex: 1; }
  /* 16px — щоб iOS не збільшував сторінку при фокусі */
  input[type=text], input[type=password], input[type=number], input[type=time], input[type=search], select { font-size: 16px; height: 46px; }
  .seg label { height: 46px; }
  .btn { height: 44px; }
  .btn.sm { height: 38px; }
  .icon-btn { width: 40px; height: 40px; }
  .list-row { padding: 12px; align-items: flex-start; }

  /* модалка — знизу на весь екран */
  .modal-wrap { place-items: end stretch; padding: 0; }
  .modal, .modal.wide {
    max-width: none; width: 100%; border-radius: 20px 20px 0 0; border-bottom: 0;
    max-height: calc(100dvh - 24px); animation: sheet .22s ease;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-head { position: sticky; top: 0; background: var(--surface); padding: 14px 16px 10px; z-index: 1; border-bottom: 1px solid var(--border); }
  .modal-head::before { content: ''; position: absolute; top: 6px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--border-strong); }
  .modal-body { padding: 14px 16px 18px; }
  .form-actions { position: sticky; bottom: 0; background: var(--surface); padding-top: 10px; margin-bottom: -4px; }
  .form-actions .btn { flex: 1; }
  .form-actions .left { flex-basis: 100%; order: 3; margin-right: 0; }

  .toasts { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .toast { max-width: none; text-align: center; }
  .footer { flex-direction: column; gap: 4px; text-align: center; align-items: center; }
}
@media (max-width: 520px) {
  .container, .topbar-in { padding-left: 16px; padding-right: 16px; }
  main.container { padding-top: 16px; }
  .topbar-in { height: 60px; gap: 10px; }
  .brand { gap: 10px; }
  .brand-logo { width: 40px; height: 40px; }
  .form-row { grid-template-columns: 1fr; }
  .card { padding: 14px; }
  .brand-text b { font-size: 15px; white-space: nowrap; }
  .nav { gap: 2px; }
  .nav .btn-label { display: none; }
  .nav .btn.primary.sm { width: 40px; height: 40px; padding: 0; }
  .nav .nav-link.cab { display: none; }
  .crumbs { display: none; }
  .times-row { grid-template-columns: 70px 1fr 1fr; }
  .tabs { margin-left: -16px; margin-right: -16px; border-radius: 0; border-left: 0; border-right: 0; }
  .tab { padding: 10px 12px; }
  .wk-label { font-size: 16px; }
  .wk-dot { font-size: 12px; height: 34px; }
  .day-row { grid-template-columns: 54px 1fr; gap: 8px; padding: 10px; }
  .l-subj { font-size: 14px; }
  .l-meta { font-size: 13px; }
  .tt-tools .btn.sm { padding: 0 10px; }
  .filter-card { gap: 12px; }
  .auth .card { padding: 20px 16px; }
}
@keyframes sheet { from { transform: translateY(40px); opacity: .4; } }

/* ─────────── Друк ─────────── */
@media print {
  .print-week { display: block; margin-bottom: 8px; font-weight: 700; }
  .topbar, .footer, .filter-card, .no-print, .tabs, .toasts { display: none !important; }
  body { background: #fff; }
  .tt { display: table !important; }
  .tt-list { display: none !important; }
  .tt-wrap { box-shadow: none; }
  .lesson { break-inside: avoid; }
}
