/* Pactes NDM — mobile-first */
:root {
  --bg: #f4f6fa; --card: #fff; --text: #1e293b; --muted: #64748b; --line: #e2e8f0;
  --primary: #1e3a8a; --primary-2: #2546b0; --danger: #dc2626; --ok: #16a34a; --warn: #b45309;
  --radius: 10px; --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--primary-2); }
h1 { font-size: 1.45rem; margin: .4rem 0 .6rem; }
h2 { font-size: 1.15rem; margin: 0 0 .7rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
code { background: #eef2f7; padding: 0 .3em; border-radius: 4px; font-size: .9em; }
hr { border: 0; border-top: 1px solid var(--line); margin: .6rem 0; }
.muted { color: var(--muted); } .small { font-size: .86rem; } .center { text-align: center; } .nowrap { white-space: nowrap; }
.grow { flex: 1; } .inline { display: inline; } .warn-text { color: var(--warn); font-style: normal; }

/* ---- Barre du haut */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; flex-wrap: wrap; gap: .5rem;
  background: var(--primary); color: #fff; padding: .55rem 16px; }
.brand { display: flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; margin-right: auto; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: #fff; color: var(--primary); font-weight: 800; }
.logo.big { width: 48px; height: 48px; font-size: 1.6rem; border-radius: 12px; background: var(--primary); color: #fff; }
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.burger { display: flex; flex-direction: column; gap: 4px; padding: 8px; cursor: pointer; }
.burger span { width: 22px; height: 2px; background: #fff; border-radius: 2px; }
.nav { display: none; width: 100%; flex-direction: column; gap: .15rem; padding: .4rem 0; }
.nav-toggle:checked ~ .nav { display: flex; }
.nav a, .nav .btn-link { color: #e0e7ff; text-decoration: none; padding: .55rem .6rem; border-radius: 6px; text-align: left; }
.nav a.active, .nav a:hover, .nav .btn-link:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.user-link small { display: block; font-size: .72rem; opacity: .75; }
.btn-link { background: none; border: 0; font: inherit; cursor: pointer; }
.nav-sep { display: none; }

/* ---- Mise en page */
.container { max-width: 1100px; margin: 0 auto; padding: 14px 16px 30px; }
.container.wide { max-width: 1500px; }
.container.narrow { max-width: 720px; }
.footer { text-align: center; color: var(--muted); font-size: .78rem; padding: 10px 16px 24px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.grid-2, .grid-3 { display: grid; gap: 14px; grid-template-columns: 1fr; }
.grid-2 > .card, .grid-3 > .card { margin-bottom: 0; }
.grid-2, .grid-3 { margin-bottom: 14px; }
.row-2 { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.toolbar input[type=search] { flex: 1 1 200px; }

/* ---- Formulaires */
label { display: block; margin-bottom: .7rem; font-weight: 600; font-size: .9rem; }
input, select, textarea { display: block; width: 100%; margin-top: .25rem; padding: .55rem .65rem; font: inherit; font-weight: 400;
  color: var(--text); background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; min-height: 42px; }
input[type=checkbox] { display: inline-block; width: 18px; height: 18px; min-height: 0; margin: 0 .4rem 0 0; vertical-align: -3px; accent-color: var(--primary); }
input[type=color] { width: 52px; padding: 2px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #93c5fd; border-color: var(--primary-2); }
label.check { font-weight: 400; display: flex; align-items: center; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; margin: 0 0 .8rem; }
legend { font-weight: 600; font-size: .9rem; padding: 0 .3rem; }
.checks { display: flex; flex-wrap: wrap; gap: .2rem 1.2rem; }
.checks .check { margin-bottom: .3rem; }
.form .actions, .actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.row-form { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: .3rem 0; }
.row-form input, .row-form select { width: auto; flex: 1 1 120px; margin: 0; }
.row-form .w-xs { flex: 0 0 64px; } .row-form .w-sm { flex: 0 1 110px; }
.row-form input[type=color] { flex: 0 0 52px; }
.row-form .check { margin: 0; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.filters .filter-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .5rem; }
.danger-zone { margin-top: 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.confirm-hint { color: var(--danger); }

/* ---- Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; min-height: 40px; padding: .45rem .9rem;
  font: inherit; font-weight: 600; color: var(--text); background: #fff; border: 1px solid #cbd5e1; border-radius: 8px;
  text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f1f5f9; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); }
.btn-danger { background: #fff; border-color: #fca5a5; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 32px; padding: .25rem .6rem; font-size: .85rem; }
.btn-block { width: 100%; }

/* ---- Messages, badges */
.flashes { margin-bottom: 12px; }
.flash { padding: .65rem .85rem; border-radius: 8px; margin-bottom: .5rem; border: 1px solid; }
.flash-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.flash-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.flash-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.flash-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.badge { display: inline-block; padding: .05rem .45rem; border-radius: 999px; font-size: .75rem; font-weight: 600;
  background: #eef2f7; color: #334155; border: 1px solid #dbe2ea; }
.badge-warn { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.badge-ok { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.badge-week { background: #e0e7ff; color: #3730a3; border-color: #c7d2fe; vertical-align: middle; }
.warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: .55rem .7rem; border-radius: 8px; margin-bottom: .7rem; font-size: .9rem; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: .4rem; vertical-align: -1px; }

/* ---- Tableaux */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .5rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); }
.table .num { text-align: right; }
.table tr.inactive td { opacity: .55; }
.hide-sm { display: none; }
ul.compact { margin: .3rem 0; padding-left: 1.1rem; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; }

/* ---- Stats et tuiles */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; text-decoration: none; color: var(--text); }
.stat b { display: block; font-size: 1.5rem; color: var(--primary); }
.stat span { font-size: .85rem; color: var(--muted); }
.tiles { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 14px; }
.tile { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; text-decoration: none; color: var(--text); border-left: 4px solid var(--primary); }
.tile b { display: block; } .tile span { color: var(--muted); font-size: .86rem; }
.tile:hover { background: #f8fafc; }
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 12px; }
.tabs a { padding: .4rem .8rem; background: #fff; border-radius: 999px; text-decoration: none; box-shadow: var(--shadow); }
.toc { display: flex; flex-direction: column; gap: .25rem; }

/* ---- Connexion */
.login-card { margin-top: 8vh; }
.login-head { display: flex; gap: .8rem; align-items: center; margin-bottom: 1rem; }
.login-head h1 { margin: 0; } .login-head p { margin: 0; }

/* ---- Calendrier */
.cal-head { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .5rem; }
.cal-title h1 { margin: 0; } .cal-title p { margin: 0; }
.cal-nav { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.cal-nav .goto { display: flex; flex-wrap: wrap; gap: .4rem; }
.cal-nav .goto input, .cal-nav .goto select { width: auto; margin: 0; min-height: 40px; }
.cal { margin-top: .4rem; }
.cell { position: relative; min-height: 44px; display: flex; flex-direction: column; gap: 4px; padding: 4px; border-radius: 6px; }
.cell.clickable { cursor: pointer; }
.cell.clickable:hover { background: #eef4ff; }
.cell.past { background: #fafafa; }
.cell .add { align-self: flex-start; border: 1px dashed #cbd5e1; background: transparent; color: var(--muted); border-radius: 6px;
  width: 30px; height: 26px; font-size: 1rem; line-height: 1; cursor: pointer; }
.cell.clickable:hover .add { border-color: var(--primary-2); color: var(--primary-2); }
.chip { display: block; width: 100%; text-align: left; font: inherit; font-size: .84rem; line-height: 1.25; padding: 4px 6px;
  border: 1px solid var(--line); border-left: 4px solid; border-radius: 6px; cursor: pointer; color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.chip strong { font-weight: 700; }
.chip:hover { filter: brightness(.96); }
.chip-ro { cursor: default; }
.chip .noemail { color: var(--warn); font-style: normal; font-size: .75rem; }
/* mobile : jours empilés */
.day-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; overflow: hidden; }
.day-card h3 { margin: 0; padding: .6rem .8rem; background: #eef2f7; display: flex; justify-content: space-between; align-items: center; }
.day-card.today h3 { background: #dbeafe; }
.day-row { display: grid; grid-template-columns: 78px 1fr; border-top: 1px solid var(--line); }
.day-time { padding: .55rem .5rem; font-size: .8rem; color: var(--muted); font-weight: 600; border-right: 1px solid var(--line); }
/* grille ordinateur */
.grid-wrap { overflow-x: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.grid { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 760px; }
.grid th, .grid td { border: 1px solid var(--line); vertical-align: top; }
.grid thead th { background: #eef2f7; padding: .45rem; font-size: .9rem; }
.grid thead th small { display: block; color: var(--muted); font-weight: 400; }
.grid thead th.today { background: #dbeafe; }
.grid .th-slot { width: 64px; background: #f8fafc; font-size: .8rem; text-align: center; padding: .35rem .2rem; }
.grid .th-slot small { display: block; color: var(--muted); }
.grid td { padding: 0; }
.grid .cell { min-height: 58px; border-radius: 0; }
.grid .cell.today { background: #f5f9ff; }
.legend { display: flex; flex-wrap: wrap; gap: .3rem .9rem; margin-top: .8rem; font-size: .85rem; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: .3rem; vertical-align: -1px; }

/* ---- Fenêtre (dialog) */
.dlg { width: min(560px, calc(100vw - 20px)); max-height: calc(100vh - 20px); border: 0; border-radius: 14px; padding: 0; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.dlg::backdrop { background: rgba(15, 23, 42, .45); }
.dlg form { padding: 16px; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; }
.dlg-head h2 { margin: 0; }
.dlg-close { border: 0; background: none; font-size: 1.7rem; line-height: 1; cursor: pointer; color: var(--muted); }
.dlg-when { margin: .2rem 0 .9rem; font-weight: 600; color: var(--primary); }
.dlg-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .6rem; }
#f-teacher-search { margin-bottom: .35rem; }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 50; max-width: calc(100vw - 32px);
  background: #0f172a; color: #fff; padding: .7rem 1rem; border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); }
.toast-err { background: var(--danger); }
.ldap-res { list-style: none; padding: 0; margin: 0; }
.ldap-res li { padding: .3rem 0; border-bottom: 1px solid var(--line); }

/* ---- Écrans plus larges */
@media (min-width: 640px) {
  .row-2 { grid-template-columns: 1fr 1fr; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .tiles { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .filters { grid-template-columns: repeat(4, 1fr); }
  .hide-sm { display: table-cell; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .toc { flex-direction: row; flex-wrap: wrap; gap: .3rem 1rem; }
}
@media (min-width: 900px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .burger { display: none; }
  .nav { display: flex; flex-direction: row; align-items: center; width: auto; padding: 0; gap: .2rem; }
  .nav a, .nav .btn-link { padding: .4rem .65rem; }
  .nav-sep { display: block; width: 1px; height: 26px; background: rgba(255, 255, 255, .25); margin: 0 .3rem; }
  .cal-head { flex-direction: row; justify-content: space-between; align-items: flex-end; }
}
@media print {
  .topbar, .cal-nav, .footer, .legend, .cell .add { display: none !important; }
  body { background: #fff; }
}

/* ---- Quotas de pactes (v1.0) */
.red { color: var(--danger); }
.quota-info { color: var(--danger); font-weight: 700; background: #fef2f2; border: 1px solid #fecaca; padding: .5rem .7rem; border-radius: 8px; margin-bottom: .7rem; }
.cal-layout { display: grid; grid-template-columns: 1fr; gap: 14px; }
.cal-main { min-width: 0; }
.cal-side h2 { margin-bottom: .2rem; }
.cal-side input { margin-bottom: .5rem; }
.side-list { list-style: none; margin: 0; padding: 0; max-height: 70vh; overflow-y: auto; }
.side-list li { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; padding: .35rem .1rem; border-bottom: 1px solid var(--line); font-size: .86rem; }
.side-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-count { white-space: nowrap; text-align: right; }
.side-count small { color: var(--muted); }
.side-done .side-name { color: var(--muted); }
.quota-input { width: 70px; min-height: 34px; padding: .25rem .4rem; margin: 0; }
@media (min-width: 1100px) {
  .cal-layout { grid-template-columns: minmax(0, 1fr) 280px; align-items: start; }
  .cal-side { position: sticky; top: 70px; margin: .4rem 0 0; }
}
.quota-input.saved { outline: 2px solid #86efac; }
