:root {
  --brand: #1e3a8a; --brand-2: #2f55d4; --brand-soft: #e8eefc;
  --bg: #f4f6fb; --card: #ffffff; --text: #1b2437; --muted: #6b7690; --line: #e3e8f2;
  --ok: #138a4b; --ok-bg: #e3f6ec; --warn: #a15c00; --warn-bg: #fff2d9;
  --bad: #b42323; --bad-bg: #fde8e8; --info: #1d5fb8; --info-bg: #e2effd;
  --radius: 12px; --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 14px rgba(20, 30, 60, .05);
  --side: 258px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #8fb0ff; --brand-2: #6c8cff; --brand-soft: #1d2a4d;
    --bg: #0f1422; --card: #171d2f; --text: #e6eaf5; --muted: #98a3bd; --line: #262e45;
    --ok: #4ad08a; --ok-bg: #12301f; --warn: #f0b24e; --warn-bg: #3a2c10;
    --bad: #ff8c8c; --bad-bg: #3b1818; --info: #7db6ff; --info-bg: #14283f;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
body.noscroll { overflow: hidden; }
h1 { font-size: 1.45rem; margin: 0; line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
h3 { margin: 0; font-size: 1.05rem; }
p { margin: .3rem 0; }
code { background: var(--brand-soft); padding: 2px 6px; border-radius: 6px; font-size: .95em; }
a { color: var(--brand-2); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.ic { flex: none; vertical-align: middle; }
[hidden] { display: none !important; }

/* ---------- mise en page ---------- */
#app { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--brand); color: #fff; display: flex; flex-direction: column; z-index: 40; transition: transform .22s; }
@media (prefers-color-scheme: dark) { .sidebar { background: #111a33; border-right: 1px solid var(--line); color: #e6eaf5; } }
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px 14px; }
.brand-logo { width: 42px; height: 42px; border-radius: 10px; background: rgba(255,255,255,.16); display: grid; place-items: center; overflow: hidden; flex: none; }
.brand-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand-name { font-weight: 700; line-height: 1.2; font-size: .98rem; }
.brand-sub { opacity: .75; font-size: .78rem; }
.nav { flex: 1; overflow-y: auto; padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; padding: 10px 12px; border-radius: 10px; opacity: .88; }
.nav a:hover { background: rgba(255,255,255,.1); opacity: 1; }
.nav a.active { background: rgba(255,255,255,.2); opacity: 1; font-weight: 600; }
.side-foot { padding: 10px; border-top: 1px solid rgba(255,255,255,.14); display: grid; gap: 6px; }
.side-user { display: flex; gap: 10px; align-items: center; background: none; border: 0; color: inherit; text-align: left; padding: 6px; border-radius: 10px; cursor: pointer; font: inherit; }
.side-user:hover { background: rgba(255,255,255,.1); }
.side-user b { display: block; font-size: .92rem; } .side-user small { opacity: .7; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.22); display: grid; place-items: center; font-weight: 700; }
.avatar::before { content: "☺"; }
.side-foot .btn.ghost { color: #fff; border-color: rgba(255,255,255,.25); }
.content { margin-left: var(--side); min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 10px 22px; background: var(--card); border-bottom: 1px solid var(--line); }
.top-title { font-weight: 600; flex: 1; }
.menu-btn { display: none; }
.main { padding: 22px; max-width: 1280px; margin: 0 auto; padding-bottom: 90px; }
.scrim { position: fixed; inset: 0; background: rgba(8, 12, 30, .5); z-index: 30; }
.icon-btn { background: none; border: 0; color: var(--text); width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; position: relative; }
.icon-btn:hover { background: var(--brand-soft); }
.bell-count { position: absolute; top: 3px; right: 2px; background: var(--bad); color: #fff; font-size: .68rem; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; font-weight: 700; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); } .sidebar.open { box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .sidebar.open { transform: none; }
  .content { margin-left: 0; }
  .menu-btn { display: grid; }
  .topbar { padding: 8px 10px; padding-top: calc(8px + env(safe-area-inset-top)); }
  .main { padding: 14px 12px 90px; }
}

/* ---------- composants ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card > h2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stat { display: flex; gap: 12px; align-items: center; }
.stat .ico { width: 44px; height: 44px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex: none; }
.stat b { font-size: 1.45rem; display: block; line-height: 1.1; } .stat span { color: var(--muted); font-size: .85rem; }
.stat.warn .ico { background: var(--warn-bg); color: var(--warn); } .stat.ok .ico { background: var(--ok-bg); color: var(--ok); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; min-height: 40px; text-decoration: none; }
.btn:hover { border-color: var(--brand-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: .86rem; }
.btn.block { width: 100%; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); } .badge.info { background: var(--info-bg); color: var(--info); }
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field > span { font-size: .85rem; color: var(--muted); font-weight: 600; }
.field small { color: var(--muted); }
.field.inline { margin: 0; min-width: 190px; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); font: inherit; min-height: 40px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: 0; border-color: transparent; }
input[type=checkbox] { width: auto; min-height: 0; }
.check { display: flex; gap: 8px; align-items: center; margin: 4px 0 10px; cursor: pointer; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 12px; }
.form-error { background: var(--bad-bg); color: var(--bad); padding: 9px 12px; border-radius: 10px; margin: 8px 0; font-size: .9rem; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.toolbar .field { margin: 0; }
.toolbar .grow { flex: 1; min-width: 180px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; font: inherit; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--brand-2); border-color: var(--brand-2); font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 34px 12px; display: grid; justify-items: center; gap: 6px; }
.empty.bad { color: var(--bad); }
.loading { display: grid; place-items: center; padding: 60px; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--brand-2); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { background: var(--line); border-radius: 999px; height: 8px; overflow: hidden; min-width: 80px; }
.progress > div { height: 100%; background: var(--brand-2); border-radius: 999px; }
.progress.ok > div { background: var(--ok); } .progress.warn > div { background: #e0a020; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; text-align: right; }
.list-row { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: center; }
.list-row:last-child { border: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--brand-soft); color: var(--brand); border-radius: 999px; padding: 3px 6px 3px 10px; font-size: .85rem; }
.chip button { border: 0; background: none; cursor: pointer; color: inherit; padding: 0 4px; font-size: 1rem; }
.level-card h2 { margin-bottom: 4px; }
.class-pill { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 6px 6px 12px; margin: 4px 6px 4px 0; background: var(--bg); }
.class-pill small { color: var(--muted); }

/* ---------- tableaux ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: color-mix(in srgb, var(--brand-soft) 45%, transparent); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; } .tbl .ctr { text-align: center; }
.tbl .act { text-align: right; }
.tbl .act .btn { margin: 2px 0 2px 4px; white-space: nowrap; }
.tbl input.grade { width: 90px; text-align: center; font-weight: 600; }
.good { color: var(--ok); font-weight: 600; } .low { color: var(--bad); font-weight: 600; }
@media (max-width: 700px) {
  .tbl.stack thead { display: none; }
  .tbl.stack, .tbl.stack tbody, .tbl.stack tr, .tbl.stack td { display: block; width: 100%; }
  .tbl.stack tr { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; padding: 6px 10px; background: var(--card); }
  .tbl.stack td { border: 0; padding: 5px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .tbl.stack td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; flex: none; }
  .tbl.stack td.act { justify-content: flex-end; flex-wrap: wrap; }
  .tbl.stack td.act::before, .tbl.stack td:empty { display: none; }
}

/* ---------- fenêtres ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(8, 12, 30, .55); z-index: 100; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--card); border-radius: 16px; width: 100%; max-width: 480px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.35); animation: pop .15s ease-out; }
.modal.wide { max-width: 860px; }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 6px; }
.modal-body { padding: 8px 16px 14px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
@media (max-width: 600px) {
  .modal-back { align-items: end; padding: 0; }
  .modal, .modal.wide { max-width: none; border-radius: 18px 18px 0 0; max-height: 94vh; }
  .modal-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: grid; gap: 8px; max-width: calc(100vw - 32px); }
.toast { background: #172033; color: #fff; padding: 11px 16px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.3); border-left: 5px solid var(--ok); animation: pop .2s; }
.toast.bad { border-color: #ff6b6b; } .toast.warn { border-color: #f0b24e; } .toast.out { opacity: 0; transition: .3s; }
.notif { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); margin-bottom: 8px; }
.notif.unread { background: var(--brand-soft); border-color: transparent; }
.notif p { margin: 2px 0 4px; font-size: .92rem; }

/* ---------- connexion ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(145deg, #1e3a8a, #2f55d4 60%, #4b74f0); }
.login-card { background: var(--card); border-radius: 20px; padding: 28px 26px; width: 100%; max-width: 400px; box-shadow: 0 24px 70px rgba(0,0,0,.3); }
.login-card h1 { text-align: center; font-size: 1.3rem; } .login-card > p { text-align: center; margin-bottom: 18px; }
.login-logo, .login-logo-ph { display: block; margin: 0 auto 10px; width: 72px; height: 72px; object-fit: contain; border-radius: 16px; }
.login-logo-ph { background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; }

/* ---------- spécifiques ---------- */
.grade-sheet-actions { position: sticky; bottom: 0; background: var(--card); padding: 12px 0 2px; display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line); margin-top: 10px; }
.course-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.course-item:last-child { border: 0; }
.course-item .ico { width: 40px; height: 40px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex: none; }
.course-item .grow { flex: 1; min-width: 0; } .course-item .grow p { color: var(--muted); font-size: .9rem; word-break: break-word; }
.bulletin-big { font-size: 1.8rem; font-weight: 700; color: var(--brand-2); }
.summary-box { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 12px; }
.summary-box > div { background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.summary-box small { color: var(--muted); display: block; } .summary-box b { font-size: 1.15rem; }
.print-only { display: none; }
@media print { .sidebar, .topbar, .page-actions, .toasts { display: none !important; } .content { margin: 0; } }
.view > .grid { margin-bottom: 16px; }

/* importation */
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
ul.err-list li { color: var(--bad, #b42318); }

.tabs a.btn { border-radius: 8px 8px 0 0; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.btn.primary { box-shadow: none; }
.embed .page-head { display: none; }

#supportBar { background: #b45309; color: #fff; text-align: center; padding: 6px 10px; font-size: 13px; position: sticky; top: 0; z-index: 60; }

/* Marque de l'éditeur (JAyS@ft - Gestion Scolaire) : distincte du nom et du logo de l'établissement */
.powered { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line, #e3e8f2); font-size: .74rem; color: #6b7390; }
.powered img { height: 46px; width: auto; }
.side-brand { display: flex; align-items: center; gap: 9px; background: #fff; border-radius: 10px; padding: 6px 9px; margin-bottom: 10px; }
.side-brand img { height: 44px; width: auto; flex: none; }
.side-brand span { display: flex; flex-direction: column; line-height: 1.15; color: #1f3a8a; }
.side-brand b { font-size: .86rem; } .side-brand small { font-size: .68rem; color: #5b6685; }
