* {
  box-sizing: border-box;
}

:root {
  font-family: Arial, sans-serif;
  color: #222;
  background: #f5f7fa;
  line-height: 1.5;
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
}

body.theme-dark {
  color-scheme: dark;
  color: #cccccc;
  background: #1e1e1e;
}

body.has-sidebar {
  background: #f3f6fb;
}

body.has-sidebar.theme-dark {
  background: #1e1e1e;
}

.note:disabled {
  background: #f1f5f9;
  color: #94a3b8;
  cursor: not-allowed;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: min(300px, 100%);
  flex: 0 0 300px;
  height: 100vh;
  background: linear-gradient(145deg, #081224 0%, #1746b7 45%, #2563eb 100%);
  color: #fff;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 12px 0 40px rgba(15, 23, 42, 0.2);
  position: fixed;
  top: 0;
  left: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
  transition: transform 0.25s ease, width 0.25s ease;
  z-index: 1000;
}

.has-sidebar .main-content {
  margin-left: 300px;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 6px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.18);
}

.sidebar__brand img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 18px;
  background: rgba(255,255,255,0.96);
  padding: 7px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
  flex-shrink: 0;
}

.sidebar__brand-text {
  min-width: 0;
}

.sidebar__profile {
  padding: 14px 13px;
}

.sidebar__profile h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.sidebar__brand h2 {
  margin: 0 0 2px;
  font-size: 1rem;
  line-height: 1.3;
  font-weight: 700;
}

.sidebar__brand p {
  margin: 0;
  color: rgba(255,255,255,0.82);
  font-size: 0.95rem;
}

.sidebar__card {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 16px;
  padding: 12px 13px;
  backdrop-filter: blur(10px);
  transition: transform 0.2s ease, background 0.2s ease;
}

.sidebar__card:hover {
  transform: translateY(-2px);
  background: rgba(255,255,255,0.18);
}

.sidebar__eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.74rem;
  color: rgba(255,255,255,0.72);
}

.sidebar__card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.sidebar__card p,
.sidebar__card ul {
  margin: 0;
  color: rgba(255,255,255,0.92);
  font-size: 0.95rem;
  line-height: 1.55;
}

.sidebar__card--muted {
  background: rgba(255,255,255,0.08);
}

.sidebar__card ul {
  padding-left: 18px;
}

.sidebar__direction-switch {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  border-radius: 12px;
  background: rgba(255,255,255,0.14);
}

.sidebar__direction-option {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(255,255,255,0.82);
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
  padding: 8px 10px;
  text-align: left;
}

.sidebar__direction-option:hover {
  background: #ffffff;
  color: #1746b7;
}

.sidebar__direction-option.is-active {
  background: #198754;
  color: #ffffff;
  border: 1px solid #198754;
}

.sidebar__settings-button {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  border-radius: 10px;
  background: #ffffff;
  color: #1746b7;
  padding: 10px 12px;
  text-align: center;
  text-decoration: none;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
}

.sidebar__settings-button:hover {
  background: #eff6ff;
}

.sidebar__link {
  margin-top: auto;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.14);
  text-align: center;
  transition: background 0.2s ease;
}

.sidebar__link:hover {
  background: rgba(255,255,255,0.2);
}

.sidebar__dd-links {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.sidebar__logout-link {
  width: 100%;
  border: 0;
  font: inherit;
  cursor: pointer;
}

.sidebar--dd > .sidebar__link {
  margin-top: 0;
}

.sidebar__toggle {
  align-self: flex-end;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: rgba(255,255,255,0.16);
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.2s ease, transform 0.2s ease;
}

.sidebar__toggle:hover {
  background: rgba(255,255,255,0.24);
  transform: scale(1.03);
}

body.theme-dark .sidebar {
  background: #181818;
  box-shadow: 12px 0 40px rgba(0, 0, 0, 0.35);
}

body.theme-dark .sidebar__card {
  background: #252526;
  border-color: #3e3e42;
}

body.theme-dark .sidebar__card:hover {
  background: #2d2d30;
}

body.theme-dark .sidebar__settings-button {
  background: #3c3c3c;
  color: #cccccc;
  box-shadow: none;
}

body.theme-dark .sidebar__settings-button:hover {
  background: #4a4a4d;
}

body.theme-dark .sidebar__link,
body.theme-dark .sidebar__theme-toggle {
  background: #252526;
  border-color: #3e3e42;
}

body.theme-dark .sidebar__direction-switch {
  background: #181818;
}

body.theme-dark .sidebar__direction-option {
  color: #cccccc;
}

body.theme-dark .sidebar__direction-option:hover,
body.theme-dark .sidebar__direction-option.is-active {
  background: #3c3c3c;
  color: #ffffff;
}

body.theme-dark .sidebar__link:hover,
body.theme-dark .sidebar__theme-toggle:hover {
  background: #2d2d30;
}

.sidebar.is-collapsed {
  width: 92px;
  flex-basis: 92px;
  align-items: center;
}

.has-sidebar .sidebar.is-collapsed + .main-content {
  margin-left: 92px;
}

.sidebar.is-collapsed .sidebar__brand-text,
.sidebar.is-collapsed .sidebar__card,
.sidebar.is-collapsed .sidebar__link {
  display: none;
}

.sidebar.is-collapsed .sidebar__brand {
  justify-content: center;
  padding-bottom: 10px;
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: 24px;
}

@media (max-width: 960px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-basis: auto;
    height: auto;
    min-height: auto;
    position: relative;
    overflow: visible;
    box-shadow: none;
  }

  .has-sidebar .main-content,
  .has-sidebar .sidebar.is-collapsed + .main-content {
    margin-left: 0;
  }

  .main-content {
    padding: 18px;
  }
}

@media (max-width: 640px) {
  .sidebar {
    padding: 18px 14px;
    gap: 14px;
  }

  .sidebar__brand {
    flex-direction: column;
    align-items: flex-start;
  }

  .main-content {
    padding: 14px;
  }
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
  width: 100%;
}

header,
footer,
.card {
  background: #ffffff;
  border: 1px solid #d7dde6;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 18px;
}

header h1 {
  margin-top: 0;
}

.toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.card h2 {
  margin-top: 0;
}

#student-page-form .form-section {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid #d7dde6;
  border-radius: 10px;
  background: #ffffff;
}

#student-page-form .form-section h2,
#student-page-form .form-section p {
  grid-column: 1 / -1;
}

#student-page-form .form-section label {
  min-width: 0;
  margin-bottom: 0;
}

body.theme-dark #student-page-form .form-section {
  border-color: #334155;
  background: #111827;
}

@media (max-width: 900px) {
  #student-page-form .form-section {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  #student-page-form .form-section {
    grid-template-columns: 1fr;
  }
}

label {
  display: block;
  margin-bottom: 12px;
  font-weight: 600;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 16px;
}

.form-row label {
  display: flex;
  flex-direction: column;
  flex: 1 1 180px;
  min-width: 140px;
  margin-bottom: 0;
}

.form-row button {
  flex: 0 0 auto;
}

.compact-form-row {
  gap: 10px;
  margin-bottom: 14px;
}

.compact-form-row label {
  flex: 1 1 120px;
  min-width: 120px;
  margin-bottom: 0;
}

.compact-form-row input,
.compact-form-row select {
  padding: 8px 10px;
  font-size: 0.95rem;
}

.checkbox-inline-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.checkbox-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #334155;
  font-weight: 700;
  line-height: 1.1;
}

.checkbox-option input {
  width: auto;
  margin: 0;
}

.direction-context-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  font-size: 0.86rem;
  font-weight: 800;
  white-space: nowrap;
}

input,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #b7c2cf;
  border-radius: 6px;
  font-size: 1rem;
}

.help-text {
  margin-top: -8px;
  margin-bottom: 14px;
  font-size: 0.95rem;
  color: #475569;
  line-height: 1.4;
}

.maxima-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.75rem;
}

.maxima-table th,
.maxima-table td {
  border: 1px solid #d1d5db;
  padding: 0.5rem 0.75rem;
  text-align: center;
}

.maxima-table th.editable-header-cell {
  cursor: pointer;
  background: #eef2ff;
}

.primary-structure-empty {
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 14px;
  color: #64748b;
  background: #f8fafc;
}

.primary-bulletin-table {
  min-width: 980px;
  font-size: 0.84rem;
}

.primary-bulletin-table th,
.primary-bulletin-table td {
  padding: 0.38rem 0.45rem;
  vertical-align: middle;
}

.primary-bulletin-table th {
  text-align: center;
}

.primary-domain-row td {
  position: relative;
  background: #dbeafe;
  color: #0f172a;
  font-weight: 900;
  letter-spacing: 0;
  text-align: center;
}

.primary-subdomain-row td {
  position: relative;
  background: #f1f5f9;
  color: #1e293b;
  font-weight: 800;
  text-align: left;
}

.primary-course-row td:first-child {
  text-align: left;
  font-weight: 650;
}

.primary-row-actions {
  float: right;
  display: inline-flex;
  gap: 6px;
  margin-left: 10px;
  white-space: nowrap;
}

.header-editor {
  position: absolute;
  z-index: 2000;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  border-radius: 14px;
  padding: 16px;
  min-width: 280px;
  max-width: 320px;
}

.header-editor label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 12px;
  font-size: 0.95rem;
  color: #0f172a;
}

.header-editor label span {
  font-weight: 600;
}

.header-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.header-editor-actions button.secondary {
  background: #f1f5f9;
  color: #0f172a;
}

.header-editor-actions button.secondary:hover {
  background: #e2e8f0;
}

.disabled-note-form {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3000;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  padding: 12px 14px;
  width: min(220px, 100%);
  display: grid;
  gap: 10px;
  font-size: 0.9rem;
  color: #334155;
}

.disabled-note-form__content {
  display: grid;
  gap: 5px;
}

.disabled-note-form__content strong {
  display: block;
  font-size: 0.95rem;
}

.disabled-note-form__content p {
  margin: 0;
  color: #64748b;
  line-height: 1.4;
}

.disabled-note-form__close {
  justify-self: end;
  border: none;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  padding: 7px 10px;
  cursor: pointer;
}

.disabled-note-form__close:hover {
  background: #1d4ed8;
}

.button-row,
.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

button,
.btn,
button[type="button"],
button[type="submit"],
button[type="reset"] {
  cursor: pointer;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.95rem;
  min-width: 80px;
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.18);
}

button:hover,
.btn:hover,
button[type="button"]:hover,
button[type="submit"]:hover,
button[type="reset"]:hover {
  opacity: 0.96;
  transform: translateY(-1px);
}

button.secondary,
.btn.secondary {
  background: #e2e8f0;
  color: #0f172a;
  box-shadow: none;
}

button.secondary:hover,
.btn.secondary:hover {
  background: #cbd5e1;
}

button.primary,
.btn.primary {
  background: linear-gradient(135deg, #0f766e 0%, #0d9488 100%);
  box-shadow: 0 6px 16px rgba(13, 148, 136, 0.2);
}

button.primary:hover,
.btn.primary:hover {
  background: #0f766e;
}

button.danger,
.btn.danger {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  box-shadow: 0 6px 16px rgba(220, 38, 38, 0.18);
}

button.danger:hover,
.btn.danger:hover {
  background: #b91c1c;
}

button:disabled,
.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

button#travaux-btn.teacher-centered,
#travaux-btn.teacher-centered {
  display: block;
  width: min(320px, 100%);
  max-width: 360px;
  margin: 0 auto;
  font-size: calc(0.95rem + 3px);
}

button.danger,
.btn.danger {
  background: #dc2626;
}

button.danger:hover,
.btn.danger:hover {
  background: #b91c1c;
}

.action-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.action-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #ffffff;
}

.action-list li span {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #e2e8f0;
}

.line-row:last-child {
  border-bottom: none;
}

.line-label {
  flex: 1 1 0;
  min-width: 0;
  font-weight: 600;
}

.line-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn-small {
  padding: 5px 8px;
  font-size: 0.8rem;
}

.item-details {
  flex: 1 1 0;
  min-width: 0;
}

.item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.item-meta {
  color: #475569;
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
}

.item-preview {
  margin-top: 6px;
  color: #475569;
  font-size: 0.92rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.class-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 12px;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}

.class-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.class-code {
  text-align: right;
  color: #475569;
  font-weight: 600;
  white-space: nowrap;
}

.student-class {
  display: block;
  font-size: 0.9rem;
  color: #475569;
  margin-top: 2px;
}

.action-list li button,
.action-list li .btn,
.action-list li a {
  flex: 0 0 auto;
}

.action-list li .btn {
  min-width: 70px;
  padding: 7px 10px;
  font-size: 0.92rem;
  white-space: nowrap;
}

.action-list li .btn.danger {
  background: #dc2626 !important;
}

.action-list li .btn.danger:hover {
  background: #b91c1c !important;
}

button:hover,
.btn:hover {
  opacity: 0.95;
}

.hidden {
  display: none;
}

.message {
  margin-top: 12px;
  color: #b91c1c;
}

ul {
  padding-left: 18px;
  margin: 0;
}

ul li {
  margin-bottom: 8px;
}

#bulletin-content {
  overflow-x: auto;
}

#block-list,
#branch-list,
#discipline-preview {
  display: none;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table th,
table td {
  border: 1px solid #dee2e6;
  padding: 10px;
  text-align: left;
}

table th {
  background: #eef2ff;
}

.data-table td:last-child {
  white-space: nowrap;
}

.data-table .professor-name {
  font-weight: 600;
  color: #111827;
}

.data-table .direction-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.1;
  white-space: normal;
}

.data-table .direction-badge--primaire {
  border-color: #bbf7d0;
  background: #ecfdf3;
  color: #166534;
}

.data-table .direction-badge--maternelle {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a3412;
}

.data-table .direction-badge--secondaire {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.data-table .class-pill {
  display: inline-block;
  background: #e0e7ff;
  color: #3730a3;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.9rem;
  margin-bottom: 6px;
}

.data-table .course-list {
  margin: 0;
  padding-left: 18px;
}

.data-table .course-list li {
  margin-bottom: 4px;
}

.data-table .action-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.data-table .btn {
  margin-right: 0;
}

body.print-mode .action-buttons,
body.print-mode .button-row .btn.primary,
body.print-mode .button-row .btn.secondary,
body.print-mode header,
body.print-mode .page > main > .button-row {
  display: none !important;
}

body.print-mode .page {
  padding: 0;
  background: #fff;
}

body.print-mode .page > main {
  padding: 0;
  margin: 0;
}

body.print-mode .add-work-btn {
  display: none !important;
}

body.print-mode .data-table,
body.print-mode .data-table th,
body.print-mode .data-table td {
  border: 1px solid #000 !important;
}

body.print-mode .data-table {
  border-collapse: collapse;
  width: 100%;
  display: table;
}

body.print-mode .data-table th,
body.print-mode .data-table td {
  padding: 8px;
  vertical-align: top;
}

.students-table-wrapper {
  margin-top: 20px;
  overflow-x: auto;
}

.student-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

.student-table th,
.student-table td {
  border: 1px solid #dbe2ea;
  padding: 8px;
  vertical-align: top;
  min-width: 120px;
}

.student-table th:first-child,
.student-table td:first-child {
  min-width: 180px;
  text-align: left;
}

.student-table input.note {
  width: 90%;
  max-width: 72px;
  padding: 4px 6px;
  font-size: 0.95rem;
  text-align: center;
  border: 1px solid #94a3b8;
  border-radius: 6px;
}

.student-table td.total,
.student-table td.col-total {
  background: #f8fafc;
  font-weight: 700;
  color: #1f2937;
}

.student-table th.vertical {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  width: 20px;
  max-width: 20px;
}

.student-table th.nature {
  width: 120px;
  text-align: center;
  vertical-align: middle;
}

.student-table th.period-exam {
  background: #f1f5f9;
  color: #0f172a;
}

.student-table th.period-total {
  background: #e2e8f0;
  color: #0f172a;
}

.entry-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.entry-chip {
  display: inline-block;
  padding: 3px 6px;
  border-radius: 999px;
  background: #e2e8f0;
  font-size: 12px;
}

.btn.small {
  padding: 4px 8px;
  font-size: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  width: min(100%, 420px);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.modal-content label {
  display: block;
  margin-bottom: 10px;
}

.class-block {
  margin-bottom: 20px;
  border: 1px solid #d7dde6;
  border-radius: 10px;
  padding: 12px 14px;
  background: #fff;
}

.class-block h3 {
  margin: 0 0 10px 0;
  color: #0c4a6e;
}

.search-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  background: #fff;
  border: 1px solid #d7dde6;
  border-radius: 10px;
}

.search-filters label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.95rem;
}

#definitions-panel {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid #d7dde6;
  border-radius: 12px;
  background: #fff;
}

#definitions-panel .panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.panel {
  padding: 18px;
  border: 1px solid #d7dde6;
  border-radius: 12px;
  background: #ffffff;
  margin-bottom: 18px;
}

.definition-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.definition-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid #d7dde6;
  border-radius: 10px;
  background: #f8fafc;
}

.definition-meta {
  color: #475569;
  font-size: 0.9rem;
  margin-top: 5px;
}

.definition-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.definition-form {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid #d7dde6;
  border-radius: 10px;
  background: #ffffff;
}

.definition-form.hidden {
  display: none;
}

.definition-form .form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.definition-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
}

.definition-form input,
.definition-form select {
  width: 100%;
}

.definition-form .form-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn.tiny {
  padding: 4px 8px;
  font-size: 0.82rem;
}

.student-table th.vertical {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  width: 20px;
  max-width: 20px;
}

.student-table th.nature {
  width: 120px;
  text-align: center;
  vertical-align: middle;
}

.button-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

footer small {
  color: #475569;
}

.settings-page {
  max-width: 1180px;
}

.settings-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.settings-hero h1 {
  margin-bottom: 8px;
}

.settings-hero p {
  margin: 0;
  max-width: 680px;
  color: #475569;
}

.settings-layout {
  display: grid;
  gap: 24px;
}

.settings-section {
  display: grid;
  gap: 14px;
}

.settings-section__head h2 {
  margin: 0 0 6px;
  color: #0f172a;
}

.settings-section__head p {
  margin: 0;
  color: #475569;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
}

.settings-card {
  min-height: 190px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  background: #ffffff;
  border: 1px solid #d7dde6;
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.06);
}

.settings-card h3 {
  margin: 0 0 8px;
  color: #0f172a;
}

.settings-card p {
  margin: 0;
  color: #475569;
}

.settings-card__action {
  align-self: flex-start;
}

.backup-page {
  max-width: 1220px;
}

.backup-layout {
  display: grid;
  gap: 18px;
}

.backup-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.backup-status-card {
  background: #ffffff;
  border: 1px solid #d7dde6;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

.backup-status-card span {
  display: block;
  color: #64748b;
  font-weight: 700;
  font-size: 0.84rem;
  text-transform: uppercase;
}

.backup-status-card strong {
  display: block;
  margin-top: 6px;
  color: #0f172a;
  font-size: 1.05rem;
}

.backup-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.backup-card__head h2 {
  margin: 0 0 6px;
}

.backup-card__head p {
  margin: 0;
  color: #475569;
}

.backup-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #b7c2cf;
  border-radius: 6px;
  resize: vertical;
  font: inherit;
}

.backup-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.backup-check input {
  width: auto;
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.backup-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #1e40af;
  font-weight: 800;
  font-size: 0.82rem;
}

.backup-table-wrap {
  overflow-x: auto;
}

.backup-message {
  min-height: 24px;
  margin: 0;
  font-weight: 700;
}

.backup-message.is-success {
  color: #047857;
}

.backup-message.is-error {
  color: #b91c1c;
}

.backup-message.is-warning {
  color: #a16207;
}

@media (max-width: 700px) {
  .settings-hero {
    flex-direction: column;
  }

  .backup-card__head {
    flex-direction: column;
  }
}

.sidebar__theme-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 12px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  padding: 10px 12px;
  font-weight: 800;
  box-shadow: none;
}

.sidebar__theme-toggle:hover {
  background: rgba(255,255,255,0.2);
}

.sidebar__theme-icon {
  display: inline-grid;
  place-items: center;
  min-width: 52px;
  border-radius: 999px;
  background: rgba(255,255,255,0.18);
  padding: 3px 8px;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar.is-collapsed .sidebar__theme-label {
  display: none;
}

body.theme-dark .main-content,
body.theme-dark .page {
  background: #1e1e1e;
  color: #cccccc;
}

body.theme-dark header,
body.theme-dark footer,
body.theme-dark .card,
body.theme-dark .settings-hero,
body.theme-dark .backup-card,
body.theme-dark .modal-content,
body.theme-dark .class-block,
body.theme-dark .search-filters,
body.theme-dark #definitions-panel,
body.theme-dark .panel,
body.theme-dark .definition-form,
body.theme-dark .settings-card,
body.theme-dark .backup-status-card,
body.theme-dark #student-page-form .form-section,
body.theme-dark .header-editor,
body.theme-dark .disabled-note-form,
body.theme-dark .action-list li,
body.theme-dark .temp-password-box {
  background: #252526;
  border-color: #3e3e42;
  color: #cccccc;
}

body.theme-dark header p,
body.theme-dark .help-text,
body.theme-dark .item-meta,
body.theme-dark .item-preview,
body.theme-dark .class-code,
body.theme-dark .student-class,
body.theme-dark .disabled-note-form__content p,
body.theme-dark .backup-card__head p,
body.theme-dark .backup-meta,
body.theme-dark .backup-note,
body.theme-dark .definition-meta,
body.theme-dark .settings-card p,
body.theme-dark .settings-hero p {
  color: #9d9d9d;
}

body.theme-dark .class-block h3,
body.theme-dark .settings-section__head h2,
body.theme-dark .settings-card h3,
body.theme-dark .header-editor label {
  color: #cccccc;
}

body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea,
body.theme-dark .backup-form textarea {
  background: #3c3c3c;
  border-color: #6b6b6b;
  color: #cccccc;
}

body.theme-dark input:disabled,
body.theme-dark select:disabled,
body.theme-dark .note:disabled {
  background: #2d2d30;
  color: #858585;
}

body.theme-dark button.secondary,
body.theme-dark .btn.secondary,
body.theme-dark .header-editor-actions button.secondary {
  background: #3c3c3c;
  color: #cccccc;
  border: 1px solid #6b6b6b;
}

body.theme-dark button.secondary:hover,
body.theme-dark .btn.secondary:hover,
body.theme-dark .header-editor-actions button.secondary:hover {
  background: #4a4a4d;
}

body.theme-dark table th,
body.theme-dark .maxima-table th {
  background: #2d2d30;
  color: #cccccc;
}

body.theme-dark table td,
body.theme-dark table th,
body.theme-dark .maxima-table th,
body.theme-dark .maxima-table td {
  border-color: #334155;
}

body.theme-dark table td,
body.theme-dark .maxima-table td {
  background: #252526;
  color: #cccccc;
}

body.theme-dark .student-table {
  background: #252526;
}

body.theme-dark .maxima-table th.editable-header-cell {
  background: #264f78;
}

body.theme-dark .primary-structure-empty {
  background: #252526;
  border-color: #334155;
  color: #cccccc;
}

body.theme-dark .primary-domain-row td {
  background: #264f78;
  color: #ffffff;
}

body.theme-dark .primary-subdomain-row td {
  background: #2d2d30;
  color: #e5e7eb;
}

body.theme-dark .data-table .professor-name {
  color: #ffffff;
}

body.theme-dark .data-table .class-pill,
body.theme-dark .backup-pill {
  background: #264f78;
  color: #ffffff;
}

body.theme-dark .data-table .direction-badge {
  border-color: #475569;
  background: #1f2937;
  color: #e5e7eb;
}

body.theme-dark .data-table .direction-badge--primaire {
  border-color: #15803d;
  background: #052e16;
  color: #bbf7d0;
}

body.theme-dark .data-table .direction-badge--maternelle {
  border-color: #c2410c;
  background: #431407;
  color: #fed7aa;
}

body.theme-dark .data-table .direction-badge--secondaire {
  border-color: #1d4ed8;
  background: #172554;
  color: #bfdbfe;
}

body.theme-dark .checkbox-option {
  border-color: #475569;
  background: #252526;
  color: #e5e7eb;
}

body.theme-dark .direction-context-pill {
  border-color: #475569;
  background: #1f2937;
  color: #e5e7eb;
}

body.theme-dark .line-row {
  border-color: #3e3e42;
}

body.theme-dark .message {
  color: #fca5a5;
}

@media print {
  body.theme-dark,
  body.has-sidebar.theme-dark,
  body.theme-dark .main-content,
  body.theme-dark .page,
  body.theme-dark header,
  body.theme-dark footer,
  body.theme-dark .card {
    background: #fff !important;
    color: #000 !important;
  }
}
