/* Assistant variable font */
@font-face {
  font-family: "Assistant";
  src: url("./assets/fonts/Assistant-VariableFont_wght.ttf") format("truetype");
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
}

:root {
  font-family: "Assistant", "Segoe UI", Arial, sans-serif;
  color: #254d49;
  background: #f4f7f4;
  line-height: 1.55;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
[hidden] { display: none !important; }
button, input, select { font: inherit; }
.site-header {
  min-height: 88px;
  padding: 1rem max(1.25rem, calc((100vw - 1380px)/2));
  background: #245e59;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 4px 18px #183f3b20;
}
.brand { display: inline-flex; align-items: center; gap: .85rem; color: inherit; text-decoration: none; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px; background: #ffffff20; font-weight: 800; letter-spacing: -.06em; }
.brand strong { display: block; font-size: 1.25rem; letter-spacing: -.02em; }
.brand small { display: block; color: #d9efeb; font-size: .85rem; }
.header-actions { display: flex; align-items: center; gap: .8rem; }
.user-label { color: #e5f2eb; font-size: .92rem; }
.page-shell { max-width: 1380px; margin: 2rem auto; padding: 0 1.25rem 3rem; }
.panel { background: #fff; border: 1px solid #dce8e1; border-radius: 18px; box-shadow: 0 8px 28px #244d4910; }
.auth-card { max-width: 650px; margin: 4rem auto; padding: clamp(1.5rem, 4vw, 3rem); }
.auth-intro { margin-bottom: 1.5rem; }
.auth-intro h1 { margin: .3rem 0; font-size: 1.8rem; }
.auth-intro p, .muted { color: #71847d; }
.eyebrow { color: #3d8b80; font-size: .78rem; font-weight: 800; letter-spacing: .06em; }
.app-layout { display: grid; grid-template-columns: 235px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.sidebar { padding: 1rem; position: sticky; top: 1rem; display: flex; flex-direction: column; gap: .35rem; }
.sidebar-heading { padding: .65rem .8rem .35rem; color: #8a9a93; font-size: .76rem; font-weight: 700; }
.nav-button { width: 100%; display: flex; align-items: center; gap: .7rem; padding: .78rem .85rem; border: 0; border-radius: 10px; background: transparent; color: #48645c; text-align: right; cursor: pointer; font-weight: 600; }
.nav-button span { width: 22px; text-align: center; color: #3d8b80; font-size: 1.15rem; }
.nav-button:hover, .nav-button.active { background: #e8f3ed; color: #245e59; }
.nav-create { margin-top: .35rem; background: #3d8b80; color: #fff; }
.nav-create span, .nav-create:hover { color: #fff; background: #245e59; }
.nav-divider { height: 1px; background: #e8efeb; margin: .65rem .5rem; }
.content-area { min-width: 0; }
.content-panel { padding: clamp(1.1rem, 2.5vw, 2rem); margin-bottom: 1.25rem; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.section-heading h1 { margin: .2rem 0; font-size: clamp(1.45rem, 2.5vw, 1.9rem); }
.section-heading p { margin: .2rem 0 0; }
.count-chip { background: #e5f2eb; color: #286b52; border-radius: 999px; padding: .4rem .8rem; font-size: .85rem; font-weight: 700; white-space: nowrap; }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem; padding: 1rem; margin-bottom: 1.25rem; background: #f7faf8; border: 1px solid #e5eee8; border-radius: 13px; }
.search-field { flex: 1 1 250px; position: relative; }
.search-field > span { position: absolute; right: .8rem; top: 50%; transform: translateY(-50%); color: #7c968b; font-size: 1.35rem; }
.search-field input { padding-right: 2.4rem; }
.filter-control { flex: 0 1 155px; display: grid; gap: .3rem; font-size: .82rem; font-weight: 700; color: #587269; }
input, select { min-width: 0; width: 100%; padding: .68rem .8rem; border: 1px solid #c8d8cf; border-radius: 9px; background: #fff; color: #254d49; }
select[multiple] { min-height: 115px; }
input:focus, select:focus { outline: 3px solid #c8e7dc; border-color: #3d8b80; }
.button { border: 1px solid transparent; border-radius: 9px; padding: .68rem 1rem; cursor: pointer; font-weight: 700; transition: background .15s, transform .15s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button-primary { background: #3d8b80; color: #fff; }
.button-primary:hover:not(:disabled) { background: #245e59; }
.button-secondary, .button-light { background: #e5f2eb; color: #245e59; border-color: #cfe5d9; }
.button-outline { background: #fff; color: #356d63; border-color: #cbded4; }
.button-outline:hover:not(:disabled) { background: #f0f7f3; }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid #e5eee8; border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 520px; }
th, td { padding: .85rem 1rem; text-align: right; border-bottom: 1px solid #e8efeb; }
th { background: #e8f3ed; color: #315e54; font-size: .88rem; font-weight: 800; }
td { color: #415e55; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdfb; }
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: .65rem;
  margin-top: 1.25rem;
  direction: rtl;
}
.pagination .button {
  min-width: 92px;
  min-height: 38px;
  padding: .45rem .8rem;
  border-radius: 10px;
  border: 1px solid #b9d7c9;
  background: #f6faf7;
  color: #245e59;
  font-size: .88rem;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(36,94,89,.05);
}
.pagination .button:hover:not(:disabled) {
  background: #e5f2eb;
  border-color: #80b4a1;
  transform: none;
}
.pagination .button:disabled {
  background: #f8faf9;
  border-color: #e7eeea;
  color: #9aaea5;
  opacity: 1;
  box-shadow: none;
  cursor: not-allowed;
}
.pagination .button:focus-visible {
  outline: 2px solid #3d8b80;
  outline-offset: 2px;
}
.pagination .muted {
  min-width: 155px;
  text-align: center;
  color: #55766a;
  font-size: .87rem;
}

.empty-state { padding: 2.5rem 1rem; text-align: center; color: #84958e; }
.form-grid { display: grid; gap: .65rem; max-width: 520px; }
.form-grid label, .inline-create-form label { color: #45645a; font-weight: 700; }
.form-grid input, .form-grid select { margin-top: .25rem; }
.two-columns { max-width: 760px; grid-template-columns: 170px minmax(0, 1fr); align-items: center; gap: .9rem 1rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: .65rem; margin-top: .5rem; }
.form-actions .button { flex: 1; }
.full-width { grid-column: 1 / -1; }
.hint { color: #899991; font-size: .82rem; font-weight: 400; }
.inline-create-form { display: flex; flex-wrap: wrap; align-items: end; gap: .8rem; padding: 1rem; margin-bottom: 1.25rem; background: #f7faf8; border: 1px solid #e5eee8; border-radius: 12px; }
.inline-create-form label { flex: 1 1 150px; display: grid; gap: .35rem; font-size: .85rem; }
.inline-create-form .button { min-height: 44px; }
.message { min-height: 1.4rem; margin: .8rem 0 0; }
.message:empty { display: none; }
.message.error { color: #99453d; background: #fff0ed; border: 1px solid #f2c8c0; padding: .75rem .9rem; border-radius: 9px; }
.message.success { color: #286b52; background: #e5f2eb; padding: .75rem .9rem; border-radius: 9px; }
@media (max-width: 850px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar-heading, .nav-divider { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .site-header { align-items: flex-start; }
  .brand strong { font-size: 1rem; }
  .page-shell { margin: 1rem auto; padding-inline: .75rem; }
  .sidebar { grid-template-columns: 1fr 1fr; }
  .nav-button { font-size: .88rem; padding: .7rem .55rem; }
  .content-panel { padding: 1rem; }
  .section-heading { align-items: flex-start; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .filter-control { min-width: 0; }
  .two-columns { grid-template-columns: 1fr; }
  .two-columns label { margin-top: .35rem; }
  .form-actions.full-width { grid-column: auto; }
  .auth-card { margin: 1.5rem auto; }
}

/* Weekly timetable */
.weekly-grid-wrap { overflow-x: auto; }
.weekly-grid { min-width: 760px; table-layout: fixed; }
.weekly-grid thead th { text-align: center; white-space: nowrap; }
.weekly-grid thead th:first-child,
.weekly-grid .lesson-number { width: 72px; background: #f0f6f2; text-align: center; }
.weekly-grid td.schedule-slot { height: 82px; vertical-align: top; padding: .45rem; background: #fff; }
.weekly-grid td.empty-slot { color: #c2cec7; text-align: center; vertical-align: middle; }
.weekly-grid td.unavailable-slot { color: #aebbb4; background: #f3f5f3; text-align: center; vertical-align: middle; }
.session-chip { display: grid; gap: .15rem; margin: .12rem 0; padding: .45rem .5rem; border-right: 3px solid #3d8b80; border-radius: 7px; background: #e5f2eb; color: #245e59; font-size: .78rem; line-height: 1.35; overflow-wrap: anywhere; }
.session-chip strong { font-size: .8rem; }
.session-chip span { color: #55766a; }
@media (max-width: 700px) {
  .weekly-grid { min-width: 700px; }
  .weekly-grid td.schedule-slot { height: 74px; padding: .3rem; }
  .session-chip { font-size: .72rem; padding: .35rem; }
}

.clickable-slot { padding: .25rem !important; }
.slot-add-button {
  width: 100%; min-height: 58px; border: 1px dashed #9fc6b3;
  border-radius: 8px; background: #f5faf7; color: #438477;
  font-size: .76rem; font-weight: 700; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.slot-add-button:hover { background: #e5f2eb; border-color: #3d8b80; }

/* Refined add-session action inside timetable cells */
.weekly-grid td.schedule-slot.clickable-slot {
  padding: .35rem !important;
  vertical-align: middle;
  background: #fbfdfb;
}
.weekly-grid button.slot-add-button {
  -webkit-appearance: none !important;
  appearance: none !important;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  width: 100%;
  min-height: 52px;
  padding: .55rem .4rem;
  border: 1px dashed #9fc8b7 !important;
  border-radius: 10px !important;
  background: #f0f7f3 !important;
  color: #34796e !important;
  box-shadow: none !important;
  font-family: inherit;
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.35;
  white-space: normal;
  cursor: pointer;
}
.weekly-grid button.slot-add-button::before {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border-radius: 50%;
  background: #dcefe5;
  color: #286b5e;
  font-size: 1rem;
  line-height: 1;
}
.weekly-grid button.slot-add-button:hover {
  border-style: solid !important;
  border-color: #6eaa97 !important;
  background: #e5f2eb !important;
  color: #245e59 !important;
}
.weekly-grid button.slot-add-button:focus-visible {
  outline: 3px solid #b8ddce;
  outline-offset: 2px;
}

/* Stronger visual distinction: occupied sessions vs. available slots */
.weekly-grid td.schedule-slot:has(.session-chip) {
  background: #f1f7f3;
}
.weekly-grid .session-chip {
  background: #d0e8dc;
  border-right: 5px solid #245e59;
  border-top: 1px solid #b5d6c7;
  border-bottom: 1px solid #b5d6c7;
  box-shadow: 0 1px 3px rgba(36, 94, 89, .10);
  color: #174d47;
  padding: .55rem .6rem;
}
.weekly-grid .session-chip strong {
  color: #174d47;
  font-weight: 800;
}
.weekly-grid .session-chip span {
  color: #315f56;
}
.weekly-grid td.schedule-slot.clickable-slot {
  background: #ffffff;
}
.weekly-grid button.slot-add-button {
  min-height: 58px;
  border: 2px dashed #a8cbb9 !important;
  background: #fbfdfb !important;
  color: #548477 !important;
  font-weight: 700;
}
.weekly-grid button.slot-add-button::before {
  background: #e3f1e9;
  color: #39796b;
}
.weekly-grid button.slot-add-button:hover {
  background: #edf6f0 !important;
  border-color: #579984 !important;
}

/* The button label already contains a plus sign; hide the decorative duplicate. */
.weekly-grid button.slot-add-button::before {
  display: none;
  content: none;
}


/* Icon-only add action: final override */
.weekly-grid td.schedule-slot.clickable-slot {
  padding: .35rem !important;
  vertical-align: middle;
  background: #fbfdfb;
}
.weekly-grid button.slot-add-button {
  -webkit-appearance: none !important;
  appearance: none !important;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  min-height: 38px;
  margin: 0 auto;
  padding: 0;
  border: 1px dashed #9fc8b7 !important;
  border-radius: 50% !important;
  background: #f0f7f3 !important;
  color: #286b5e !important;
  box-shadow: none !important;
  font-family: inherit;
  font-size: 0;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .15s;
}
.weekly-grid button.slot-add-button::before {
  content: "+";
  display: block;
  font-size: 1.45rem;
  font-weight: 500;
  line-height: 1;
}
.weekly-grid button.slot-add-button:hover {
  border-style: solid !important;
  border-color: #6eaa97 !important;
  background: #dcefe5 !important;
  transform: scale(1.06);
}
.weekly-grid button.slot-add-button:focus-visible {
  outline: 3px solid #b8ddce;
  outline-offset: 2px;
}


/* Polished plus action: clearer, softer circular control */
.weekly-grid td.schedule-slot.clickable-slot {
  background: #f8fcf9 !important;
}
.weekly-grid button.slot-add-button {
  width: 40px !important;
  height: 40px !important;
  min-height: 40px !important;
  border: 1px solid #b8d9ca !important;
  border-radius: 50% !important;
  background: linear-gradient(145deg, #edf7f1, #dcefe5) !important;
  color: #246b5d !important;
  box-shadow: 0 2px 5px rgba(36, 94, 89, .12) !important;
  font-size: 0 !important;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease !important;
}
.weekly-grid button.slot-add-button::before {
  content: "+" !important;
  display: grid !important;
  place-items: center !important;
  width: 100% !important;
  height: 100% !important;
  border: 0 !important;
  border-radius: 50% !important;
  background: transparent !important;
  color: #246b5d !important;
  font-family: Arial, sans-serif !important;
  font-size: 1.55rem !important;
  font-weight: 500 !important;
  line-height: 1 !important;
}
.weekly-grid button.slot-add-button:hover {
  transform: translateY(-1px) scale(1.06) !important;
  background: linear-gradient(145deg, #dff1e7, #cce7d9) !important;
  border-color: #79b39d !important;
  box-shadow: 0 4px 9px rgba(36, 94, 89, .18) !important;
}
.weekly-grid button.slot-add-button:active {
  transform: scale(.96) !important;
  box-shadow: 0 1px 3px rgba(36, 94, 89, .14) !important;
}


/* Final typography and plus alignment refinement */
:root {
  font-family: "Assistant", Arial, sans-serif;
}
html,
body,
button,
input,
select,
textarea,
table,
thead,
tbody,
tr,
th,
td {
  font-family: "Assistant", Arial, sans-serif !important;
}
button,
input,
select,
textarea {
  font-size: inherit;
}

/* Compact plus button with the glyph optically centered. */
.weekly-grid button.slot-add-button {
  position: relative !important;
  display: block !important;
  width: 30px !important;
  height: 30px !important;
  min-height: 30px !important;
  padding: 0 !important;
  border: 1px solid #b8d9ca !important;
  border-radius: 50% !important;
  background: #e7f3ec !important;
  box-shadow: 0 1px 4px rgba(36, 94, 89, .10) !important;
  font-size: 0 !important;
  line-height: 0 !important;
}
.weekly-grid button.slot-add-button::before {
  content: "+" !important;
  position: absolute !important;
  left: 50% !important;
  top: 50% !important;
  display: block !important;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: #286b5e !important;
  font-family: Arial, sans-serif !important;
  font-size: 1.05rem !important;
  font-weight: 400 !important;
  line-height: 1 !important;
  transform: translate(-50%, -54%) !important;
}
.weekly-grid button.slot-add-button:hover {
  background: #dcefe5 !important;
  border-color: #83b8a3 !important;
  box-shadow: 0 2px 6px rgba(36, 94, 89, .14) !important;
  transform: translateY(-1px) !important;
}
.weekly-grid button.slot-add-button:active {
  transform: scale(.97) !important;
}


/* Center teacher and student labels inside each timetable card */
.weekly-grid .session-chip {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  gap: .18rem !important;
  width: 100%;
  box-sizing: border-box;
}
.weekly-grid .session-chip strong,
.weekly-grid .session-chip span {
  display: block;
  width: 100%;
  text-align: center !important;
  overflow-wrap: anywhere;
}


/* Compact, consistent add-student action inside an existing group card */
.weekly-grid .session-chip {
  position: relative;
}
.weekly-grid .session-chip .session-add-student-button {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  align-self: center !important;
  flex: 0 0 22px !important;
  width: 22px !important;
  min-width: 22px !important;
  max-width: 22px !important;
  height: 22px !important;
  min-height: 22px !important;
  margin: .28rem auto 0 !important;
  padding: 0 0 2px !important;
  border: 1px solid #b8d9ca !important;
  border-radius: 50% !important;
  background: #f3faf6 !important;
  color: #286b5e !important;
  box-shadow: 0 1px 3px rgba(36, 94, 89, .10) !important;
  font-family: "Assistant", Arial, sans-serif !important;
  font-size: 16px !important;
  font-weight: 500 !important;
  line-height: 1 !important;
  cursor: pointer !important;
  transition: background .15s ease, border-color .15s ease, transform .15s ease !important;
}
.weekly-grid .session-chip .session-add-student-button:hover {
  background: #dcefe5 !important;
  border-color: #83b8a3 !important;
  transform: translateY(-1px) !important;
}
.weekly-grid .session-chip .session-add-student-button:focus-visible {
  outline: 2px solid #3d8b80 !important;
  outline-offset: 2px !important;
}

/* Edit and delete actions for timetable sessions */
.weekly-grid .session-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  margin-top: .3rem;
}
.weekly-grid .session-action-button {
  display: inline-grid;
  place-items: center;
  width: 25px;
  height: 25px;
  padding: 0;
  border: 1px solid #b8d9ca;
  border-radius: 7px;
  background: #f3faf6;
  color: #286b5e;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.weekly-grid .session-action-button:hover {
  background: #dcefe5;
  border-color: #83b8a3;
}
.weekly-grid .session-delete-button {
  color: #a34b42;
  border-color: #e9c7c1;
  background: #fff7f5;
}
.weekly-grid .session-delete-button:hover {
  background: #fbe7e3;
  border-color: #dbaaa1;
}
.weekly-grid .session-action-button:focus-visible {
  outline: 2px solid #3d8b80;
  outline-offset: 2px;
}

/* Unified inline actions below each session */
.weekly-grid .session-chip .session-actions {
  display: flex;
  width: 100%;
  justify-content: center;
  align-items: center;
  gap: .45rem;
  margin-top: .3rem;
  padding-top: .35rem;
  border-top: 1px solid #b5d6c7;
}
.weekly-grid .session-chip .session-actions button {
  position: static !important;
  display: inline-grid !important;
  place-items: center !important;
  align-self: center !important;
  flex: 0 0 24px !important;
  width: 24px !important;
  min-width: 24px !important;
  max-width: 24px !important;
  height: 24px !important;
  min-height: 24px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 6px !important;
  background: transparent !important;
  box-shadow: none !important;
  color: #286b5e !important;
  font-family: "Assistant", Arial, sans-serif !important;
  font-size: 19px !important;
  line-height: 1 !important;
}
.weekly-grid .session-chip .session-actions button:hover {
  background: #b5d6c7 !important;
}
.weekly-grid .session-chip .session-actions .session-delete-button {
  color: #a34b42 !important;
}
.weekly-grid .session-chip .session-actions .session-delete-button:hover {
  background: #f4d9d5 !important;
}
.schedule-heading-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.print-only { display: none; }
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  html, body { background: #fff !important; color: #111 !important; }
  .site-header, .sidebar, .filters, .pagination, #sessions-message,
  .schedule-heading-actions, .session-actions, .slot-add-button,
  .eyebrow, #schedule-subtitle { display: none !important; }
  .page-shell, .app-layout, .content-area, .content-panel, #schedule-view {
    display: block !important; width: 100% !important; max-width: none !important;
    margin: 0 !important; padding: 0 !important; border: 0 !important;
    box-shadow: none !important; background: #fff !important;
  }
  .section-heading { margin-bottom: 4mm; }
  #schedule-title { display: none; }
  .print-only { display: block; text-align: center; font-size: 18pt; margin: 0 0 6mm; }
  .table-wrap, .weekly-grid-wrap { overflow: visible !important; border: 0 !important; }
  .weekly-grid { min-width: 0 !important; width: 100% !important; table-layout: fixed; }
  .weekly-grid th, .weekly-grid td { border: 1px solid #aab8ae !important; padding: 3mm !important; }
  .weekly-grid td.schedule-slot { height: 22mm; }
  .weekly-grid .session-chip { box-shadow: none !important; break-inside: avoid; }
  .weekly-grid tr { break-inside: avoid; }
}

/* Schedule toolbar */
.schedule-heading-actions .schedule-tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: 39px;
  padding: .5rem .85rem;
  border: 1px solid #b9d6c9;
  border-radius: 10px;
  background: #f2f8f4;
  color: #245e59;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(36,94,89,.06);
}
.schedule-heading-actions .schedule-tool-button:hover {
  background: #e2f0e8;
  border-color: #7dad9a;
}
.schedule-heading-actions .schedule-tool-button svg {
  width: 17px;
  height: 17px;
  flex: none;
}
@media print {
  /* Only the active weekly timetable is printable. Other sections must stay hidden. */
  #auth-section, #create-view, #teachers-view, #students-view,
  .header-actions, .sidebar, .site-header,
  .schedule-heading-actions, .filters, .pagination,
  #sessions-message, #sessions-empty, .session-actions,
  .slot-add-button, .eyebrow, #schedule-subtitle {
    display: none !important;
  }
  #app-layout { display: block !important; }
  #schedule-view { display: block !important; }
  #weekly-schedule { display: table !important; }
  #schedule-head { display: table-header-group !important; }
  #sessions-body { display: table-row-group !important; }
  .weekly-grid tr { break-inside: avoid; page-break-inside: avoid; }
  .weekly-grid td.schedule-slot { height: auto !important; min-height: 0 !important; }
  .weekly-grid th, .weekly-grid td { padding: 2mm !important; }
  .weekly-grid .session-chip { margin: 1mm 0 !important; padding: 1mm 1.5mm !important; font-size: 8pt !important; }
  .weekly-grid .session-chip strong { font-size: 8pt !important; }
  .print-only { display: block !important; }
}

/* Refined minimal schedule toolbar */
.schedule-heading-actions {
  gap: .35rem;
}
.schedule-heading-actions .schedule-tool-button {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-height: 34px;
  padding: .35rem .55rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  color: #356d63;
  font-size: .91rem;
  font-weight: 600;
  transition: background .15s ease, color .15s ease;
}
.schedule-heading-actions .schedule-tool-button svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.7;
}
.schedule-heading-actions .schedule-tool-button:hover {
  background: #eaf4ee;
  border-color: transparent;
  color: #245e59;
  transform: none;
}
.schedule-heading-actions .schedule-tool-button:focus-visible {
  outline: 2px solid #3d8b80;
  outline-offset: 2px;
}
@media (max-width: 600px) {
  .schedule-heading-actions { gap: .15rem; }
  .schedule-heading-actions .schedule-tool-button { padding: .3rem .4rem; font-size: .85rem; }
}


/* Weekly timetable: center occupied cards vertically; keep the add action
   small and in the top-right corner of genuinely empty slots only. */
@media screen {
  .weekly-grid td.schedule-slot:has(.session-chip) {
    vertical-align: middle !important;
  }
  .weekly-grid td.schedule-slot:has(.session-chip) .session-chip {
    margin-top: .12rem;
    margin-bottom: .12rem;
  }
  .weekly-grid td.schedule-slot.clickable-slot {
    vertical-align: top !important;
    text-align: right !important;
  }
  .weekly-grid td.schedule-slot.clickable-slot button.slot-add-button {
    display: block !important;
    width: 24px !important;
    height: 24px !important;
    min-height: 24px !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .weekly-grid td.schedule-slot.clickable-slot button.slot-add-button::before {
    font-size: .92rem !important;
  }
}


/* Consistent heights and baseline for timetable filter controls. */
@media screen {
  .filters {
    align-items: end;
  }
  .filters .filter-control select,
  .filters .search-field input,
  .filters #clear-filters {
    box-sizing: border-box;
    height: 48px;
    min-height: 48px;
  }
  .filters #clear-filters {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: end;
    white-space: nowrap;
  }
}


/* Unified type scale for the on-screen application (print styles unchanged). */
@media screen {
  body { font-size: 16px; }
  .section-heading h1 {
    font-size: clamp(1.75rem, 2.6vw, 2rem);
    font-weight: 750;
    line-height: 1.25;
  }
  .section-heading p {
    font-size: 1rem;
    line-height: 1.5;
  }
  .section-heading .eyebrow {
    font-size: .95rem;
    font-weight: 750;
    letter-spacing: 0;
    line-height: 1.4;
  }
  .filter-control {
    font-size: .875rem;
    font-weight: 650;
  }
  .filters .filter-control select,
  .filters .search-field input,
  .filters #clear-filters {
    font-size: .9375rem;
    font-weight: 600;
    line-height: 1.35;
  }
  .filters #clear-filters { font-weight: 650; }
  .weekly-grid th,
  .weekly-grid .lesson-number {
    font-size: .9375rem;
    font-weight: 700;
  }
  .weekly-grid .session-chip,
  .weekly-grid .session-chip strong,
  .weekly-grid .session-chip span {
    font-size: .875rem;
    line-height: 1.4;
  }
  .weekly-grid .session-chip strong { font-weight: 700; }
  .nav-button,
  .schedule-heading-actions .schedule-tool-button {
    font-size: .9375rem;
  }
  .count-chip,
  .pagination .muted { font-size: .875rem; }
}

/* Multi-session timetable cells: fixed column widths, one card at a time. */
@media screen {
  .weekly-grid { table-layout: fixed; width: 100%; }
  .weekly-grid th:first-child { width: 64px; }
  .weekly-grid td.schedule-slot { position: relative; }
  .multi-session-slot { position: relative; padding-top: 22px; min-width: 0; }
  .multi-session-slot .session-chip { margin: 0; }
  .slot-expand-button {
    position: absolute; top: 0; left: 0;
    display: grid; place-items: center;
    width: 24px; height: 24px; padding: 0;
    border: 1px solid #b8d9ca; border-radius: 6px;
    background: #f3faf6; color: #245e59;
    cursor: pointer; font-size: 18px;
  }
  .slot-navigation { display: flex; align-items: center; justify-content: space-between; gap: 3px; margin-top: 5px; }
  .slot-nav-button {
    display: grid; place-items: center; flex: 0 0 25px;
    width: 25px; height: 25px; padding: 0;
    border: 1px solid #b8d9ca; border-radius: 6px;
    background: #f3faf6; color: #245e59; cursor: pointer;
  }
  .slot-nav-button:hover, .slot-expand-button:hover { background: #dcefe5; }
  .slot-nav-count { color: #356d63; font-size: .75rem; white-space: nowrap; }
  .slot-print-all { display: none; }
}
.sessions-dialog {
  direction: rtl; width: min(520px, calc(100vw - 32px)); max-height: min(80vh, 760px);
  padding: 22px; border: 1px solid #c6ddd2; border-radius: 16px;
  background: #fff; color: #174d47; box-shadow: 0 18px 70px #122d2840;
}
.sessions-dialog::backdrop { background: #132e2b80; }
.sessions-dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.sessions-dialog-heading h2 { margin: 0; font-size: 1.15rem; }
.sessions-dialog-list { display: grid; gap: 12px; max-height: 60vh; overflow-y: auto; }
.sessions-dialog-list .session-chip { margin: 0; padding: 12px; }
@media print {
  .multi-session-slot, .sessions-dialog { display: none !important; }
  .slot-print-all { display: block !important; }
  .slot-print-all .session-chip { display: grid !important; }
}

/* Apply timetable action styling in the expanded sessions dialog too. */
.sessions-dialog-list .session-chip {
  border-right: 5px solid #245e59;
  border-radius: 8px;
  background: #e5f2eb;
  color: #174d47;
  box-shadow: 0 1px 3px rgba(36,94,89,.10);
}
.sessions-dialog-list .session-chip strong { color: #174d47; font-weight: 700; }
.sessions-dialog-list .session-chip span { color: #315f56; }
.sessions-dialog-list .session-actions {
  display: flex; align-items: center; justify-content: center;
  gap: .45rem; margin-top: .4rem; padding-top: .4rem;
  border-top: 1px solid #c2dbce;
}
.sessions-dialog-list .session-action-button,
.sessions-dialog-list .session-add-student-button {
  display: inline-grid !important;
  place-items: center !important;
  flex: 0 0 28px !important;
  width: 28px !important; min-width: 28px !important; max-width: 28px !important;
  height: 28px !important; min-height: 28px !important;
  margin: 0 !important; padding: 0 !important;
  border: 1px solid #b8d9ca !important;
  border-radius: 7px !important;
  background: #f3faf6 !important;
  color: #286b5e !important;
  font-size: 18px !important;
  line-height: 1 !important;
  box-shadow: none !important;
  cursor: pointer;
}
.sessions-dialog-list .session-add-student-button { font-size: 17px !important; }
.sessions-dialog-list .session-delete-button {
  color: #a34b42 !important;
  border-color: #e9c7c1 !important;
  background: #fff7f5 !important;
}
.sessions-dialog-list .session-action-button:hover,
.sessions-dialog-list .session-add-student-button:hover { background: #dcefe5 !important; }
.sessions-dialog-list .session-delete-button:hover { background: #fbe7e3 !important; }
.sessions-dialog-list button:focus-visible { outline: 2px solid #3d8b80; outline-offset: 2px; }

/* Keep the expand control inside the top-left corner of the session card. */
@media screen {
  .multi-session-slot { padding-top: 0; }
  .multi-session-slot > .session-chip {
    position: relative;
    padding-top: 1.8rem;
  }
  .multi-session-slot > .slot-expand-button {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 1;
    width: 24px;
    height: 24px;
    border-radius: 6px;
  }
  .multi-session-slot > .slot-expand-button svg { display: block; width: 15px; height: 15px; }
}

/* Uniform timetable cards: the card is the same size whether it has navigation or not. */
@media screen {
  .weekly-grid td.schedule-slot:has(> .session-chip),
  .weekly-grid td.schedule-slot:has(> .multi-session-slot) {
    vertical-align: middle !important;
  }
  .weekly-grid td.schedule-slot > .session-chip,
  .weekly-grid td.schedule-slot > .multi-session-slot > .session-chip {
    box-sizing: border-box;
    width: 100%;
    height: 142px;
    min-height: 142px;
    max-height: 142px;
    margin: 0 !important;
    overflow: hidden;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    gap: .25rem !important;
  }
  .weekly-grid td.schedule-slot > .multi-session-slot > .session-chip {
    padding-top: 28px !important;
  }
  .weekly-grid td.schedule-slot > .session-chip {
    margin-bottom: 30px !important;
  }
  .weekly-grid .multi-session-slot {
    padding-top: 0;
    min-width: 0;
  }
  .weekly-grid .multi-session-slot .slot-navigation {
    height: 26px;
    margin-top: 4px;
    box-sizing: border-box;
  }
  .weekly-grid .multi-session-slot > .slot-expand-button {
    top: 6px;
    left: 6px;
  }
  .weekly-grid td.schedule-slot > .session-chip strong,
  .weekly-grid td.schedule-slot > .multi-session-slot > .session-chip strong,
  .weekly-grid td.schedule-slot > .session-chip span,
  .weekly-grid td.schedule-slot > .multi-session-slot > .session-chip span {
    overflow-wrap: anywhere;
    text-align: center;
  }
}

/* Align content baselines in single- and multi-session cards. */
@media screen {
  .weekly-grid td.schedule-slot > .session-chip,
  .weekly-grid td.schedule-slot > .multi-session-slot > .session-chip {
    display: grid !important;
    grid-template-rows: minmax(0, 38px) minmax(0, 40px) 34px;
    align-content: center !important;
    align-items: center !important;
    justify-items: stretch;
    gap: 0 !important;
    padding: 20px 10px 8px !important;
  }
  .weekly-grid td.schedule-slot > .session-chip > strong,
  .weekly-grid td.schedule-slot > .multi-session-slot > .session-chip > strong,
  .weekly-grid td.schedule-slot > .session-chip > span,
  .weekly-grid td.schedule-slot > .multi-session-slot > .session-chip > span {
    width: 100%;
    min-width: 0;
    margin: 0 !important;
    line-height: 1.35;
    text-align: center !important;
    align-self: center;
    overflow: hidden;
    overflow-wrap: anywhere;
  }
  .weekly-grid td.schedule-slot > .session-chip > .session-actions,
  .weekly-grid td.schedule-slot > .multi-session-slot > .session-chip > .session-actions {
    align-self: stretch;
    margin: 0 !important;
    padding-top: 4px !important;
    min-height: 0;
    box-sizing: border-box;
  }
  /* The expand icon overlays reserved top padding; it must not shift card content. */
  .weekly-grid .multi-session-slot > .slot-expand-button {
    top: 6px;
    left: 6px;
  }
}

/* Compact timetable cards while keeping all content rows aligned. */
@media screen {
  .weekly-grid td.schedule-slot > .session-chip,
  .weekly-grid td.schedule-slot > .multi-session-slot > .session-chip {
    height: 120px;
    min-height: 120px;
    max-height: 120px;
    grid-template-rows: minmax(0, 26px) minmax(0, 30px) 32px;
    padding: 20px 10px 4px !important;
    align-content: center !important;
  }
}
