/* e-school Manager — feuille de style */
:root {
  --brand: #4338ca; --brand-600: #4f46e5; --brand-50: #eef2ff; --brand-100: #e0e7ff;
  --bg: #f5f6fa; --surface: #ffffff; --surface-2: #f8f9fc; --border: #e4e6ef; --border-strong: #cfd3e1;
  --text: #1c1f2e; --text-2: #4b5168; --muted: #757b93;
  --green: #15803d; --green-bg: #dcfce7; --red: #b91c1c; --red-bg: #fee2e2; --amber: #a16207; --amber-bg: #fef3c7;
  --blue: #0369a1; --blue-bg: #e0f2fe; --gray-bg: #eef0f5; --purple: #7e22ce; --purple-bg: #f3e8ff;
  --radius: 10px; --radius-sm: 7px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06); --shadow-lg: 0 12px 40px rgba(16,24,40,.18);
  --on-brand: #ffffff; --on-sidebar: #ffffff; --font-size: 14px;
  --sidebar: 248px; --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #818cf8; --brand-600: #6366f1; --brand-50: #1e1b4b; --brand-100: #312e81;
    --bg: #0f111a; --surface: #171a26; --surface-2: #1d2130; --border: #2a2f42; --border-strong: #3a4058;
    --text: #e8eaf3; --text-2: #b7bbd0; --muted: #8b90a8;
    --green: #4ade80; --green-bg: #14321f; --red: #f87171; --red-bg: #3b1515; --amber: #fbbf24; --amber-bg: #3a2c0b;
    --blue: #38bdf8; --blue-bg: #0c2b3d; --gray-bg: #23283a; --purple: #c084fc; --purple-bg: #2e1946;
    color-scheme: dark;
  }
}
/* mode sombre choisi explicitement (préférence de l'utilisateur ou de l'établissement) */
:root[data-theme="dark"] {
    --brand: #818cf8; --brand-600: #6366f1; --brand-50: #1e1b4b; --brand-100: #312e81;
    --bg: #0f111a; --surface: #171a26; --surface-2: #1d2130; --border: #2a2f42; --border-strong: #3a4058;
    --text: #e8eaf3; --text-2: #b7bbd0; --muted: #8b90a8;
    --green: #4ade80; --green-bg: #14321f; --red: #f87171; --red-bg: #3b1515; --amber: #fbbf24; --amber-bg: #3a2c0b;
    --blue: #38bdf8; --blue-bg: #0c2b3d; --gray-bg: #23283a; --purple: #c084fc; --purple-bg: #2e1946;
    color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: var(--font-size)/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 16px; font-weight: 650; }
code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--gray-bg); padding: 2px 6px; border-radius: 5px; word-break: break-all; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.boot, .loading { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 60px; color: var(--muted); }
.spinner { width: 18px; height: 18px; border: 2.5px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- Structure ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar); background: var(--surface); border-inline-end: 1px solid var(--border); position: fixed; inset-block: 0; inset-inline-start: 0; display: flex; flex-direction: column; z-index: 30; overflow-y: auto; }
.content { flex: 1; margin-inline-start: var(--sidebar); min-width: 0; display: flex; flex-direction: column; }
.main { padding: 24px 28px 48px; max-width: 1400px; width: 100%; margin: 0 auto; }
.main:focus { outline: none; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: var(--text); text-decoration: none !important; }
.brand strong { display: block; font-size: 15px; } .brand small { display: block; color: var(--muted); font-size: 12px; }
.brand-logo { width: 36px; height: 36px; border-radius: 9px; object-fit: cover; }
.logo-mark { width: 36px; height: 36px; border-radius: 9px; background: var(--brand); color: var(--on-sidebar); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
nav { padding: 4px 10px 16px; flex: 1; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 6px; font-weight: 600; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; text-decoration: none !important; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--brand-50); color: var(--brand); }
.nav-link span:first-of-type { flex: 1; }
.nav-badge { background: var(--brand); color: var(--on-sidebar); border-radius: 10px; font-size: 11px; padding: 0 7px; font-weight: 600; }
.sidebar-foot { padding: 12px 20px 18px; border-top: 1px solid var(--border); font-size: 12.5px; }
.sidebar-foot a { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 28px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.menu-toggle { display: none; }
.search { position: relative; flex: 1; max-width: 560px; }
.search-spacer { flex: 1; }
.search input { width: 100%; padding-block: 9px; padding-inline: 36px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); color: var(--text); font: inherit; }
.search input:focus { background: var(--surface); border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-100); }
.search-icon { position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-panel { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; max-height: 70vh; overflow-y: auto; }
.search-group { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 8px 4px; font-weight: 600; }
.search-item { display: flex; gap: 10px; align-items: center; width: 100%; padding: 7px 8px; border: 0; background: none; border-radius: 7px; cursor: pointer; text-align: start; color: var(--text); font: inherit; }
.search-item:hover, .search-item:focus { background: var(--brand-50); outline: none; }
.search-item strong { display: block; font-weight: 600; } .search-item small { color: var(--muted); }
.search-all { width: 100%; padding: 8px; border: 0; border-top: 1px solid var(--border); margin-top: 4px; background: none; color: var(--brand); cursor: pointer; font: inherit; font-weight: 500; }
.search-empty { padding: 14px; color: var(--muted); }
.bell { position: relative; margin-inline-start: auto; color: var(--text-2); }
.bell .dot { position: absolute; top: 2px; inset-inline-end: 0; background: var(--red); color: #fff; font-size: 10px; border-radius: 9px; padding: 0 5px; line-height: 16px; font-weight: 700; }
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 9px; border: 0; background: none; cursor: pointer; padding: 4px 6px; border-radius: 9px; color: var(--text); font: inherit; text-align: start; }
.user-btn:hover { background: var(--surface-2); }
.user-name strong { display: block; font-size: 13px; } .user-name small { display: block; color: var(--muted); font-size: 11.5px; max-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dropdown { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); min-width: 200px; padding: 6px; z-index: 40; }
.dropdown a, .dropdown button { display: flex; gap: 9px; align-items: center; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 7px; color: var(--text); font: inherit; cursor: pointer; text-decoration: none !important; }
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); }
.scrim { display: none; }

/* ---------- Pages ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header p { margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); margin-bottom: 8px; font-size: 13px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > select { width: auto; }
.spacer { flex: 1; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-body { padding: 16px 18px; }
.card-body:has(> .table-wrap:only-child) { padding: 0; }
.card-body > .table-wrap:only-child .table { border: 0; }
.stat { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat-icon { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-indigo .stat-icon { background: var(--brand-50); color: var(--brand); } .stat-green .stat-icon { background: var(--green-bg); color: var(--green); }
.stat-amber .stat-icon { background: var(--amber-bg); color: var(--amber); } .stat-red .stat-icon { background: var(--red-bg); color: var(--red); }
.stat-blue .stat-icon { background: var(--blue-bg); color: var(--blue); } .stat-purple .stat-icon { background: var(--purple-bg); color: var(--purple); }
.stat-label { color: var(--muted); font-size: 12.5px; } .stat-value { font-size: 22px; font-weight: 700; letter-spacing: -.01em; } .stat-sub { font-size: 12px; color: var(--muted); }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty p { margin: 0; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; text-decoration: none !important; transition: background .12s, border-color .12s; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand-600); color: var(--on-brand); } .btn-primary:hover:not(:disabled) { background: var(--brand); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); } .btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); } .btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { background: #dc2626; color: #fff; } .btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-success { background: #16a34a; color: #fff; } .btn-success:hover:not(:disabled) { background: #15803d; }
.btn-sm { padding: 5px 10px; font-size: 13px; } .btn-icon { padding: 7px; } .btn-lg { padding: 12px 20px; font-size: 15px; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: start; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; } .table tr.clickable:hover td { background: var(--surface-2); }
.table .num { text-align: end; font-variant-numeric: tabular-nums; } .table .center { text-align: center; }
.table tr.muted-row td { opacity: .55; }
.person { display: flex; align-items: center; gap: 10px; } .person strong { display: block; font-weight: 600; } .person small { color: var(--muted); }
.avatar { border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--brand-100); }
.avatar-initials { display: inline-flex; align-items: center; justify-content: center; color: var(--brand); font-weight: 700; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-top: 1px solid var(--border); }
.pager > div { display: flex; align-items: center; gap: 4px; } .pager-info { padding: 0 8px; color: var(--text-2); }
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-gray { background: var(--gray-bg); color: var(--text-2); } .badge-green { background: var(--green-bg); color: var(--green); } .badge-red { background: var(--red-bg); color: var(--red); }
.badge-amber { background: var(--amber-bg); color: var(--amber); } .badge-blue { background: var(--blue-bg); color: var(--blue); } .badge-indigo { background: var(--brand-50); color: var(--brand); } .badge-purple { background: var(--purple-bg); color: var(--purple); }
.dot-color { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; }

/* ---------- Filtres et formulaires ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.filters input, .filters select { min-width: 150px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 8px 10px; width: 100%; }
.filters input, .filters select { width: auto; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--brand-600); }
textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px 16px; }
.field { grid-column: span 6; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.half { grid-column: span 3; } .field.third { grid-column: span 2; }
.field label { font-weight: 550; font-size: 13px; color: var(--text-2); }
.field .req { color: var(--red); }
.field-error, .form-error { color: var(--red); font-size: 12.5px; min-height: 0; }
.field-error:empty { display: none; }
.form-section { grid-column: span 6; font-weight: 650; padding-top: 8px; border-top: 1px solid var(--border); margin-top: 4px; color: var(--brand); }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px 12px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); max-height: 220px; overflow-y: auto; }
.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 8px 18px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* ---------- Onglets ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { border: 0; background: none; padding: 10px 14px; font: inherit; font-weight: 550; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tab:hover { color: var(--text); } .tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-count { background: var(--gray-bg); color: var(--text-2); border-radius: 10px; font-size: 11px; padding: 0 7px; }

/* ---------- Modales et notifications ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 18, 30, .5); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 100; overflow-y: auto; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); width: 100%; display: flex; flex-direction: column; max-height: 88vh; animation: pop .16s; }
.modal:focus { outline: none; }
.modal-sm { max-width: 440px; } .modal-md { max-width: 640px; } .modal-lg { max-width: 920px; } .modal-xl { max-width: 1180px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 12px 12px; }
@keyframes fade { from { opacity: 0; } } @keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
#toasts { position: fixed; bottom: 20px; inset-inline-end: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: min(420px, calc(100vw - 40px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 9px; background: #1c1f2e; color: #fff; box-shadow: var(--shadow-lg); animation: pop .2s; transition: opacity .3s; }
.toast-success svg { color: #4ade80; } .toast-error { background: #7f1d1d; } .toast-info svg { color: #93c5fd; }
.toast.hide { opacity: 0; }
.secret { display: flex; gap: 10px; align-items: center; padding: 8px 0; flex-wrap: wrap; } .secret code { font-size: 14px; flex: 1; }

/* ---------- Divers ---------- */
.profile-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.profile-head .avatar { border: 3px solid var(--surface); box-shadow: var(--shadow); }
.photo-edit { position: relative; } .photo-edit button { position: absolute; bottom: -2px; inset-inline-end: -2px; border-radius: 50%; padding: 6px; }
.list { display: flex; flex-direction: column; } .list-item { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; } .list-item .grow { flex: 1; min-width: 0; } .list-item small { color: var(--muted); display: block; }
.progress { height: 8px; background: var(--gray-bg); border-radius: 6px; overflow: hidden; } .progress > div { height: 100%; background: var(--brand-600); border-radius: 6px; }
.progress-green > div { background: #16a34a; } .progress-amber > div { background: #d97706; } .progress-red > div { background: #dc2626; }
.chart { width: 100%; height: auto; display: block; direction: ltr; } .chart .grid { stroke: var(--border); stroke-dasharray: 3 3; } .chart .axis { fill: var(--muted); font-size: 10px; }
.grade-input { width: 80px; text-align: center; } .score { font-weight: 700; font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 10px; font: inherit; font-size: 12.5px; cursor: pointer; color: var(--text-2); border-inline-end: 1px solid var(--border); }
.seg button:last-child { border-inline-end: 0; }
.seg button.on-present { background: var(--green-bg); color: var(--green); font-weight: 600; } .seg button.on-absent { background: var(--red-bg); color: var(--red); font-weight: 600; }
.seg button.on-late { background: var(--amber-bg); color: var(--amber); font-weight: 600; } .seg button.on-excused { background: var(--blue-bg); color: var(--blue); font-weight: 600; }
.timetable { display: grid; grid-template-columns: 64px repeat(6, minmax(120px, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; min-width: 760px; }
.tt-head { background: var(--surface-2); padding: 8px; font-weight: 600; text-align: center; border-bottom: 1px solid var(--border); border-inline-start: 1px solid var(--border); }
.tt-time { font-size: 11.5px; color: var(--muted); padding: 4px 6px; border-top: 1px solid var(--border); text-align: end; }
.tt-col { position: relative; border-inline-start: 1px solid var(--border); background: repeating-linear-gradient(to bottom, transparent 0, transparent 55px, var(--border) 55px, var(--border) 56px); }
.tt-slot { position: absolute; left: 3px; right: 3px; border-radius: 6px; padding: 4px 7px; font-size: 12px; overflow: hidden; border-inline-start: 3px solid; cursor: default; line-height: 1.3; }
.tt-slot strong { display: block; font-size: 12.5px; } .tt-slot.editable { cursor: pointer; } .tt-slot.editable:hover { filter: brightness(.96); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cal-dow { background: var(--surface-2); padding: 8px; text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); }
.cal-day { min-height: 104px; padding: 6px; border-inline-end: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-day:nth-child(7n) { border-inline-end: 0; } .cal-day.out { background: var(--surface-2); } .cal-day.out .cal-num { color: var(--muted); }
.cal-num { font-size: 12px; font-weight: 600; } .cal-day.today .cal-num { background: var(--brand-600); color: var(--on-brand); border-radius: 10px; padding: 0 7px; align-self: flex-start; }
.cal-item { font-size: 11.5px; padding: 2px 6px; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; border-inline-start: 3px solid; background: var(--surface-2); }
.matrix { border-collapse: separate; border-spacing: 0; width: 100%; }
.matrix th, .matrix td { padding: 7px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
.matrix thead th { position: sticky; top: 0; background: var(--surface-2); z-index: 1; font-size: 12px; text-align: center; }
.matrix tbody th { text-align: start; font-weight: 500; } .matrix td { text-align: center; }
.matrix .mod-row th { background: var(--brand-50); color: var(--brand); font-weight: 650; }
.matrix select { width: auto; padding: 3px 6px; font-size: 12.5px; }
.scope-all { background: var(--green-bg) !important; color: var(--green); } .scope-own { background: var(--amber-bg) !important; color: var(--amber); }
.msg-body { white-space: pre-wrap; line-height: 1.6; }
.msg-item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.msg-item:hover { background: var(--surface-2); } .msg-item.unread strong { font-weight: 700; } .msg-item.unread { background: var(--brand-50); }
.msg-item .grow { flex: 1; min-width: 0; } .msg-item p { margin: 2px 0 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--brand-50); color: var(--brand); border-radius: 16px; padding: 3px 6px 3px 10px; font-size: 12.5px; font-weight: 550; }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; display: inline-flex; }
.highlight { background: linear-gradient(135deg, var(--brand-600), var(--brand)); color: var(--on-brand); border: 0; }
.highlight .muted, .highlight small { color: rgba(255,255,255,.8); }
.child-card { display: flex; gap: 14px; align-items: center; }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.doc-icon { width: 38px; height: 38px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* ---------- Connexion ---------- */
.login-page { background: var(--bg); }
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-side { background: linear-gradient(150deg, var(--brand), var(--brand-600)); color: var(--on-brand); padding: 64px 56px; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.login-side p { font-size: 16px; opacity: .9; max-width: 460px; margin: 0; }
.brand-lg { display: flex; align-items: center; gap: 12px; font-size: 26px; font-weight: 750; }
.brand-lg .logo-mark { width: 48px; height: 48px; background: rgba(255,255,255,.16); }
.login-points { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 10px; }
.login-points li { display: flex; gap: 10px; align-items: center; opacity: .95; }
.login-card { display: flex; flex-direction: column; justify-content: center; padding: 48px; max-width: 460px; width: 100%; margin: 0 auto; gap: 6px; }
.login-form { display: flex; flex-direction: column; gap: 14px; margin: 18px 0; }
.login-form .btn { padding: 11px; }

/* ---------- Impression ---------- */
@media print {
  .sidebar, .topbar, .actions, .filters, .pager, .tabs { display: none !important; }
  .content { margin: 0; } .main { padding: 0; } .card { box-shadow: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-main { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  [dir=rtl] .sidebar { transform: translateX(100%); }
  body.nav-open[dir=rtl] .sidebar, [dir=rtl] body.nav-open .sidebar { transform: none; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 25; }
  .content { margin-inline-start: 0; }
  .menu-toggle { display: inline-flex; }
  .main { padding: 18px 16px 40px; } .topbar { padding: 8px 12px; gap: 8px; }
  .user-name { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; } .login-side { padding: 36px 24px; } .login-card { padding: 28px 20px; }
  .field.half, .field.third { grid-column: span 6; }
  .table.responsive thead { display: none; }
  .table.responsive tr { display: block; border-bottom: 1px solid var(--border); padding: 6px 0; }
  .table.responsive td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 14px; }
  .table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: 12px; }
}
@media (max-width: 520px) { .grid-4 { grid-template-columns: 1fr; } .stat-value { font-size: 19px; } }

/* ---------- Langues ---------- */
/* flèches et icônes directionnelles inversées en écriture de droite à gauche */
[dir=rtl] .rtl-flip { transform: scaleX(-1); }
/* police adaptée à l'arabe (polices système, aucune ressource externe) */
:lang(ar) body, [lang=ar] body { font-family: "Segoe UI", Tahoma, "Geeza Pro", "Noto Sans Arabic", "Noto Naskh Arabic", system-ui, sans-serif; }
/* identifiants, codes, montants et dates restent lisibles de gauche à droite */
[dir=rtl] code, [dir=rtl] input[type=email], [dir=rtl] input[type=password], [dir=rtl] input[type=tel] { direction: ltr; unicode-bidi: plaintext; text-align: end; }
.login-lang { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.login-lang select, .select-sm { padding: 4px 8px; font-size: 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-family: inherit; }

/* ---------- Apparence personnalisée ---------- */
/* barre latérale aux couleurs de l'établissement */
[data-sidebar="brand"] .sidebar { background: var(--brand); border-inline-end-color: transparent; color: var(--on-sidebar); }
[data-sidebar="brand"] .sidebar .brand, [data-sidebar="brand"] .nav-link, [data-sidebar="brand"] .sidebar-foot a { color: var(--on-sidebar); }
[data-sidebar="brand"] .nav-section, [data-sidebar="brand"] .sidebar .brand small, [data-sidebar="brand"] .sidebar-foot a { color: var(--on-sidebar); opacity: .78; }
[data-sidebar="brand"] .nav-link:hover { background: color-mix(in srgb, var(--on-sidebar) 12%, transparent); color: var(--on-sidebar); }
[data-sidebar="brand"] .nav-link.active { background: color-mix(in srgb, var(--on-sidebar) 20%, transparent); color: var(--on-sidebar); font-weight: 600; }
[data-sidebar="brand"] .sidebar .logo-mark { background: color-mix(in srgb, var(--on-sidebar) 18%, transparent); }
[data-sidebar="brand"] .nav-badge { background: var(--on-sidebar); color: var(--brand); }
[data-sidebar="brand"] .sidebar-foot { border-top-color: color-mix(in srgb, var(--on-sidebar) 22%, transparent); }
/* éditeur d'apparence */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; padding: 0; }
.swatch.selected { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.swatch-custom { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.theme-preview { border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; background: var(--bg); }
.contrast-note { font-size: 12.5px; }
.contrast-note.warn { color: var(--amber); }

/* Échéance de la licence de l'établissement (administrateurs) */
.license-banner { display: flex; align-items: center; gap: 10px; padding: 10px 28px; border-block-end: 1px solid transparent; font-size: 14px; }
.license-banner > span { flex: 1; }
.license-warning { background: var(--amber-bg); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 30%, transparent); }
.license-urgent { background: var(--red-bg); color: var(--red); border-color: color-mix(in srgb, var(--red) 30%, transparent); font-weight: 600; }
.license-banner .btn { color: inherit; flex-shrink: 0; }
@media (max-width: 760px) { .license-banner { padding: 10px 16px; flex-wrap: wrap; } }
@media print { .license-banner { display: none !important; } }
