*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.5;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--pri);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3 {
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0;
}

h1 { font-size: clamp(1.6rem, 3.2vw, 2.1rem); }
h2 { font-size: 1.05rem; letter-spacing: -0.01em; }

p { margin: 0; }

.ic { flex-shrink: 0; display: block; }
.small { font-size: 0.85rem; }

/* ---------- Shell ---------- */

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.shell-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

.brand {
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-size: 1.3rem;
  text-decoration: none;
}

.brand:hover { text-decoration: none; }
.brand span { color: var(--pri); }

.topbar-mobile {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--paper);
  border-bottom: var(--border-w) solid var(--line);
}

.cabinet-sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: var(--border-w) solid var(--line);
  padding: 1.5rem 0.9rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.cabinet-sidebar .brand { padding: 0 0.85rem 1.35rem; }

/* Long menus (administration) scroll inside the sidebar; the user block with «Вийти» stays visible. */
.cabinet-sidebar > .nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: thin; margin-right: -0.4rem; padding-right: 0.4rem; }
.cabinet-sidebar .sidebar-foot { flex-shrink: 0; padding-top: 0.6rem; border-top: var(--border-w) solid var(--line); }

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.62rem 0.85rem;
  border-radius: 12px;
  font-weight: 600;
  color: var(--mut);
  text-decoration: none;
  border: none;
  background: none;
  font: inherit;
  cursor: pointer;
  width: 100%;
  text-align: left;
}

.nav-link:hover {
  background: var(--pri-t);
  color: var(--pri);
  text-decoration: none;
}

.nav-link.is-active {
  background: var(--pri-t);
  color: var(--pri);
  font-weight: 700;
}

.nav-link.is-disabled {
  opacity: 0.5;
  cursor: default;
}

.nav-link.is-disabled:hover { background: none; color: var(--mut); }

.nav-soon {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--line);
}

.nav-badge {
  margin-left: auto;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-emoji { width: 1.3rem; text-align: center; font-size: 1.05rem; }

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-top: 1rem;
}

.me {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.6rem;
}

.avatar {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 999px;
  background: var(--pri-t);
  color: var(--pri);
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.me-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.me-text b {
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.me-text .muted { font-size: 0.78rem; }

.nav-logout { font-size: 0.92rem; }

.sidebar-mascot { padding: 0 0.6rem 0.25rem; }

.sidebar-mascot svg {
  width: 56px;
  height: auto;
  display: block;
}

.cabinet-main,
.manage-main {
  flex: 1;
  min-width: 0;
  padding: 2.25rem 2.75rem 3.5rem;
}

.cabinet-main { max-width: 1180px; }

.page-narrow {
  max-width: 440px;
  margin: 3rem auto;
  padding: 0 1.25rem 3rem;
}

/* ---------- Page header ---------- */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.6rem;
}

.page-head .eyebrow { margin-bottom: 0.3rem; }
.page-head .lead { margin-top: 0.4rem; max-width: 46rem; }

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.back-link {
  display: inline-block;
  color: var(--mut);
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.lead,
.muted,
.mut {
  color: var(--mut);
}

.eyebrow {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--mut);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.row-between {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ---------- Cards & lists ---------- */

.auth-card,
.card {
  background: var(--paper);
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius);
  padding: 1.35rem 1.45rem;
  box-shadow: var(--shadow-card);
}

.auth-card { padding: 2rem; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.card-head h2 { font-size: 0.95rem; color: var(--mut); font-weight: 700; letter-spacing: 0; }
.card-head a { font-size: 0.88rem; font-weight: 700; }

.card-foot { margin-top: 1rem; }

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

/* A list of rows inside a card: title left, meta/chip right */
.rows { list-style: none; margin: 0; padding: 0; }

.rows > li,
.rows > a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}

.rows > li:first-child,
.rows > a:first-child { border-top: none; padding-top: 0.1rem; }

.rows > a:hover .row-title { color: var(--pri); }

.row-title { font-weight: 700; min-width: 0; }
.row-sub { color: var(--mut); font-size: 0.88rem; font-weight: 500; }
.row-meta { color: var(--mut); font-weight: 600; font-size: 0.9rem; white-space: nowrap; }

.empty { color: var(--mut); font-weight: 500; }

/* Lesson cards */
.lesson-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

a.lesson-row { color: inherit; text-decoration: none; }
a.lesson-row:hover .row-title { color: var(--pri); }

.lesson-row .lesson-left {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
}

.lesson-now {
  background: var(--pri-t);
  border-color: rgba(91, 84, 238, 0.22);
}

.lesson-now .lesson-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-top: 0.55rem;
}

.lesson-now .lesson-sub { color: var(--mut); font-weight: 600; margin-top: 0.15rem; }

.day-label {
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--mut);
  margin: 0.4rem 0 -0.35rem;
}

/* ---------- Chips ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  padding: 0.22rem 0.7rem;
  font-weight: 700;
  font-size: 0.8rem;
  background: var(--pri-t);
  color: var(--pri);
  white-space: nowrap;
}

.chip-lg { font-size: 0.92rem; padding: 0.35rem 0.85rem; }
.chip-grn { background: var(--grn-t); color: var(--grn); }
.chip-amb { background: var(--amb-t); color: var(--amb); }
.chip-red { background: var(--red-t); color: var(--red); }
.chip-sky { background: var(--sky-t); color: var(--sky); }
.chip-lav { background: var(--lav-t); color: var(--lav); }
.chip-mut { background: var(--bg); color: var(--mut); }

.chip-x {
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  padding: 0 0 0 0.15rem;
  opacity: 0.55;
  line-height: 1;
}

.chip-x:hover { opacity: 1; }

.dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--line);
  margin-right: 0.35rem;
  vertical-align: 0.05em;
}

.dot-grn { background: var(--grn); }
.dot-red { background: var(--red); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: var(--radius-btn);
  padding: 0.72rem 1.3rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  background: var(--pri);
  color: #fff;
  box-shadow: var(--shadow-btn);
  white-space: nowrap;
  transition: transform 0.08s ease, filter 0.12s ease;
}

.btn:hover { text-decoration: none; filter: brightness(0.96); }
.btn:active { transform: translateY(1px) scale(0.99); }

.btn-ghost {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}

.btn-red {
  background: var(--red);
  box-shadow: 0 8px 20px -8px rgba(217, 45, 32, 0.5);
}

.btn-sm { padding: 0.42rem 0.8rem; font-size: 0.88rem; }
.btn-block { width: 100%; }

.inline { display: inline; margin: 0; }

:focus-visible {
  outline: 2px solid var(--pri);
  outline-offset: 2px;
}

/* ---------- Segmented controls ---------- */

.seg,
.switcher {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.seg-btn,
.switcher a {
  border: none;
  background: none;
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--mut);
  padding: 0.4rem 0.7rem;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.seg-btn:hover,
.switcher a:hover { background: var(--bg); color: var(--ink); text-decoration: none; }

.switcher a.is-on { background: var(--pri-t); color: var(--pri); }
.seg-btn.is-on.seg-present { background: var(--grn-t); color: var(--grn); }
.seg-btn.is-on.seg-absent { background: var(--red-t); color: var(--red); }
.seg-btn.is-on.seg-late { background: var(--amb-t); color: var(--amb); }
.seg-btn.is-on.seg-excused { background: var(--sky-t); color: var(--sky); }

/* ---------- Forms ---------- */

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.92rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="file"],
select,
textarea {
  border: 1px solid rgba(16, 24, 40, 0.16);
  border-radius: 10px;
  padding: 0.68rem 0.85rem;
  font: inherit;
  background: #fff;
  color: var(--ink);
  max-width: 100%;
}

.grade-form {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.grade-form input[type="number"] { width: 4.6rem; padding: 0.42rem 0.5rem; }
.grade-form input[type="text"] { width: 8rem; padding: 0.42rem 0.6rem; }

.journal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 1rem 1.25rem;
}

.journal-bar p { max-width: 44rem; font-size: 0.9rem; }

/* ---------- Messages ---------- */

.messages {
  list-style: none;
  padding: 0;
  margin: 0 0 1.25rem;
}

.msg {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: var(--grn-t);
  color: var(--ink);
  font-weight: 600;
  animation: msg-in 0.25s ease-out;
}

.msg-error {
  background: var(--red-t);
  color: var(--red);
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Tables ---------- */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--paper);
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.table th,
.table td {
  text-align: left;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }

.table th {
  font-size: 0.8rem;
  color: var(--mut);
  background: var(--bg);
  font-weight: 700;
}

.card .table { box-shadow: none; border: none; border-radius: 0; }
.card .table th { background: none; padding-left: 0; }
.card .table td { padding-left: 0; }

.table tr.is-unread td { font-weight: 700; }

a.sort-th {
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}

a.sort-th:hover,
a.sort-th.is-sorted {
  color: var(--ink);
}

/* ---------- Misc ---------- */

.layout-manage { display: contents; }

.stat-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.75rem;
  margin-bottom: 1.5rem;
  color: var(--mut);
  font-weight: 600;
}

.stat-line b { color: var(--ink); font-size: 1.1rem; margin-right: 0.25rem; }

.meter {
  height: 0.5rem;
  border-radius: 999px;
  background: var(--bg);
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--grn);
}

.big-num {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.note-line {
  margin-top: 1.25rem;
  color: var(--mut);
  font-size: 0.9rem;
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .cabinet-main,
  .manage-main { padding: 1.75rem 1.5rem 3rem; }
}

@media (max-width: 900px) {
  .shell-body { flex-direction: column; }
  .topbar-mobile { display: flex; }

  .cabinet-sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    height: auto;
    width: 100%;
    border-right: none;
    border-bottom: var(--border-w) solid var(--line);
    padding: 0.5rem 0.75rem;
  }

  .cabinet-sidebar .brand,
  .sidebar-foot { display: none; }

  .nav {
    flex-direction: row;
    overflow-x: auto;
    gap: 0.25rem;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar { display: none; }

  .nav-link {
    width: auto;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    white-space: nowrap;
  }

  .nav-link.is-disabled { display: none; }

  .cabinet-main,
  .manage-main { padding: 1.25rem 1rem 2.5rem; }

  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  body { font-size: 14.5px; }

  .lesson-row { flex-direction: column; align-items: stretch; }
  .lesson-row .btn { width: 100%; }
  .lesson-row.compact { flex-direction: row; align-items: center; }

  .card { padding: 1.1rem 1.1rem; }

  /* Tables become stacked cards: each cell shows its column name */
  .table.stack-mobile,
  .table.stack-mobile tbody,
  .table.stack-mobile tr,
  .table.stack-mobile td { display: block; width: 100%; }

  .table.stack-mobile thead { display: none; }
  .table.stack-mobile { background: none; border: none; box-shadow: none; }

  .table.stack-mobile tr {
    background: var(--paper);
    border: var(--border-w) solid var(--line);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow-card);
  }

  .card .table.stack-mobile tr { box-shadow: none; padding: 0.6rem 0; border: none; border-top: 1px solid var(--line); border-radius: 0; margin: 0; }

  .table.stack-mobile td {
    border: none;
    padding: 0.2rem 0;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
  }

  .table.stack-mobile td[data-label]::before {
    content: attr(data-label);
    color: var(--mut);
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
  }

  .table.stack-mobile td:empty { display: none; }

  .grade-form { flex-wrap: wrap; }
}

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

/* ---------- Parent cabinet ---------- */

.grid-even { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.tone-grn { color: var(--grn); }
.tone-amb { color: var(--amb); }
.tone-red { color: var(--red); }

.child-card { color: inherit; text-decoration: none; display: flex; flex-direction: column; }
.child-card:hover { text-decoration: none; border-color: rgba(91, 84, 238, 0.35); }
.child-card .child-name { color: var(--ink); font-size: 1.05rem; }
.child-cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.card-link {
  margin-top: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--pri);
  font-weight: 700;
}

@media (max-width: 640px) {
  .grid-even { grid-template-columns: minmax(0, 1fr); }
  .switcher { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
}

/* ---------- Teacher cabinet ---------- */

.line-actions {
  display: flex;
  gap: 0.9rem;
  font-weight: 700;
  font-size: 0.88rem;
  white-space: nowrap;
}

.lesson-line .lesson-left { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }

@media (max-width: 640px) {
  .lesson-line { flex-wrap: wrap; }
  .line-actions { padding-left: 3.6rem; }
}

/* ---------- Notifications ---------- */

.notif-open { flex: 1; min-width: 0; }

.notif-open button {
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  width: 100%;
}

.notif-open button:hover .row-title { color: var(--pri); }
.notif-list li:not(.is-unread) .row-title { font-weight: 600; color: var(--mut); }
.notif-list .row-meta { display: flex; align-items: center; gap: 0.6rem; }

@media (max-width: 640px) {
  .notif-list li { flex-direction: column; align-items: flex-start; }
}

/* ---------- Fixes after visual pass ---------- */

.lesson-row > .actions { flex-wrap: nowrap; flex-shrink: 0; }
.rows a.row-title { color: var(--ink); }
.rows a.row-title:hover { color: var(--pri); text-decoration: none; }
.dash-grid { grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); }
.nowrap { white-space: nowrap; }

@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  .lesson-row > .actions { flex-wrap: wrap; }
  .lesson-row > .actions .btn { flex: 1; }
}
.journal .seg { flex-wrap: nowrap; }
.journal-name { min-width: 11rem; }
@media (max-width: 640px) {
  .journal-name { min-width: 0; }
  .table.stack-mobile td > .seg,
  .table.stack-mobile td > .chips { justify-content: flex-end; }
  .grade-form input[type="text"] { width: 6.5rem; }
}
.actions { min-width: 0; max-width: 100%; }

@media (max-width: 900px) {
  /* Dense /manage/ tables scroll inside themselves instead of widening the page */
  .manage-main .table:not(.stack-mobile) {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

@media (max-width: 640px) {
  .page-head > .actions { width: 100%; }
}
@media (max-width: 640px) {
  .table.stack-mobile td { flex-wrap: wrap; }
  .table.stack-mobile td > .seg { width: 100%; justify-content: space-between; }
}

/* ---------- Forms in cards ---------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 1rem;
  align-items: end;
}

.form-grid .span-2 { grid-column: 1 / -1; }
.form-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
label.check { flex-direction: row; align-items: center; gap: 0.5rem; font-weight: 600; }
label.check input { width: 1.05rem; height: 1.05rem; }
.form-inline { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: end; }
.form-inline label { flex: 1 1 10rem; }
.help { color: var(--mut); font-size: 0.82rem; font-weight: 500; }

.row-block { display: block !important; }
.sub-rows { margin: 0.4rem 0 0 0.25rem; }
.sub-rows > li { padding: 0.45rem 0; font-size: 0.92rem; }
.is-off { opacity: 0.5; text-decoration: line-through; }
.rows select { max-width: 60%; padding: 0.4rem 0.6rem; font-size: 0.88rem; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.filters label { flex: 1 1 9rem; }
.filters label:first-child { flex: 3 1 16rem; }

summary.link-like {
  cursor: pointer;
  color: var(--pri);
  font-weight: 700;
  font-size: 0.92rem;
}

/* ---------- Timetable / week ---------- */

.tt-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
}

.tt-day { padding: 1rem; }
.tt-day h2 { font-size: 0.95rem; margin-bottom: 0.65rem; }
.tt-day.is-today { border-color: rgba(91, 84, 238, 0.45); }

.tt-slot {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-top: 1px solid var(--line);
}

.tt-slot:first-of-type { border-top: none; }
.tt-body { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; font-size: 0.9rem; }
.tt-body b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-body .row-sub { font-size: 0.8rem; }
a.tt-link { color: inherit; text-decoration: none; }
a.tt-link:hover b { color: var(--pri); }
.is-cancelled b { text-decoration: line-through; color: var(--mut); }

.week-table td { vertical-align: top; min-width: 9rem; }
.week-table td .tt-slot { border-top: none; padding: 0.15rem 0; }
.week-table th.is-today { color: var(--pri); }
.week-nav { display: flex; gap: 0.35rem; margin-left: auto; }
.wide-cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

@media (max-width: 1100px) {
  .tt-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}
.event-chip { display: flex; white-space: normal; margin-bottom: 0.4rem; }

/* ---------- Journal grid ---------- */

.cabinet-main.is-wide { max-width: none; }

.jgrid-wrap {
  overflow-x: auto;
  background: var(--paper);
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.jgrid { border-collapse: separate; border-spacing: 0; font-size: 0.9rem; }
.jgrid th, .jgrid td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0.2rem; text-align: center; }
.jgrid thead th { background: var(--bg); font-size: 0.78rem; color: var(--mut); padding: 0.5rem 0.35rem; position: sticky; top: 0; }
.jgrid thead a { color: inherit; }
.jgrid .jname {
  position: sticky; left: 0; z-index: 1; background: var(--paper);
  text-align: left; padding: 0.4rem 0.75rem; white-space: nowrap; font-weight: 600; min-width: 11rem;
}
.jgrid thead .jname { background: var(--bg); z-index: 2; }
.jgrid .jsum { background: var(--bg); min-width: 3.4rem; }

.jcell {
  width: 2.6rem; height: 2.1rem; text-align: center; font: inherit; font-weight: 700;
  border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--ink);
  padding: 0;
}
.jcell:hover:not([readonly]) { border-color: var(--line); }
.jcell:focus { outline: none; border-color: var(--pri); background: var(--pri-t); }
.jcell.is-absent { color: var(--red); }
.jcell.has-error { border-color: var(--red); background: var(--red-t); }
.jcell[readonly] { cursor: default; }
.jcell-period { width: 3rem; background: var(--paper); border-color: var(--line); }
.jextra { display: block; font-size: 0.72rem; color: var(--lav); font-weight: 700; }

.review-form { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.review-form input[type="number"] { width: 4.4rem; padding: 0.42rem 0.5rem; }
.review-form input[type="text"] { flex: 1 1 9rem; padding: 0.42rem 0.6rem; }
.review-form select { padding: 0.42rem 0.5rem; }
.teacher-note { margin-top: 0.75rem; padding: 0.7rem 0.9rem; border-radius: 12px; background: var(--amb-t); }
.jgrid-wrap { width: fit-content; max-width: 100%; }
.week-table { table-layout: fixed; }
.week-table th:first-child, .week-table td:first-child { width: 8.5rem; }
.week-table td { min-width: 0; }
.week-table .tt-body b { font-size: 0.85rem; }

/* ---------- Messages / billing ---------- */

.section-title { font-size: 1.1rem; margin: 0.5rem 0 0.85rem; }
.blocked-card { max-width: 40rem; }
.blocked-card h1 { font-size: 1.6rem; margin-bottom: 0.5rem; }
.msg-preview { display: block; font-weight: 500; }
.rows > a.is-unread .row-title { color: var(--ink); }

.chat-card { display: flex; flex-direction: column; gap: 1rem; max-width: 52rem; }
.chat-list {
  display: flex; flex-direction: column; gap: 0.6rem;
  max-height: 60vh; overflow-y: auto; padding: 0.25rem;
}
.bubble {
  align-self: flex-start; max-width: 80%;
  background: var(--bg); border-radius: 14px 14px 14px 4px; padding: 0.6rem 0.85rem;
}
.bubble.is-mine { align-self: flex-end; background: var(--pri-t); border-radius: 14px 14px 4px 14px; }
.bubble-head { font-size: 0.75rem; color: var(--mut); font-weight: 700; margin-bottom: 0.15rem; }
.bubble-body { white-space: normal; overflow-wrap: anywhere; }
.chat-form { display: flex; gap: 0.5rem; align-items: flex-end; }
.chat-form textarea { flex: 1; resize: vertical; min-height: 2.8rem; }
textarea { font: inherit; }

/* ---------- Reports & print ---------- */

.report-form { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.report-form select, .report-form input { padding: 0.42rem 0.6rem; font-size: 0.88rem; }
.report-form input[type="text"] { flex: 1 1 10rem; }
.print-only { display: none; }

@media print {
  .cabinet-sidebar, .topbar-mobile, .no-print, .messages, .btn, form button { display: none !important; }
  .print-only { display: block; margin-bottom: 1rem; }
  body, .card, .table { background: #fff !important; box-shadow: none !important; }
  .card { border: none; padding: 0; }
  .cabinet-main { padding: 0; max-width: none; }
  select { border: none; appearance: none; -webkit-appearance: none; padding: 0; }
}

/* ---------- Table tools (static/js/tables.js) ---------- */

.table-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0 0 0.75rem;
}

.table-tools input[type="search"] { flex: 1 1 14rem; padding: 0.55rem 0.8rem; }
.table-tools select { padding: 0.55rem 0.7rem; max-width: 14rem; }
.table-count { margin-left: auto; color: var(--mut); font-size: 0.85rem; font-weight: 600; }
.list-search { width: 100%; margin-bottom: 0.6rem; padding: 0.55rem 0.8rem; }

th.is-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.is-sortable:hover { color: var(--ink); }
th.is-sortable::after { content: "↕"; opacity: 0.3; margin-left: 0.3rem; font-size: 0.75em; }
th[aria-sort="ascending"]::after { content: "↑"; opacity: 1; }
th[aria-sort="descending"]::after { content: "↓"; opacity: 1; }
th.is-sortable:focus-visible { outline: 2px solid var(--pri); }
.card .table-tools { margin-top: 0.25rem; }

.quiz-q { border: 1px solid var(--line); border-radius: 12px; padding: 0.75rem 1rem; display: flex; flex-direction: column; gap: 0.4rem; }
.quiz-q legend { padding: 0 0.25rem; }
.quiz-choices { border: 1px dashed var(--line); border-radius: 12px; padding: 0.75rem; display: flex; flex-direction: column; gap: 0.4rem; }
