:root {
  --green-900: #0f3d22; --green-800: #14532d; --green-700: #1b6b3a; --green-100: #e3f1e7; --green-50: #f0f8f2;
  --gold: #d99a1f; --gold-100: #fbf0d4;
  --red: #b42318; --red-100: #fde8e6; --blue: #175cd3; --blue-100: #e5eefc; --orange: #b54708; --orange-100: #fdf0df;
  --bg: #f6f5f0; --card: #fff; --ink: #1d2a22; --muted: #66736b; --line: #e4e2da; --radius: 10px;
  --surface-2: #faf9f5; --input-line: #cfcdc4; --hover: var(--green-50); --notice-bg: #fff4d6; --notice-line: #e6c860; --notice-ink: #5a4300; color-scheme: light;
  --shadow: 0 1px 2px rgba(20,40,28,.06), 0 4px 14px rgba(20,40,28,.06);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
a { color: var(--green-700); }
button, input, select, textarea { font: inherit; color: inherit; }
.ic { flex: none; vertical-align: middle; }
[hidden] { display: none !important; }

/* ── Connexion ── */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: linear-gradient(160deg, var(--green-900), var(--green-700)); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art::after { content: ""; position: absolute; right: -90px; bottom: -90px; width: 340px; height: 340px; border-radius: 50%; border: 56px solid rgba(217,154,31,.28); }
.login-art h1 { font-size: 40px; letter-spacing: -.5px; }
.login-art p { max-width: 420px; opacity: .88; font-size: 17px; }
.login-art ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 10px; opacity: .92; }
.login-art li::before { content: "✓"; color: var(--gold); font-weight: 700; margin-right: 10px; }
.stripe { display: flex; height: 6px; width: 120px; border-radius: 3px; overflow: hidden; }
.stripe i { flex: 1; } .stripe i:nth-child(1) { background: #ce1126; } .stripe i:nth-child(2) { background: #fcd116; } .stripe i:nth-child(3) { background: #009460; }
.login-form-side { display: grid; place-items: center; padding: 32px; }
.login-card { width: min(400px, 100%); }
.login-card h2 { font-size: 26px; margin-bottom: 6px; }
.login-card .sub { color: var(--muted); margin: 0 0 24px; }
.login-card label { display: grid; gap: 6px; margin-bottom: 16px; font-weight: 600; font-size: 13px; }
@media (max-width: 800px) { .login-wrap { grid-template-columns: 1fr; } .login-art { display: none; } }

/* ── Structure ── */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: var(--green-900); color: #dbe9df; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; color: #fff; font-weight: 700; font-size: 18px; }
.brand .logo { width: 34px; height: 34px; border-radius: 9px; background: var(--gold); color: var(--green-900); display: grid; place-items: center; font-weight: 800; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8fb09b; padding: 14px 12px 4px; }
.sidebar a.nav { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px; color: inherit; text-decoration: none; font-weight: 500; }
.sidebar a.nav:hover { background: rgba(255,255,255,.08); }
.sidebar a.nav.active { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.sidebar .spacer { flex: 1; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 12px 26px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar .school { font-weight: 700; }
.topbar .year { color: var(--muted); font-size: 13px; }
.topbar .grow { flex: 1; }
.userbox { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--green-100); color: var(--green-800); display: grid; place-items: center; font-weight: 700; }
.userbox small { display: block; color: var(--muted); line-height: 1.1; }
.menu-btn { display: none; }
#view { padding: 26px; max-width: 1300px; width: 100%; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .nav-open .sidebar { transform: none; }
  .nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; }
  .menu-btn { display: inline-flex; }
  #view { padding: 16px; } .topbar { padding: 10px 14px; }
  .userbox .who { display: none; }
}

/* ── Composants ── */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; } .page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { background: var(--green-50); border-color: #cfe1d4; }
.btn.primary { background: var(--green-800); border-color: var(--green-800); color: #fff; }
.btn.primary:hover { background: var(--green-700); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { border: 0; background: transparent; cursor: pointer; padding: 6px; border-radius: 6px; font-size: 16px; }
.icon-btn:hover { background: var(--green-50); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h2 { font-size: 16px; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 16px; }
.cols-2 { grid-template-columns: 1.4fr 1fr; } @media (max-width: 1000px) { .cols-2 { grid-template-columns: 1fr; } }
.kpi { display: grid; gap: 4px; position: relative; overflow: hidden; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi .value { font-size: 24px; font-weight: 700; letter-spacing: -.3px; }
.kpi .sub { font-size: 12.5px; color: var(--muted); }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--green-700); }
.kpi.gold::before { background: var(--gold); } .kpi.red::before { background: var(--red); } .kpi.blue::before { background: var(--blue); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.toolbar .search { min-width: 240px; flex: 1; max-width: 360px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: var(--surface-2); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; } tbody tr.click:hover { background: var(--green-50); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.actions-cell { text-align: right; white-space: nowrap; }
.empty { padding: 36px; text-align: center; color: var(--muted); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--green-100); color: var(--green-800); }
.badge.red { background: var(--red-100); color: var(--red); } .badge.orange { background: var(--orange-100); color: var(--orange); }
.badge.blue { background: var(--blue-100); color: var(--blue); } .badge.gray { background: #eceae3; color: #55605a; }
.muted { color: var(--muted); } .small { font-size: 13px; } .right { text-align: right; }
.alerts { display: grid; gap: 8px; }
.alert { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 8px; text-decoration: none; font-weight: 500; }
.alert.rouge { background: var(--red-100); color: var(--red); } .alert.orange { background: var(--orange-100); color: var(--orange); } .alert.bleu { background: var(--blue-100); color: var(--blue); }
.alert.vert { background: var(--green-100); color: var(--green-800); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 10px 16px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--green-800); border-color: var(--gold); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; } .kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 500; }
.progress { height: 8px; background: #eceae3; border-radius: 999px; overflow: hidden; } .progress i { display: block; height: 100%; background: var(--green-700); }
.bars { display: flex; align-items: flex-end; gap: 14px; height: 190px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 6px; }
.bars .bar i { width: 100%; max-width: 54px; background: linear-gradient(var(--green-700), var(--green-800)); border-radius: 6px 6px 0 0; min-height: 3px; }
.bars .bar span { font-size: 12px; color: var(--muted); } .bars .bar b { font-size: 11.5px; }
.note-input { width: 90px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; text-align: right; }
.note-input:focus, input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 0; border-color: var(--gold); }

/* ── Formulaires et fenêtres ── */
input, select, textarea { padding: 8px 10px; border: 1px solid var(--input-line); border-radius: 8px; background: var(--card); width: 100%; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; padding: 0; flex: none; accent-color: var(--green, #14532d); vertical-align: middle; }
dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.28); overflow: hidden; }
dialog.wide { width: min(900px, calc(100vw - 24px)); }
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(15,40,25,.5); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 18px; }
.modal-body { padding: 20px; overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-form label { display: grid; gap: 5px; font-size: 13px; font-weight: 600; align-content: start; }
.grid-form label small { font-weight: 400; color: var(--muted); }
.grid-form .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.form-error { color: var(--red); margin: 0; font-weight: 600; min-height: 0; }
@media (max-width: 560px) { .grid-form { grid-template-columns: 1fr; } }
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 100; }
.toast { background: var(--green-900); color: #fff; padding: 11px 16px; border-radius: 8px; box-shadow: var(--shadow); max-width: 360px; transition: opacity .4s, transform .4s; }
.toast.err { background: var(--red); } .toast.out { opacity: 0; transform: translateY(8px); }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 44px; }
.pw-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; cursor: pointer; padding: 6px; color: var(--muted); border-radius: 6px; display: grid; place-items: center; }
.pw-eye:hover { color: var(--green-800); background: var(--green-50); }
.ocr-box { border: 1px dashed var(--green-600, #2e7d4f); background: var(--green-50); border-radius: 10px; padding: 12px 14px; }
.ocr-box p { margin: 6px 0; }
.ocr-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.ocr-box progress { width: 100%; }
.ocr-filled { background: #e8f6ec !important; border-color: #2e7d4f !important; }
.docs-panel { display: grid; gap: 14px; }
.photo-box { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.photo-frame { width: 110px; height: 135px; border-radius: 10px; background: var(--green-50); border: 1px solid #cfe3d6; display: grid; place-items: center; overflow: hidden; font-size: 40px; font-weight: 700; color: var(--green-800); }
.photo-frame img { width: 100%; height: 100%; object-fit: cover; }
.doc-block h3 { margin: 0 0 6px; font-size: 14px; }
.doc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.doc-list li { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 6px 10px; border: 1px solid #e3e8e4; border-radius: 8px; flex-wrap: wrap; }
.doc-add { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.doc-add select { width: auto; }
.err { color: #b3261e; }
.doc-photo { float: right; width: 80px; height: 100px; object-fit: cover; border: 1px solid #333; margin: 0 0 8px 14px; }
.ver { font-size: 11px; opacity: .6; padding: 8px 16px 12px; color: #fff; }
.ver.bad { opacity: 1; background: #b3261e; border-radius: 6px; margin: 8px; padding: 6px 8px; }
.notice { background: var(--card)4d6; border: 1px solid #e6c860; color: #5a4300; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.btn.warn { border-color: #e6a100; color: #8a5a00; background: var(--card)8e6; }
.aff-row { border: 1px solid #e3e8e4; border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
.aff-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.aff-head select { width: auto; max-width: 100%; }
.aff-mats { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; }
.aff-mat { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.aff-mat input { width: auto; }
/* ── Badges ── */
.badge-sheet { display: grid; grid-template-columns: repeat(2, 85.6mm); gap: 4mm; justify-content: center; }
.idcard { width: 85.6mm; height: 54mm; box-sizing: border-box; border: 0.3mm solid #14532d; border-radius: 3mm; overflow: hidden; background: #fff; color: #111; font-family: Arial, Helvetica, sans-serif; display: flex; flex-direction: column; break-inside: avoid; page-break-inside: avoid; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.idcard .b-head { background: #14532d; color: #fff; display: flex; align-items: center; gap: 2mm; padding: 1.4mm 3mm; min-height: 9mm; }
.idcard .b-head img { height: 7mm; width: 7mm; object-fit: contain; background: #fff; border-radius: 1mm; }
.idcard .b-school { display: flex; flex-direction: column; line-height: 1.1; overflow: hidden; }
.idcard .b-school b { font-size: 8.5pt; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.idcard .b-school i { font-size: 6pt; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.idcard .b-title { background: #f5c542; color: #14532d; font-size: 6.5pt; font-weight: 700; letter-spacing: .4pt; text-align: center; padding: 0.6mm 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.idcard .b-body { flex: 1; display: flex; gap: 2.5mm; padding: 2mm 3mm 0; align-items: flex-start; }
.idcard .b-photo { width: 20mm; height: 25mm; border: 0.2mm solid #999; background: #eef3ef; display: grid; place-items: center; font-size: 16pt; font-weight: 700; color: #14532d; flex: none; overflow: hidden; }
.idcard .b-photo img { width: 100%; height: 100%; object-fit: cover; }
.idcard .b-info { flex: 1; min-width: 0; font-size: 7pt; line-height: 1.35; }
.idcard .b-name { font-size: 9pt; font-weight: 700; text-transform: uppercase; line-height: 1.15; margin-bottom: 1mm; overflow-wrap: anywhere; }
.idcard .b-name span { text-transform: none; font-weight: 600; font-size: 8.5pt; }
.idcard .b-line em { font-style: normal; color: #555; display: inline-block; min-width: 11mm; }
.idcard .b-qr { width: 15mm; height: 15mm; flex: none; align-self: flex-end; margin-bottom: 1mm; }
.idcard .b-qr svg { width: 100%; height: 100%; display: block; }
.idcard .b-foot { font-size: 5.5pt; color: #444; text-align: center; padding: 0.8mm 3mm 1.2mm; border-top: 0.2mm solid #cfd8d2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media print { .badge-sheet { gap: 4mm; } }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* ── Documents imprimables (reçu, bulletin, fiche de paie) ── */
.doc { background: #fff; color: #111; font-family: Georgia, "Times New Roman", serif; padding: 28px 32px; border: 1px solid #ccc; max-width: 760px; margin: 0 auto 16px; font-size: 14px; }
.doc h1 { font-size: 17px; text-align: center; text-transform: uppercase; letter-spacing: 1px; margin: 8px 0; }
.doc .head { display: flex; align-items: center; justify-content: center; gap: 12px; text-align: center; border-bottom: 2px solid #14532d; padding-bottom: 5px; }
.doc .head-logo { max-height: 42px; max-width: 90px; object-fit: contain; flex: none; }
.doc .head b { font-size: 15px; display: block; } .doc .head span { display: block; font-size: 10.5px; color: #444; }
.doc .republique { display: flex; justify-content: space-between; font-size: 9px; line-height: 1.25; text-transform: uppercase; color: #333; margin-bottom: 4px; }
.doc table { margin: 10px 0; } .doc th, .doc td { border: 1px solid #999; padding: 5px 8px; font-size: 13px; } .doc th { background: #eee; color: #111; }
.doc .row { display: flex; justify-content: space-between; gap: 20px; margin: 6px 0; }
.doc .amount { font-size: 22px; font-weight: 700; border: 2px solid #14532d; padding: 8px 16px; display: inline-block; margin: 8px 0; }
.doc .sign { display: flex; justify-content: space-between; margin-top: 36px; font-size: 13px; }
.doc .sign div { width: 40%; text-align: center; border-top: 1px solid #333; padding-top: 4px; }
.doc .legend { font-size: 11.5px; color: #444; }
.doc .republique .tutelle, .doc .republique .rep { display: flex; flex-direction: column; gap: 1px; max-width: 48%; }
.doc .republique .rep { text-align: right; align-items: flex-end; }
.doc .head .devise { display: block; font-style: italic; font-size: 11px; color: #14532d; margin: 0; }
.doc.cover { display: flex; flex-direction: column; min-height: 250mm; border: 3px double #14532d; }
.doc.cover .cover-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 10px 0; }
.cover-logo { max-height: 120px; max-width: 220px; object-fit: contain; }
.cover-school { font-size: 24px; font-weight: 700; text-transform: uppercase; color: #14532d; }
.cover .devise { font-style: italic; font-size: 15px; }
.cover-meta { font-size: 12.5px; color: #444; }
.cover-title { font-size: 34px; font-weight: 700; letter-spacing: 4px; margin: 26px 0 14px; padding: 8px 28px; border-top: 3px solid #14532d; border-bottom: 3px solid #14532d; }
.cover-photo { width: 130px; height: 162px; object-fit: cover; border: 1px solid #333; }
.cover-name { font-size: 24px; font-weight: 700; text-transform: uppercase; margin-top: 6px; }
.cover-id { margin: 6px auto; border-collapse: collapse; min-width: 60%; text-align: left; }
.cover-id td { border: 0 !important; border-bottom: 1px dotted #999 !important; padding: 4px 8px; }
.cover-foot { text-align: center; font-size: 11.5px; color: #444; border-top: 3px double #14532d; padding-top: 8px; }
.doc.page-break { page-break-after: always; break-after: page; }
#print-root { display: none; }
/* Relevé de notes : présentation distincte du bulletin */
.doc.releve { border: 3px double #1e3a8a; }
.doc.releve .head { border-bottom-color: #1e3a8a; } .doc.releve .head b, .doc.releve .head .devise { color: #1e3a8a; }
.doc.releve .rel-title { text-align: center; background: #1e3a8a; color: #fff; padding: 4px 8px; margin: 8px 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.doc.releve .rel-title h1 { margin: 0; color: #fff; font-size: 17px; letter-spacing: 3px; } .doc.releve .rel-title span { font-size: 11px; }
.doc.releve th { background: #dbe4f7; }
.doc.releve .rel-id { display: flex; gap: 14px; align-items: center; margin: 6px 0; line-height: 1.7; }
.doc.releve .rel-decision { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; border: 1px solid #1e3a8a; padding: 6px 10px; margin: 8px 0; }
.doc-photo { width: 70px; height: 88px; }
@media print {
  .doc, .doc table { break-inside: auto; } .doc tr { break-inside: avoid; }
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing #print-root { display: block; }
  .doc { border: 0; margin: 0; max-width: none; padding: 8mm; }
  @page { margin: 10mm; }
}

/* ── Statistiques, suivi des enseignants, bibliothèque ── */
.grid.two { grid-template-columns: 1fr 1fr; } @media (max-width: 800px) { .grid.two { grid-template-columns: 1fr; } }
.bar-h { display: inline-block; vertical-align: middle; width: 110px; height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-right: 8px; }
.bar-h i { display: block; height: 100%; background: var(--green-700); border-radius: 99px; }
.dist { display: grid; grid-template-columns: 48px 1fr 28px; align-items: center; gap: 8px; margin: 5px 0; font-size: 13px; } .dist .bar-h { width: 100%; margin: 0; height: 12px; }
tbody tr.sel { background: var(--green-50); }
.cal { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-head span { background: var(--surface-2); padding: 6px; text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.cal-cell { min-height: 78px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); padding: 4px 5px; display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.cal-cell:nth-child(7n+1) { border-left: 0; } .cal-cell.off { background: var(--surface-2); } .cal-cell.sun { background: var(--surface-2); } .cal-cell[data-day] { cursor: pointer; } .cal-cell[data-day]:hover { background: var(--green-50); }
.cal-cell.today { outline: 2px solid var(--gold, #e0b020); outline-offset: -2px; }
.cal-n { font-size: 12px; font-weight: 700; color: var(--muted); }
.cal-ev { font-size: 11px; background: var(--green-100); color: var(--green-800); border-radius: 4px; padding: 1px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev.abs { background: var(--red-100); color: var(--red); }
@media (max-width: 700px) { .cal-cell { min-height: 56px; } .cal-ev { font-size: 10px; } }
.books { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.book { display: flex; gap: 14px; align-items: flex-start; padding: 14px; }
.book-ic { font-size: 38px; line-height: 1; text-align: center; flex: none; width: 54px; } .book-ic small { display: block; font-size: 10px; font-weight: 700; color: var(--muted); margin-top: 4px; }
.book-info { display: flex; flex-direction: column; gap: 5px; min-width: 0; } .book-info b { overflow-wrap: anywhere; }
.book-act { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
dialog.reader-modal { width: min(1000px, calc(100vw - 24px)); }
.reader { width: 100%; height: min(72vh, 760px); border: 1px solid var(--line); border-radius: 8px; background: #f4f4f4; }
@media print { .no-print { display: none !important; } }
.toolbar select, .toolbar input:not(.search):not([type=search]) { width: auto; min-width: 150px; }
.toolbar input[type=search], .toolbar .search { width: auto; min-width: 240px; flex: 1; max-width: 360px; }
.badge { white-space: nowrap; }


/* ═══════════ Thèmes d'affichage ═══════════ */
html[data-theme="ocean"] { --green-900: #0b2f5b; --green-800: #12447f; --green-700: #1c5fb0; --green-100: #e1ecfa; --green-50: #eef5fd; --gold: #e0a526; --bg: #f2f6fb; --line: #dde5f0; --surface-2: #f6f9fd; --ink: #16263a; --muted: #5d6e84; }
html[data-theme="bordeaux"] { --green-900: #4a1020; --green-800: #6d1a31; --green-700: #8c2542; --green-100: #f6e3e8; --green-50: #fbf0f3; --gold: #d9a21f; --bg: #faf6f4; --line: #eadfdc; --surface-2: #fcf8f6; --ink: #2b1a1d; --muted: #77686b; }
html[data-theme="ardoise"] { --green-900: #1f2933; --green-800: #323f4b; --green-700: #52606d; --green-100: #e4e7eb; --green-50: #f1f3f5; --gold: #d99a1f; --bg: #f3f4f6; --line: #dfe2e6; --surface-2: #f7f8f9; --ink: #1f2933; --muted: #616e7c; }
html[data-theme="sable"] { --green-900: #5b3d14; --green-800: #7a5320; --green-700: #9a6a2a; --green-100: #f6ead6; --green-50: #fbf5ea; --gold: #2f7d57; --gold-100: #dcefe4; --bg: #fbf6ec; --card: #fffdf8; --line: #ecdfc7; --surface-2: #fdf8ef; --ink: #33261a; --muted: #7d6d58; }
html[data-theme="sombre"] { color-scheme: dark; --green-900: #0a1710; --green-800: #2e9158; --green-700: #3fae6c; --green-100: #1d3a2a; --green-50: #18291f; --gold: #e0a93a; --gold-100: #3a2f14;
  --red: #ff8f85; --red-100: #3d1e1b; --blue: #7db0ff; --blue-100: #182b49; --orange: #ffb15c; --orange-100: #3b2813;
  --bg: #0f1612; --card: #17211b; --ink: #e5eee8; --muted: #9db2a5; --line: #28372e; --surface-2: #1c2820; --input-line: #365044; --hover: #1f3026;
  --notice-bg: #3a3014; --notice-line: #6f5a1a; --notice-ink: #f4dc8a; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.35); }
html[data-theme="contraste"] { --green-900: #00250f; --green-800: #004d1f; --green-700: #006b2b; --green-100: #d7f0df; --green-50: #eaf8ef; --gold: #b37400; --bg: #ffffff; --card: #ffffff; --ink: #000000; --muted: #2e2e2e; --line: #6b6b6b; --input-line: #000000; --surface-2: #f2f2f2; --shadow: none; }
html[data-theme="contraste"] .btn, html[data-theme="contraste"] .card, html[data-theme="contraste"] .table-wrap { border-width: 2px; }
html[data-theme="sombre"] .doc, html[data-theme="sombre"] .idcard { color-scheme: light; }
html[data-theme="sombre"] input[type=month], html[data-theme="sombre"] input[type=date], html[data-theme="sombre"] input[type=time] { color-scheme: dark; }

/* Densité et taille du texte */
html[data-size="small"], html[data-size="small"] body { font-size: 13.5px; }
html[data-size="large"], html[data-size="large"] body { font-size: 17px; }
html[data-size="xlarge"], html[data-size="xlarge"] body { font-size: 19px; }
html[data-density="compact"] th, html[data-density="compact"] td { padding: 5px 10px; }
html[data-density="compact"] .btn { padding: 5px 11px; } html[data-density="compact"] .btn.sm { padding: 3px 8px; }
html[data-density="compact"] .card { padding: 12px; } html[data-density="compact"] #view { padding-top: 14px; }
html[data-density="compact"] .sidebar a.nav { padding: 6px 12px; } html[data-density="compact"] .page-head { margin-bottom: 10px; }
html[data-density="spacious"] th, html[data-density="spacious"] td { padding: 14px 16px; }
html[data-density="spacious"] .sidebar a.nav { padding: 12px 14px; } html[data-density="spacious"] .card { padding: 22px; }

/* Sélecteur d'apparence */
.ui-themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 8px 0 18px; }
.ui-theme { border: 2px solid var(--line); border-radius: 12px; background: var(--card); padding: 8px; cursor: pointer; text-align: left; color: var(--ink); font: inherit; }
.ui-theme:hover { border-color: var(--green-700); } .ui-theme[aria-pressed="true"] { border-color: var(--green-700); box-shadow: 0 0 0 3px var(--green-100); }
.ui-theme b { display: block; font-size: 13.5px; margin-top: 6px; } .ui-theme small { color: var(--muted); font-size: 11.5px; }
.ui-prev { display: grid; grid-template-columns: 28% 1fr; height: 62px; border-radius: 8px; overflow: hidden; border: 1px solid rgba(0,0,0,.15); }
.ui-prev i { display: block; } .ui-prev .m { display: grid; gap: 5px; padding: 7px; align-content: start; } .ui-prev .m u { display: block; height: 8px; border-radius: 3px; text-decoration: none; }
.ui-opt { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 16px; }
.ui-opt button { padding: 7px 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; cursor: pointer; font: inherit; font-weight: 600; }
.ui-opt button[aria-pressed="true"] { background: var(--green-800); border-color: var(--green-800); color: #fff; }
.ui-fab { position: fixed; right: 14px; bottom: 14px; z-index: 20; border-radius: 999px; padding: 8px 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); box-shadow: var(--shadow); cursor: pointer; font: inherit; font-weight: 600; }
@media print { html, body { background: #fff !important; color: #000 !important; } }

/* ── Messagerie ── */
.nav-badge { margin-left: auto; background: #dc2626; color: #fff; border-radius: 99px; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; }
.nav-badge[hidden] { display: none; }
.chat { display: grid; grid-template-columns: 340px 1fr; height: calc(100vh - 230px); min-height: 440px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.chat-list { border-right: 1px solid var(--line); overflow-y: auto; }
.chat-item { display: flex; gap: 12px; width: 100%; text-align: left; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: inherit; cursor: pointer; font: inherit; }
.chat-item:hover { background: var(--hover); } .chat-item.sel { background: var(--green-50); }
.chat-av { flex: none; width: 42px; height: 42px; border-radius: 50%; background: var(--green-100); color: var(--green-800); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-size: 17px; }
.chat-av.annonce, .chat-av.groupe { background: var(--surface-2); font-size: 19px; }
.chat-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.chat-item-top, .chat-item-bot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chat-item-top b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .chat-item-top small { color: var(--muted); flex: none; }
.chat-prev { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-unread { background: var(--green-700); color: #fff; border-radius: 99px; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.chat-none, .chat-empty { color: var(--muted); text-align: center; padding: 40px 20px; margin: auto; }
.chat-thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-th-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.chat-th-title { display: flex; flex-direction: column; min-width: 0; } .chat-th-title b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .chat-th-title small { color: var(--muted); }
.chat-back { display: none; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 6px; background: var(--surface-2); }
.chat-day { text-align: center; margin: 10px 0 4px; } .chat-day span { background: var(--card); color: var(--muted); font-size: 12px; padding: 3px 12px; border-radius: 99px; border: 1px solid var(--line); text-transform: capitalize; }
.chat-more { text-align: center; }
.msg { display: flex; } .msg.mine { justify-content: flex-end; }
.bub { max-width: min(560px, 82%); background: var(--card); border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; padding: 7px 11px; overflow-wrap: anywhere; }
.msg.mine .bub { background: var(--green-700); color: #fff; border-color: transparent; border-radius: 14px 14px 4px 14px; }
.msg-who { font-size: 12px; font-weight: 700; color: var(--green-700); } .msg-who small { font-weight: 400; color: var(--muted); }
.msg-txt { white-space: pre-wrap; line-height: 1.4; }
.msg-meta { font-size: 11px; opacity: .75; text-align: right; margin-top: 2px; } .msg-meta .lu { color: #7dd3fc; font-weight: 700; }
.msg:not(.mine) .msg-meta .lu { color: var(--green-700); }
.msg-del { background: none; border: 0; cursor: pointer; opacity: 0; font-size: 12px; padding: 0 2px; color: inherit; } .msg:hover .msg-del, .msg-del:focus { opacity: .8; }
@media (hover: none) { .msg-del { opacity: .5; } }
.msg-dl { background: rgba(0,0,0,.06); border: 0; border-radius: 8px; padding: 6px 10px; cursor: pointer; font: inherit; color: inherit; text-align: left; } .msg.mine .msg-dl { background: rgba(255,255,255,.18); }
.msg-img { display: block; max-width: 100%; max-height: 240px; border-radius: 8px; margin-bottom: 6px; cursor: zoom-in; background: rgba(0,0,0,.05); min-height: 40px; }
.chat-compose { border-top: 1px solid var(--line); padding: 8px 10px; background: var(--card); }
.chat-row { display: flex; gap: 8px; align-items: flex-end; }
.chat-row textarea { flex: 1; resize: none; max-height: 130px; border-radius: 12px; padding: 9px 12px; line-height: 1.35; }
.chat-att { font-size: 13px; padding: 4px 6px 8px; }
.chat-ro { padding: 12px 16px; background: var(--card); border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.seg { display: flex; gap: 6px; margin-bottom: 12px; } .seg button { flex: 1; padding: 9px; border: 1px solid var(--line); background: var(--card); color: inherit; border-radius: 10px; cursor: pointer; font: inherit; font-weight: 600; } .seg button.on { background: var(--green-700); color: #fff; border-color: transparent; }
.nm-list { max-height: 46vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.nm-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 9px 12px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: inherit; cursor: pointer; font: inherit; } .nm-item:hover { background: var(--hover); }
.nm-txt { display: flex; flex-direction: column; min-width: 0; } .nm-txt small { color: var(--muted); }
.kids { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; } .kid { display: flex; gap: 14px; align-items: center; }
@media (max-width: 800px) {
  .chat { grid-template-columns: 1fr; height: calc(100dvh - 210px); min-height: 380px; border-radius: 10px; }
  .chat-thread { display: none; } .chat.open .chat-thread { display: flex; } .chat.open .chat-list { display: none; }
  .chat.open { position: fixed; inset: 0; z-index: 60; height: 100dvh; min-height: 0; border-radius: 0; border: 0; }
  .chat.open .chat-compose { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .chat-back { display: inline-flex; } .bub { max-width: 88%; }
  .chat-head .head-actions .btn { padding: 8px 12px; }
}
@media print { .chat { display: none; } }

/* ── Confort téléphone : appel, notes, accueil enseignant ── */
.srows{display:flex;flex-direction:column;gap:8px}
.srow{background:var(--card,#fff);border:1px solid var(--border,#e2e8f0);border-radius:12px;padding:10px 12px;display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px}
.srow-name{flex:1 1 140px;min-width:0;font-size:15px}
.srow-f{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.srow-f label{display:flex;flex-direction:column;font-size:11px;color:var(--muted,#64748b);gap:2px}
.srow .note-input{width:76px;min-height:44px;font-size:18px;text-align:center}
.srow .note-input.bad{border-color:#dc2626;background:#fee2e2}
.seg3{display:flex;border:1px solid var(--border,#cbd5e1);border-radius:10px;overflow:hidden}
.seg3 label{margin:0;cursor:pointer}
.seg3 input{position:absolute;opacity:0;pointer-events:none}
.seg3 span{display:block;padding:11px 14px;min-height:44px;font-size:14px;font-weight:600;background:transparent;color:var(--muted,#475569)}
.seg3 .p input:checked+span{background:#16a34a;color:#fff}
.seg3 .a input:checked+span{background:#dc2626;color:#fff}
.seg3 .r input:checked+span{background:#f59e0b;color:#fff}
.seg3 input:focus-visible+span{outline:2px solid #2563eb;outline-offset:-2px}
.srow .extra{display:none;flex:1 1 100%;gap:8px;align-items:center;flex-wrap:wrap}
.srow[data-pres="absence"] .extra,.srow[data-pres="retard"] .extra{display:flex}
.srow .extra .motif{flex:1 1 160px;min-height:40px}
.savebar{position:sticky;bottom:0;display:flex;gap:8px;align-items:center;justify-content:flex-end;flex-wrap:wrap;padding:10px 12px calc(10px + env(safe-area-inset-bottom));background:var(--card,#fff);border-top:1px solid var(--border,#e2e8f0);margin:12px -4px 0;z-index:5}
.savebar .muted{margin-right:auto;font-size:13px}
.savebar .btn{min-height:44px}
.tiles{display:grid;grid-template-columns:repeat(2,1fr);gap:12px}
.tile{display:flex;flex-direction:column;gap:4px;padding:18px 14px;border-radius:14px;background:var(--card,#fff);border:1px solid var(--border,#e2e8f0);text-decoration:none;color:inherit;min-height:112px}
.tile-ic{font-size:30px}.tile b{font-size:16px}.tile small{color:var(--muted,#64748b)}
.home-h{font-size:15px;margin:22px 0 8px}
.cls-row{display:flex;justify-content:space-between;align-items:center;padding:10px 12px;border:1px solid var(--border,#e2e8f0);border-radius:12px;margin-bottom:8px;background:var(--card,#fff)}
.cls-row .btn{margin-left:6px;min-height:40px}
.chat-av.alerte{background:#fef3c7}
@media(min-width:900px){.tiles{grid-template-columns:repeat(4,1fr)}}

/* ── Catalogue matières / classes types ── */
.cat-grid{display:grid;grid-template-columns:minmax(150px,1fr) 2fr;gap:16px;margin-top:8px}
.cm-classes{max-height:46vh;overflow:auto;margin:6px 0}
.cm-liste{max-height:42vh;overflow:auto;margin:8px 0}
.cm-row{display:flex;gap:8px;align-items:center;margin-bottom:6px}
.cm-row .cm-nom{flex:1;min-width:0}.cm-row .cm-coef{width:76px}
.chk{display:flex;gap:8px;align-items:center;margin:6px 0;cursor:pointer}
@media(max-width:700px){.cat-grid{grid-template-columns:1fr}}

/* Logo de l'école à côté de son nom */
.school-line { display: flex; align-items: center; gap: 10px; min-width: 0; }
.school-logo { height: 38px; width: auto; max-width: 64px; object-fit: contain; border-radius: 6px; background: #fff; padding: 2px; border: 1px solid rgba(0,0,0,.08); flex: none; }
@media (max-width: 700px) { .school-logo { height: 32px; max-width: 48px; } }

/* Fiche de classement */
.doc.classement h1 { background: #14532d; color: #fff; padding: 7px 10px; letter-spacing: 3px; margin: 10px 0 8px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.doc .cl-sub { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; border-bottom: 1px solid #bbb; padding-bottom: 6px; }
.doc .cl-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.doc .cl-stats div { border: 1px solid #14532d; border-radius: 6px; padding: 5px 8px; text-align: center; background: #f1f8f3; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.doc .cl-stats small { display: block; font-size: 10.5px; color: #444; text-transform: uppercase; letter-spacing: .4px; }
.doc .cl-stats b { font-size: 18px; color: #14532d; } .doc .cl-stats em { font-size: 11px; color: #555; font-style: normal; margin-left: 6px; }
.doc .cl-tab th { background: #14532d; color: #fff; border-color: #14532d; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.doc .cl-tab td { border-color: #ccc; } .doc .cl-tab tbody tr:nth-child(even) td { background: #f6f6f6; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.doc .cl-tab tr.sous td:nth-child(4) { color: #b91c1c; }
.doc .cl-distrib { margin-top: 10px; font-size: 12px; }
.doc .cl-bar { display: flex; align-items: center; gap: 8px; margin: 3px 0; } .doc .cl-bar span { width: 90px; }
.doc .cl-bar i { flex: 1; height: 10px; background: #e5e5e5; border-radius: 5px; overflow: hidden; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.doc .cl-bar u { display: block; height: 100%; background: #14532d; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.doc .cl-bar em { width: 24px; font-style: normal; text-align: right; }

/* Reçu : deux exemplaires sur une page A4 */
.recu-duo { max-width: 760px; margin: 0 auto; }
.doc.recu { position: relative; padding: 10px 18px; margin-bottom: 0; break-inside: avoid; page-break-inside: avoid; }
.doc.recu h1 { font-size: 15px; margin: 4px 0; } .doc.recu p { margin: 4px 0; line-height: 1.45; font-size: 12.5px; }
.doc.recu .row { margin: 3px 0; font-size: 12.5px; }
.doc.recu .recu-tag { display: table; margin: 0 auto 4px; font: 700 9.5px/1 Arial, sans-serif; letter-spacing: 1px; border: 1px solid #14532d; color: #14532d; padding: 2px 6px; border-radius: 3px; }
.doc.recu .recu-mt { display: flex; align-items: center; gap: 14px; } .doc.recu .amount { font-size: 18px; padding: 4px 12px; margin: 2px 0; white-space: nowrap; }
.doc.recu .sign { margin-top: 18px; }
.recu-cut { text-align: center; color: #777; font-size: 11px; overflow: hidden; white-space: nowrap; margin: 6px 0; font-family: Arial, sans-serif; }

/* Emploi du temps et pointage des enseignants */
.edt { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.edt-col { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px; min-height: 120px; }
.edt-h { font-weight: 700; color: var(--green-800); border-bottom: 2px solid var(--gold); padding-bottom: 4px; margin-bottom: 6px; }
.edt-slot { background: var(--green-50); border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; font-size: 13px; position: relative; }
.edt-slot .edt-act { position: absolute; top: 2px; right: 2px; display: flex; gap: 2px; } .edt-slot .btn { padding: 0 6px; }
tr.row-abs td { background: rgba(185, 28, 28, .07); }

/* Licence et verrouillage */
.licence-ov, .verrou-ov { position: fixed; inset: 0; z-index: 9000; display: grid; place-items: center; padding: 16px; background: rgba(20, 30, 25, .72); backdrop-filter: blur(6px); }
.verrou-ov { z-index: 9500; background: var(--bg); backdrop-filter: none; }
.licence-card, .verrou-card { width: min(460px, 100%); padding: 24px; }
.licence-card textarea { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.licence-code { font: 700 20px/1 ui-monospace, Consolas, monospace; letter-spacing: 1px; padding: 12px; margin: 6px 0 14px; background: var(--surface-2, #f6f9fd); border: 1px dashed var(--line); border-radius: 8px; text-align: center; user-select: all; }
.licence-bandeau { margin: 0 0 12px; padding: 8px 14px; border-radius: 8px; background: #fff4d6; color: #6b4b00; font-size: 14px; }
.verrou-card { text-align: center; } .verrou-card input { width: 100%; margin: 10px 0; text-align: center; } .verrou-card .logo-lock { font-size: 40px; }
@media print { .licence-ov, .verrou-ov, .licence-bandeau { display: none !important; } }
