:root {
  --ink: #1c2430;
  --muted: #6b7280;
  --line: #e3e7ed;
  --bg: #f6f7f9;
  --accent: #1f4e79;
  --accent2: #2e6da4;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--accent2); text-decoration: none; }

/* ---------- barre ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 16px; background: rgba(246, 247, 249, .94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; letter-spacing: .02em; margin-right: 8px; white-space: nowrap; }
.brand .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #2f855a; margin-right: 6px; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { padding: 6px 10px; border-radius: 6px; color: var(--muted); font-weight: 500; }
.topbar nav a.on { background: #eef2f7; color: var(--accent); }
.month-form { margin-left: 6px; }
.month-form select { padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px;
  background: #fff; font-weight: 600; color: var(--ink); }
.who { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.who .badge { background: #eef2f7; color: #445; }
.quit { font-size: 11px; color: #8a94a3; }
.quit:hover { color: #b23b3b; }
.gen-form { display: inline; }
.btn, button {
  font: inherit; border-radius: 7px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); padding: 7px 11px; cursor: pointer;
}
.btn:hover, button:hover { border-color: #c9d2de; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.primary:hover { background: #173d5e; }
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-body {
  position: absolute; right: 0; top: 38px; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(20,30,50,.12); padding: 6px; min-width: 220px;
  max-height: 420px; overflow: auto; z-index: 30;
}
.menu-body a { display: block; padding: 7px 9px; border-radius: 6px; color: var(--ink); }
.menu-body a:hover { background: #f2f5f9; }

/* ---------- structure ---------- */
.wrap {
  padding: 14px;
}
.board { min-width: 0; }
.page { padding: 18px 22px; max-width: 1100px; }
.page h1 { margin: 0 0 4px; font-size: 20px; }

/* ---------- alertes ---------- */
.alert {
  background: #fff8e6; border: 1px solid #f0d58a; border-radius: 9px;
  padding: 10px 12px; margin-bottom: 10px;
}
.alert.small { padding: 8px 12px; }
.alert-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.alert-head strong { color: #8a5a00; }
.alert-head span { color: #7a6428; font-size: 12px; }
.alert details { margin-top: 6px; }
.alert summary { cursor: pointer; color: #8a5a00; font-size: 12px; }
.alert-list { margin: 8px 0 0; padding-left: 18px; max-height: 170px; overflow: auto; }
.alert-list li { margin: 3px 0; font-size: 12px; }
.hint { color: #2f6b3f; }
.ok {
  background: #eaf6ee; border: 1px solid #b9dfc6; color: #245c37;
  border-radius: 9px; padding: 9px 12px; margin-bottom: 10px; font-weight: 600;
}

/* ---------- grille ---------- */
.board { min-width: 0; }
.grid-scroll {
  background: #fff; border: 1px solid var(--line); border-radius: 9px;
  overflow: auto; max-height: calc(100vh - 210px);
}
table.planning { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: 100%; min-width: 1080px; }
table.planning th, table.planning td {
  border-right: 1px solid #edf0f4; border-bottom: 1px solid #edf0f4;
  text-align: center; vertical-align: middle; white-space: nowrap;
}
table.planning thead th {
  position: sticky; top: 0; background: #f3f5f8; z-index: 3;
  font-size: 10.5px; font-weight: 700; padding: 5px 3px; height: 26px;
}
table.planning thead tr:nth-child(2) th { top: 26px; height: 20px; }
table.planning thead th.person { border-left: 2px solid #d7dde6; width: 64px; min-width: 64px; padding: 3px 1px; height: 34px; line-height: 1.05; }
table.planning thead th.person .prole { display: block; font-size: 7.5px; font-weight: 500; color: var(--muted); letter-spacing: .02em; }
table.planning thead th.person .pname { display: block; font-size: 9.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
table.planning thead th.person.interne { color: #2e6da4; }
table.planning thead th.sub { font-weight: 500; color: var(--muted); font-size: 8.5px; width: 32px; min-width: 32px; }
table.planning td { height: 22px; font-size: 8.5px; padding: 0 1px; }
table.planning td.date {
  position: sticky; left: 0; z-index: 2; background: #fff;
  width: 62px; min-width: 62px; font-weight: 600; font-size: 9.5px; color: #333;
  border-right: 1px solid #dfe4ea;
}
table.planning thead th.date { left: 0; z-index: 4; background: #f3f5f8; width: 62px; min-width: 62px; }
table.planning td.we, table.planning th.we { width: 48px; min-width: 48px; font-size: 8.5px; color: #555; }
table.planning td.cell { width: 32px; min-width: 32px; }
table.planning td.act { font-weight: 700; color: #17202b; }
table.planning td.oncall { background: #ff00ff; color: #fff; font-weight: 800; }
table.planning td.abs { font-size: 8.5px; color: #333; }
table.planning tr.weekend td { background: #fafbfc; }
table.planning tr.weekend td.date { background: #f4f6f8; }
table.planning tbody tr:hover td { filter: brightness(.97); }

.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; padding: 10px 4px; font-size: 11px; color: #444; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 11px; height: 11px; border-radius: 2px; border: 1px solid #b9c0c9; display: inline-block; }

/* ---------- panneau latéral (tiroir) ---------- */
.side {
  position: fixed; top: 52px; right: 0; bottom: 0; width: 360px;
  background: var(--bg); border-left: 1px solid var(--line);
  box-shadow: -10px 0 28px rgba(20, 30, 50, .08);
  padding: 12px; overflow: auto; z-index: 15;
  display: flex; flex-direction: column; gap: 12px;
  transform: translateX(103%); transition: transform .18s ease;
}
body.panel-open .side { transform: none; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 0; }
.side-head b { font-size: 12px; color: var(--ink); }
.close-panel { padding: 5px 9px; font-size: 11px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 12px; }
.card h2 { margin: 0 0 10px; font-size: 13px; letter-spacing: .02em; }
.count { background: #eef2f7; color: var(--accent); border-radius: 999px;
  padding: 1px 7px; font-size: 11px; margin-left: 4px; }
.stack { display: flex; flex-direction: column; gap: 9px; }
.stack label, .card label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); }
.stack input, .stack select, .card input[type=text], .card select {
  font: inherit; color: var(--ink); padding: 7px 8px; border: 1px solid var(--line);
  border-radius: 7px; background: #fff; width: 100%;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions { display: flex; gap: 8px; align-items: center; }
.muted { color: var(--muted); }
.tiny { font-size: 10.5px; margin: 6px 0 0; }
.inline { display: inline; }
.clist { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow: auto; }
.clist li {
  display: grid; grid-template-columns: 38px 1fr auto 18px 18px; gap: 5px;
  align-items: center; padding: 5px 0; border-bottom: 1px solid #f0f2f5; font-size: 11.5px;
}
.cdate { color: var(--muted); font-variant-numeric: tabular-nums; }
.cname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctype { color: #555; font-size: 10.5px; }
.cnote { grid-column: 2 / -1; font-size: 10px; color: var(--muted); }
.edit { color: #8a94a3; }
.del { border: none; background: none; color: #b23b3b; font-size: 15px; padding: 0 5px; }
table.stats { width: 100%; border-collapse: collapse; font-size: 11px; }
table.stats th { text-align: left; color: var(--muted); font-weight: 500; padding: 3px 2px; }
table.stats td { padding: 3px 2px; border-top: 1px solid #f0f2f5; }
table.stats td:not(:first-child) { text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- équipe ---------- */
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin: 14px 0; }
.inline-form label { flex: 1 1 160px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card.person { display: flex; flex-direction: column; gap: 9px; }
.phead { display: flex; justify-content: space-between; align-items: center; }
.badge { font-size: 10px; padding: 2px 7px; border-radius: 999px; background: #eef2f7; color: #445; text-transform: uppercase; letter-spacing: .04em; }
.badge.interne { background: #e6f0fa; color: #1f4e79; }
.check { flex-direction: row !important; align-items: center; gap: 7px !important; }

@media (max-width: 700px) {
  .side { width: 100%; }
  .topbar { gap: 6px; }
  .month-form { margin-left: 0; }
}

/* ---------- connexion ---------- */
body.auth {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: #eef1f5; padding: 20px;
}
.auth-card {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 24px; width: min(94vw, 380px);
  box-shadow: 0 12px 34px rgba(20, 30, 50, .09);
}
.auth-card h1 { font-size: 18px; margin: 16px 0 10px; }
.auth-card .brand { margin-bottom: 2px; }
.error {
  background: #fdecec; border: 1px solid #f3c2c2; color: #8f2b2b;
  border-radius: 7px; padding: 8px 10px; font-size: 12px; margin-bottom: 10px;
}
