:root {
  --navy: #1f3864; --navy-2: #2c4c85; --bg: #f4f6fa; --card: #fff; --line: #dde3ec; --text: #1d2433;
  --muted: #667085; --accent: #ffd166;
  --s-a: #98a2b3; --s-p: #2f6fd6; --s-r: #1f9d55; --s-x: #d64545; --s-w: #e08a00;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--navy-2); }
h1 { font-size: 1.35rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.muted { color: var(--muted); } .center { text-align: center; } .pad { padding: 2rem 1rem; }
.small { font-size: .85rem; } .nowrap { white-space: nowrap; } .right { text-align: right; }

/* en-tête */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: var(--navy); color: #fff; padding: .55rem 1rem; }
.brand { display: flex; align-items: center; gap: .6rem; }
.brand small { display: block; opacity: .75; font-size: .75rem; }
.logo { width: 30px; height: 30px; border-radius: 7px; background: var(--accent);
  mask: radial-gradient(circle at 25% 30%, #000 22%, transparent 23%), radial-gradient(circle at 75% 30%, #000 22%, transparent 23%),
        radial-gradient(circle at 25% 70%, #000 22%, transparent 23%), radial-gradient(circle at 75% 70%, #000 22%, transparent 23%),
        linear-gradient(#000 0 0) center/30% 12% no-repeat; }
.nav { display: flex; gap: .2rem; flex-wrap: wrap; flex: 1; }
.nav button { background: transparent; border: 0; color: #dfe7f5; padding: .45rem .7rem; border-radius: 7px; cursor: pointer; }
.nav button:hover { background: rgba(255,255,255,.1); }
.nav button.on { background: #fff; color: var(--navy); font-weight: 600; }
.nav .count { background: var(--s-w); color: #fff; border-radius: 9px; padding: 0 .4rem; font-size: .75rem; margin-left: .3rem; }
.who { display: flex; align-items: center; gap: .6rem; font-size: .9rem; }
.who button { background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 7px; padding: .35rem .7rem; cursor: pointer; }

main { max-width: 1250px; margin: 0 auto; padding: 1.2rem 1rem 4rem; }

/* éléments */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grid { display: grid; gap: .8rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .8rem; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; box-shadow: var(--shadow); }
.tile b { display: block; font-size: 1.6rem; color: var(--navy); line-height: 1.2; }
.tile span { color: var(--muted); font-size: .85rem; }
.btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: .45rem .85rem; cursor: pointer; }
.btn:hover { border-color: #b8c2d3; }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.primary:hover { background: var(--navy-2); }
.btn.danger { color: var(--s-x); border-color: #f0c4c4; }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }
.chips { display: flex; gap: .35rem; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: .3rem; background: #eef2f8; border-radius: 999px; padding: .1rem .55rem; font-size: .8rem; }
.chip button { border: 0; background: none; cursor: pointer; padding: 0; color: var(--muted); font-size: 1rem; line-height: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: .4rem .8rem; cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--navy); color: #fff; }

/* statuts */
.badge { display: inline-block; border-radius: 999px; padding: .05rem .55rem; font-size: .75rem; font-weight: 600; color: #fff; white-space: nowrap; }
.st-aprep { background: var(--s-a); } .st-prep { background: var(--s-p); } .st-real { background: var(--s-r); }
.st-ann { background: var(--s-x); } .st-wait { background: var(--s-w); }
.bl-aprep { border-left: 4px solid var(--s-a); } .bl-prep { border-left: 4px solid var(--s-p); } .bl-real { border-left: 4px solid var(--s-r); }
.bl-ann { border-left: 4px solid var(--s-x); } .bl-wait { border-left: 4px solid var(--s-w); }

/* créneaux */
.week-title { margin: 1.3rem 0 .5rem; color: var(--navy); font-weight: 600; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .6rem; }
.slot { text-align: left; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .85rem;
  cursor: pointer; box-shadow: var(--shadow); width: 100%; }
.slot:hover { border-color: #9fb0cc; }
.slot .when { font-weight: 600; }
.slot .when::first-letter { text-transform: uppercase; }
.slot .row { flex-wrap: nowrap; align-items: flex-start; }
.slot .act { margin: .3rem 0; }
.slot .moved { color: var(--s-w); font-size: .8rem; }

/* planning */
.planning { width: 100%; border-collapse: separate; border-spacing: 4px; table-layout: fixed; }
.planning th { font-weight: 600; font-size: .85rem; color: var(--muted); padding: .2rem; }
.planning thead th::first-letter { text-transform: uppercase; }
.planning th.rowh { width: 90px; text-align: left; }
.planning td { background: #fff; border: 1px solid var(--line); border-radius: 8px; vertical-align: top; padding: 4px; height: 86px; }
.planning td.off { background: #eef0f4; }
.planning td.add { cursor: pointer; }
.planning td.add:hover { background: #f5f8ff; }
.pchip { display: block; width: 100%; text-align: left; border: 0; border-radius: 6px; padding: .3rem .45rem; margin-bottom: 3px;
  font-size: .8rem; cursor: pointer; background: #eef2f8; line-height: 1.25; }
.pchip b { display: block; }
.pchip.mine { outline: 2px solid var(--navy-2); }
.pchip.other { opacity: .65; cursor: default; }
.pchip.bl-aprep { border-left: 4px solid var(--s-a); } .pchip.bl-prep { border-left: 4px solid var(--s-p); } .pchip.bl-real { border-left: 4px solid var(--s-r); }
.pchip.bl-ann { border-left: 4px solid var(--s-x); } .pchip.bl-wait { border-left: 4px solid var(--s-w); }
.pchip.bl-aprep, .pchip.bl-prep, .pchip.bl-real, .pchip.bl-ann, .pchip.bl-wait { border-radius: 0 6px 6px 0; }
.pchip.cancel { text-decoration: line-through; }
.legend { display: flex; gap: .8rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin: .6rem 0; }

/* tableaux */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { padding: .45rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { background: #f7f9fc; font-weight: 600; font-size: .82rem; color: #475467; position: sticky; top: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr.click { cursor: pointer; } table.data tr.click:hover td { background: #f7faff; }
table.data tr.total td { font-weight: 700; background: #f7f9fc; }
.bar { height: 8px; background: #edf0f5; border-radius: 4px; overflow: hidden; min-width: 80px; }
.bar i { display: block; height: 100%; background: var(--s-r); }
.bar i.p { background: var(--s-p); }
.warn { color: var(--s-w); font-weight: 600; } .bad { color: var(--s-x); font-weight: 600; } .good { color: var(--s-r); font-weight: 600; }

/* référentiel */
.bloc { margin-bottom: 1rem; }
.comp { border-top: 1px solid var(--line); padding: .6rem 0; display: grid; grid-template-columns: 70px 1fr auto; gap: .7rem; }
.comp:first-of-type { border-top: 0; }
.comp .code { font-weight: 700; color: var(--navy); }
.comp .cont { white-space: pre-line; color: #475467; font-size: .9rem; }
.newtag { background: #fff3d6; color: #8a5a00; border-radius: 6px; padding: .05rem .4rem; font-size: .75rem; }

/* formulaires */
label.f { display: block; margin-bottom: .7rem; }
label.f > span { display: block; font-size: .82rem; font-weight: 600; color: #475467; margin-bottom: .2rem; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; border: 1px solid #c9d2e0; border-radius: 8px; padding: .45rem .6rem; background: #fff; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid #8fb2ff; outline-offset: 1px; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.cols3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem .4rem; margin: 0 0 1rem; }
legend { font-weight: 700; color: var(--navy); padding: 0 .3rem; }
.radio { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .7rem; }
.radio label { border: 1px solid var(--line); border-radius: 8px; padding: .35rem .7rem; cursor: pointer; background: #fff; }
.radio input { margin-right: .3rem; }

/* fenêtre */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(760px, 96vw); max-height: 92vh; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15,23,42,.45); }
#modal-body { padding: 1.1rem 1.3rem; overflow: auto; max-height: 92vh; }
.mhead { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: .8rem; }
.mhead h1::first-letter { text-transform: uppercase; }
.mfoot { display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap; position: sticky; bottom: -1.1rem;
  background: #fff; padding: .8rem 0 .2rem; border-top: 1px solid var(--line); margin-top: .5rem; }
.x { border: 0; background: none; font-size: 1.5rem; cursor: pointer; color: var(--muted); line-height: 1; }
.history { font-size: .82rem; color: var(--muted); }

/* connexion */
.login { max-width: 420px; margin: 3rem auto; }
.login h1 { margin-bottom: 1rem; }
.alert { background: #fff7e6; border: 1px solid #ffd591; border-radius: 8px; padding: .6rem .8rem; margin: .6rem 0; font-size: .9rem; }
.alert.err { background: #fdecec; border-color: #f5b5b5; }

#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #1d2433; color: #fff; padding: .6rem 1rem;
  border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; max-width: 90vw; }
#toast.on { opacity: 1; }

@media (max-width: 760px) {
  .cols2, .cols3 { grid-template-columns: 1fr; }
  .comp { grid-template-columns: 1fr; gap: .2rem; }
  .planning th.rowh { width: 52px; font-size: .7rem; }
  .planning td { height: auto; min-height: 60px; }
  .top { padding: .5rem .6rem; gap: .4rem; }
  .nav { order: 3; flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; }
  .nav button { white-space: nowrap; }
  .who { margin-left: auto; }
  .brand small { display: none; }
  main { padding: 1rem .6rem 4rem; }
}
@media print {
  .top, .noprint, dialog { display: none !important; }
  body { background: #fff; }
}
