:root {
  --navy: #0b2545;
  --navy-2: #13315c;
  --blue: #1d6fe0;
  --blue-soft: #e8f0fd;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1b2433;
  --muted: #64748b;
  --line: #e2e8f0;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --err: #b91c1c;
  --err-soft: #fee2e2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 8px rgba(15, 23, 42, .04);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
  display: grid; grid-template-columns: 236px 1fr; min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 650; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

body.bare { display: grid; grid-template-columns: 1fr; place-items: center; background: linear-gradient(160deg, #0b2545, #13315c 60%, #1d6fe0); }
.auth-card { width: min(420px, 92vw); background: #fff; border-radius: 14px; padding: 28px 30px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.auth-card .brand-line { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.auth-card .brand-line b { font-size: 18px; color: var(--navy); }
.auth-card .brand-line span { display: block; font-size: 11px; color: var(--muted); }
.auth-card .form-row { grid-template-columns: 1fr; }
.auth-foot { margin-top: 18px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; }
/* ---- sidebar ---- */
.sidebar { background: var(--navy); color: #c9d6ea; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; }
.brand b { font-size: 17px; letter-spacing: .01em; }
.brand span { display: block; font-size: 11px; color: #8fa6c8; }
.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6f87ab; padding: 12px 10px 4px; }
.sidebar a { color: #c9d6ea; padding: 8px 10px; border-radius: 7px; display: flex; gap: 10px; align-items: center; }
.sidebar a:hover { background: var(--navy-2); text-decoration: none; color: #fff; }
.sidebar a.active { background: var(--blue); color: #fff; }
.sidebar .ico { width: 18px; text-align: center; opacity: .9; }
.sidebar .foot { margin-top: auto; font-size: 11px; color: #6f87ab; padding: 10px; }

/* ---- main ---- */
main { padding: 22px 28px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi b { display: block; font-size: 24px; font-weight: 650; }
.kpi span { color: var(--muted); font-size: 12px; }

/* ---- buttons / forms ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 7px 13px; border-radius: 7px; font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f1f5f9; text-decoration: none; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #185fc2; }
.btn.danger { color: var(--err); border-color: #f3c4c4; }
.btn.danger:hover { background: var(--err-soft); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.big { padding: 10px 18px; font-size: 15px; }
form.inline { display: inline; }
label { display: block; font-size: 12px; font-weight: 600; color: #334155; margin-bottom: 4px; }
input[type=text], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 7px 9px; border: 1px solid #cbd5e1; border-radius: 7px; font: inherit; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfd5fb; border-color: var(--blue); }
input[type=color] { width: 44px; height: 34px; padding: 2px; border: 1px solid #cbd5e1; border-radius: 7px; background: #fff; }
textarea { font-family: ui-monospace, Consolas, monospace; min-height: 180px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 12px; align-items: end; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.checks label { display: flex; gap: 6px; align-items: center; font-weight: 500; font-size: 13px; margin: 0; }
.chip-check input { display: none; }
.chip-check span { display: inline-block; padding: 5px 10px; border-radius: 99px; border: 1px solid var(--line); cursor: pointer; font-weight: 500; }
.chip-check input:checked + span { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---- tables ---- */
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); background: #f8fafc; }
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:hover td { background: #fafcff; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data input[type=number] { width: 70px; padding: 4px 6px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; background: #eef2f7; color: #334155; margin: 1px 2px 1px 0; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 6px; }
.g-F { color: #be185d; } .g-M { color: #1d4ed8; }

/* ---- flash ---- */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.flash.ok { background: var(--ok-soft); border-color: #bbf7d0; color: #14532d; }
.flash.warning { background: var(--warn-soft); border-color: #fde68a; color: #78350f; }
.flash.error { background: var(--err-soft); border-color: #fecaca; color: #7f1d1d; }

/* ---- availability grid ---- */
table.avail { border-collapse: separate; border-spacing: 3px; }
table.avail th { font-size: 11px; color: var(--muted); font-weight: 600; padding: 4px 6px; cursor: pointer; user-select: none; }
table.avail th.row { text-align: right; white-space: nowrap; }
table.avail th:hover { color: var(--blue); }
table.avail td { padding: 0; }
table.avail .cell { display: block; width: 64px; height: 26px; border-radius: 5px; cursor: pointer; border: 1px solid; }
.s-, .sw.s- { background: var(--ok-soft); border-color: #bbf7d0 !important; }
.s-x, .sw.s-x { background: var(--err-soft); border-color: #fca5a5 !important;
  background-image: repeating-linear-gradient(45deg, transparent 0 5px, rgba(185,28,28,.14) 5px 10px); }
.s-a, .sw.s-a { background: #fef3c7; border-color: #fcd34d !important;
  background-image: repeating-linear-gradient(-45deg, transparent 0 6px, rgba(180,83,9,.12) 6px 9px); }
table.avail td.closed .cell { background: #e2e8f0; border-color: #e2e8f0 !important; cursor: not-allowed; background-image: none; }
table.avail tr.lunch td, table.avail tr.lunch th { padding-top: 10px; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -3px; margin-right: 5px; border: 1px solid; }
.paint { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.paint .btn.active { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }

td.coteach { white-space: nowrap; }
td.coteach select { width: auto; padding: 3px 5px; font-size: 12px; margin-right: 3px; }
/* ---- steps ---- */
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.steps li:last-child { border-bottom: 0; }
.steps .dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: #e2e8f0; color: #475569; flex: none; }
.steps .done .dot { background: var(--ok); color: #fff; }
.issue { padding: 8px 10px; border-left: 3px solid; border-radius: 4px; margin-bottom: 6px; background: #fff; }
.issue.error { border-color: var(--err); background: #fff7f7; }
.issue.warning { border-color: var(--warn); background: #fffbeb; }
.issue b { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; margin-right: 6px; }

/* ---- classes ---- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a { padding: 6px 14px; border-radius: 99px; border: 1px solid var(--line); background: #fff; color: var(--text); }
.tabs a.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.tabs a:hover { text-decoration: none; border-color: var(--blue); }
.class-card h2 { display: flex; justify-content: space-between; align-items: center; }
.bar { height: 8px; border-radius: 99px; background: #93c5fd; overflow: hidden; display: flex; margin: 6px 0 10px; }
.bar i { background: #f472b6; display: block; height: 100%; }
.stu-list { list-style: none; padding: 0; margin: 0; max-height: 520px; overflow-y: auto; }
.stu-list li { display: flex; align-items: center; gap: 6px; padding: 4px 2px; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.stu-list li .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stu-list select { width: auto; padding: 2px 4px; font-size: 12px; }
.acad { font-size: 10px; padding: 1px 5px; border-radius: 4px; background: #f1f5f9; color: #475569; }

/* ---- timetable ---- */
table.tt { width: 100%; border-collapse: separate; border-spacing: 4px; table-layout: fixed; }
table.tt th { font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px; }
table.tt th.time { width: 84px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.tt td { height: 66px; padding: 0; vertical-align: top; }
table.tt td.empty { background: #f8fafc; border: 1px dashed #e2e8f0; border-radius: 7px; }
table.tt td.closed { background: repeating-linear-gradient(45deg, #eef2f7 0 6px, #f8fafc 6px 12px); border-radius: 7px; }
table.tt td.unavail { background: repeating-linear-gradient(45deg, #fee2e2 0 6px, #fff5f5 6px 12px); border-radius: 7px; }
table.tt td.gap { background: #fff7ed; border: 1px dashed #fdba74; border-radius: 7px; text-align: center; vertical-align: middle; }
table.tt td.gap span { font-size: 11px; color: #c2410c; text-transform: uppercase; letter-spacing: .06em; }
table.tt.dragging td[data-slot] { outline: 2px dashed transparent; outline-offset: -2px; }
table.tt.dragging td.drop-ok { outline-color: #16a34a; background: #dcfce7 !important; }
table.tt.dragging td.drop-ko { outline-color: #fca5a5; background-color: #fff1f2 !important; }
table.tt.dragging td.drop-origin { outline-color: #0b2545; }
table.tt td.drop-hover { outline: 3px solid #1d6fe0 !important; }
.lesson[draggable="true"] { cursor: grab; }
.lesson.dragged { opacity: .45; }
.dnd-toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #0b2545; color: #fff;
  padding: 10px 16px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-size: 13px; z-index: 50; max-width: 80vw; }
table.tt td.empty.avoid { background: #fffbeb; border-color: #fde68a; }
table.tt tr.lunch td { height: 10px; background: none; border: 0; }
.cellstack { display: flex; gap: 3px; height: 100%; }
.lesson { flex: 1; min-width: 0; height: 100%; border-radius: 7px; padding: 6px 8px; color: #fff; overflow: hidden; line-height: 1.3;
  box-shadow: 0 1px 2px rgba(0,0,0,.08); display: block; position: relative; text-decoration: none !important; }
.lesson:hover { filter: brightness(1.08); }
.lesson.locked { box-shadow: inset 0 0 0 2px rgba(255,255,255,.85), 0 0 0 2px #0b2545; }
.cellstack.multi .lesson { padding: 4px 5px; }
.cellstack.multi .lesson b { font-size: 11px; }
.cellstack.multi .lesson span { font-size: 10px; }
.lesson .tags { position: absolute; right: 4px; bottom: 3px; font-style: normal; display: flex; gap: 3px; }
.lesson .tags i { font-style: normal; font-size: 10px; }
.lesson .wk { background: rgba(255,255,255,.9); color: #0b2545; border-radius: 4px; padding: 0 4px; font-weight: 700; }
.lesson b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lesson span { display: block; font-size: 11px; opacity: .92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { height: 8px; background: #e2e8f0; border-radius: 99px; overflow: hidden; margin: 10px 0; }
.progress i { display: block; height: 100%; background: var(--blue); transition: width .8s linear; }
.spinner { width: 16px; height: 16px; border: 2px solid #bfd5fb; border-top-color: var(--blue); border-radius: 50%; animation: spin 0.9s linear infinite; display: inline-block; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }

.by-nanuq { display: block !important; padding: 10px 0 12px !important; opacity: .85; }
.by-nanuq:hover { background: none !important; opacity: 1; }
.by-nanuq span { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: #6f87ab; margin-bottom: 4px; }
.by-nanuq img { width: 112px; height: auto; display: block; }
.print-only { display: none; }
.about-logo { max-width: 360px; width: 100%; height: auto; margin: 6px 0 14px; }

@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .sidebar .nav-title, .sidebar .foot { display: none; }
  main { padding: 16px; }
}
@media print {
  body { display: block; background: #fff; }
  .sidebar, .no-print, .flash { display: none !important; }
  .print-only { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 10px; color: #64748b; }
  main { padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .lesson { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.chip-check input:disabled + span { opacity: .4; cursor: not-allowed; text-decoration: line-through; }

/* AESH */
.lesson .note { display: block; font-style: italic; font-weight: 600; background: rgba(255,255,255,.22); border-radius: 4px; padding: 0 4px; margin-top: 2px; }
.lesson.faded { filter: grayscale(.85) opacity(.55); }
.lesson.faded:hover { filter: grayscale(.6) opacity(.75); }

/* Équipes pédagogiques */
.table-scroll { overflow-x: auto; }
.svc-table th, .svc-table td { white-space: nowrap; vertical-align: top; }
.svc-table .sticky { position: sticky; left: 0; background: #fff; z-index: 1; }
.svc-table select.svc { width: 150px; padding: 3px 6px; font-size: 12px; display: block; color: #64748b; }
.svc-table select.svc + select.svc { margin-top: 3px; }
.svc-table select.svc.set { color: #0b2545; font-weight: 600; border-color: #2563eb; background: #eff6ff; }
