:root {
  --paper: #EEF0F4; --surface: #FFFFFF; --surface-2: #F5F6FA; --ink: #161C3A; --ink-2: #4A5375; --ink-3: #6D7592;
  --line: #DCE0E9; --line-2: #C3C9D8; --accent: #2E3AA8; --accent-ink: #FFFFFF; --accent-soft: #E6E8F7;
  --saffron: #E3A72F; --saffron-soft: #FBEFD4;
  --ok: #17835A; --ok-soft: #DCF1E6; --warn: #9A5F08; --warn-soft: #FAEBCB; --bad: #C0392B; --bad-soft: #FBE0DC;
  --we: #F0F3F8; --shadow: 0 12px 32px rgba(19, 30, 56, .18), 0 2px 6px rgba(19, 30, 56, .08);
  --f-display: 'Segoe UI', system-ui, -apple-system, sans-serif; /* polices distantes retirées : la passerelle Assan n'autorise que les polices locales */
  --f-ui: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --f-cond: 'Arial Narrow', 'Segoe UI', system-ui, sans-serif;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0E1226; --surface: #161B35; --surface-2: #1B2242; --ink: #E9ECF7; --ink-2: #AAB2CE; --ink-3: #8089A6;
    --line: #272F50; --line-2: #39436B; --accent: #8E9AFF; --accent-ink: #0E1226; --accent-soft: #252D60;
    --saffron: #F0BE5A; --saffron-soft: #3A2F16;
    --ok: #4CC790; --ok-soft: #173A2E; --warn: #E9B25A; --warn-soft: #3B2E14; --bad: #FF8A7A; --bad-soft: #43201F;
    --we: #182140; --shadow: 0 12px 32px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .3);
  }
}
:root[data-theme="dark"] {
  --paper: #0E1226; --surface: #161B35; --surface-2: #1B2242; --ink: #E9ECF7; --ink-2: #AAB2CE; --ink-3: #8089A6;
  --line: #272F50; --line-2: #39436B; --accent: #8E9AFF; --accent-ink: #0E1226; --accent-soft: #252D60;
  --saffron: #F0BE5A; --saffron-soft: #3A2F16;
  --ok: #4CC790; --ok-soft: #173A2E; --warn: #E9B25A; --warn-soft: #3B2E14; --bad: #FF8A7A; --bad-soft: #43201F;
  --we: #182140; --shadow: 0 12px 32px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .3);
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 14px/1.5 var(--f-ui); min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Boutons et champs ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 13px; border: 1px solid var(--line-2); background: var(--surface); border-radius: 6px; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.quiet:hover { background: var(--accent-soft); color: var(--ink); }
.btn.danger { color: var(--bad); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.ico { width: 34px; height: 34px; display: inline-grid; place-items: center; border: 1px solid transparent; background: transparent; border-radius: 6px; color: var(--ink-2); padding: 0; }
.ico:hover:not([disabled]) { background: var(--accent-soft); color: var(--ink); }
.ico[disabled] { opacity: .35; cursor: not-allowed; }
.ico.danger { color: var(--bad); }
.ico.danger:hover { background: var(--bad-soft); color: var(--bad); }
.ico svg, .btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.fld { height: 34px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); min-width: 0; }
.fld:hover { border-color: var(--ink-3); }
select.fld { padding-right: 6px; }
.fld.num { width: 68px; text-align: right; font-variant-numeric: tabular-nums; }
.fld.time { width: 92px; font-variant-numeric: tabular-nums; }
.fld.code { width: 68px; font-family: var(--f-cond); font-weight: 600; text-transform: none; }
.fld.grow { flex: 1 1 180px; }
input[type=color] { width: 34px; height: 34px; padding: 2px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
label.chk { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.hint { color: var(--ink-2); max-width: 66ch; }
.muted { color: var(--ink-3); }

/* ---------- Marque ---------- */
.mark { display: inline-flex; align-items: center; gap: 10px; font-family: var(--f-display); font-weight: 800; font-size: 22px; letter-spacing: -.02em; color: var(--ink); background: none; border: 0; padding: 0; }
.mark svg { width: 26px; height: 26px; flex: none; }

/* ---------- Accueil ---------- */
.home { max-width: 1240px; margin: 0 auto; padding: 22px 24px 64px; }
.home-top { display: flex; align-items: center; justify-content: space-between; padding-bottom: 8px; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 48px; align-items: center; padding: 44px 0 52px; }
.hero h1 { font-family: var(--f-display); font-weight: 800; font-size: clamp(2.3rem, 5.2vw, 4rem); line-height: 1.02; letter-spacing: -.035em; max-width: 12ch; }
.hero p { margin-top: 20px; font-size: 17px; line-height: 1.55; color: var(--ink-2); max-width: 48ch; }
.tapestry { display: grid; grid-template-columns: repeat(var(--cols, 14), 1fr); gap: 4px; }
.tapestry i { display: block; aspect-ratio: 1; border-radius: 3px; animation: weave .5s cubic-bezier(.2, .7, .3, 1) both; animation-delay: calc(var(--c) * 38ms + var(--r) * 14ms); }
@keyframes weave { from { opacity: 0; transform: scale(.55); } to { opacity: 1; transform: scale(1); } }
.home-cols { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 56px; align-items: start; }
.home h2 { font-family: var(--f-display); font-weight: 700; font-size: 22px; letter-spacing: -.02em; margin-bottom: 6px; }
.sect-list { display: grid; grid-template-columns: 1fr 1fr; column-gap: 28px; margin-top: 14px; border-top: 1px solid var(--line-2); }
.sect { display: grid; grid-template-columns: 34px 1fr; gap: 12px; text-align: left; align-items: start; padding: 14px 8px 14px 4px; background: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.sect:hover { background: var(--surface); }
.sect .sw { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; width: 34px; margin-top: 3px; }
.sect .sw i { aspect-ratio: 1; border-radius: 2px; display: block; }
.sect b { display: block; font-weight: 600; font-size: 15px; }
.sect span { display: block; color: var(--ink-2); font-size: 13px; line-height: 1.4; margin-top: 2px; }
.docs { margin-top: 14px; border-top: 1px solid var(--line-2); }
.doc-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.doc-open { text-align: left; background: none; border: 0; padding: 12px 4px; border-radius: 0; min-width: 0; }
.doc-open:hover b { text-decoration: underline; text-underline-offset: 3px; }
.doc-open b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-open span { display: block; color: var(--ink-3); font-size: 13px; }
.doc-tools { display: flex; gap: 2px; }
.empty { padding: 18px 4px; color: var(--ink-2); }

/* ---------- Barre d'application ---------- */
.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; background: var(--paper); border-bottom: 1px solid var(--line); }
.bar-in { max-width: 1680px; margin: 0 auto; padding: 10px 20px; display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.bar .mark { font-size: 19px; }
.bar .mark svg { width: 22px; height: 22px; }
.docname { font-family: var(--f-display); font-weight: 700; font-size: 18px; letter-spacing: -.015em; height: 36px; border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 0 8px; min-width: 120px; flex: 1 1 200px; max-width: 420px; }
.docname:hover { border-color: var(--line-2); }
.docname:focus { border-color: var(--accent); background: var(--surface); outline: none; }
.spacer { flex: 1 1 0; }
.period { display: flex; align-items: center; gap: 4px; }
.period .lbl { font-weight: 600; min-width: 148px; text-align: center; font-variant-numeric: tabular-nums; }
.tabs { max-width: 1680px; margin: 0 auto; padding: 0 20px; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tab { padding: 10px 14px 9px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--ink-2); font-weight: 500; white-space: nowrap; border-radius: 0; }
.tab:hover { color: var(--ink); }
.tab[aria-selected=true] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tab small { color: var(--ink-3); font-weight: 400; margin-left: 4px; }
.saved { color: var(--ink-3); font-size: 12px; white-space: nowrap; }

.main { max-width: 1680px; margin: 0 auto; padding: 18px 20px 72px; }
.layout { display: block; }

/* ---------- Statut du planning ---------- */
.status { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.pill { display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 12px; border-radius: 99px; font-weight: 500; font-size: 13px; background: var(--surface); border: 1px solid var(--line); }
.pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.pill.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.pill.bad::before { background: var(--bad); }
.pill.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.pill.warn::before { background: var(--warn); }
.pill.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }

.brushbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.brushbar .lbl { font-weight: 600; margin-right: 4px; }
.bchip { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 11px 0 6px; border: 1px solid var(--line-2); background: var(--surface); border-radius: 6px; font-size: 13px; }
.bchip:hover { border-color: var(--ink-3); }
.bchip[aria-pressed=true] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), inset 0 0 0 1px var(--accent); font-weight: 600; }
.bchip .sq { width: 20px; height: 20px; border-radius: 4px; display: grid; place-items: center; font: 600 11px/1 var(--f-cond); }
.bchip.eraser { padding-left: 11px; }

/* ---------- Grille ---------- */
.gridwrap { overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; max-width: 100%; }
@media (min-width: 900px) { .gridwrap { max-height: calc(100vh - 250px); } }
table.grid { border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.grid th, .grid td { padding: 0; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); background: var(--surface); }
.grid thead th { position: sticky; z-index: 3; background: var(--surface); font-weight: 500; }
.grid thead tr:first-child th { top: 0; height: 30px; text-align: left; padding: 0 10px; font-weight: 600; font-size: 12.5px; color: var(--ink-2); }
.weekhead { display: inline-flex; align-items: center; gap: 5px; }
.wk-copy-btn { width: 19px; height: 19px; padding: 0; border: 0; background: transparent; color: var(--ink-3); display: inline-grid; place-items: center; border-radius: 4px; flex: none; }
.wk-copy-btn:hover { background: var(--accent-soft); color: var(--ink); }
.wk-copy-btn svg { width: 13px; height: 13px; stroke-width: 2; }
.grid thead tr:nth-child(2) th { top: 30px; height: 40px; text-align: center; font-size: 12px; line-height: 1.15; color: var(--ink-2); }
.grid thead th b { display: block; font-size: 14px; color: var(--ink); font-weight: 600; }
.grid .we { background: var(--we) !important; }
.grid th.corner, .grid th.who { position: sticky; left: 0; z-index: 4; text-align: left; min-width: 176px; max-width: 176px; border-right: 2px solid var(--line-2); }
.grid thead th.corner { z-index: 6; }
.grid th.who { z-index: 2; padding: 4px 10px; font-weight: 400; }
.who b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.25; }
.who small { display: block; color: var(--ink-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.25; }
.grid td.c { width: 46px; min-width: 46px; height: 44px; }
.grid td.tot, .grid th.tot { min-width: 62px; text-align: center; font-family: var(--f-cond); font-size: 13px; background: var(--surface-2); border-right: 2px solid var(--line-2); }
.grid td.tot b { font-weight: 600; font-size: 14px; }
.grid td.tot.over { color: var(--bad); }
.grid td.tot small { color: var(--ink-3); }
.cell { display: flex; flex-direction: column; gap: 2px; width: 100%; height: 100%; min-height: 43px; padding: 3px; border: 0; background: transparent; border-radius: 0; position: relative; touch-action: manipulation; }
.brushing .cell { touch-action: none; cursor: crosshair; }
.cell:hover { background: var(--accent-soft); }
.cell:focus-visible { outline-offset: -2px; }
.cell.bad { box-shadow: inset 0 0 0 2px var(--bad); }
.cell.warn { box-shadow: inset 0 0 0 2px var(--warn); }
.cell.flash { animation: flash 1.5s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: inset 0 0 0 3px var(--accent), 0 0 0 4px var(--accent-soft); } 100% { box-shadow: none; } }
.chip { flex: 1 1 0; min-height: 0; display: grid; place-items: center; border-radius: 4px; font: 600 12px/1 var(--f-cond); letter-spacing: .01em; }
.chip.st { background-image: repeating-linear-gradient(135deg, rgba(255, 255, 255, .34) 0 4px, transparent 4px 8px); }
.grid tfoot th, .grid tfoot td { background: var(--surface); }
.grid tr.covh th { position: sticky; left: 0; background: var(--surface-2); font-family: var(--f-display); font-weight: 700; padding: 7px 10px; text-align: left; font-size: 13px; border-right: 2px solid var(--line-2); z-index: 2; }
.grid tr.covh td { background: var(--surface-2); }
.grid tr.cov th { position: sticky; left: 0; z-index: 2; text-align: left; font-weight: 500; padding: 3px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 176px; border-right: 2px solid var(--line-2); font-size: 13px; }
.grid tr.cov th i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 7px; }
.grid tr.cov td { text-align: center; height: 28px; font-family: var(--f-cond); font-size: 13px; }
.cov .ok { color: var(--ok); }
.cov .short { background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.cov .over { background: var(--warn-soft); color: var(--warn); }
.cov .none { color: var(--line-2); }

/* ---------- Panneau des alertes ---------- */
.side { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; max-height: calc(100vh - 180px); overflow: auto; position: sticky; top: 132px; }
.side h3 { font-family: var(--f-display); font-weight: 700; font-size: 16px; padding: 14px 16px 6px; letter-spacing: -.01em; }
.side .grp { padding: 10px 16px 4px; font-weight: 600; font-size: 13px; color: var(--ink-2); }
.side ul { list-style: none; margin: 0; padding: 0; }
.iss { display: grid; grid-template-columns: 10px 1fr; gap: 10px; width: 100%; text-align: left; padding: 9px 16px; border: 0; border-top: 1px solid var(--line); background: none; border-radius: 0; }
.iss:hover { background: var(--surface-2); }
.iss i { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; background: var(--bad); }
.iss.warn i { background: var(--warn); }
.iss b { font-weight: 600; display: block; }
.iss span { color: var(--ink-2); display: block; font-size: 13px; line-height: 1.4; }
.side .allgood { padding: 6px 16px 18px; color: var(--ink-2); }

/* ---------- Panneaux de saisie ---------- */
.pane { max-width: 1180px; }
.pane-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 24px; margin-bottom: 16px; }
.pane-head h2 { font-family: var(--f-display); font-weight: 700; font-size: 24px; letter-spacing: -.02em; }
.pane-head .hint { margin-top: 2px; }
.sub { font-family: var(--f-display); font-weight: 700; font-size: 17px; letter-spacing: -.01em; margin: 30px 0 10px; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.home-top .tools .fld { width: auto; }
.fn-list { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.fn { display: inline-flex; align-items: center; border: 1px solid var(--line-2); background: var(--surface); border-radius: 6px; padding-left: 4px; }
.fn input { border: 0; background: transparent; height: 32px; padding: 0 6px; width: 150px; border-radius: 6px; }
.fn input:focus { outline-offset: -2px; }
.rows { border-top: 1px solid var(--line-2); }
.row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.row .col { display: flex; flex-direction: column; gap: 3px; }
.row .col > label, .row .k { font-size: 12px; color: var(--ink-3); }
.row .col.grow { flex: 1 1 260px; }
.row .inl { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.days { display: inline-flex; gap: 3px; }
.dtog { width: 30px; height: 30px; border: 1px solid var(--line-2); background: var(--surface); border-radius: 5px; font-size: 12px; font-weight: 500; padding: 0; color: var(--ink-2); }
.dtog[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.dtog.we { border-style: dashed; }
.effs { display: inline-flex; gap: 4px; }
.effs .col { align-items: center; }
.effs input { width: 44px; text-align: center; padding: 0 2px; }
.l { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; padding: 12px 14px; border-top: 1px dashed var(--line); }
.dur { font-size: 13px; padding-bottom: 7px; }
.mini { display: flex; flex-wrap: wrap; gap: 5px; }
.tg { height: 28px; padding: 0 10px; border: 1px solid var(--line-2); background: var(--surface); border-radius: 99px; font-size: 13px; color: var(--ink-2); }
.tg[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 500; }

/* ---------- Cartes repliables (postes, personnes, statuts, règles) ---------- */
.cards { border-top: 1px solid var(--line-2); }
.card { border-bottom: 1px solid var(--line); }
.card > .row { border-bottom: 0; padding: 12px 14px; }
.sumrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 11px 14px; min-height: 30px; }
.sumrow > b { font-weight: 600; }
.sumrow .swatch { width: 16px; height: 16px; border-radius: 4px; flex: none; }
.sumrow .tag { font-size: 11.5px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; padding: 2px 8px; white-space: nowrap; }
.sumrow.rule-sum.off { opacity: .55; }
.rule-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rule-txt .muted { font-size: 12.5px; }
.chevbtn svg { transition: transform .15s ease; }
.chevbtn[aria-expanded=true] svg { transform: rotate(180deg); }
.chevbtn span { display: none; }
@media (min-width: 640px) { .chevbtn span { display: inline; } }

/* ---------- Règles : détail déplié ---------- */
.grp-h { font-family: var(--f-display); font-weight: 700; margin: 24px 0 4px; font-size: 15px; }
.adder { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 16px 0 4px; }

/* ---------- Bilan ---------- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table.bilan { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.bilan th, .bilan td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.bilan th:first-child, .bilan td:first-child { text-align: left; }
.bilan thead th { font-weight: 600; color: var(--ink-2); font-size: 12.5px; background: var(--surface-2); vertical-align: bottom; }
.bilan td b { font-weight: 600; }
.bilan .pos { color: var(--warn); }
.bilan .neg { color: var(--ink-3); }
.bar1 { display: inline-block; width: 70px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; vertical-align: middle; margin-left: 8px; }
.bar1 i { display: block; height: 100%; background: var(--accent); }
.bar1 i.hi { background: var(--warn); }
.bilan tfoot td { font-weight: 600; background: var(--surface-2); }

/* ---------- Surcouches ---------- */
.scrim { position: fixed; inset: 0; background: rgba(13, 19, 36, .45); z-index: 60; display: grid; place-items: center; padding: 20px; }
.dialog { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); width: min(480px, 100%); padding: 24px; }
.dialog h3 { font-family: var(--f-display); font-weight: 700; font-size: 20px; letter-spacing: -.015em; margin-bottom: 8px; }
.dialog p { color: var(--ink-2); margin-bottom: 16px; }
.dialog textarea { width: 100%; min-height: 150px; padding: 10px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); resize: vertical; }
.dialog .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.pop { position: fixed; z-index: 70; width: 252px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); padding: 8px; max-height: 70vh; overflow: auto; }
.pop h4 { font-size: 13px; font-weight: 600; padding: 4px 8px 8px; color: var(--ink-2); }
.pop .opt { display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 9px; width: 100%; text-align: left; border: 0; background: none; padding: 6px 8px; border-radius: 6px; }
.pop .opt:hover { background: var(--surface-2); }
.pop .opt[aria-pressed=true] { background: var(--accent-soft); font-weight: 600; }
.pop .opt .sq { width: 24px; height: 24px; border-radius: 4px; display: grid; place-items: center; font: 600 11px/1 var(--f-cond); }
.pop .opt small { color: var(--ink-3); font-weight: 400; }
.pop hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.menu { position: fixed; z-index: 70; min-width: 250px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; }
.menu button:hover { background: var(--surface-2); }
.menu button small { display: block; color: var(--ink-3); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(22px + env(safe-area-inset-bottom, 0px)); z-index: 80; background: var(--ink); color: var(--paper); padding: 11px 14px 11px 18px; border-radius: 10px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 14px; max-width: min(92vw, 640px); }
.toast button { background: none; border: 0; color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; padding: 4px; }

@media (max-width: 1100px) {
  .hero { grid-template-columns: 1fr; gap: 28px; padding: 28px 0 36px; }
  .home-cols { grid-template-columns: 1fr; gap: 40px; }
}
@media (max-width: 720px) {
  .home { padding: 16px 16px 48px; }
  .sect-list { grid-template-columns: 1fr; }
  .tapestry { gap: 3px; }
  .bar-in { padding: 8px 12px; }
  .tabs { padding: 0 8px; }
  .main { padding: 14px 12px 64px; }
  .grid th.corner, .grid th.who { min-width: 118px; max-width: 118px; }
  .rule { grid-template-columns: 1fr; }
  .period .lbl { min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .tapestry i, .cell.flash { animation: none; }
}

/* ============================================================
   v1.2 — fluidité et repères visuels
   ============================================================ */
:root { --row-hover: rgba(51, 71, 224, .045); --today: #3347E0; --ease: cubic-bezier(.2, .7, .3, 1); }
:root[data-theme="dark"] { --row-hover: rgba(136, 150, 255, .07); --today: #8896FF; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --row-hover: rgba(136, 150, 255, .07); --today: #8896FF; } }

/* Transitions de base */
.btn, .ico, .bchip, .tg, .dtog, .pill, .tab, .sect, .doc-open, .iss, .menu button, .pop .opt { transition: background-color .14s ease, border-color .14s ease, color .14s ease, box-shadow .14s ease, transform .08s ease; }
.btn:active:not([disabled]), .ico:active:not([disabled]), .bchip:active, .pill:active { transform: translateY(1px); }
.btn.lg { height: 42px; padding: 0 18px; font-size: 15px; border-radius: 8px; }
.btn.busy svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hide-sm { display: inline; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; font-size: inherit; }

/* Indicateur d'enregistrement : pastille + mot court, pulsation à chaque sauvegarde */
.saved { display: inline-flex; align-items: center; gap: 6px; }
.saved::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.saved.err { color: var(--bad); }
.saved.err::before { background: var(--bad); }
.saved.pulse::before { animation: pulse .7s var(--ease); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--ok-soft); transform: scale(1.5); } 100% { box-shadow: 0 0 0 6px transparent; transform: scale(1); } }

/* Entrée de vue (changement d'onglet ou de planning) */
.enter > * { animation: fadeUp .22s var(--ease) both; }
.enter > *:nth-child(2) { animation-delay: .03s; }
.enter > *:nth-child(3) { animation-delay: .06s; }
.enter > *:nth-child(n+4) { animation-delay: .09s; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Pastilles de statut cliquables */
button.pill { cursor: pointer; font: inherit; font-weight: 500; font-size: 13px; }
button.pill:hover { filter: brightness(.97); box-shadow: 0 0 0 3px var(--line); }
button.pill::after { content: '→'; opacity: .55; margin-left: 2px; }

/* Bandeau « prêt à composer » */
.cta { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 22px; padding: 18px 20px; margin-bottom: 16px; border-radius: 12px;
  background: linear-gradient(120deg, var(--accent-soft), var(--surface) 70%); border: 1px solid var(--line); }
.cta-art { display: grid; grid-template-columns: repeat(3, 14px); gap: 4px; flex: none; }
.cta-art i { width: 14px; height: 14px; border-radius: 3px; animation: weave .5s var(--ease) both; animation-delay: calc(var(--i) * 70ms); }
.cta-txt { flex: 1 1 320px; min-width: 0; }
.cta-txt b { display: block; font-family: var(--f-display); font-weight: 700; font-size: 18px; letter-spacing: -.015em; }
.cta-txt span { color: var(--ink-2); }

/* Pinceau */
.brushbar { padding: 6px; margin-left: -6px; border-radius: 10px; transition: background-color .15s ease; }
.brushbar.on { background: var(--accent-soft); }
.bhint { margin-left: 6px; }

/* Grille : jour avec trou, aujourd'hui, survol de ligne, jauge hebdo */
.grid th.day { position: sticky; }
.grid th.day.gap::after { content: ''; position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--bad); }
.grid th.day.today { color: var(--today); }
.grid th.day.today b { color: var(--accent-ink); background: var(--today); border-radius: 99px; width: 24px; height: 20px; line-height: 20px; margin: 1px auto 0; }
.grid td.c.today { box-shadow: inset 2px 0 0 var(--today); }
.grid tbody tr:hover > th.who { background: var(--accent-soft); }
.grid tbody tr:hover .cell:not(:hover) { background: var(--row-hover); }
.cell.bad::after, .cell.warn::after { content: ''; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 2px var(--surface); }
.cell.warn::after { background: var(--warn); }
.cell { transition: background-color .12s ease; }
.meter { display: block; width: 38px; height: 3px; margin: 3px auto 0; background: var(--line); border-radius: 2px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--ok); border-radius: 2px; transition: width .3s var(--ease); }
.meter.lo i { background: var(--ink-3); }
.meter.hi i { background: var(--warn); }
.grid td.tot { line-height: 1.15; padding: 4px 2px; }
.grid td.tot.cw { color: var(--warn); box-shadow: inset 0 0 0 2px var(--warn); background: var(--warn-soft); }
.grid td.tot.cb { color: var(--bad); box-shadow: inset 0 0 0 2px var(--bad); background: var(--bad-soft); }
td[data-cov].flash { animation: flash 1.5s ease-out; }
.gridwrap { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }

/* Apparition des postes après une composition, jour par jour */
.fresh .chip { animation: chipIn .38s var(--ease) both; animation-delay: calc(var(--d) * 16ms); }
@keyframes chipIn { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }

/* Aide clavier sous la grille */
.kbd-hint { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 12.5px; margin-top: 10px; }
.kbd-hint svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; }
@media (pointer: coarse) { .kbd-hint { display: none; } }

/* Menus et popover : apparition */
.menu, .pop { animation: popIn .14s var(--ease) both; transform-origin: top left; }
@keyframes popIn { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.toast { animation: toastIn .22s var(--ease) both; }
.noanim { animation: none !important; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }
.menu .mi-ico { display: grid; grid-template-columns: 20px 1fr; gap: 10px; align-items: start; }
.menu .mi-ico svg { width: 18px; height: 18px; margin-top: 2px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; color: var(--accent); }
.menu .mi-ico.danger svg, .menu .mi-ico.danger > span { color: var(--bad); }
.menu .mi-ico small { font-weight: 400; }
.menu button { font-weight: 500; }
.menu button:focus-visible { outline-offset: -2px; }
.m-more { width: 290px; padding: 8px; }
.menu .mh { font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); padding: 8px 6px 5px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; }
.menu .seg button { padding: 6px 4px; text-align: center; font-size: 12.5px; border-radius: 6px; }
.menu .seg button[aria-pressed=true] { background: var(--surface); box-shadow: 0 1px 2px rgba(19, 30, 56, .12); font-weight: 600; color: var(--ink); }
.kb { list-style: none; margin: 0; padding: 0 6px 4px; display: grid; gap: 6px; font-size: 12.5px; color: var(--ink-2); line-height: 1.4; }

/* Accueil : cartes de plannings avec bande de couverture */
.doc-row { position: relative; }
.doc-row::before { content: ''; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 2px; background: var(--doc); }
.doc-open { padding-left: 14px; }
.doc-health { display: flex !important; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 6px; }
.strip { display: inline-flex !important; gap: 2px; }
.strip i { width: 7px; height: 12px; border-radius: 2px; background: var(--line); display: block; }
.strip i.we { opacity: .7; }
.strip i.o { background: var(--ok); }
.strip i.g { background: var(--bad); }
.strip i.b { background: var(--warn); }
.dh-txt { font-size: 12.5px; font-weight: 500; }
.dh-txt.ok { color: var(--ok); }
.dh-txt.bad { color: var(--bad); }
.dh-txt.mute { color: var(--ink-3); }
.dh-time { font-size: 12px; color: var(--ink-3); }
.fair { transition: none; }
.fairs { margin-bottom: 22px; }
.fair { padding: 8px 12px; border-radius: 8px; background: var(--ok-soft); color: var(--ok); font-weight: 500; font-size: 13px; font-variant-numeric: tabular-nums; }
.fair.warn { background: var(--warn-soft); color: var(--warn); }
.fairs { display: flex; flex-wrap: wrap; gap: 8px; }
.pop-iss { list-style: none; margin: 0 0 6px; padding: 0 4px; display: grid; gap: 4px; }
.pop-iss li { font-size: 12.5px; line-height: 1.35; padding: 6px 8px; border-radius: 6px; border-left: 3px solid; }
.pop-iss li.bad { background: var(--bad-soft); color: var(--bad); }
.pop-iss li.warn { background: var(--warn-soft); color: var(--warn); }
.btn[disabled].primary { filter: grayscale(.4); }
.print-title { display: none; }

@media (max-width: 720px) {
  .hide-sm { display: none; }
  .bar .saved { font-size: 0; gap: 0; }
  .bhint { display: none; }
  .cta { padding: 14px; }
  .cta .btn.lg { width: 100%; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  .enter > *, .fresh .chip, .menu, .pop, .toast, .cta-art i, .saved.pulse::before, td[data-cov].flash { animation: none !important; }
  .btn.busy svg { animation-duration: 3s; }
}

/* ---------- Impression : la grille entière, sans barre ni panneaux ---------- */
@page { size: A4 landscape; margin: 10mm; }
/* ============================================================
   v1.3 — planning en largeur
   ============================================================ */
/* La grille occupe toute la largeur : les colonnes de jours s'étirent */
table.grid { width: 100%; }
.gridwrap { max-width: none; }
@media (min-width: 900px) { .gridwrap { max-height: calc(100vh - 210px); } }
.grid td.c { width: auto; min-width: 40px; }
.grid td.tot, .grid th.tot { width: 58px; min-width: 58px; }

/* Densité compacte (par défaut) : lignes basses, nom et fonction sur une ligne */
.grid.compact thead tr:first-child th { height: 26px; }
.grid.compact thead tr:nth-child(2) th { top: 26px; height: 34px; }
.grid.compact thead th b { font-size: 13px; }
.grid.compact th.corner, .grid.compact th.who { min-width: 190px; max-width: 190px; }
.grid.compact th.who { padding: 0 10px; display: table-cell; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid.compact .who b, .grid.compact .who small { display: inline; }
.grid.compact .who small { margin-left: 6px; font-size: 11.5px; }
.grid.compact td.c { height: 30px; }
.grid.compact .cell { min-height: 29px; flex-direction: row; gap: 2px; padding: 2px; }
.grid.compact .chip { font-size: 11.5px; border-radius: 3px; }
.grid.compact td.tot { padding: 2px; }
.grid.compact td.tot b { font-size: 13px; }
.grid.compact .meter { margin-top: 2px; }
.grid.compact tr.cov td { height: 22px; font-size: 12px; }
.grid.compact tr.cov th { padding: 1px 10px; font-size: 12px; }
.grid.compact tr.covh th { padding: 4px 10px; }
.grid.compact .cell.bad::after, .grid.compact .cell.warn::after { width: 6px; height: 6px; top: 2px; right: 2px; }

/* Tiroir « À vérifier » */
.status .side-tg { margin-left: auto; }
.status .side-tg b { margin-left: 4px; background: var(--ink); color: var(--paper); border-radius: 99px; padding: 0 7px; font-size: 12px; line-height: 18px; }
.status .side-tg[aria-expanded=true] { background: var(--accent-soft); color: var(--ink); }
.side { position: fixed; top: calc(98px + env(safe-area-inset-top, 0px)); right: 12px; bottom: 12px; width: min(380px, calc(100vw - 24px)); max-height: none; z-index: 40;
  box-shadow: var(--shadow); border-radius: 12px; animation: drawerIn .2s var(--ease) both; }
.side-h { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 0 0; position: sticky; top: 0; background: var(--surface); z-index: 1; }
@keyframes drawerIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@media (max-width: 720px) {
  .grid.compact th.corner, .grid.compact th.who { min-width: 118px; max-width: 118px; }
  .grid.compact .who small { display: none; }
  .side { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 70vh; }
}
@media (prefers-reduced-motion: reduce) { .side { animation: none; } }

/* ============================================================
   v1.3.1 — corrections visuelles
   ============================================================ */
/* 1. Nom du planning : largeur du contenu, rétrécit proprement si la place manque */
.docname { flex: 0 1 auto; width: auto; max-width: min(460px, 42vw); min-width: 90px; text-overflow: ellipsis; }
/* 2. Barre : sur écran moyen, libellé Exporter et texte « Enregistré » masqués (icône / pastille seules) */
@media (max-width: 1200px) {
  .bar .hide-sm { display: none; }
  .bar .saved { font-size: 0; gap: 0; }
  .bar-in { gap: 8px 10px; }
}
/* 3. Toast : pleine largeur utile sur mobile (left:50% divisait la largeur disponible par deux) */
.toast { left: 12px; right: 12px; margin: 0 auto; width: fit-content; max-width: min(640px, calc(100vw - 24px)); transform: none; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
/* 4. Codes de 3 à 5 lettres : le carré s'élargit au lieu de déborder */
.bchip .sq, .pop .opt .sq { width: auto; min-width: 20px; padding: 0 3px; white-space: nowrap; }
.pop .opt .sq { min-width: 24px; }
/* 5. Popover plus large, horaires sur une ligne */
.pop { width: 290px; }
.pop .opt { grid-template-columns: auto 1fr auto; }
.pop .opt small { white-space: nowrap; font-variant-numeric: tabular-nums; }
/* 6. Détail d'un poste : libellés au-dessus des champs (comme ailleurs) */
.l .col { display: flex; flex-direction: column; gap: 3px; }
.l .col > label { font-size: 12px; color: var(--ink-3); }
.l label.chk { padding-bottom: 7px; }
.effs { display: grid; grid-template-columns: repeat(7, 48px); gap: 4px; }
.effs .fld.num { width: 100%; text-align: center; padding: 0 2px; }
/* 7. Champ « grow » dans une colonne : la base flex s'appliquait à la hauteur (champ Nom de 180 px) */
.col > .fld.grow { flex: none; width: 100%; min-width: 170px; }
/* 8. Heures : assez large pour « 02:00 PM » selon la langue du navigateur */
.fld.time { width: 132px; }
/* 9. Pastilles : le texte long passe à la ligne sans sortir de la pastille */
.pill { height: auto; min-height: 28px; padding: 4px 12px; line-height: 1.35; }
/* 10. Pinceau sur écran étroit : une seule ligne qui défile horizontalement */
@media (max-width: 900px) {
  .brushbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-right: -12px; padding-right: 12px; }
  .brushbar::-webkit-scrollbar { display: none; }
  .brushbar > * { flex: none; }
}
/* 11. Bilan : lignes plus basses */
.bilan th, .bilan td { padding: 7px 12px; }
/* 12. Bouton « copier la semaine » : visible au survol de l'en-tête */
.wk-copy-btn { width: 22px; height: 22px; color: var(--ink-3); opacity: .7; }
th:hover .wk-copy-btn, .wk-copy-btn:focus-visible { opacity: 1; }
.wk-copy-btn svg { width: 14px; height: 14px; }
@media (max-width: 720px) {
  .effs { grid-template-columns: repeat(7, minmax(0, 1fr)); width: 100%; }
  .effs input { width: 100%; }
  .l { padding: 12px 4px; }
  .l .col { min-width: 0; }
  .bar .brand-txt { display: none; }
  .docname { max-width: calc(100vw - 72px); font-size: 17px; }
}

/* ============================================================
   v1.5 — redesign « la trame »
   Le planning se lit comme un tissage : jours en chaîne, personnes en trame, postes en
   fils colorés. L'indigo teint porte l'interface, le safran ne marque qu'aujourd'hui.
   ============================================================ */
:root { --today: var(--saffron); }
:root[data-theme="dark"] { --today: var(--saffron); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --today: var(--saffron); } }

/* ---------- En-tête : une rangée, onglets intégrés ---------- */
.bar { background: var(--surface); }
.bar-in { flex-wrap: nowrap; padding: 0 20px; min-height: 58px; gap: 8px 16px; }
.bar .mark { flex: none; }
.bar .docname { font-size: 17px; height: 34px; }
.bar .tabs { max-width: none; margin: 0; padding: 0; align-self: stretch; display: flex; gap: 0; }
.bar .tab { display: inline-flex; align-items: center; gap: 4px; padding: 0 12px; height: 100%; border-bottom: 3px solid transparent; border-top: 3px solid transparent; }
.bar .tab[aria-selected=true] { border-bottom-color: var(--accent); color: var(--ink); }
.bar .acts { display: flex; align-items: center; gap: 6px; flex: none; }
@media (max-width: 1180px) {
  .bar-in { flex-wrap: wrap; padding-top: 8px; }
  .bar .tabs { order: 10; flex: 1 0 100%; height: 42px; margin: 0 -8px; overflow-x: auto; scrollbar-width: none; }
}

/* ---------- Barre d'outils du planning ---------- */
.ptools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 14px; }
.ptools .status { margin: 0; }
.period { display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.period-lbl { font: 700 15px/1 var(--f-display); letter-spacing: -.01em; padding: 0 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.period .fld { height: 30px; border-color: transparent; background: var(--surface-2); }
.period .fld.date { width: 132px; }
.period .btn[disabled] { opacity: .4; }
.side-tg { flex: none; }

/* ---------- Grille : personnes groupées par fonction ---------- */
.av { --rc: #8A93A8; display: inline-grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 50%; font: 600 10.5px/1 var(--f-ui); letter-spacing: .02em;
  color: var(--rc); background: color-mix(in srgb, var(--rc) 16%, var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--rc) 30%, transparent); }
.grid th.who { box-shadow: inset 3px 0 0 var(--rc, transparent); }
.grid th.who { display: table-cell; }
.grid th.who > .av { vertical-align: middle; margin-right: 8px; }
.grid .who-t { display: inline; vertical-align: middle; }
.grid.comfy .who-t { display: inline-block; max-width: calc(100% - 34px); }
.grid.comfy .who-t b, .grid.comfy .who-t small { display: block; }
.grid tbody tr.role-start > * { border-top: 2px solid var(--line-2); }
.grid th.day.today b { color: var(--ink); background: var(--today); }
.grid th.day.today { color: var(--ink); font-weight: 600; }
.grid td.c.today { box-shadow: inset 2px 0 0 var(--today); }
.grid td.c.today .cell { background: color-mix(in srgb, var(--today) 7%, transparent); }

/* ---------- Champs « nus » : lisibles comme du texte, éditables au survol ---------- */
.fld.bare { border-color: transparent; background: transparent; padding: 0 8px; }
.fld.bare:hover { border-color: var(--line-2); background: var(--surface); }
.fld.bare:focus { border-color: var(--accent); background: var(--surface); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Équipe : tableau groupé par fonction ---------- */
.pane.wide { max-width: 1320px; }
.roster { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.rrow { display: grid; grid-template-columns: minmax(190px, 1.4fr) minmax(150px, 1fr) 92px 236px minmax(140px, 1.1fr) auto; align-items: center; gap: 6px 12px; padding: 5px 12px; border-top: 1px solid var(--line); }
.rrow:hover { background: var(--row-hover); }
.rhead { border-top: 0; background: var(--surface-2); font-size: 12.5px; color: var(--ink-2); font-weight: 600; padding-top: 9px; padding-bottom: 9px; }
.rhead:hover { background: var(--surface-2); }
.c-name { display: flex; align-items: center; gap: 4px; min-width: 0; }
.c-name .fld { flex: 1 1 auto; min-width: 0; font-weight: 600; }
.c-role .fld { width: 100%; }
.c-ctr { display: flex; align-items: center; gap: 4px; }
.c-ctr .fld.num { width: 62px; }
.c-act { display: flex; justify-content: flex-end; gap: 0; }
.c-act .ico { width: 30px; height: 30px; }
.rrow .dtog { width: 28px; height: 28px; }
.rrow .tg { height: 26px; padding: 0 9px; font: 600 12px/1 var(--f-cond); }
.role-grp { --rc: #8A93A8; }
.role-h { display: flex; align-items: center; gap: 10px; padding: 12px 12px 8px; border-top: 1px solid var(--line-2); background: color-mix(in srgb, var(--rc) 5%, var(--surface)); }
.role-grp:first-of-type .role-h { border-top: 0; }
.role-sw { width: 10px; height: 10px; border-radius: 3px; background: var(--rc); flex: none; }
.role-name { font: 700 16px/1.2 var(--f-display); letter-spacing: -.01em; border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 3px 6px; margin-left: -6px; min-width: 0; }
.role-name:hover { border-color: var(--line-2); background: var(--surface); }
.role-name:focus { border-color: var(--accent); background: var(--surface); outline: none; }
@media (max-width: 1120px) {
  .rhead { display: none; }
  .rrow { grid-template-columns: 1fr auto; grid-template-areas: "name act" "role ctr" "days days" "evite evite"; padding: 10px 12px; }
  .c-name { grid-area: name; } .c-role { grid-area: role; } .c-ctr { grid-area: ctr; } .c-days { grid-area: days; } .c-evite { grid-area: evite; } .c-act { grid-area: act; }
}

/* ---------- Postes : journée type + liste ---------- */
.code-b { display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 5px; border-radius: 5px; font: 600 12px/1 var(--f-cond); white-space: nowrap; flex: none; }
.code-b.lg { min-width: 38px; height: 32px; font-size: 14px; border-radius: 7px; }
.code-b.st { background-image: repeating-linear-gradient(135deg, rgba(255, 255, 255, .34) 0 4px, transparent 4px 8px); }
.dayview { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px 12px; margin-bottom: 22px; }
.dv-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 12px; }
.dv-head h3 { font: 700 16px/1.2 var(--f-display); letter-spacing: -.01em; }
.dv-head .hint { font-size: 13px; }
.dv-axis, .dv-lane { display: grid; grid-template-columns: minmax(150px, 220px) 1fr; gap: 14px; align-items: center; }
.dv-scale { position: relative; height: 18px; }
.dv-tick { position: absolute; transform: translateX(-50%); font: 500 11.5px/1 var(--f-cond); color: var(--ink-3); top: 2px; }
.dv-tick:first-child { transform: none; } .dv-tick:last-child { transform: translateX(-100%); }
.dv-lane { padding: 5px 0; }
.dv-lbl { display: flex; align-items: center; gap: 8px; min-width: 0; }
.dv-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.dv-track { position: relative; height: 16px; border-radius: 4px;
  background: repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px calc(100% / 4)), var(--surface-2); }
.dv-track i { position: absolute; top: 2px; bottom: 2px; border-radius: 4px; min-width: 4px; }
.shift-sum { gap: 8px 14px; }
.shift-t { display: flex; flex-direction: column; min-width: 0; }
.shift-t b { font-weight: 600; }
.shift-t .muted { font-size: 12.5px; font-variant-numeric: tabular-nums; }
.effmini { display: inline-flex; align-items: flex-end; gap: 3px; height: 34px; padding: 0 4px; }
.em-c { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; width: 13px; height: 100%; }
.em-c i { display: block; width: 8px; border-radius: 2px 2px 0 0; min-height: 1px; }
.em-c small { font: 500 10px/1 var(--f-cond); color: var(--ink-3); margin-top: 2px; }
.em-c.we small { color: var(--ink-3); opacity: .75; }
.sumrow .tag.night { background: var(--accent-soft); border-color: transparent; color: var(--ink); }
.card.open { background: var(--surface); box-shadow: inset 3px 0 0 var(--accent); }
.chk.opt { margin: 16px 0 6px; }
.sub-head { margin-top: 32px; }
.pane-head h2 + .hint { margin-top: 2px; }

/* ---------- Règles : groupes, interrupteur, badges ---------- */
.rule-grp { margin-bottom: 18px; }
.grp-h { font: 700 16px/1.2 var(--f-display); letter-spacing: -.01em; margin: 6px 0 8px; }
.grp-h small { font: 500 12.5px var(--f-ui); color: var(--ink-3); margin-left: 6px; }
.switch { position: relative; display: inline-block; width: 34px; height: 20px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line-2); transition: background-color .15s ease; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(22, 28, 58, .3); transition: transform .15s var(--ease); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.badge { font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 99px; white-space: nowrap; }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.scope { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); font-weight: 500; }
.rule-sum { gap: 8px 12px; }
.rule-sum.off .rule-txt, .rule-sum.off .badge { opacity: .5; }
.rule-sum.off { opacity: 1; }
.conv { margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line-2); }
.conv .hint { margin-bottom: 10px; }

/* ---------- Bilan : graphique heures / contrat ---------- */
.seg.inline { display: inline-grid; }
.seg.inline button { border: 0; background: none; padding: 6px 12px; font-size: 13px; border-radius: 6px; color: var(--ink-2); }
.seg.inline button[aria-pressed=true] { background: var(--surface); box-shadow: 0 1px 2px rgba(22, 28, 58, .12); color: var(--ink); font-weight: 600; }
.fair-wrap { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 8px; }
.fair-wrap .hint { font-size: 13px; }
.bullet { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.bl-row { display: grid; grid-template-columns: minmax(170px, 230px) minmax(220px, 1fr) 110px repeat(4, 64px); align-items: center; gap: 12px; padding: 7px 16px; border-top: 1px solid var(--line); }
.bl-row:hover { background: var(--row-hover); }
.bl-head { border-top: 0; background: var(--surface-2); font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.bl-head:hover { background: var(--surface-2); }
.bl-legend { display: block; font-weight: 400; color: var(--ink-3); font-size: 11.5px; }
.bl-who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bl-who span { display: flex; flex-direction: column; min-width: 0; }
.bl-who b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bl-who small { color: var(--ink-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bl-chart { display: flex; align-items: center; gap: 10px; min-width: 0; }
.bl-trk { position: relative; flex: 1 1 auto; height: 18px; }
.bl-fill { position: absolute; left: 0; top: 4px; bottom: 4px; border-radius: 0 4px 4px 0; background: var(--accent); }
.bl-fill.over { background: var(--warn); }
.bl-fill.under { background: color-mix(in srgb, var(--accent) 45%, var(--surface)); }
.bl-tick { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--ink); border-radius: 1px; }
.bl-val { flex: none; width: 92px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bl-val b { font-weight: 600; }
.bl-val small { color: var(--ink-3); margin-left: 3px; }
.bl-diff { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink-2); }
.bl-diff.over { color: var(--warn); font-weight: 600; }
.bl-diff.under { color: var(--ink-2); font-weight: 600; }
.bl-diff span[aria-hidden] { font-size: 10px; }
.bl-n { text-align: right; font-variant-numeric: tabular-nums; }
.bl-foot { background: var(--surface-2); font-weight: 600; grid-template-columns: minmax(170px, 230px) 1fr; }
@media (max-width: 860px) {
  .bl-row { grid-template-columns: 1fr 1fr; }
  .bl-head > :nth-child(n+3), .bl-row > .bl-n { display: none; }
  .bl-chart { grid-column: 1 / -1; order: 3; }
}

/* ---------- Accueil ---------- */
.home.back .tapestry { margin: 6px 0 28px; gap: 3px; }
.home.back .tapestry i { border-radius: 2px; }
.mine h1 { font: 800 clamp(1.9rem, 3.4vw, 2.6rem)/1.05 var(--f-display); letter-spacing: -.03em; margin-bottom: 18px; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.doc-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; transition: border-color .15s ease, box-shadow .15s ease; }
.doc-card:hover { border-color: var(--line-2); box-shadow: 0 6px 18px rgba(22, 28, 58, .08); }
.doc-card .doc-open { display: flex; flex-direction: column; gap: 4px; width: 100%; text-align: left; padding: 16px 18px 14px; background: none; border: 0; border-radius: 14px; }
.doc-card .doc-open b { font: 700 17px/1.25 var(--f-display); letter-spacing: -.01em; padding-right: 64px; }
.doc-card .strip { display: flex !important; gap: 2px; margin-bottom: 10px; }
.doc-card .strip i { flex: 1 1 0; max-width: 14px; height: 18px; border-radius: 2px; }
.doc-meta { color: var(--ink-2); font-size: 13px; }
.doc-card .doc-health { margin-top: 8px; display: flex; justify-content: space-between; gap: 8px; }
.doc-card .doc-tools { position: absolute; top: 34px; right: 8px; }
.backup { margin-top: 14px; }
.create { margin-top: 44px; }
.create h2 { font: 700 22px/1.2 var(--f-display); letter-spacing: -.02em; }
.create .sect-list { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.home.first .create { margin-top: 0; }

/* ---------- Détails : retirer les tics typographiques ---------- */
.menu .mh { text-transform: none; letter-spacing: 0; font-size: 12.5px; color: var(--ink-2); }
button.pill::after { content: none; }
button.pill { text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px; }
button.pill:hover { text-decoration-color: currentColor; box-shadow: none; }
.kbd-hint button { margin-left: 4px; }

@media print {
  :root { --paper: #fff; --surface: #fff; --surface-2: #F5F7FB; --ink: #000; --ink-2: #333; --ink-3: #555; --line: #C9CFDA; --line-2: #9AA3B5; --we: #F0F3F8; }
  body { background: #fff; font-size: 10px; }
  .bar, .side, .brushbar, .status, .ptools, .kbd-hint, .wk-copy-btn, #ov { display: none !important; }
  .main { max-width: none; padding: 0; }
  .layout { display: block; }
  .gridwrap { max-height: none !important; overflow: visible !important; border: 0; }
  .grid thead th, .grid th.corner, .grid th.who, .grid tr.cov th, .grid tr.covh th { position: static; }
  .grid td.c { width: auto; min-width: 26px; height: 26px; }
  .grid th.corner, .grid th.who { min-width: 110px; max-width: 110px; }
  .cell { min-height: 24px; box-shadow: none !important; }
  .chip, .grid .we, .cov .short, .cov .over { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  tr { break-inside: avoid; }
  .pane { max-width: none; }
  .print-title { display: block; font: 700 16px/1.2 var(--f-display); margin: 0 0 8px; }
}

/* v1.5 : le tiroir suit la nouvelle hauteur d'en-tête */
.side { top: calc(68px + env(safe-area-inset-top, 0px)); }
@media (max-width: 1180px) { .side { top: calc(108px + env(safe-area-inset-top, 0px)); } }
@media (max-width: 720px) { .side { top: auto; } }

/* v1.5 : finitions après revue des captures */
/* Champs dont la largeur suit le texte (nom du planning, nom de fonction) */
.docname, .role-name { field-sizing: content; }
/* Accueil : titres de secteur en encre (la règle « .sect span » les grisait) */
.sect b { color: var(--ink); }
/* Carte de planning : actions au-dessus de la bande, le titre garde toute la largeur */
.doc-card .doc-tools { top: 8px; right: 8px; }
.doc-card .strip { margin-right: 76px; }
.doc-card .doc-open b { padding-right: 0; }
/* Étiquettes : majuscule initiale (« Au moins 1 Infirmier·ère ») */
.sumrow .tag { display: inline-block; }
.sumrow .tag::first-letter { text-transform: uppercase; }
/* Bilan : la colonne nom/fonction ne doit pas s'appliquer au rond d'initiales */
.bl-who span { display: inline-grid; }
.bl-who > span:not(.av) { display: flex; flex-direction: column; }
/* Piste des barres du bilan, discrète */
.bl-trk::before { content: ''; position: absolute; left: 0; right: 0; top: 8px; height: 2px; background: var(--line); border-radius: 1px; }
/* Mobile : barre de période sur toute la largeur, sans champ date (les flèches suffisent) */
@media (max-width: 720px) {
  .ptools .period { width: 100%; flex-wrap: wrap; }
  .period .fld.date { display: none; }
  .period-lbl { flex: 1 1 auto; text-align: center; font-size: 14px; }
  .ptools .status { flex: 1 1 auto; }
}
/* Titres qui passent à la ligne au lieu d'être coupés */
.doc-card .doc-open b { white-space: normal; overflow: visible; text-overflow: clip; }
.role-h { flex-wrap: wrap; }
.role-name { flex: 0 1 auto; max-width: 100%; }
@media (max-width: 720px) { .role-h .muted { flex-basis: 100%; order: 5; margin-left: 20px; margin-top: -6px; } }
@media (min-width: 721px) and (max-width: 1120px) {
  /* Fiches sur deux colonnes de champs quand la place le permet */
  .rrow { grid-template-columns: minmax(200px, 1fr) minmax(160px, 1fr) auto; grid-template-areas: "name role act" "ctr days evite"; }
}
