:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1c1e26;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-ink: #ffffff;
  --danger: #dc2626;
  --good: #059669;
  --ok-bg: #ecfdf5;
  --ok-border: #a7f3d0;
  --err-bg: #fef2f2;
  --err-border: #fecaca;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161c;
    --surface: #1e2129;
    --border: #333844;
    --text: #e7e9ee;
    --muted: #9aa1ad;
    --primary: #7c73ff;
    --good: #34d399;
    --ok-bg: #0d2b22;
    --ok-border: #1c5a45;
    --err-bg: #3a1a1a;
    --err-border: #7a2e2e;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--primary); }
h1 { font-size: 1.3rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
.muted, .hint { color: var(--muted); font-size: .9rem; }
.hint { margin: .6rem 0 1.2rem; }
code { background: rgba(127, 127, 127, .15); padding: .05em .35em; border-radius: 4px; font-size: .85em; }

/* ── Top bar ── */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem;
  padding: .6rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.mainnav { display: flex; flex-wrap: wrap; gap: .25rem; flex: 1; }
.mainnav a {
  text-decoration: none; color: var(--muted); padding: .35rem .6rem;
  border-radius: 8px; font-weight: 500;
}
.mainnav a.on { background: var(--primary); color: var(--primary-ink); }
.me { color: var(--muted); font-size: .85rem; }

.wrap { max-width: 1000px; margin: 0 auto; padding: 1rem; }
.foot {
  max-width: 1000px; margin: 2rem auto 3rem; padding: 1rem;
  color: var(--muted); font-size: .8rem; text-align: center;
}

/* ── Flash ── */
.flash {
  max-width: 1000px; margin: .8rem auto 0; padding: .6rem .9rem; border-radius: 8px;
  border: 1px solid var(--ok-border); background: var(--ok-bg); font-size: .9rem;
}
.flash-err { border-color: var(--err-border); background: var(--err-bg); }

/* ── Buttons / inputs ── */
button, .btn-ghost {
  font: inherit; cursor: pointer; border-radius: 8px; padding: .5rem .9rem;
  border: 1px solid var(--primary); background: var(--primary); color: #fff;
  text-decoration: none; display: inline-block;
}
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: var(--surface); color: var(--primary); }
.btn-danger { background: var(--danger); border-color: var(--danger); }

input, select {
  font: inherit; padding: .45rem .55rem; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); color: var(--text); max-width: 100%;
}
input[type=color] { padding: 2px; height: 2.4rem; width: 3rem; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); }
label input, label select { color: var(--text); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 1rem; box-shadow: var(--shadow);
}
.row { display: flex; flex-wrap: wrap; gap: .7rem; align-items: flex-end; }
.row-actions { margin-top: .8rem; }
.check-inline { flex-direction: row; align-items: center; gap: .35rem; }

/* ── Login ── */
.login-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 1rem; }
.login-split {
  display: flex; width: 100%; max-width: 880px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.login-hero { flex: 1 1 48%; min-width: 0; background: var(--bg); }
.login-hero img { width: 100%; height: 100%; min-height: 100%; object-fit: cover; display: block; }
.login-card { max-width: 360px; width: 100%; display: flex; flex-direction: column; gap: .8rem; }
.login-split .login-card {
  flex: 1 1 52%; max-width: none; border: 0; border-radius: 0; box-shadow: none;
  margin: 0; align-self: center; padding: 1.6rem;
}
.login-card h1 { margin: 0; }
.login-card button { margin-top: .3rem; }

@media (max-width: 720px) {
  .login-split { flex-direction: column; max-width: 400px; }
  .login-hero { flex: none; max-height: 160px; }
  .login-split .login-card { padding: 1.2rem; }
}

/* ── Week nav ── */
.week-nav { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.week-nav a { font-size: .85rem; padding: .4rem .7rem; }

/* ── Week grid ── */
.grid-scroll {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border); border-radius: var(--radius);
}
table.week { border-collapse: collapse; width: 100%; min-width: 640px; background: var(--surface); }
table.week th, table.week td { border: 1px solid var(--border); padding: 0; text-align: left; }
table.week thead th { padding: .5rem .6rem; font-size: .8rem; background: var(--bg); }
table.week thead th.is-today { color: var(--primary); }
th.corner { min-width: 90px; }
th.child {
  padding: .5rem .6rem; font-weight: 600; font-size: .9rem;
  border-left: 4px solid var(--c, var(--primary)); white-space: nowrap;
}
td.cell { vertical-align: top; }
td.cell.is-today { background: color-mix(in srgb, var(--primary) 8%, transparent); }

/* ── Cell editor ── */
.editor { width: 100%; }
.editor > summary {
  list-style: none; cursor: pointer; padding: .5rem .6rem; min-height: 2.6rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .5rem;
}
.editor > summary::-webkit-details-marker { display: none; }
.editor > summary:hover { background: rgba(127, 127, 127, .06); }
.who { font-weight: 700; font-size: .9rem; color: var(--who, var(--text)); }
.who.unset { color: var(--muted); font-weight: 400; }
.time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; }
.check { color: var(--good); font-weight: 700; }
.note-dot { color: var(--primary); }
.rec { color: var(--muted); font-size: .8rem; }
.exc { color: var(--danger); font-weight: 700; font-size: .8rem; }
.edit-label { color: var(--primary); font-size: .85rem; font-weight: 600; }

/* pastille couleur adulte */
.who-dot {
  display: inline-block; width: .7rem; height: .7rem; border-radius: 50%;
  background: var(--who, var(--primary)); vertical-align: middle; margin-left: .15rem;
}
.tag {
  font-size: .75rem; color: var(--muted); background: rgba(127, 127, 127, .12);
  padding: .1rem .4rem; border-radius: 6px;
}
.cell-form {
  display: grid; gap: .55rem; padding: .7rem .6rem .8rem;
  border-top: 1px dashed var(--border); background: var(--bg);
}
.cf-title { margin: 0; font-weight: 600; font-size: .85rem; color: var(--text); }
.cell-form button { margin-top: .2rem; }

/* ── Today list ── */
.day-title { text-transform: capitalize; }
.today-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .7rem; }
.today-card {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 5px solid var(--c, var(--primary)); border-radius: var(--radius);
  padding: .8rem .9rem; box-shadow: var(--shadow);
}
.today-card.status-no_school { opacity: .6; }
.tc-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.tc-name { font-weight: 700; font-size: 1.05rem; }
.tc-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.tc-who { margin-top: .2rem; }
.tc-who .unset { color: var(--muted); }
.tc-who .ok { color: var(--good); font-weight: 600; }
.tc-note { margin-top: .3rem; font-size: .85rem; color: var(--muted); }
.today-card .editor > summary {
  margin-top: .5rem; padding: .45rem .5rem; border: 1px solid var(--border);
  border-radius: 8px; justify-content: center;
}
.today-card .editor[open] > summary { background: var(--primary); }
.today-card .editor[open] > summary .edit-label { color: #fff; }

/* ── Admin (enfants / adultes) ── */
.add-form .row { align-items: flex-end; }
fieldset.sched {
  margin: .9rem 0 0; border: 1px solid var(--border); border-radius: 8px;
  padding: .7rem; display: flex; flex-wrap: wrap; gap: .6rem;
}
fieldset.sched legend { font-size: .8rem; color: var(--muted); padding: 0 .3rem; }
.child-card.is-inactive, .person-row.is-inactive { opacity: .55; }
.person-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; }
.person-row .row { flex: 1; }
.delete-form { margin: -.4rem 0 1rem; }
.delete-form .btn-danger { font-size: .8rem; padding: .35rem .7rem; }

/* ── Journal ── */
.log-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.log-list li {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: .5rem .7rem; display: flex; flex-wrap: wrap; gap: .3rem .7rem; align-items: baseline;
}
.log-list time { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; min-width: 80px; }
.log-actor { font-weight: 600; }
.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin-top: 1.2rem; }

.empty {
  color: var(--muted); padding: 1.5rem; text-align: center; background: var(--surface);
  border: 1px dashed var(--border); border-radius: var(--radius);
}

/* ── Toast ── */
.toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translate(-50%, 1rem);
  background: #111827; color: #fff; padding: .6rem 1rem; border-radius: 8px;
  font-size: .9rem; opacity: 0; transition: opacity .25s, transform .25s; z-index: 50; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-err { background: var(--danger); }

/* ── Badge semaine A/B ── */
.week-badge {
  align-self: center; font-size: .8rem; font-weight: 700; color: var(--primary);
  border: 1px solid var(--primary); border-radius: 999px; padding: .15rem .6rem;
}

/* ── Congé (jour grisé) ── */
.cell.is-break, .today-card.is-break { background: repeating-linear-gradient(
  -45deg, transparent, transparent 6px,
  color-mix(in srgb, var(--muted) 14%, transparent) 6px,
  color-mix(in srgb, var(--muted) 14%, transparent) 12px); }
.cf-break { color: var(--muted); }
.cell.is-exception > .editor > summary { box-shadow: inset 3px 0 0 var(--danger); }

/* ── Vue mois ── */
.month-title { text-transform: capitalize; margin: .2rem 0 .8rem; }
table.month { border-collapse: collapse; width: 100%; min-width: 720px; background: var(--surface); table-layout: fixed; }
table.month th {
  padding: .4rem .5rem; font-size: .78rem; background: var(--bg);
  border: 1px solid var(--border); text-align: left;
}
table.month th .d-short { display: none; }
td.mcell { border: 1px solid var(--border); vertical-align: top; height: 5.5rem; padding: 0; }
td.mcell.out { background: var(--bg); }
td.mcell.out .mday { color: var(--muted); }
td.mcell.is-today { outline: 2px solid var(--primary); outline-offset: -2px; }
td.mcell.is-exception { box-shadow: inset 3px 0 0 var(--danger); }
td.mcell.is-break { background: repeating-linear-gradient(
  -45deg, transparent, transparent 5px,
  color-mix(in srgb, var(--muted) 12%, transparent) 5px,
  color-mix(in srgb, var(--muted) 12%, transparent) 10px); }
.mcell-link { display: block; height: 100%; padding: .35rem .4rem; text-decoration: none; color: var(--text); }
.mcell-link:hover { background: rgba(127,127,127,.06); }
.mcell-head { display: flex; align-items: center; justify-content: space-between; gap: .25rem; }
.mday { font-weight: 700; font-size: .85rem; }
.mdots { display: inline-flex; gap: .1rem; }
.mbreak { font-size: .72rem; color: var(--muted); margin-top: .2rem; }
.mline { font-size: .74rem; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mdot { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; background: var(--c, var(--primary)); vertical-align: middle; }
.mchild { font-weight: 600; }
.marrow { color: var(--muted); }
.mtime { font-variant-numeric: tabular-nums; color: var(--muted); }
.mcell-dots { display: none; gap: 4px; flex-wrap: wrap; margin-top: .3rem; }
.cdot {
  width: .8rem; height: .8rem; border-radius: 50%;
  background: var(--who, var(--primary)); box-shadow: 0 0 0 2px var(--c, var(--primary));
}
.cdot.exc-dot { outline: 2px solid var(--danger); outline-offset: 1px; }

@media (max-width: 640px) {
  table.month { min-width: 0; }
  table.month th { padding: .35rem .2rem; text-align: center; font-size: .72rem; }
  table.month th .d-long { display: none; }
  table.month th .d-short { display: inline; }
  td.mcell { height: auto; min-height: 3.4rem; }
  .mcell-link { padding: .3rem .25rem; }
  .mcell-head { justify-content: center; flex-direction: column; gap: .1rem; }
  .mday { font-size: .8rem; }
  .mcell-lines { display: none; }
  .mcell-dots { display: flex; justify-content: center; }
  .mbreak { text-align: center; font-size: .62rem; }
}

/* ── Réglages « rythme des semaines » ── */
.rythme p { margin: .4rem 0 .7rem; color: var(--muted); font-size: .9rem; }
.rythme form { display: inline; }

/* ── Horaires : 2 champs par jour ── */
fieldset.sched { display: block; }
.sched-day { display: flex; align-items: center; gap: .5rem; margin: .3rem 0; }
.sched-lbl { min-width: 3rem; font-size: .82rem; color: var(--muted); }
.sched-day input[type=time] { width: 8rem; }
.sched-hint { margin: .5rem 0 0; font-size: .78rem; color: var(--muted); }

/* ── Récurrences (carte enfant) ── */
.rec-card { margin-top: -.6rem; }
.rec-list { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; gap: .4rem; }
.rec-list li { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; font-size: .9rem; }
.rec-list form { display: inline; }
.rec-list .btn-danger { font-size: .75rem; padding: .25rem .55rem; }

/* ── Liste des congés ── */
.breaks-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.breaks-list li {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: .5rem .7rem; display: flex; align-items: center; gap: .3rem .8rem; flex-wrap: wrap;
}
.breaks-list li.is-past { opacity: .5; }
.bk-label { font-weight: 600; }
.bk-dates { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.breaks-list form { margin-left: auto; }
.breaks-list .btn-danger { font-size: .75rem; padding: .25rem .55rem; }

@media (max-width: 560px) {
  .me { width: 100%; order: 3; }
  h1 { font-size: 1.15rem; }
  .sched-day input[type=time] { width: 6.5rem; }
}
